mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
🎨 https://github.com/siyuan-note/siyuan/issues/5066 click menu icon
This commit is contained in:
parent
fe3c6012c8
commit
839308173a
3 changed files with 24 additions and 7 deletions
|
|
@ -82,6 +82,16 @@ export class Menu {
|
|||
}
|
||||
}
|
||||
|
||||
public addSeparator() {
|
||||
this.addItem({type: "separator"});
|
||||
}
|
||||
|
||||
public addItem(option: IMenu) {
|
||||
const menuItem = new MenuItem(option);
|
||||
this.append(menuItem.element);
|
||||
return menuItem.element;
|
||||
}
|
||||
|
||||
public remove() {
|
||||
if (window.siyuan.menus.menu.removeCB) {
|
||||
window.siyuan.menus.menu.removeCB();
|
||||
|
|
@ -170,7 +180,7 @@ export class MenuItem {
|
|||
});
|
||||
}
|
||||
let html = `<span class="b3-menu__label">${options.label}</span>`;
|
||||
if (options.iconHTML) {
|
||||
if (typeof options.iconHTML === "string") {
|
||||
html = options.iconHTML + html;
|
||||
} else {
|
||||
html = `<svg class="b3-menu__icon${["HTML (SiYuan)", window.siyuan.languages.template].includes(options.label) ? " ft__error" : ""}" style="${options.icon === "iconClose" ? "height:10px;" : ""}"><use xlink:href="#${options.icon || ""}"></use></svg>${html}`;
|
||||
|
|
|
|||
|
|
@ -39,16 +39,14 @@ export class Menu {
|
|||
if (this.isOpen) {
|
||||
return;
|
||||
}
|
||||
const menuItem = new MenuItem(option);
|
||||
this.menu.append(menuItem.element);
|
||||
return menuItem.element;
|
||||
return this.menu.addItem(option);
|
||||
}
|
||||
|
||||
addSeparator() {
|
||||
if (this.isOpen) {
|
||||
return;
|
||||
}
|
||||
this.addItem({type: "separator"});
|
||||
this.menu.addSeparator();
|
||||
}
|
||||
|
||||
open(options: { x: number, y: number, h?: number, w?: number, isLeft: false }) {
|
||||
|
|
|
|||
|
|
@ -708,6 +708,12 @@ export class Gutter {
|
|||
}
|
||||
}).element);
|
||||
}
|
||||
this.app?.plugins?.forEach((plugin) => {
|
||||
plugin.eventBus.emit("click-blockicon", {
|
||||
menu: window.siyuan.menus.menu,
|
||||
blockElements: selectsElement,
|
||||
});
|
||||
});
|
||||
return window.siyuan.menus.menu;
|
||||
}
|
||||
|
||||
|
|
@ -1501,8 +1507,11 @@ 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", [nodeElement]);
|
||||
this.app?.plugins?.forEach((plugin) => {
|
||||
plugin.eventBus.emit("click-blockicon", {
|
||||
menu: window.siyuan.menus.menu,
|
||||
blockElements: [nodeElement]
|
||||
});
|
||||
});
|
||||
return window.siyuan.menus.menu;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue