From 804ca9710e51f51ceddb8b654d9a405715008537 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 26 Nov 2022 11:14:57 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/6720 --- app/src/protyle/toolbar/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 7a8e5deb1..f8b8f0d4c 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); }