You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow discovery of plugin buttons via ae_uibridge #667
AlloyEditor supports using CKEditor plugins thanks to the ae_*bridge set of plugins. However, in order to add the buttons to a toolbar, the user needs to figure out how is the particular plugin naming the button, so for instance, in order to use the Paste from Word plugin, one would need to do the following:
Since this is error-prone and forces the user to dig into the plugin code for the exact string, it would be nice to have some kind of API so a user could simply do:
Hey @julien, thanks for working on this. Unfortunately, I don't think that's a viable implementation. We need these to be dynamic in a way that only available buttons show up and in a way we don't have to manually maintain a plugin list.
On top of that, there are some plugins exposing more than one ui component. For example the font plugin introduces two buttons Font and FontSize
The expected behaviour would be:
// Scenario 1, font plugin is loaded using extraPluginseditor.getButtonsFor('font');// ['Font', 'FontSize']
// Scenario 2, font plugin is not loadededitor.getButtonsFor('font');// []
I haven't prepared any pr yet, but as I understand we need some kind of "iterator" to go through all the "required" plugins given a plugin name ... (please correct me if I'm wrong)
AlloyEditor.getButtonFor('PasteFromWord');// output: ["pastefromword", "clipboard", "dialog", "dialogui"]// or in the case of an unexisting pluginAlloyEditor.getButtonFor('NoSuchPluginRegistered');// output: ''
The PluginIterator might not be the best name and should probably be placed in another file (or it's own file) rather than being in the getButtonFor function, but tell me if that looks better than previously.
Activity
jbalsas commentedon Jan 13, 2017
This won't make it in the
1.3.1milestone. Targeting next release now...julien commentedon Jan 23, 2017
Hi @jbalsas,
Could you tell me if something like this
Would be a possible implementation?
Thanks!
jbalsas commentedon Jan 23, 2017
Hey @julien, thanks for working on this. Unfortunately, I don't think that's a viable implementation. We need these to be dynamic in a way that only available buttons show up and in a way we don't have to manually maintain a plugin list.
On top of that, there are some plugins exposing more than one ui component. For example the
font pluginintroduces two buttonsFontandFontSizeThe expected behaviour would be:
I think the common entry point is https://github.com/liferay/alloy-editor/blob/master/src/ui/react/src/uibridge/uibridge.js#L27-L35, or inside the independent
addhandlers of every bridge. Plugins registering ui components are necessarily running over those handlers, and if we could identify the calling plugin, then we'd have a dynamic and real map of the available buttons.julien commentedon Jan 24, 2017
Hi @jbalsas you're welcome, and thanks for the pointers I will have a look in that direction.
julien commentedon Jan 24, 2017
Hi again @jbalsas,
So I had a look at https://github.com/liferay/alloy-editor/blob/master/src/ui/react/src/uibridge/uibridge.js#L27-L35 and it was a good starting point.
I haven't prepared any pr yet, but as I understand we need some kind of "iterator" to go through all the "required" plugins given a plugin name ... (please correct me if I'm wrong)
I've modified my previous code to look like this
Which would work the following way
The
PluginIteratormight not be the best name and should probably be placed in another file (or it's own file) rather than being in thegetButtonForfunction, but tell me if that looks better than previously.Thanks!
jbalsas commentedon Jan 25, 2017
Hey @julien, you're overthinking this. Take the
fontplugin as an example.You can see that it will call the
editor.ui.addRichCombomethod one per registered ui component.In there, we already have the buttons names, so we could simply do:
Then, you should simply need something like:
Now, of course throwing an error to get the plugin name sounds like a very bad idea, so it'd be better to be able to do it in a nicer way :)
Overrides CKEDITOR.plugins.load to wrap plugin lifecycle methods and …
jbalsas commentedon Apr 6, 2017
I've re-added this to the now
1.4.0milestone. Based on #718 I'm confident we can land this soon....Adds a plugin discovery feature
7 remaining items
Allows for the buttons input to be a function that returns the array …
Updates tests for getButtons API
Overrides CKEDITOR.plugins.load to wrap plugin lifecycle methods and …
Updates registerBridgeButton API and usage
Makes sure bridge handlers are added before plugins init phase is pro…
Improves API name so it is clear what it does
Sets the processing plugin to null instead of deleting it
Uses Object.keys for safer iteration
Renames API to getButtons and makes it async for easier usage
Allows for the buttons input to be a function that returns the array …
Updates tests for getButtons API
Source formatting
Add build files (auto-generated)
Adds a plugin discovery feature