From d822e04c0d6029743a4dc6e4908df65c88c85241 Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Wed, 5 Jan 2022 21:43:28 +0800 Subject: [PATCH] fix: inline paste range error --- packages/engine/src/change/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/engine/src/change/index.ts b/packages/engine/src/change/index.ts index a7e0bd1e..718d7af0 100644 --- a/packages/engine/src/change/index.ts +++ b/packages/engine/src/change/index.ts @@ -360,8 +360,14 @@ class ChangeModel implements ChangeInterface { if (!isCollapsed) { this.delete(range, onlyOne || !isBlockLast, followActiveMark); } else if (range.startNode.isText()) { + const inlineNode = inline.closest(range.startNode); const text = range.startNode.text(); - if (/^\u200B/.test(text)) range.startNode.text(text.substr(1)); + if ( + inlineNode.length === 0 && + !inlineNode.equal(range.startNode) && + /^\u200B/.test(text) + ) + range.startNode.text(text.substr(1)); } let startRange: { node: NodeInterface; offset: number } | undefined = undefined;