Skip to content

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

:bug: Guard unsupported block menu actions in Protyle Lite https://github.com/siyuan-note/siyuan/issues/19137

Daniel3cb32b1a476a
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 68981b6bc9..003e828d37 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -3,6 +3,10 @@
@use "wysiwyg" as *;
@use "attr" as *;
+.protyle-lite-fragment .protyle-action__menu {
+ display: none;
+}
+
.protyle-scroll {
--b3-dynamicscroll-width: 200px;
position: absolute;
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index dde1bd0f4d..775cd8f711 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -613,30 +613,32 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}
});
}
- submenu.push({
- id: "defBlock",
- iconHTML: "",
- label: window.siyuan.languages.defBlock,
- click() {
- fetchPost("/api/block/swapBlockRef", {
- refID: id,
- defID: refBlockId,
- includeChildren: false
- });
- }
- });
- submenu.push({
- id: "defBlockChildren",
- iconHTML: "",
- label: window.siyuan.languages.defBlockChildren,
- click() {
- fetchPost("/api/block/swapBlockRef", {
- refID: id,
- defID: refBlockId,
- includeChildren: true
- });
- }
- });
+ if (!protyle.lite) {
+ submenu.push({
+ id: "defBlock",
+ iconHTML: "",
+ label: window.siyuan.languages.defBlock,
+ click() {
+ fetchPost("/api/block/swapBlockRef", {
+ refID: id,
+ defID: refBlockId,
+ includeChildren: false
+ });
+ }
+ });
+ submenu.push({
+ id: "defBlockChildren",
+ iconHTML: "",
+ label: window.siyuan.languages.defBlockChildren,
+ click() {
+ fetchPost("/api/block/swapBlockRef", {
+ refID: id,
+ defID: refBlockId,
+ includeChildren: true
+ });
+ }
+ });
+ }
window.siyuan.menus.menu.append(new MenuItem({
id: "turnInto",
label: window.siyuan.languages.turnInto,
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 04d8e5494b..3fa807e844 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -3487,6 +3487,11 @@ export class WYSIWYG {
if (selectElements.length > 1 ||
getBlockSelectionModeElement(protyle.wysiwyg.element) && selectElements.length > 0) {
// 多选块
+ if (!protyle.gutter) {
+ event.preventDefault();
+ window.siyuan.menus.menu.remove();
+ return;
+ }
hideElements(["util"], protyle);
protyle.gutter.renderMenu(protyle, selectElements[0]);
window.siyuan.menus.menu.popup({x, y});
@@ -3495,6 +3500,11 @@ export class WYSIWYG {
const target = event.detail.target || event.target as HTMLElement;
const embedElement = isInEmbedBlock(target);
if (embedElement) {
+ if (!protyle.gutter) {
+ event.preventDefault();
+ window.siyuan.menus.menu.remove();
+ return;
+ }
if (getSelection().rangeCount === 0) {
focusSideBlock(embedElement);
}
@@ -3690,6 +3700,11 @@ export class WYSIWYG {
}
}
} else if (protyle.toolbar.range.toString() === "") {
+ if (!protyle.gutter) {
+ event.preventDefault();
+ window.siyuan.menus.menu.remove();
+ return;
+ }
hideElements(["util"], protyle);
if (protyle.gutter) {
protyle.gutter.renderMenu(protyle, nodeElement);
@@ -4789,6 +4804,11 @@ export class WYSIWYG {
const menuElement = hasClosestByClassName(event.target, "protyle-action__menu");
if (menuElement) {
+ if (!protyle.gutter) {
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
protyle.gutter.renderMenu(protyle, menuElement.parentElement.parentElement);
/// #if MOBILE
window.siyuan.menus.menu.fullscreen();
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index a861c18d9a..5b3bcae3ff 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -982,6 +982,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
selectElements.push(nodeElement);
}
+ if (!protyle.gutter) {
+ window.siyuan.menus.menu.remove();
+ return;
+ }
if (selectElements.length === 1) {
protyle.gutter.renderMenu(protyle, selectElements[0]);
} else {