-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Modify contents from browser extension #11974
Comments
Any changes done to HTML or selection in CKEditor 5 have to be done through model and there is no way around that. When you create editor, you are most likely assigning it to window object.
Having that you can use a lot (not all) of API in the browser console e.g.
|
Thank you @jswiderski for your answer. In the ckEditor demo, where the editor property is exposed (in window.editors array), I am, indeed, making the changes through the ckEditor model. It works flawlessly. On the other hand, I am writing a browser extension for various clients. There was a long discussion about it, but how it was eventually approached was not mentioned. |
Ok, so, for anyone interested in this, it is answered on FAQ |
@octavianSandu I tried that approach described in the FAQ, but the |
You need to run the code in the main world. See Chrome documentation. |
@tavi100 thanks, I didn't understand what that meant initially, but I got it to work. The only small problem I found is that Firefox does not support |
@cosimo - How you were able to make that work ? |
@Durgaprasad-Budhwani it's unfortunately been a very long time since I've got that code working, and I haven't used it in a while. This is what I believe worked:
Hope this is useful. |
@cosimo This works for me and thank you so much !!! |
📝 I need to be able to change the text contents of a ckEditor 5 instance via a browser extension
I know this is possible as it is done by Grammarly, but I have no idea how.
I guess that this is more of providing some documentation link and not adding new functionality.
For the demo site ( https://ckeditor.com/ckeditor-5/demo/ ) all works as I am using the ckEditor API that is available in the window.editors array. But, in real life, the API is not directly available.
So, is there any generic way to get access to the ckEditor API ?
Or how is it safe to make changes to the view without being blocked by the model?
Mostly, the API is used for making a selection (with the text to be removed), inserting the content, moving the cursor, refocusing the editor when focus is lost.
The text was updated successfully, but these errors were encountered: