diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts index 7ba6db9a0..6b40bb8c3 100644 --- a/app/src/menus/Menu.ts +++ b/app/src/menus/Menu.ts @@ -186,30 +186,37 @@ export class MenuItem { window.siyuan.menus.menu.remove(); }); } - let html = `${options.label}`; - if (typeof options.iconHTML === "string") { - html = options.iconHTML + html; - } else { - html = `${html}`; - } - if (options.accelerator) { - html += `${updateHotkeyTip(options.accelerator)}`; - } - if (options.action) { - html += ``; - } if (options.id) { this.element.setAttribute("data-id", options.id); } if (options.type === "readonly") { this.element.classList.add("b3-menu__item--readonly"); } - this.element.innerHTML = html; + + if (options.element) { + this.element.append(options.element); + } else { + let html = `${options.label}`; + if (typeof options.iconHTML === "string") { + html = options.iconHTML + html; + } else { + html = `${html}`; + } + if (options.accelerator) { + html += `${updateHotkeyTip(options.accelerator)}`; + } + if (options.action) { + html += ``; + } + this.element.innerHTML = html; + } + if (options.bind) { // 主题 rem craft 需要使用 b3-menu__item--custom 来区分自定义菜单 by 281261361 this.element.classList.add("b3-menu__item--custom"); options.bind(this.element); } + if (options.submenu) { const submenuElement = document.createElement("div"); submenuElement.classList.add("b3-menu__submenu"); diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 649922edf..922e35c4f 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -731,6 +731,7 @@ declare interface IMenu { current?: boolean bind?: (element: HTMLElement) => void index?: number + element?: HTMLElement } declare interface IBazaarItem {