Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get toolbar available items in CKEDITOR 5?

Tags:

I wanted to configure the toolbar in CKEDITOR 5. I took a look at the documentation.

https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/builds/guides/integration/configuration.html

Yet, the only script related to my question is:

Array.from( editor.ui.componentFactory.names ); 

It is way too difficult for a frontend programmer to understand. Where do I put this script? How do I output the results? Is there a detailed tutorial?

Matter fact, it would be nice if CKEDITOR simply put the available items in the documentation. That will save a hell lot of troubles.

Thanks!

like image 687
stonyau Avatar asked Nov 20 '17 11:11

stonyau


People also ask

How do I add items to CKEditor toolbar?

The simplest way to configure the toolbar is to use the dedicated toolbar configurator that is available in each editor installation package starting from CKEditor 4.5. The editor instance below was configured by using the accessible "toolbar groups" approach, with some unwanted buttons removed by setting the config.

How do I edit CKEditor toolbar?

Click the Toolbar Configurator button in the top right-hand corner of the sample page to proceed to editing your toolbar. There are two types of toolbar configurator available: the basic, more visual one and the advanced one.

How do I add plugins to CKEditor 5?

Adding a plugin to a buildClone the build repository. Install the plugin package. Add it to the build configuration. Bundle the build.


2 Answers

You can put this code right in the body of code samples which you can find e.g. in CKEditor 5 Build's Basic API guide. For example:

ClassicEditor     .create( document.querySelector( '#editor' ) )     .then( editor => {         console.log( Array.from( editor.ui.componentFactory.names() ) );     } )     .catch( error => {         console.error( error );     } ); 

As @Szymon Cofalik mentioned in his answer – there's no single list of buttons which are available in all builds. CKEditor 5 builds may differ not only visually – they may also contain different plugins and hence different buttons. So, using that code snippet is the safest and future-proof solution.

like image 126
Reinmar Avatar answered Sep 28 '22 16:09

Reinmar


you can use console.log( Array.from( editor.ui.componentFactory.names() ) ); which will give you:

["undo", "redo", "bold", "italic", "blockQuote", "ckfinder", "imageTextAlternative", "imageUpload", "heading", "imageStyle:full", "imageStyle:side", "link", "numberedList", "bulletedList", "mediaEmbed", "insertTable", "tableColumn", "tableRow", "mergeTableCells"]

like image 35
Dirk J. Faber Avatar answered Sep 28 '22 17:09

Dirk J. Faber