mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
This commit is contained in:
parent
d0b9f9b6ca
commit
083f20357d
1 changed files with 10 additions and 3 deletions
|
|
@ -85,9 +85,10 @@ export const initBar = (app: App) => {
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-name", "barmore");
|
window.siyuan.menus.menu.element.setAttribute("data-name", "barmore");
|
||||||
(target.getAttribute("data-hideids") || "").split(",").forEach((itemId) => {
|
(target.getAttribute("data-hideids") || "").split(",").forEach((itemId) => {
|
||||||
const hideElement = toolbarElement.querySelector("#" + itemId);
|
const hideElement = toolbarElement.querySelector("#" + itemId);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
const useElement = hideElement.querySelector("use")
|
||||||
|
const menuOptions: IMenu = {
|
||||||
label: itemId === "toolbarVIP" ? window.siyuan.languages.account : hideElement.getAttribute("aria-label"),
|
label: itemId === "toolbarVIP" ? window.siyuan.languages.account : hideElement.getAttribute("aria-label"),
|
||||||
icon: itemId === "toolbarVIP" ? "iconAccount" : hideElement.querySelector("use").getAttribute("xlink:href").substring(1),
|
icon: itemId === "toolbarVIP" ? "iconAccount" : (useElement ? useElement.getAttribute("xlink:href").substring(1) : undefined),
|
||||||
click: () => {
|
click: () => {
|
||||||
if (itemId.startsWith("plugin")) {
|
if (itemId.startsWith("plugin")) {
|
||||||
hideElement.dispatchEvent(new CustomEvent("click"));
|
hideElement.dispatchEvent(new CustomEvent("click"));
|
||||||
|
|
@ -95,7 +96,13 @@ export const initBar = (app: App) => {
|
||||||
toolbarElement.dispatchEvent(new CustomEvent("click", {detail: itemId}));
|
toolbarElement.dispatchEvent(new CustomEvent("click", {detail: itemId}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).element);
|
};
|
||||||
|
if (!useElement) {
|
||||||
|
const svgElement = hideElement.querySelector("svg")
|
||||||
|
svgElement.classList.add("b3-menu__icon");
|
||||||
|
menuOptions.iconHTML = svgElement.outerHTML;
|
||||||
|
}
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem(menuOptions).element);
|
||||||
});
|
});
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true);
|
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue