From 04fc6e50322ef00f63e1489f88d19904b1caffae Mon Sep 17 00:00:00 2001 From: JiHong88 <0125ses@hanmail.net> Date: Sat, 26 Jun 2021 14:41:29 +0900 Subject: [PATCH] fix: delete component --- src/lib/core.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/core.js b/src/lib/core.js index 4af9b13ba..f559ef157 100755 --- a/src/lib/core.js +++ b/src/lib/core.js @@ -6288,13 +6288,18 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re } if (!selectRange && (core.isEdgePoint(range.endContainer, range.endOffset) || (selectionNode === formatEl ? !!formatEl.childNodes[range.startOffset] : false))) { - const sel = selectionNode === formatEl ? formatEl.childNodes[range.startOffset] : selectionNode; + const sel = selectionNode === formatEl ? formatEl.childNodes[range.startOffset] || selectionNode : selectionNode; // delete nonEditable if (sel && util.isNonEditable(sel.nextSibling)) { e.preventDefault(); e.stopPropagation(); util.removeItem(sel.nextSibling); break; + } else if (util.isComponent(sel)) { + e.preventDefault(); + e.stopPropagation(); + util.removeItem(sel); + break; } } @@ -6945,13 +6950,14 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re const eCell = util.getRangeFormatElement(ec); const sIsCell = util.isCell(sCell); const eIsCell = util.isCell(eCell); + const ancestor = range.commonAncestorContainer; if (((sIsCell && !sCell.previousElementSibling && !sCell.parentElement.previousElementSibling) || (eIsCell && !eCell.nextElementSibling && !eCell.parentElement.nextElementSibling)) && sCell !== eCell) { if (!sIsCell) { - util.removeItem(util.getParentElement(eCell, util.isComponent)); + util.removeItem(util.getParentElement(eCell, function(current) {return ancestor === current.parentNode;})); } else if (!eIsCell) { - util.removeItem(util.getParentElement(sCell, util.isComponent)); + util.removeItem(util.getParentElement(sCell, function(current) {return ancestor === current.parentNode;})); } else { - util.removeItem(util.getParentElement(sCell, util.isComponent)); + util.removeItem(util.getParentElement(sCell, function(current) {return ancestor === current.parentNode;})); core.nativeFocus(); return true; }