-
Notifications
You must be signed in to change notification settings - Fork 715
[css-pseudo-4] Proposal: Highlight API #4307
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
Comments
@atanassov, could you please add the 'Agenda+' label to this issue and include it in the CSS WG agenda for TPAC? I don't have permission to do so myself. Thanks! |
Full list of existing Highlight API issues: https://github.com/MicrosoftEdge/MSEdgeExplainers/issues?q=is%3Aissue+is%3Aopen+label%3A%22Highlight+API%22 |
I'm happy to see this moving forward; I've wanted an API like this for a while. A few thoughts:
|
We already use "highlight" in CSS, although the name isn't exposed to authors. |
Yeah, it'd be: if(!CSS.highlights.has("foo")) {
CSS.highlights.set("foo", new HighlightRangeGroup);
}
CSS.highlights.get("foo").add(myRange); This is assuming that the HighlightRangeGroup is live and immediately responds to changes. Depending on semantics, it might be more like TypedOM and require you to re-set it before it sees the change, in which case the code could look like: CSS.highlights.set("foo",
(CSS.highlights.get("foo") || new HighlightRangeGroup)
.add(anotherRange)); So yeah, a little painful. That said, in practice, I'm not sure why a page would run into this situation. If they're doing highlighting, presumably they'd create and register the highlight group sometime early in the page lifecycle, and just hold onto it and modify the set as they need to change things? |
Hi CSS WG! I'm writing from the sync media in publications CG. We are working on a synchronized narration format, intended for use with standalone HTML documents and also with publications. Both the concept and format have precedent with DAISY books and EPUB media overlays: playback of content with text phrase highlight synchronized with audio clip playback. Have a look at our new demo. One perennial issue for us is referencing elements in an HTML file -- ID fragments have historically been the go-to, but something non-destructive would be ideal. Perhaps the highlight API can help? Anyone at TPAC this week and want to chat, I'd love to :) |
The HighlightsMap is a maplike object, so I would expect it to behave just like the JS Map in this regard. So this should work:
Here's an example of how this may be used: A spellchecking extension like Grammarly creates a highlight group for its spellcheck highlights when it first parses the page, and adds the group to the CSS.highlights map. (The extension may call .has to ensure there are no name conflicts before calling .set on the highlights map.) The extension will hold onto the group's name or the group itself. Subsequently, as the user types, a new misspelling is created. In response, the extension will create a range to surround the new spelling error and add the range to the group, either by directly calling .add if it was holding onto the group itself or via |
@marisademeglio: I'm at TPAC the whole week, so would be happy to chat. We could sync up during a coffee break and find some time. |
Huh, did the minutes here get lost? |
Discussion starts here in the logs |
And from the end https://logs.csswg.org/irc.w3.org/css/2019-09-15/#e1235420 RESOLVED: Adopt css-highlight-api as ED with sanketj, florian , and hober as editors; add issue into css-pseudo-4 for where it might be integrated pointing at the ED |
Just in case: I've implemented highlights in Sciter engine 3 years ago and have quite possitive experience with them so far. Primary usage: spell checker highlights and syntax colorization. The only major difference from the Highlight API spec is that I am using Yet it would be very benificial I think to allow
So these can be used as code editors. Some details and samples: |
Thanks @c-smile. We have an open issue to make highlights work inside textarea and inputs: MicrosoftEdge/MSEdgeExplainers#78. I think we also need to make them work well with closed web components. We were tracking the highlight API in the MSEdgeExplainer repo before, but it will soon be moved over to this repo. |
Link to existing highlight pseudo element spec: https://www.w3.org/TR/css-pseudo-4/#highlight-pseudos
Link to highlight API explainer: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/highlight/explainer.md
Short summary of the concept (first paragraph from highlight API explainer):
The Highlight API extends the concept of CSS Highlight Pseudo-elements by providing a way for web developers to style the text of arbitrary Range objects, rather than being limited to the user-agent defined ::selection, ::inactive-selection, ::spelling-error, and ::grammar-error. This is useful in a variety of scenarios, including editing frameworks that wish to implement their own selection, find-on-page over virtualized documents, multiple selection to represent online collaboration, and spellchecking frameworks.
I would like to discuss this proposal with the CSS WG at TPAC 2019. Creating this issue to track that request.
Hoped outcomes from CSS WG discussion at TPAC:
Issues to discuss:
Requested amount of time: 30 minutes
The text was updated successfully, but these errors were encountered: