fix: inline paste range error

This commit is contained in:
yanmao 2022-01-05 21:43:28 +08:00
parent f73ebe947c
commit d822e04c0d
1 changed files with 7 additions and 1 deletions

View File

@ -360,8 +360,14 @@ class ChangeModel implements ChangeInterface {
if (!isCollapsed) { if (!isCollapsed) {
this.delete(range, onlyOne || !isBlockLast, followActiveMark); this.delete(range, onlyOne || !isBlockLast, followActiveMark);
} else if (range.startNode.isText()) { } else if (range.startNode.isText()) {
const inlineNode = inline.closest(range.startNode);
const text = range.startNode.text(); 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 = let startRange: { node: NodeInterface; offset: number } | undefined =
undefined; undefined;