From 3fb7929604af5c2d5fe6dcb2cc6c0a7e526cf913 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 10 Nov 2022 10:03:41 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/6481 --- app/src/protyle/toolbar/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index f8ef15194..c97b471d6 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -614,7 +614,12 @@ export class Toolbar { this.range.collapse(true); } else { if (lastNewNode.lastChild) { - this.range.setEnd(lastNewNode.lastChild, lastNewNode.lastChild.textContent.length); + if (lastNewNode.lastChild.textContent === Constants.ZWSP) { + // 新建元素时光标消失 https://github.com/siyuan-note/siyuan/issues/6481 + this.range.collapse(); + } else { + this.range.setEnd(lastNewNode.lastChild, lastNewNode.lastChild.textContent.length); + } } else if (lastNewNode.nodeType === 3) { this.range.setEnd(lastNewNode, lastNewNode.textContent.length); if (lastNewNode.textContent === Constants.ZWSP) {