Skip to content

"Copy link to highlight" experiment#1512

Merged
cdrini merged 16 commits intointernetarchive:masterfrom
schu96:custom-live-server
Apr 7, 2026
Merged

"Copy link to highlight" experiment#1512
cdrini merged 16 commits intointernetarchive:masterfrom
schu96:custom-live-server

Conversation

@schu96
Copy link
Copy Markdown
Collaborator

@schu96 schu96 commented Feb 18, 2026

Experiment adding a selection menu with a "Copy link to highlight" experiment. Uses the browser-native TextFragments to do the highlighting. In a future PR we will switch away from this to native

Known issues:

  • The browser-native text fragment auto-scrolls, which creates a confusing UI.
  • Some quotes/selections don't work correctly in some browsers. There are some very subtle discrepancies between how the browsers handle TextFragment support.
Recording.2026-04-07.192141.mp4

@schu96 schu96 force-pushed the custom-live-server branch from 548778a to 4cdb476 Compare February 18, 2026 20:56
@schu96 schu96 force-pushed the custom-live-server branch 3 times, most recently from d13eff6 to a523b45 Compare February 27, 2026 08:06
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 50.52083% with 95 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.98%. Comparing base (1c6792b) to head (c86d4c7).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
src/util/TextSelectionManager.js 52.41% 59 Missing ⚠️
src/plugins/url/plugin.url.js 50.00% 17 Missing ⚠️
src/plugins/url/UrlPlugin.js 11.11% 8 Missing ⚠️
src/plugins/plugin.text_selection.js 33.33% 6 Missing ⚠️
src/BookReader.js 60.00% 4 Missing ⚠️
src/BookReader/Mode2UpLit.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1512      +/-   ##
==========================================
- Coverage   69.71%   68.98%   -0.73%     
==========================================
  Files          65       65              
  Lines        5375     5556     +181     
  Branches     1183     1229      +46     
==========================================
+ Hits         3747     3833      +86     
- Misses       1594     1689      +95     
  Partials       34       34              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@schu96 schu96 changed the title Text highlight fragment share as Experiment Text highlight fragment share as Experiment - URL Mode History Mar 3, 2026
Copy link
Copy Markdown
Contributor

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! A number of code quality fixes / naming / etc. Note I got up to src/util/TextSelectionManager.js, but still have the rest of the diff to get through.

@schu96 schu96 force-pushed the custom-live-server branch from c53bba1 to d7116ab Compare March 10, 2026 20:50
postEndRange.setStart(selection.focusNode, selection.focusNode.textContent.length);
postEndRange.setEnd(pageLayer.lastElementChild, pageLayer.lastElementChild.childElementCount);
}
postEndRange.setStart(endNode, endNode.textContent.length);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got an error on this line ; sometimes it seems like the the endNode can have no selection in it!

To repro:
http://127.0.0.1:8000/details/adventureofsherl0000unse/page/62/mode/2up

  1. Highlight "It missed him" on the bottom of the right page.
  2. Double/triple click on the selection until the entire line is highlighted
  3. Try to copy link

Errors:

Image

@cdrini cdrini changed the title Text highlight fragment share as Experiment - URL Mode History "Copy link to highlight" experiment Apr 7, 2026
@cdrini cdrini marked this pull request as ready for review April 7, 2026 17:25
@cdrini cdrini self-assigned this Apr 7, 2026
@cdrini cdrini force-pushed the custom-live-server branch 2 times, most recently from 4c168cc to 342fc62 Compare April 7, 2026 23:18
Copy link
Copy Markdown
Contributor

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! Updated the description with our notes/next steps. This shouldn't otherwise cause any issues with text selection, although I will do a thorough re-test of text selection before this is deployed out. Otherwise tested it and it worked -- given the known issues in the description.

@cdrini cdrini force-pushed the custom-live-server branch from 342fc62 to c86d4c7 Compare April 7, 2026 23:31
@cdrini cdrini merged commit 2908b1e into internetarchive:master Apr 7, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants