-
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
Plugin Configuration: Support Optional Dependencies to Plugins #12199
Comments
For integrating into optionally available plugins, we need to wait for their schema elements to be registered, prior to extending these registrations. Added a similar approach as for GHS, to workaround any other better approach, as suggested in ckeditor/ckeditor5#12199.
Interesting subject. If you need to, for now, you can workaround this by using When it comes to what What I see in |
Hi @scofalik,
I did not try it, but one of my colleagues, and he reported, it failed – at least trying to hook into the
Yes, it looks like a hack, but reading it, it looks as if it got developed having to deal with several pains in initialization order. For the given use-case, such an extra event would help. But plugins should not register more elements at this stage, they should only be allowed to extend existing registered elements. Otherwise, if plugin A registers a new element in this new event, plugin B could not extend it or struggles with the same issues. Side note: For the /*
* As GHS registers `htmlImg` late in CKEditor's initialization process,
* there does not seem to be a good/robust way to extend `htmlImg` element.
* That is why we instead listen to `checkAttribute` to handle this case
* on demand.
*/
schema.on(
"checkAttribute",
(evt, args) => {
const context = args[0];
const attributeName = args[1];
if (context.endsWith("htmlImg") && attributeName === "xdiff-changetype") {
// Prevent next listeners from being called.
evt.stop();
// Set the checkAttribute()'s return value.
evt.return = true;
}
},
{ priority: "high" }
); This works like a charm. Kudos to your documentation. |
Yes, of course, we should have some simple and clear rules what is a good place to do what. We miss that right now, so the rules are basically:
|
There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may be relevant, so if you're interested in the solution, leave a comment or reaction under this issue. |
Yes, I'd still be interested in a better dependency management. Now that the CKE5 plugin ecosystem grows and thrives and more plugins will come out that depend on one another, there's growing demand I guess to define precise dependencies somewhat along the lines of what's been proposed in the issue summary. That is, a plugin should be able to specifically say "I depend on other plugin XY and want to be initialized after it". Otherwise we'd have to resort to afterInit(), afterAfterInit(), afterInitButBeforeAfterAfterInit() and so on. It'll be a mess. So I'll definitely keep up my +1 to this. Thank you :-) PS, sorry I forgot... See this e.g. for a current issue where this has become a problem: https://www.drupal.org/project/ckeditor_media_resize/issues/3387079 |
📝 Provide a description of the new feature
We have a challenge similar to the GHS feature: Integrate to other plugins, if they are installed.
GHS does so by listing to the event
init
ofeditor.data
:ckeditor5/packages/ckeditor5-html-support/src/datafilter.js
Lines 260 to 283 in e48c341
As you can see, it contains a lot of inline comments, a comment about "how to carefully select a priority", which makes us feel: Doing it the same way may easily break, unless CKEditor provides a contract, that this will work.
Use Case Details
As sometimes, it is easier understanding the use-case (to think of possible alternatives), here is ours:
In our solution, we want to "optionally depend" not only on the Image-Plugin (
inlineImage
), but also on GHS'htmlImg
, if the Image-Plugin is not installed.Suggestion
Without knowing details, something like this may provide a more general solution:
optionallyDependingOn
should adjust the initialization order, in that way, that, ifImageInline
plugin is available, that the "optionally depending" plugin'sinit()
method is called after theinit()
method ofImageInline
.If you'd like to see this feature implemented, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: