This commit is contained in:
parent
f8ab2c6d50
commit
6e6114ac34
2 changed files with 51 additions and 9 deletions
|
@ -328,3 +328,27 @@ export const bindMenuKeydown = (event: KeyboardEvent) => {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
export class subMenu {
|
||||
public menus: IMenu[];
|
||||
|
||||
constructor() {
|
||||
this.menus = [];
|
||||
}
|
||||
|
||||
addSeparator(index?: number) {
|
||||
if (typeof index === "number") {
|
||||
this.menus.splice(index, 0, {type: "separator"});
|
||||
} else {
|
||||
this.menus.push({type: "separator"});
|
||||
}
|
||||
}
|
||||
|
||||
addItem(menu: IMenu) {
|
||||
if (typeof menu.index === "number") {
|
||||
this.menus.splice(menu.index, 0, menu);
|
||||
} else {
|
||||
this.menus.push(menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByMatchTag, hasClosestByTag} from "../util/hasClosest";
|
||||
import {getIconByType} from "../../editor/getIcon";
|
||||
import {iframeMenu, setFold, tableMenu, videoMenu, zoomOut} from "../../menus/protyle";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {MenuItem, subMenu} from "../../menus/Menu";
|
||||
import {copySubMenu, openAttr, openWechatNotify} from "../../menus/commonMenuItem";
|
||||
import {copyPlainText, updateHotkeyTip, writeText} from "../util/compatibility";
|
||||
import {
|
||||
|
@ -726,13 +726,22 @@ export class Gutter {
|
|||
}
|
||||
}).element);
|
||||
}
|
||||
const pluginSubMenu = new subMenu();
|
||||
this.app?.plugins?.forEach((plugin) => {
|
||||
plugin.eventBus.emit("click-blockicon", {
|
||||
protyle,
|
||||
menu: window.siyuan.menus.menu,
|
||||
menu: pluginSubMenu,
|
||||
blockElements: selectsElement,
|
||||
});
|
||||
});
|
||||
if (pluginSubMenu.menus.length > 0) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.plugin,
|
||||
type: "submenu",
|
||||
submenu: pluginSubMenu.menus,
|
||||
}).element);
|
||||
}
|
||||
return window.siyuan.menus.menu;
|
||||
}
|
||||
|
||||
|
@ -1533,6 +1542,22 @@ export class Gutter {
|
|||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
}
|
||||
const pluginSubMenu = new subMenu();
|
||||
this.app?.plugins?.forEach((plugin) => {
|
||||
plugin.eventBus.emit("click-blockicon", {
|
||||
protyle,
|
||||
menu: pluginSubMenu,
|
||||
blockElements: [nodeElement]
|
||||
});
|
||||
});
|
||||
if (pluginSubMenu.menus.length > 0) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.plugin,
|
||||
type: "submenu",
|
||||
submenu: pluginSubMenu.menus,
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
}
|
||||
let updateHTML = nodeElement.getAttribute("updated") || "";
|
||||
if (updateHTML) {
|
||||
updateHTML = `${window.siyuan.languages.modifiedAt} ${dayjs(updateHTML).format("YYYY-MM-DD HH:mm:ss")}<br>`;
|
||||
|
@ -1542,13 +1567,6 @@ export class Gutter {
|
|||
type: "readonly",
|
||||
label: `${updateHTML}${window.siyuan.languages.createdAt} ${dayjs(id.substr(0, 14)).format("YYYY-MM-DD HH:mm:ss")}`,
|
||||
}).element);
|
||||
this.app?.plugins?.forEach((plugin) => {
|
||||
plugin.eventBus.emit("click-blockicon", {
|
||||
protyle,
|
||||
menu: window.siyuan.menus.menu,
|
||||
blockElements: [nodeElement]
|
||||
});
|
||||
});
|
||||
return window.siyuan.menus.menu;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue