mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
e32c8f8c1c
commit
2a3b72bb8a
2 changed files with 26 additions and 16 deletions
|
|
@ -25,6 +25,7 @@ import {afterLoadPlugin, loadPlugins} from "../plugin/loader";
|
||||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||||
import {removeBlock} from "../protyle/wysiwyg/remove";
|
import {removeBlock} from "../protyle/wysiwyg/remove";
|
||||||
import {isNotEditBlock} from "../protyle/wysiwyg/getBlock";
|
import {isNotEditBlock} from "../protyle/wysiwyg/getBlock";
|
||||||
|
import {Menu} from "../plugin/Menu";
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
public plugins: import("../plugin").Plugin[] = [];
|
public plugins: import("../plugin").Plugin[] = [];
|
||||||
|
|
@ -98,9 +99,29 @@ class App {
|
||||||
initFramework(this);
|
initFramework(this);
|
||||||
initRightMenu(this);
|
initRightMenu(this);
|
||||||
openChangelog();
|
openChangelog();
|
||||||
|
const unPinsMenu: IMenu[] = [];
|
||||||
this.plugins.forEach(item => {
|
this.plugins.forEach(item => {
|
||||||
afterLoadPlugin(item);
|
const unPinMenu = afterLoadPlugin(item);
|
||||||
|
if (unPinMenu) {
|
||||||
|
unPinMenu.forEach(unpinItem => {
|
||||||
|
unPinsMenu.push(unpinItem);
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
if (unPinsMenu.length > 0) {
|
||||||
|
const pluginElement = document.createElement("div");
|
||||||
|
pluginElement.classList.add("b3-menu__item");
|
||||||
|
pluginElement.setAttribute("data-menu", "true");
|
||||||
|
pluginElement.innerHTML = `<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>`;
|
||||||
|
pluginElement.addEventListener("click", () => {
|
||||||
|
const menu = new Menu();
|
||||||
|
unPinsMenu.forEach(item => {
|
||||||
|
menu.addItem(item);
|
||||||
|
});
|
||||||
|
menu.fullscreen();
|
||||||
|
});
|
||||||
|
document.querySelector("#menuAbout").after(pluginElement);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -150,11 +150,11 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isWindow() || isMobile()) {
|
if (!isWindow() || isMobile()) {
|
||||||
const pluginMenu: IMenu[] = [];
|
const unPinMenu: IMenu[] = [];
|
||||||
plugin.topBarIcons.forEach(element => {
|
plugin.topBarIcons.forEach(element => {
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
|
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
|
||||||
pluginMenu.push({
|
unPinMenu.push({
|
||||||
iconHTML: element.firstElementChild.outerHTML,
|
iconHTML: element.firstElementChild.outerHTML,
|
||||||
label: element.textContent.trim(),
|
label: element.textContent.trim(),
|
||||||
click() {
|
click() {
|
||||||
|
|
@ -171,19 +171,8 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
||||||
document.querySelector("#" + (element.getAttribute("data-position") === "right" ? "barPlugins" : "drag")).before(element);
|
document.querySelector("#" + (element.getAttribute("data-position") === "right" ? "barPlugins" : "drag")).before(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (isMobile() && pluginMenu.length > 0) {
|
if (isMobile() && unPinMenu.length > 0) {
|
||||||
const pluginElement = document.createElement("div");
|
return unPinMenu;
|
||||||
pluginElement.classList.add("b3-menu__item");
|
|
||||||
pluginElement.setAttribute("data-menu", "true");
|
|
||||||
pluginElement.innerHTML = `<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>`;
|
|
||||||
pluginElement.addEventListener("click", () => {
|
|
||||||
const menu = new Menu();
|
|
||||||
pluginMenu.forEach(item => {
|
|
||||||
menu.addItem(item);
|
|
||||||
});
|
|
||||||
menu.fullscreen();
|
|
||||||
});
|
|
||||||
document.querySelector("#menuAbout").after(pluginElement);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue