Skip to content

[css-highlight-api] Need to support a mechanism for creating ranges inside textarea and input elements #4603

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

Open
sanketj opened this issue Dec 14, 2019 · 10 comments

Comments

@sanketj
Copy link
Member

sanketj commented Dec 14, 2019

Moving this issue over from: MicrosoftEdge/MSEdgeExplainers#78.

Textarea and input elements can't be highlighted with this proposal. We need a mechanism to express the position of a range inside these elements so that spellchecking/grammar extensions can add squiggles to these elements too.

@frivoal
Copy link
Collaborator

frivoal commented Dec 16, 2019

I suspect this might be best handled by an extension to range objects that can reach into these elements, and that this should be discussed over in https://github.com/whatwg/dom/issues

@sanketj
Copy link
Member Author

sanketj commented Apr 15, 2021

Closing this issue out for now as it is not relevant for css-highlight-api-1. This will likely require a new proposal, and yes, it most likely live over in WHATWG DOM.

@sanketj sanketj closed this as completed Apr 15, 2021
@frivoal
Copy link
Collaborator

frivoal commented Apr 26, 2021

I suspect we should check with the WHATWG / the TAG that they agree this is likely to be solved the way we think before closing, because if not, we've got some harder thinking to do.

@frivoal frivoal reopened this Apr 26, 2021
@sanketj
Copy link
Member Author

sanketj commented Feb 3, 2022

@frivoal I think this is beyond scope for css-highlight-api-1. This is also just a tracking issue for future work in WHATWG DOM. What's the best way to keep this issue around, but not let it block css-highlight-api-1?

cc: @dandclark

@frivoal
Copy link
Collaborator

frivoal commented Feb 3, 2022

I think we should either conclude that this is indeed going to be solved by some future addition and close this issue (most likely), or that the fact that we haven't solved this shows the whole approach is wrong and we need to start from scratch (I very sincerely hope not). @atanassov @LeaVerou @plinss can the TAG have a look at this issue?

@iNalgiev
Copy link

Any updates on this thread?
I noticed the same issue also applies to contenteditable elements. It does not seem to highlight the text inside these areas.

@schenney-chromium
Copy link
Contributor

I just tested Chrome 121 and succeeded in setting highlights inside a contenteditable="true" div, and editing the content while maintaining the highlight.

Do you have an example of it not working?

Otherwise no update on the status of textarea.

@iNalgiev
Copy link

iNalgiev commented Jan 29, 2024

Here's an example with contenteditable="true" element.
This using the Ngx Tiptap editor example. The highlighting code should mark "Hello" but nothing is happening.
stackblitz demo

@schenney-chromium
Copy link
Contributor

There's a lot going on in your example, but one thing I do notice is that DevTools says the CSS highlight is named 'search-result-highlight' but the js says HIGHLIGHT_NAME='match' If I edit the CSS to name the highlight 'match' I get a yellow "Hello".

@bramus
Copy link
Contributor

bramus commented Feb 19, 2024

+1 on adding support for custom highlights textarea/input. Got numerous requests from authors about this.

As for [contenteditable]: I could get it to work but it was a lot of jumping through hoops mainly because of [contenteditable] itself doing Weird Things™. Demo + Write-up: https://www.bram.us/2024/02/18/custom-highlight-api-for-syntax-highlighting/#highlighting-contenteditable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants