Skip to content

Commit

Permalink
Fix: core._resetRangeToTextNode #1471 #1472 #1473
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Jan 3, 2025
1 parent e8fc084 commit bae73ca
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
const range = this.getRange();
if (this._selectionVoid(range)) return false;

const collapsed = range.collapsed;
let startCon = range.startContainer;
let startOff = range.startOffset;
let endCon = range.endContainer;
Expand All @@ -1294,7 +1295,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
while (endCon && endCon.nodeType === 1 && endCon.lastChild) {
endCon = endCon.lastChild;
}
endOff = endCon.textContent.length;
endOff = collapsed ? 0 : endCon.textContent.length;
}

// startContainer
Expand Down Expand Up @@ -1477,7 +1478,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
* @param {String|undefined} dir Select check point - Both edge, Front edge or End edge. ("start": Front edge, "end": End edge, undefined: Both edge)
* @returns {Boolean}
*/
isEdgePoint: function (container, offset, dir) {
isEdgePoint: function (container, offset, dir) {
if (container.nodeType === 1 && !container.textContent.length) return true;
return (dir !== 'end' && offset === 0) || ((!dir || dir !== 'start') && !container.nodeValue && offset === 1) || ((!dir || dir === 'end') && !!container.nodeValue && offset === container.nodeValue.length);
},
Expand Down Expand Up @@ -7208,12 +7209,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
e.preventDefault();
e.stopPropagation();
break;
}

if (!selectRange && core._isEdgeFormat(range.endContainer, range.endOffset, 'end') && !formatEl.nextSibling) {
e.preventDefault();
e.stopPropagation();
return;
}

if (!selectRange && core._isEdgeFormat(range.endContainer, range.endOffset, 'end') && !formatEl.nextSibling) {
e.preventDefault();
e.stopPropagation();
return;
}

// tag[contenteditable="false"]
Expand Down

0 comments on commit bae73ca

Please sign in to comment.