Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/8343

Vanessaac7e646fde42
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index 7ba6db9a02..6b40bb8c3a 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 = `<span class="b3-menu__label">${options.label}</span>`;
- 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}`;
- }
- if (options.accelerator) {
- html += `<span class="b3-menu__accelerator">${updateHotkeyTip(options.accelerator)}</span>`;
- }
- if (options.action) {
- html += `<svg class="b3-menu__action"><use xlink:href="#${options.action}"></use></svg>`;
- }
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 = `<span class="b3-menu__label">${options.label}</span>`;
+ 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}`;
+ }
+ if (options.accelerator) {
+ html += `<span class="b3-menu__accelerator">${updateHotkeyTip(options.accelerator)}</span>`;
+ }
+ if (options.action) {
+ html += `<svg class="b3-menu__action"><use xlink:href="#${options.action}"></use></svg>`;
+ }
+ 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 649922edf2..922e35c4f3 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 {