-
Notifications
You must be signed in to change notification settings - Fork 2
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
Improve attaching libraries when a plugin is needed #5
Comments
That's not completely correct, though. Plugins implemented in this module... 😉 Additional plugins currently have to do the same. |
Again ... an issue, I really tried to solve, but failed. I can't see, how this could work without bigger changes in the filter module, which would in turn probably break CK4 and other editors. Hoping for someone smarter to proceed here. 😉 |
@indigoxela I filed a PR at #82 that makes an attempt at this. Since all of our dependency logic is in Ultimately, the end-result is the same for CKEditor 5 core module when used by itself, but this should make contrib modules extending this one have a much easier time of attaching libraries, since they no longer would need to use |
Interesting approach, will test ASAP 👍 |
In the current approach the code checks if a library is in use across all text formats. Another option would be to call |
🎉 Yes, this works as expected (tested with feef plugin, which I already had around). The previously necessary hook_library_info_alter to squeeze in the dependency's now obsolete. 👍 Mind to explain the danger of creating recursive loops with hook_filter_info_alter()? Or which hook did you mean? When would one run into that? BTW, I think it would actually be OK to always load all libraries of installed plugins – I'd actually assume that:
So, if you have something in mind, that seems easier to maintain, sure - give it a try, if you like. 👍 I've left a question on the PR re the usage of the static cache in ckeditor5_get_config, which I don't understand. 😉 |
I'm having a little trouble coming up with a problematic scenario. I guess I'm just worried that
One exception to this might be the Full Screen plugin in #76. If we bundle that plugin, it will always be loaded even if it's not used. I'll take a spin at not calculating library usage and just add associated plugin libraries all the time and see if that is cleaner than the current approach. |
I filed another PR at #83 that loads all plugin libraries. I think I'm more in favor of that approach. I kept the static caching as I realized that |
Many thanks, will try to test soon. Re the "Full Screen" (actually Maximize) plugin: it's relatively small, ~ 2KB js/css, and we still have the option to just make it a contrib project. Sure, it would be more elegant to only attach plugin code as needed. But if that leads to complicated code, and given our CKE dll build has 1.4MB, where 2KB more don't really matter, I think it might be OK. Just to make sure: we attach js/css, but js is never called, as the CKE instance isn't even aware of that code, right? How about CSS? I know, that's a theoretical questions, but could that lead to any problems (just being attached)? |
Great questions. The JS would never actually be called. I've had the experience several times already where I try to use some of the (many) unused plugins that are bundled with the DLL build of CKEditor, but I forgot to specify it in the The CSS on the other hand would be present on the page. Since CKEditor 5 does not use an iframe, it would affect any content within the editor that matches the given CSS selectors. I would expect however that the plugin would be mostly targeting classes added by the JavaScript plugin. Examples like the caption support, resize handles, link indicators, etc all target classes added by their respective plugins, so I don't think most plugins would affect what you see in the editor. |
Right now in
ckeditor_library_info()
, all possible external plugins are added as dependencies of the main library. This includesbackdrop-basic-styles
,backdrop-image
, andbackdrop-link
plugins. Although most instances will probably use these 3 plugins, and loading the plugin JS file doesn't mean it will be accessible in the toolbar or executed by CKEditor. Still, we shouldn't be attaching libraries we know aren't going to be used.The text was updated successfully, but these errors were encountered: