Problem/Motivation
The svg for the icons in the Admin Toolbar UI added in [] was manually copied. In the future it would be better if there was a way to automate this, both for this project and any contrib that used icons that are embedded in the plugin code / repo.
Proposed resolution
@reinmar suggested a possible way forward, using an instantiated editor with the plugin added, calling:
editor.ui.componentFactory.create('toolbarItemName')
This returns an object with a number of useful methods, specifically a getter for icon
which returns a string of the svg.
The ckeditor 4 module in core uses a "hidden" fully loaded instance of ckeditor to get the icons for the toolbar,
we could do something similar in a build step- load the editor with the given plugin(s) and write the output svg to a file.
This same method may be useful for getting translated labels as well, since there is also a getter for the tooltip string.
Remaining tasks
- Determine the best way to automate future icon changes / additions / replacements.
- Determine how to use the icon, whether that is saved to a file, loaded dynamically in the toolbar ui etc.
- Decide whether to also get the tooltip label the same way so that tooltips are consistent and also take advantage of CKEditor 5's translation system
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3202598-6.patch | 1.95 KB | wim leers |
Comments
Comment #2
zrpnrComment #3
wim leersTalked to Piotr from CKE5.
In ~ few months these icons should be made publicly available, instead of in the current private repo.
Comment #4
wim leersComment #5
wim leersWe should bring this up in tomorrow’s meeting with the CKEditor 5 team.
Comment #6
wim leersNot sure I understand this, because this has been available for years: https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-cor....
This would allow us to delete most of the icons in
core/modules/ckeditor5/icons— not the ones that are Drupal-specific.The issue summary still outlines accurate remaining tasks — plenty of things still need to be figured out.
Comment #7
wim leersMarking for getting rid of the other icons in
core/modules/ckeditor5/icons… or automatically extracting them as part of theyarn ckeditor5:buildcommand that lives incore/package.json.The issue summary also covers more than what the title conveys: it also says we should/could be updating the button labels (in
ckeditor5.ckeditor5.yml) automatically. Clarified that.Comment #9
wim leersIOW: the question is whether we should automate the copying of SVGs from https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-cor... into
core/modules/ckeditor5/icons.Comment #11
wim leersWe never had this for CKEditor 4 either. This never became an issue there. So let's be pragmatic and retire this issue after ~1.5 years.