-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Plugins can not set data, a.k.a. editor.instanceReady #2869
Comments
We definitely miss a lot of events now. I've also spotted https://github.com/ckeditor/ckeditor5-heading/issues/40 some time ago. I guess we can add few basic events like after plugin init, on ready. But in fact, your request is a bit strange. Why would a plugin load data? I guess that you're trying to integrate CKEditor with its surrounding by defining a plugin... which isn't necessarily correct. Mind that if your plugin would listen on In other words – you reported a ticket which would be valid in CKE4 world. In CKE5 world, if you need this for your integration, just write a better But this of course doesn't change the fact that by default we could fire a few events. |
I'll add two events |
We need to talk about counting. |
This feature is required for https://github.com/ckeditor/ckeditor5-heading/issues/40. And will require small changes in the classic creator. |
I've just realised that we could also have |
I've been also thinking about the I see that we use However, there's a reason why we used So, I want to propose that constructor is the "before init" (to be used in special cases), WDYT? |
That's a very cool idea. Especially the I'm thinking if it should be a method or an event. The profit of having a method is that you can return a promise there and we could handle it. On the other hand, it might be unclear what |
You're going too far :D. There's no "I want to do something before anyone else do anything". I don't recall a case from CKEditor 4 in which that would be a problem. >90% of the code lands in And, to make it clear, in CKEditor 5 I don't want to have |
If no beforeInit, I think that an event solution would fit better. In this way we have many different points in time during the editor loading that can be listened by plugins, in the very same way. It would make the code clearer, without special cases. |
As I pointed out in ckeditor/ckeditor5-core#48 (comment) there's no simple way to have a separate |
I see that my comment was very unclear... I was talking about |
Now, the order of initialization is:
It means that plugins are
init
before theloadDataFromEditorElement
, which callssetData
. What if a plugin wants tosetData
?But wait, there is more! What if a plugin wants to modify initial data or just read them? Plugins are also initialized before the
ui
is initialized. What if a plugin wants to use the UI?So there could be an event that... the instance is ready, so plugins can execute some actions on it.
Alternatively, there could be a second method in plugins called when editor is ready. Thanks to it plugins could return a promise in this method what is not possible in events.
Another solution is to check if there is not data already loaded before calling
loadDataFromEditorElement
. It would solve only the fist problem, but it is my favorite solution because is the least intrusive and seems to be the most correct behavior (hacks-less).The text was updated successfully, but these errors were encountered: