mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-13 18:54:21 +01:00
This commit is contained in:
parent
afbdb48ddf
commit
991816eeac
3 changed files with 50 additions and 30 deletions
|
|
@ -101,29 +101,6 @@ class App {
|
|||
initFramework(this, confResponse.data.start);
|
||||
initRightMenu(this);
|
||||
openChangelog();
|
||||
const unPinsMenu: IMenu[] = [];
|
||||
this.plugins.forEach(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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import {initEditor} from "../settings/editor";
|
|||
import {App} from "../../index";
|
||||
import {isHuawei, isInAndroid, isInIOS} from "../../protyle/util/compatibility";
|
||||
import {newFile} from "../../util/newFile";
|
||||
import {afterLoadPlugin} from "../../plugin/loader";
|
||||
import {Menu} from "../../plugin/Menu";
|
||||
import {commandPanel} from "../../plugin/commandPanel";
|
||||
|
||||
export const popMenu = () => {
|
||||
activeBlur();
|
||||
|
|
@ -101,6 +104,9 @@ export const initRightMenu = (app: App) => {
|
|||
<div class="b3-menu__item" id="menuAbout">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconInfo"></use></svg><span class="b3-menu__label">${window.siyuan.languages.about}</span>
|
||||
</div>
|
||||
<div class="b3-menu__item" id="menuPlugin">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>
|
||||
</div>
|
||||
<div class="b3-menu__separator"></div>
|
||||
<div class="b3-menu__item" id="menuHelp">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconHelp"></use></svg><span class="b3-menu__label">${window.siyuan.languages.help}</span>
|
||||
|
|
@ -111,6 +117,15 @@ export const initRightMenu = (app: App) => {
|
|||
</a>
|
||||
</div>`;
|
||||
processSync();
|
||||
const unPinsMenu: IMenu[] = [];
|
||||
app.plugins.forEach(item => {
|
||||
const unPinMenu = afterLoadPlugin(item);
|
||||
if (unPinMenu) {
|
||||
unPinMenu.forEach(unpinItem => {
|
||||
unPinsMenu.push(unpinItem);
|
||||
});
|
||||
}
|
||||
});
|
||||
// 只能用 click,否则无法上下滚动 https://github.com/siyuan-note/siyuan/issues/6628
|
||||
menuElement.addEventListener("click", (event) => {
|
||||
let target = event.target as HTMLElement;
|
||||
|
|
@ -160,6 +175,25 @@ export const initRightMenu = (app: App) => {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (target.id === "menuPlugin") {
|
||||
const menu = new Menu();
|
||||
menu.addItem({
|
||||
icon: "iconLayoutBottom",
|
||||
label: window.siyuan.languages.commandPanel,
|
||||
click() {
|
||||
commandPanel(app);
|
||||
}
|
||||
});
|
||||
if (unPinsMenu.length > 0) {
|
||||
menu.addSeparator();
|
||||
}
|
||||
unPinsMenu.forEach(item => {
|
||||
menu.addItem(item);
|
||||
});
|
||||
menu.fullscreen();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (target.id === "menuNewDaily") {
|
||||
newDailyNote(app);
|
||||
closePanel();
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
import {Dialog} from "../dialog";
|
||||
import {App} from "../index";
|
||||
import {upDownHint} from "../util/upDownHint";
|
||||
/// #if !MOBILE
|
||||
import {openSetting} from "../config";
|
||||
/// #endif
|
||||
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
import {isMobile} from "../util/functions";
|
||||
|
||||
export const commandPanel = (app: App) => {
|
||||
const dialog = new Dialog({
|
||||
width: "80vw",
|
||||
height: "70vh",
|
||||
content: `<div class="fn__flex-column" style="border-radius: var(--b3-border-radius-b);overflow:hidden;">
|
||||
<div class="b3-form__icon search__header">
|
||||
width: isMobile() ? "92vw" : "80vw",
|
||||
height: isMobile() ? "80vh" : "70vh",
|
||||
title: window.siyuan.languages.commandPanel,
|
||||
content: `<div class="fn__flex-column">
|
||||
<div class="b3-form__icon search__header" style="border-top: 0;border-bottom: 1px solid var(--b3-theme-surface-lighter);">
|
||||
<svg class="b3-form__icon-icon"><use xlink:href="#iconSearch"></use></svg>
|
||||
<input class="b3-text-field b3-text-field--text" style="padding-left: 32px !important;">
|
||||
</div>
|
||||
|
|
@ -23,8 +27,11 @@ export const commandPanel = (app: App) => {
|
|||
plugin.commands.forEach(command => {
|
||||
const liElement = document.createElement("li");
|
||||
liElement.classList.add("b3-list-item");
|
||||
if (listElement.childElementCount === 0) {
|
||||
liElement.classList.add("b3-list-item--focus");
|
||||
}
|
||||
liElement.innerHTML = `<span class="b3-list-item__text">${plugin.displayName}: ${command.langText || plugin.i18n[command.langKey]}</span>
|
||||
<span class="b3-list-item__meta">${updateHotkeyTip(command.customHotkey)}</span>`;
|
||||
<span class="b3-list-item__meta${isMobile() ? " fn__none" : ""}">${updateHotkeyTip(command.customHotkey)}</span>`;
|
||||
liElement.addEventListener("click", () => {
|
||||
if (command.callback) {
|
||||
command.callback();
|
||||
|
|
@ -39,11 +46,13 @@ export const commandPanel = (app: App) => {
|
|||
|
||||
if (listElement.childElementCount === 0) {
|
||||
const liElement = document.createElement("li");
|
||||
liElement.classList.add("b3-list-item");
|
||||
liElement.innerHTML = `<span class="b3-list-item__text">${window.siyuan.languages.commandEmpty}</span>`;
|
||||
liElement.classList.add("b3-list-item", "b3-list-item--focus");
|
||||
liElement.innerHTML = `<span class="b3-list-item__text">${isMobile() ? window.siyuan.languages.emptyContent : window.siyuan.languages.commandEmpty}</span>`;
|
||||
liElement.addEventListener("click", () => {
|
||||
dialog.destroy();
|
||||
/// #if !MOBILE
|
||||
openSetting(app).element.querySelector('.b3-tab-bar [data-name="bazaar"]').dispatchEvent(new CustomEvent("click"));
|
||||
/// #endif
|
||||
});
|
||||
listElement.insertAdjacentElement("beforeend", liElement);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue