Skip to content

Commit

Permalink
fix: delete component
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Jun 26, 2021
1 parent 26ad91c commit 04fc6e5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 04fc6e5

Please sign in to comment.