How to understand CKEditor4's “justify” option?

自闭症网瘾萝莉.ら 提交于 2021-01-29 14:21:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!