-
-
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
Make Plugin an interface #2913
Comments
I would definitely help us get rid of core deps in the UI like this one https://github.com/ckeditor/ckeditor5-ui/blob/master/src/contextualballoon.js#L30. What are disadvantages of the interface approach? I struggle to find any but, for some reason, we decided to go with the |
Pretty much none. That you won't find immediately that you have a broken installation of CKE packages. Right now you get an error that you try to load something which is not an instance of a plugin and this happens if some pkg is duplicated. It's both annoying and super helpful because it catches the issue very early. Other than that, I had this idea to have plugin as an interface for a very long time and never had much against it, so there were no other reasons. The initial implementation of the plugin system defined plugin as a class and then we followed. |
I guess we can preserve this making the |
Nope. It's just a property. It doesn't check whether the core package isn't duplicated somewhere. |
OK, the plan of action here needs to make sure that we'll not be paralyzed during the process, so I propose to split it into 3 steps: 1. Allow defining plugins which are simple functionsThis is a change which needs to be done here, in this repo. We should move the documentation of All tests in this repo should stop using the We should add a warning directly in the 2. Converting existing plugins to simple functionsAfter step 1. is done and merged, we need to convert existing plugins (all across our codebase). Most of the time it's just a matter of removing 3. When no plugins leftAfter we have all existing code changed and no warnings about use of the deprecated module in the tests, we can remove the |
There will be a bit more work in step 1. because the |
I've just realised that this is a bad idea ;| Plugin is a handful util which implements the observable mixin and exposes If we'll remove this class, we'll force everyone to mix the observable API and implement Sorry for the mess. I need to yet think on whether we shouldn't do anything or just loosen the |
OK, I guess it's quite useful if you were able to pass any function as a plugin. This may be especially helpful if you're dealing with a built editor and don't have access to the In such case, we only need to split This means far less work because we won't be touching existing plugins. It's only ckeditor5-core related change. |
Sounds good. I will fix the PR. |
I guess you should just start from scratch. Don't mix two different concepts in one PR. |
Other: Introduced `PluginInterface`. A plugin doesn't need to inherit directly from the `Plugin` class, as long as it implements some minimal interface. See #78.
I think we agreed that
PluginCollection
can easily become a util. For that we have https://github.com/ckeditor/ckeditor5-core/issues/57.The second part of the puzzle is to remove the
Plugin
class and make it an interface. Interface which defines thatrequires
andpluginName
static props have special meaning and that the constructor is called with a plugin's context (which is different, depending who's the owner of the plugin collection).This will allow us to remove
ckeditor5-core
imports from many packages and will allow defining plugins on the fly. E.g. like this:Yep, class constructor is just a function, so you don't even have to use ES6 classes here.
The text was updated successfully, but these errors were encountered: