mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
This commit is contained in:
parent
f99d9e19bc
commit
f43770d8d2
7 changed files with 43 additions and 20 deletions
|
|
@ -102,7 +102,7 @@ export const initBar = (app: App) => {
|
|||
}
|
||||
};
|
||||
if (!useElement) {
|
||||
const svgElement = hideElement.querySelector("svg");
|
||||
const svgElement = hideElement.querySelector("svg").cloneNode(true) as HTMLElement;
|
||||
svgElement.classList.add("b3-menu__icon");
|
||||
menuOptions.iconHTML = svgElement.outerHTML;
|
||||
}
|
||||
|
|
@ -275,6 +275,31 @@ const openPlugin = (app: App, target: Element) => {
|
|||
// @ts-ignore
|
||||
const hasSetting = plugin.setting || plugin.__proto__.hasOwnProperty("openSetting");
|
||||
plugin.topBarIcons.forEach(item => {
|
||||
const hasUnpin = window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(item.id);
|
||||
const submenu = [{
|
||||
icon: "iconPin",
|
||||
label: hasUnpin ? window.siyuan.languages.pin : window.siyuan.languages.unpin,
|
||||
click() {
|
||||
if (hasUnpin) {
|
||||
window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].splice(window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].indexOf(item.id), 1);
|
||||
item.classList.remove("fn__none")
|
||||
} else {
|
||||
window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].push(item.id);
|
||||
window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN] = Array.from(new Set(window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN]));
|
||||
item.classList.add("fn__none")
|
||||
}
|
||||
setStorageVal(Constants.LOCAL_PLUGINTOPUNPIN, window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN]);
|
||||
}
|
||||
}];
|
||||
if (hasSetting) {
|
||||
submenu.push({
|
||||
icon: "iconSettings",
|
||||
label: window.siyuan.languages.config,
|
||||
click() {
|
||||
plugin.openSetting();
|
||||
},
|
||||
})
|
||||
}
|
||||
const menuOption: IMenu = {
|
||||
icon: "iconInfo",
|
||||
label: item.getAttribute("aria-label"),
|
||||
|
|
@ -282,25 +307,12 @@ const openPlugin = (app: App, target: Element) => {
|
|||
item.dispatchEvent(new CustomEvent("click"))
|
||||
},
|
||||
type: "submenu",
|
||||
submenu: [{
|
||||
icon: "iconPin",
|
||||
label: window.siyuan.languages.pin,
|
||||
click() {
|
||||
|
||||
}
|
||||
}, {
|
||||
icon: "iconSettings",
|
||||
label: window.siyuan.languages.config,
|
||||
disabled: !hasSetting,
|
||||
click() {
|
||||
plugin.openSetting();
|
||||
},
|
||||
}]
|
||||
submenu
|
||||
}
|
||||
if (item.querySelector("use")) {
|
||||
menuOption.icon = item.querySelector("use").getAttribute("xlink:href").replace("#", "");
|
||||
} else {
|
||||
const svgElement = item.querySelector("svg");
|
||||
const svgElement = item.querySelector("svg").cloneNode(true) as HTMLElement;
|
||||
svgElement.classList.add("b3-menu__icon")
|
||||
menuOption.iconHTML = svgElement.outerHTML;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue