Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/18151

Vanessa60f552556722
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 66f1541111..4cb03dc2eb 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -53,6 +53,23 @@ import {escapeHtml} from "../../util/escape";
import {resizeSide} from "../../history/resizeSide";
import {activeBlur} from "../../mobile/util/keyboardToolbar";
+const filterPluginToolbar = (toolbar: Array<string | IMenuItem>, lite: boolean) => {
+ if (!lite) {
+ return toolbar;
+ }
+ const filtered = toolbar.filter(item => typeof item === "string" ||
+ Constants.INLINE_TYPE.concat("|").includes(item.name) || item.showInLite);
+ return filtered.filter((item, index) => {
+ const name = typeof item === "string" ? item : item.name;
+ if (name !== "|") {
+ return true;
+ }
+ const previous = filtered[index - 1];
+ const next = filtered[index + 1];
+ return previous && next && (typeof previous === "string" ? previous : previous.name) !== "|";
+ });
+};
+
export class Toolbar {
public element: HTMLElement;
public subElement: HTMLElement;
@@ -76,7 +93,7 @@ export class Toolbar {
this.toolbarHeight = 29;
const inlineToolbarElement = document.querySelector('#keyboardToolbar .keyboard__action[data-type="inline-memo"]')?.parentElement;
protyle.app.plugins.forEach(item => {
- const pluginToolbar = item.updateProtyleToolbar(options.toolbar);
+ const pluginToolbar = filterPluginToolbar(item.updateProtyleToolbar(options.toolbar), protyle.lite);
pluginToolbar.forEach(toolbarItem => {
if (typeof toolbarItem === "string" || Constants.INLINE_TYPE.concat("|").includes(toolbarItem.name)) {
return;
@@ -144,7 +161,7 @@ export class Toolbar {
"inline-memo",
]);
protyle.app.plugins.forEach(item => {
- const pluginToolbar = item.updateProtyleToolbar(protyle.options.toolbar);
+ const pluginToolbar = filterPluginToolbar(item.updateProtyleToolbar(protyle.options.toolbar), protyle.lite);
pluginToolbar.forEach(toolbarItem => {
if (typeof toolbarItem === "string" || Constants.INLINE_TYPE.concat("|").includes(toolbarItem.name)) {
return;
diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.ts
index f247ff965c..cefa0d920a 100644
--- a/app/src/types/protyle.d.ts
+++ b/app/src/types/protyle.d.ts
@@ -386,6 +386,8 @@ interface IMenuItem {
hotkey?: string;
/** 提示的位置 */
tipPosition?: string;
+ /** 是否在精简版中显示。默认值:false */
+ showInLite?: boolean;
click?(protyle: import("../protyle").Protyle): void;
}