Vanessa 2022-09-04 22:17:08 +08:00
parent 8143c58cf5
commit 010a3eb002
4 changed files with 17 additions and 1 deletions

View file

@ -104,9 +104,15 @@
align-self: center;
height: 14px;
width: 14px;
line-height: 14px;
margin-right: 8px;
color: var(--b3-theme-on-surface);
& > svg {
height: 14px;
width: 14px;
}
&--arrow {
margin: 0 0 0 8px;
height: 10px;

View file

@ -456,8 +456,12 @@ export class Wnd {
private renderTabList(event: MouseEvent) {
window.siyuan.menus.menu.remove()
Array.from(this.headersElement.children).forEach((item: HTMLElement) => {
const iconElement = item.querySelector(".item__icon")
const graphicElement = item.querySelector(".item__graphic")
window.siyuan.menus.menu.append(new MenuItem({
label: item.querySelector(".item__text").textContent,
iconHTML: iconElement ? `<span class="b3-menu__icon">${iconElement.innerHTML}</span>` : "",
icon: graphicElement ? graphicElement.firstElementChild.getAttribute("xlink:href").substring(1) : "",
click: () => {
this.switchTab(item, true);
},

View file

@ -127,7 +127,12 @@ export class MenuItem {
window.siyuan.menus.menu.remove();
});
}
let 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><span class="b3-menu__label">${options.label}</span>`;
let html = `<span class="b3-menu__label">${options.label}</span>`;
if (options.iconHTML) {
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>`;
}

View file

@ -472,6 +472,7 @@ declare interface IMenu {
submenu?: IMenu[]
disabled?: boolean
icon?: string
iconHTML?: string
current?: boolean
bind?: (element: HTMLElement) => void
}