Skip to content

Spellcheck: Live check - #776

Open
robinbisping wants to merge 4 commits into
masterfrom
spellcheck-live-check
Open

Spellcheck: Live check#776
robinbisping wants to merge 4 commits into
masterfrom
spellcheck-live-check

Conversation

@robinbisping

@robinbisping robinbisping commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Relations:

Description

Spellchecking needs to underline mistakes in a text, but a mistake is not part of the document. The existing highlighting wraps text in marker elements, which would put the underlines into the content. This adds a second way to highlight, built on the CSS Custom Highlight API. The browser paints the ranges and the DOM stays untouched.

  • setCssHighlight({name, ranges}) highlights character ranges under a name. One call can cover ranges in many editables, and it replaces everything held under that name. The look is up to the consumer through the ::highlight() selector.
  • deleteCssHighlight({name}) removes the highlights of a name and forgets where they were.
  • getCssHighlightText({editableHost}) returns the text of an editable without its markup. This is the text the character offsets count against.
  • getCssHighlightCursorOffset({editableHost}) returns the cursor position as a character offset in that text, which tells a caller which highlight the cursor sits in.
  • getCssHighlightRects({editableHost, start, end}) returns where a character range sits on screen, so a caller can place a popover next to it.
  • replaceCssHighlight({editableHost, start, end, text}) replaces a character range with new text, dispatched like any other edit.

Changelog

  • 🎁 New API to highlight character ranges in an editable without changing its content, based on the CSS Custom Highlight API. Highlights survive markup changes such as comments and formatting.

@robinbisping robinbisping changed the title Spellcheck Spellcheck: Live check Aug 21, 2026
@robinbisping
robinbisping force-pushed the spellcheck-live-check branch from fc34d11 to 7bbb8c6 Compare August 21, 2026 12:01
@robinbisping
robinbisping marked this pull request as ready for review August 21, 2026 12:15
@robinbisping
robinbisping requested a review from eileenoo August 21, 2026 12:15
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.

1 participant