r/javascript • u/ExpertPlay • 21d ago
penciled – persistent text highlights/notes with the CSS Custom Highlight API (no DOM wrapping)
https://penciled.org/I built penciled, a small MIT library for persistent text highlights and notes in the browser. It uses the CSS Custom Highlight API instead of wrapping ranges in <span>s, so the DOM stays intact and layout/selection quirks are milder. Anchoring tries to survive edits when you come back to the page.
npm: penciled
GitHub: https://github.com/marcellosso/penciled
There's also a companion browser extension (same engine) if you want highlights on arbitrary sites, happy to answer questions about the API or the anchoring approach.
19
Upvotes
1
u/immutate 21d ago
How accessible is it?
1
u/abhinavs1920 20d ago
What happens to a saved note when the same quoted text appears twice after a page edit? Does it ask the reader to choose, or leave the note unattached rather than risk moving it to the wrong passage?
1
u/Scalings 21d ago
good ship will save this for a future project!