You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To set editor initial data we are using ElementApiMixin#loadDataFromElement that gets data from DOM element and sets it using DataController#set. After that Editor#dataReadyevent is fired.
This works fine when DOM is the only data source but does not make possible to sync editor with remote data while initialization process.
The idea is to decorate DataController#set method to make possible to override it and do some additional stuff. Besides ElementApiMixin#loadDataFromElement should return DataController#set in case that overridden method will return promise.
The text was updated successfully, but these errors were encountered:
We're entering a thin ice here. For now, the entire editor API was synchronous. As soon as some methods become asynchronous, you can never be sure how to use them unless we have a very good plan for that.
This situation is, unfortunately, very well known to me from CKEditor 4. In CKEditor 4 setData() was asynchronous because we used iframed editables (by default). However, sometimes (not sure if still, but that was true for some time), it acted synchronously if different kind of editor was used. This caused serious confusion and a lot of bugs.
However, fortunately, CKEditor 5 introduced a little detail which heavily affects this situation – the custom data model. What does it give us here? It means that setData() might be asynchronous, but the data will be available immediately.
In CKEditor 4 the data is only available from the editable. Which means that for a brief moment between setData() and dataReady, you cannot operate on your model/view.
In CKEditor 5, setData() will change the model synchronously and it will synchronously be rendered. The only thing which is asynchronous will be the dataReady event. It means that, e.g., two subsequent setData() calls or setData(); getData() will work. Actually – we must make them work!
So, to sum up – I can only agree to make setData() asynchronous if the only asynchronous thing in it is dataReady.
To set editor initial data we are using
ElementApiMixin#loadDataFromElement
that gets data from DOM element and sets it usingDataController#set
. After thatEditor#dataReady
event is fired.This works fine when DOM is the only data source but does not make possible to sync editor with remote data while initialization process.
The idea is to decorate
DataController#set
method to make possible to override it and do some additional stuff. BesidesElementApiMixin#loadDataFromElement
should returnDataController#set
in case that overridden method will return promise.The text was updated successfully, but these errors were encountered: