-
Notifications
You must be signed in to change notification settings - Fork 10.5k
fix: support text selection under search highlights #20463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: support text selection under search highlights #20463
Conversation
|
/botio preview |
From: Bot.io (Windows)ReceivedCommand cmd_preview from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.193.163.58:8877/a81d0fc6ccd40ac/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.241.84.105:8877/b10e44dc6200d7d/output.txt |
|
(this PR should be labeled as |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/b10e44dc6200d7d/output.txt Total script time: 0.99 mins Published |
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/a81d0fc6ccd40ac/output.txt Total script time: 3.51 mins Published |
| const endDiv = this.#textLayers.get(parentTextLayer); | ||
| if (endDiv) { | ||
| const anchorHighlighted = anchor.classList?.contains("highlight"); | ||
| if (endDiv && !anchorHighlighted) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fix would be more robust if we moved the highlight check to where we find the anchor:
let anchor = modifyStart ? range.startContainer : range.endContainer;
if (anchor.nodeType === Node.TEXT_NODE) {
anchor = anchor.parentNode;
}
if (anchor.classList?.contains("highlighted")) {
anchor = anchor.parentNode;
}However, I could not find a way to "break" selection with the current approach (tested with test/pdfs/chrome-text-selection-markedContent.pdf), so it's probably fine too.
|
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.241.84.105:8877/09db56172e1d42e/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_integrationtest from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.193.163.58:8877/68ec04988f22474/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/09db56172e1d42e/output.txt Total script time: 20.46 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/68ec04988f22474/output.txt Total script time: 40.20 mins
|
Fixes an issue where highlighted search results interfere with text selection. From what we can tell, the issue stems from moving
.endOfContentto the search highlight span, preventing the selection range from being extended.Steps to reproduce the issue:
pdfjs-highlight-issue.mov
The fix was tested on the demo viewer locally:
pdfjs-highlight-fix.mov