Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/11555

Vanessa479865827c47
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 872dc88a9b..0032beb5f5 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -28,6 +28,7 @@ import {hideElements} from "../ui/hideElements";
import {insertAttrViewBlockAnimation} from "../render/av/row";
import {dragUpload} from "../render/av/asset";
import * as dayjs from "dayjs";
+import {zoomOut} from "../../menus/protyle";
const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, newSourceElement: Element,
isSameDoc: boolean, isBottom: boolean, isCopy: boolean) => {
@@ -520,18 +521,22 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (protyleElement && !protyleElement.classList.contains("block__edit")) {
const editor = getInstanceById(protyleElement.getAttribute("data-id")) as Tab;
- if (editor && editor.model instanceof Editor && editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
- const newId = Lute.NewNodeID();
- doOperations.splice(0, 0, {
- action: "insert",
- id: newId,
- data: genEmptyElement(false, false, newId).outerHTML,
- parentID: editor.model.editor.protyle.block.parentID
- });
- undoOperations.splice(0, 0, {
- action: "delete",
- id: newId,
- });
+ if (editor && editor.model instanceof Editor) {
+ if (editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
+ const newId = Lute.NewNodeID();
+ doOperations.splice(0, 0, {
+ action: "insert",
+ id: newId,
+ data: genEmptyElement(false, false, newId).outerHTML,
+ parentID: editor.model.editor.protyle.block.parentID
+ });
+ undoOperations.splice(0, 0, {
+ action: "delete",
+ id: newId,
+ });
+ } else {
+ zoomOut({protyle: editor.model.editor.protyle, id: editor.model.editor.protyle.block.rootID});
+ }
}
}
/// #endif
@@ -680,18 +685,23 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (protyleElement && !protyleElement.classList.contains("block__edit")) {
const editor = getInstanceById(protyleElement.getAttribute("data-id")) as Tab;
- if (editor && editor.model instanceof Editor && editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
- const newId = Lute.NewNodeID();
- doOperations.splice(0, 0, {
- action: "insert",
- id: newId,
- data: genEmptyElement(false, false, newId).outerHTML,
- parentID: editor.model.editor.protyle.block.parentID
- });
- undoOperations.splice(0, 0, {
- action: "delete",
- id: newId,
- });
+ if (editor && editor.model instanceof Editor) {
+ if (editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
+ const newId = Lute.NewNodeID();
+ doOperations.splice(0, 0, {
+ action: "insert",
+ id: newId,
+ data: genEmptyElement(false, false, newId).outerHTML,
+ parentID: editor.model.editor.protyle.block.parentID
+ });
+ undoOperations.splice(0, 0, {
+ action: "delete",
+ id: newId,
+ });
+ } else {
+ zoomOut({protyle: editor.model.editor.protyle, id: editor.model.editor.protyle.block.rootID});
+ }
+
}
}
/// #endif