Skip to content

Commit

Permalink
fastmail#472 check if selection includes a non editable inline elemen…
Browse files Browse the repository at this point in the history
…t by iterating parent nodes instead of only checking the startContainer (which does not work)
  • Loading branch information
Alexander Gratzl committed Jan 10, 2025
1 parent d59fff8 commit bea998e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/range/Boundaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,13 @@ const moveRangeBoundariesUpTree = (

range.setStart(startContainer, startOffset);

if (startContainer instanceof HTMLElement && !startContainer.isContentEditable) {
range.setStart(endContainer, endOffset);
let node = startContainer;
while (isInline(node)) {
if (node instanceof HTMLElement && !node.isContentEditable) {
range.setStart(endContainer, endOffset);
break;
}
node = node.parentNode!;
}

range.setEnd(endContainer, endOffset);
Expand Down

0 comments on commit bea998e

Please sign in to comment.