Open jodator opened 4 years ago
I was always against dynamic config as it creates many problems:
So, I'm rather looking for API-driven ways to change the editor behavior on the fly. Every case is different and handling it via API, when needed, ย makes to me the most sense.
That could be one reason for having some of the configuration dynamic: ckeditor/ckeditor5-vue#125 (this, and the linked issue).
Another reason for having configuration dynamic: #7871. And there's a solution that is kinda OK.
The plugin has an observable property which one can set after the plugin reads a configuration. The plugins listens on this property change and updates internal state.
I agree that the notion of making all configuration values dynamic is problematic -- it's sometimes not going to be possible for a plugin to handle config values changing, and even when it is it's likely to cause friction in writing plugins because of the effort needed to handle dynamic changes, even in cases where it's not very useful.
In my opinion, it should be opt-in by the plugin authors, which I think means one of three things:
Config
classConfig
class to allow plugins to define properties as dynamic, and provide an API on Config
for updating them (that maybe throws an error when trying to update a non-dynamic config value)(3) seems kinda like the worst of both worlds. (2) kinda makes sense, but potentially risks the nested object thing (e.g. can I modify config.foo.bar
without replacing all of config.foo
and still produce a change notification to the plugin?). I'd probably think about doing something like (1), then seeing how it shakes out and if dynamic config values end up widespread enough, maybe then implement (2) and deprecate then remove the various (1) implementations.
My two cents. For now we're running off of a fork of the TextTransformation plugin (see #7871), which isn't ideal, but gets us what we need.
Merged #7278 into this issue. There are some more use cases listed.
I see that this issue went from dynamic toolbar configuration to a generic dynamic configuration discussion.
Last week as a part of CKE5 team workshops we played with making the toolbar configurable and it was fairly easy to achieve:
https://user-images.githubusercontent.com/5353898/191475304-9ef161c3-e11c-4cb2-aae1-27528e1b547b.mp4
The code can be found on the workshops/dynamic-config
branch.
The demo can be found in manual tests: http://localhost:8125/ckeditor5-utils/tests/manual/config/config.html
The implementation simply adds the emitter interface for now - but it's just 2h of hacking.
๐ Provide a description of the improvement
After quick search i can see that most of the features reads configuration options at the plugin init stage. Only few read configuration option afterwards but that feels like a side-effect of the code rather then dynamic configuration.
Should we have dynamic configuration for some options?
Pros:
Cons:
Edit:
Other things to consider:
editor.properties
) that can be change during runtime?ยReferences issues: #7278.
If you'd like to see this improvement implemented, add a ๐ reaction to this post.