mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-10 04:59:03 +08:00
This commit is contained in:
parent
b2ac7b54ea
commit
ac7e646fde
@ -186,6 +186,16 @@ export class MenuItem {
|
|||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (options.id) {
|
||||||
|
this.element.setAttribute("data-id", options.id);
|
||||||
|
}
|
||||||
|
if (options.type === "readonly") {
|
||||||
|
this.element.classList.add("b3-menu__item--readonly");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.element) {
|
||||||
|
this.element.append(options.element);
|
||||||
|
} else {
|
||||||
let html = `<span class="b3-menu__label">${options.label}</span>`;
|
let html = `<span class="b3-menu__label">${options.label}</span>`;
|
||||||
if (typeof options.iconHTML === "string") {
|
if (typeof options.iconHTML === "string") {
|
||||||
html = options.iconHTML + html;
|
html = options.iconHTML + html;
|
||||||
@ -198,18 +208,15 @@ export class MenuItem {
|
|||||||
if (options.action) {
|
if (options.action) {
|
||||||
html += `<svg class="b3-menu__action"><use xlink:href="#${options.action}"></use></svg>`;
|
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;
|
this.element.innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.bind) {
|
if (options.bind) {
|
||||||
// 主题 rem craft 需要使用 b3-menu__item--custom 来区分自定义菜单 by 281261361
|
// 主题 rem craft 需要使用 b3-menu__item--custom 来区分自定义菜单 by 281261361
|
||||||
this.element.classList.add("b3-menu__item--custom");
|
this.element.classList.add("b3-menu__item--custom");
|
||||||
options.bind(this.element);
|
options.bind(this.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.submenu) {
|
if (options.submenu) {
|
||||||
const submenuElement = document.createElement("div");
|
const submenuElement = document.createElement("div");
|
||||||
submenuElement.classList.add("b3-menu__submenu");
|
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
|
current?: boolean
|
||||||
bind?: (element: HTMLElement) => void
|
bind?: (element: HTMLElement) => void
|
||||||
index?: number
|
index?: number
|
||||||
|
element?: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface IBazaarItem {
|
declare interface IBazaarItem {
|
||||||
|
Loading…
Reference in New Issue
Block a user