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/11316

Vanessa0e082736162f
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 743274c581..168d04f2c4 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -12,7 +12,7 @@ import {
focusByWbr,
focusSideBlock,
getEditorRange,
- getSelectionOffset,
+ getSelectionOffset, setFirstNodeRange,
setLastNodeRange,
} from "../util/selection";
import {Constants} from "../../constants";
@@ -1254,7 +1254,13 @@ export class WYSIWYG {
endBlockElement = hasClosestBlock(range.endContainer);
}
if (startBlockElement && endBlockElement && !endBlockElement.isSameNode(startBlockElement)) {
- range.collapse(true);
+ if (range.startContainer.nodeType === 1 && (range.startContainer as HTMLElement).tagName === "DIV" && (range.startContainer as HTMLElement).classList.contains("protyle-attr")) {
+ setFirstNodeRange(getContenteditableElement(endBlockElement), range);
+ } else if (range.endOffset === 0 && range.endContainer.nodeType === 1 && (range.endContainer as HTMLElement).tagName === "DIV") {
+ setLastNodeRange(getContenteditableElement(startBlockElement), range, false);
+ } else {
+ range.collapse(true);
+ }
}
}
};