问题
I integrate the latest version of the CKEditor 4 Standard Version (v4.15 at the time of writing) via this link:
https://cdn.jsdelivr.net/npm/ckeditor4/ckeditor.js
By definition, the CKEditor 4 Standard Version does NOT include the "Justify" plugin, which is responsible for aligning text (left, right, center, justify) - at least to my understanding – according to the presets:
https://ckeditor.com/cke4/builder
And indeed, if I configure my setup with align rules, CKEditor won't recognise them:
CKEDITOR.toolbar = [
[ 'Undo', 'Redo' ],
[ 'Link', 'Unlink', 'Anchor' ],
[ 'JustifyLeft', 'JustifyCenter', 'JustifyRight' ], // <= not recognised
[ 'Bold', 'Italic', 'Underline', 'Strike' ],
[ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote' ],
'/',
[ 'SpecialChar' ],
[ 'Source', '-', 'RemoveFormat' ],
[ 'About' ]
]
However, as soon as I enable "justify" in the "extraPlugins" config option:
CKEDITOR.extraPlugins = "divarea,justify"
the align options mentioned above ARE recognised and work perfectly fine (even though, as already mentioned, the CKEDITOR 4 Standard Version Preset does not implement that very plugin).
I know that there is a "stylecombo" plugin, but that one is activated by default and seems not to be able to recognise the align features by itself.
In my opinion, the "justify" plugin should not work, throw an error and ignore any alignment configurations. But that's not the case...
On the other hand, when I try to include "Superscript" and "Subscript"
[ 'Bold', 'Italic', 'Underline', 'Strike', 'Superscript', 'Subscript' ],
which should be supported by the "basicstyles" plugin, they are NOT recognised. Here I was assuming that these button would be displayed in the editor.
Can anybody help me find out, what I am misunderstanding here, please? Thank you!
回答1:
JSDeliver provides NPM packages directly, so in this case you basically get NPM ckeditor4 package. And here, you are almost right on the standard
preset, however in case of NPM ckeditor4
package it provides standard-all
preset. And the difference is as README describes:
The CKEditor 4 npm package comes in the standard-all preset, so it includes all official CKEditor plugins, with those from the standard package active by default.
So this means Justify
plugin is included in the package but not active by default. And to activate it you just need to use extraPlugins configuration option as you mentioned.
This is mostly done for convenience so activating more plugins is as simple as changing editor configuration without a need to add additional packages.
来源:https://stackoverflow.com/questions/64350734/how-to-understand-ckeditor4s-justify-option