mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-08 21:02:14 +08:00
This commit is contained in:
parent
b2ac7b54ea
commit
ac7e646fde
@ -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");
|
||||
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
@ -731,6 +731,7 @@ declare interface IMenu {
|
||||
current?: boolean
|
||||
bind?: (element: HTMLElement) => void
|
||||
index?: number
|
||||
element?: HTMLElement
|
||||
}
|
||||
|
||||
declare interface IBazaarItem {
|
||||
|
Loading…
Reference in New Issue
Block a user