Skip to content

Commit

Permalink
improve handling of selected content (fix #1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
gildas-lormeau committed Mar 28, 2024
1 parent 62a4c9f commit f7a5a7f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ui/content/content-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,19 @@ function markSelectedContent() {
}
}
if (selectionFound && treeWalker.currentNode == range.endContainer && treeWalker.currentNode.querySelectorAll) {
treeWalker.currentNode.querySelectorAll("*").forEach(descendantElement => markSelectedNode(descendantElement));
for (
let offset = range.startContainer === range.endContainer ? range.startOffset : 0;
offset < range.endOffset;
offset++
) {
const node = range.endContainer.childNodes[offset];
if (node) {
markSelectedNode(node);
if (node.querySelectorAll) {
node.querySelectorAll("*").forEach(markSelectedNode);
}
}
}
}
}
}
Expand Down

0 comments on commit f7a5a7f

Please sign in to comment.