Skip to content

Commit

Permalink
fix: #584 core.insertNode
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Jan 23, 2021
1 parent 09100f5 commit f4904e2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1607,16 +1607,19 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
if (!isFormats && prevContainer) {
parentNode = prevContainer.nodeType === 3 ? prevContainer.parentNode : prevContainer;
if (parentNode.contains(container)) {
let sameParent = true;
afterNode = container;
while (afterNode.parentNode !== parentNode) {
afterNode = afterNode.parentNode;
sameParent = false;
}
if (sameParent && container === prevContainer) afterNode = afterNode.nextSibling;
} else {
afterNode = null;
}
} else {
parentNode = isFormats ? commonCon : util.isFormatElement(container) ? container : container.parentNode;
afterNode = isFormats ? endCon : util.isFormatElement(container) ? null : container;
afterNode = isFormats ? endCon : container === prevContainer ? container.nextSibling : container;
parentNode = (!afterNode || !afterNode.parentNode) ? commonCon : afterNode.parentNode;
}

while (afterNode && !util.isFormatElement(afterNode) && afterNode.parentNode !== commonCon) {
Expand Down

0 comments on commit f4904e2

Please sign in to comment.