Trigger a spellcheck in a contenteditable div
Asked Answered
S

1

6

I am making an editor without relying on contenteditable, in order to get a clean, controlled output. So I'm catching all keyboard and mouse events, building a model and creating a DOM view from that model.

Since I need spellcheck, I activated contenteditable in divs in my view. The user doesn't interact with it, because I'm catching all events.

The problem I have is that spellchecking only seems to be activated on user input on the contenteditable div, which in my case happens only when I right-click somewhere on the text (because I'm not catching that). I've found a question that just says we shouldn't expect spellchecking to be active at the beginning - but in my case even when the user types, spellchecking doesn't happens (because he doesn't type in the contenteditable, I'm building it).

HTML spellcheck in contenteditable div not working after span

So is there a way I can trigger an event that would make the browser think the user is interacting with the contenteditable?

Update: that's only for Chrome, in Firefox the spellchecker works even without events directly caused by the user.

Stretchy answered 6/7, 2015 at 9:43 Comment(0)
A
1

If the focus is still on the contenteditable then setting spellcheck attribute of the contenteditable div to false and then back to true seems to trigger spellcheck again on Chrome.

Aureomycin answered 16/8, 2023 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.