Add support for setting content state outside of an event listener
See original GitHub issueI have a modal that have a list of text options with a copy
button beside each. When you click the copy button it should take that takes and updates content
which would render CKEditor
with the correct content copied over showing. I have it wired up where onClick of the copy button updates editor content state, which works, but it doesn’t update what the editor shows in the UI since it seems it only updates via one of the set eventListeners.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
EventTarget.addEventListener() - Web APIs | MDN
It works on any event target, not just HTML or SVG elements. The method addEventListener() works by adding a function, or an object...
Read more >Wrong React hooks behaviour with event listener
Another solution is to re-register the event listener every time, so a callback always ... useState currently supports only immutable state.
Read more >Event handler in addEventListener doesn't have access to the ...
I'm using react 16.8.0-alpha.1 with hooks and typescript and noticed this strange behavior. If I attach an event listener to the document or ......
Read more >How To Handle DOM and Window Events with React
In React apps, you can use event handlers to update state data, trigger prop changes, or prevent default browser actions. To do this,...
Read more >Working with App State and Event Listeners in React Native
Firstly visiting useRef , we can give event listeners a true state value by making a couple of small changes from the above...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi,
Events are used for listening to changes that happen inside CKEditor and take actions based on that. You cannot use it the other way to perform action on CKeditor instance from outside.
To change content inside your CKEditor from your parent component(modal in your case). You need to add a ref to it and then access the child functions. Here is an example.
Add ref like this to your CKEditor.
<CKEditor ref={instance => { this.ckeditor = instance; }} />
Now you can set data in your CKEditor like this. Simply call this method in your onClick of the copy button with new data. It will be reflected in your CKEditor.
this.ckeditor.editorInstance.setData(yourData);
Hope this solves your query.
Sure will try that. Thanks