Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/6720

Vanessa804ca9710e51
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 7a8e5deb13..f8b8f0d4c1 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -595,7 +595,13 @@ export class Toolbar {
// 数学公式后面处理
} else {
if (newNodes[0].firstChild) {
- this.range.setStart(newNodes[0].firstChild, 0);
+ if (newNodes[0].firstChild.textContent === Constants.ZWSP) {
+ // 新建元素时光标消失 https://github.com/siyuan-note/siyuan/issues/6481
+ // 新建元素粘贴后元素消失 https://ld246.com/article/1665556907936
+ this.range.setStart(newNodes[0].firstChild, 1);
+ } else {
+ this.range.setStart(newNodes[0].firstChild, 0);
+ }
} else if (newNodes[0].nodeType === 3) {
this.range.setStart(newNodes[0], 0);
} else {
@@ -627,7 +633,8 @@ export class Toolbar {
if (lastNewNode.lastChild) {
if (lastNewNode.lastChild.textContent === Constants.ZWSP) {
// 新建元素时光标消失 https://github.com/siyuan-note/siyuan/issues/6481
- this.range.collapse();
+ // 新建元素粘贴后元素消失 https://ld246.com/article/1665556907936
+ this.range.collapse(true);
} else {
this.range.setEnd(lastNewNode.lastChild, lastNewNode.lastChild.textContent.length);
}