This commit is contained in:
Vanessa 2023-06-11 23:17:51 +08:00
parent 49d038f411
commit b2c2218d3f
6 changed files with 203 additions and 180 deletions

View file

@ -2,7 +2,6 @@ import {confirmDialog} from "../dialog/confirmDialog";
import {Plugin} from "./index";
import {showMessage} from "../dialog/message";
import {Dialog} from "../dialog";
import {Menu as SiyuanMenu} from "../menus/Menu";
import {fetchGet, fetchPost, fetchSyncPost} from "../util/fetch";
import {getBackend, getFrontend} from "../util/functions";
/// #if !MOBILE
@ -14,64 +13,7 @@ import {App} from "../index";
import {Constants} from "../constants";
import {Model} from "../layout/Model";
import {Setting} from "./Setting";
export class Menu {
private menu: SiyuanMenu;
public isOpen: boolean;
constructor(id?: string, closeCB?: () => void) {
this.menu = window.siyuan.menus.menu;
this.isOpen = false;
if (id) {
const dataName = this.menu.element.getAttribute("data-name");
if (dataName && dataName === id) {
this.isOpen = true;
}
}
this.menu.remove();
if (!this.isOpen) {
this.menu.element.setAttribute("data-name", id);
this.menu.removeCB = closeCB;
}
}
showSubMenu(subMenuElement: HTMLElement) {
this.menu.showSubMenu(subMenuElement);
}
addItem(option: IMenu) {
if (this.isOpen) {
return;
}
return this.menu.addItem(option);
}
addSeparator(index?: number) {
if (this.isOpen) {
return;
}
this.menu.addSeparator(index);
}
open(options: { x: number, y: number, h?: number, w?: number, isLeft?: boolean }) {
if (this.isOpen) {
return;
}
this.menu.popup(options, options.isLeft);
}
fullscreen(position: "bottom" | "all" = "all") {
if (this.isOpen) {
return;
}
this.menu.fullscreen(position);
this.menu.element.style.zIndex = "310";
}
close() {
this.menu.remove();
}
}
import {Menu} from "./Meun";
let openTab;
/// #if MOBILE