EditorConfig (core/editor)
@ckeditor/ckeditor5-core/src/editor/editorconfig
CKEditor configuration options.
An object defining the editor configuration can be passed when initializing the editor:
EditorClass
.create( {
toolbar: [ 'bold', 'italic' ],
image: {
styles: [
...
]
}
} )
.then( ... )
.catch( ... );
Check the Configuration guide for more information about setting configuration options.
Filtering
Properties
-
alignment : AlignmentConfig
module:core/editor/editorconfig~EditorConfig#alignment
-
autosave : AutosaveConfig
module:core/editor/editorconfig~EditorConfig#autosave
-
balloonToolbar : Array.<String> | Object
module:core/editor/editorconfig~EditorConfig#balloonToolbar
Contextual toolbar configuration. Used by the
BalloonToolbar
feature.Configuring toolbar items
const config = { balloonToolbar: [ 'bold', 'italic', 'undo', 'redo' ] };
You can also use
'|'
to create a separator between groups of items:const config = { balloonToolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ] };
Read also about configuring the main editor toolbar in
toolbar
.Configuring items grouping
You can prevent automatic items grouping by setting the
shouldNotGroupWhenFull
option:const config = { balloonToolbar: { items: [ 'bold', 'italic', 'undo', 'redo' ], shouldNotGroupWhenFull: true }, };
-
blockToolbar : Array.<String> | Object
module:core/editor/editorconfig~EditorConfig#blockToolbar
The block toolbar configuration. Used by the
BlockToolbar
feature.const config = { blockToolbar: [ 'paragraph', 'heading1', 'heading2', 'bulletedList', 'numberedList' ] };
You can also use
'|'
to create a separator between groups of items:const config = { blockToolbar: [ 'paragraph', 'heading1', 'heading2', '|', 'bulletedList', 'numberedList' ] };
Configuring items grouping
You can prevent automatic items grouping by setting the
shouldNotGroupWhenFull
option:const config = { blockToolbar: { items: [ 'paragraph', 'heading1', 'heading2', '|', 'bulletedList', 'numberedList' ], shouldNotGroupWhenFull: true }, };
Read more about configuring the main editor toolbar in
toolbar
. -
ckbox : CKBoxConfig
module:core/editor/editorconfig~EditorConfig#ckbox
-
ckfinder : CKFinderConfig
module:core/editor/editorconfig~EditorConfig#ckfinder
-
cloudServices : CloudServicesConfig
module:core/editor/editorconfig~EditorConfig#cloudServices
The configuration of CKEditor Cloud Services. Introduced by the
CloudServices
plugin.Read more in
CloudServicesConfig
. -
codeBlock : CodeBlockConfig
module:core/editor/editorconfig~EditorConfig#codeBlock
-
collaboration : RealTimeCollaborationConfig
module:core/editor/editorconfig~EditorConfig#collaboration
The configuration of the collaboration features. Introduced by the
RealTimeCollaborativeEditing
feature.Read more in
RealTimeCollaborationConfig
. -
comments : CommentsConfig
module:core/editor/editorconfig~EditorConfig#comments
The configuration of the comments feature. Introduced by the
Comments
feature.Read more in
CommentsConfig
. -
commentsOnly : Boolean
module:core/editor/editorconfig~EditorConfig#commentsOnly
Enables comments-only mode when the editor initializes.
ClassicEditor .create( { commentsOnly: true } ) .then( ... ) .catch( ... );
-
exportPdf : ExportPdfConfig
module:core/editor/editorconfig~EditorConfig#exportPdf
The configuration of the export to PDF feature. It is used by the PDF export features from the
@ckeditor/ckeditor5-export-pdf
package.Read more in
ExportPdfConfig
. -
exportWord : ExportWordConfig
module:core/editor/editorconfig~EditorConfig#exportWord
The configuration of the export to Word feature. It is used by the Word export feature from the
@ckeditor/ckeditor5-export-word
package.Read more in
ExportWordConfig
. -
extraPlugins : Array.<Function>
module:core/editor/editorconfig~EditorConfig#extraPlugins
The list of additional plugins to load along those already available in the editor build. It extends the
plugins
configuration.function MyPlugin( editor ) { // ... } const config = { extraPlugins: [ MyPlugin ] };
Note: This configuration works only for simple plugins which utilize the plugin interface and have no dependencies. To extend a build with complex features, create a custom build.
Note: Make sure you include the new features in you toolbar configuration. Learn more about the toolbar setup.
-
fontBackgroundColor : FontBackgroundColorConfig
module:core/editor/editorconfig~EditorConfig#fontBackgroundColor
The configuration of the font background color feature. It is introduced by the
FontBackgroundColorEditing
feature.Read more in
FontBackgroundColorConfig
. -
fontColor : FontColorConfig
module:core/editor/editorconfig~EditorConfig#fontColor
The configuration of the font color feature. It is introduced by the
FontColorEditing
feature.Read more in
FontColorConfig
. -
fontFamily : FontFamilyConfig
module:core/editor/editorconfig~EditorConfig#fontFamily
The configuration of the font family feature. It is introduced by the
FontFamilyEditing
feature.Read more in
FontFamilyConfig
. -
fontSize : FontSizeConfig
module:core/editor/editorconfig~EditorConfig#fontSize
The configuration of the font size feature. It is introduced by the
FontSizeEditing
feature.Read more in
FontSizeConfig
. -
heading : HeadingConfig
module:core/editor/editorconfig~EditorConfig#heading
The configuration of the heading feature. Introduced by the
HeadingEditing
feature.Read more in
HeadingConfig
. -
highlight : HighlightConfig
module:core/editor/editorconfig~EditorConfig#highlight
-
htmlSupport : GeneralHtmlSupportConfig
module:core/editor/editorconfig~EditorConfig#htmlSupport
The configuration of the General HTML Support feature. Introduced by the
GeneralHtmlSupport
feature.Read more in
GeneralHtmlSupportConfig
. -
image : ImageConfig
module:core/editor/editorconfig~EditorConfig#image
The configuration of the image features. Used by the image features in the
@ckeditor/ckeditor5-image
package.Read more in
ImageConfig
. -
importWord : ImportWordConfig
module:core/editor/editorconfig~EditorConfig#importWord
The configuration of the import from Word feature.
Read more in
ImportWordConfig
. -
indentBlock : IndentBlockConfig
module:core/editor/editorconfig~EditorConfig#indentBlock
-
initialData : String
module:core/editor/editorconfig~EditorConfig#initialData
The initial editor data to be used instead of the provided element's HTML content.
ClassicEditor .create( document.querySelector( '#editor' ), { initialData: '<h2>Initial data</h2><p>Foo bar.</p>' } ) .then( ... ) .catch( ... );
By default, the editor is initialized with the content of the element on which this editor is initialized. This configuration option lets you override this behavior and pass different initial data. It is especially useful if it is difficult for your integration to put the data inside the HTML element.
See also Editor.create().
Note: If initial data is passed to
Editor.create()
in the first parameter (instead of a DOM element), and, at the same time,config.initialData
is set, an error will be thrown as those two options exclude themselves.If
config.initialData
is not set when the editor is initialized, the data received inEditor.create()
call will be used to setconfig.initialData
. As a result,initialData
is always set in the editor's config and plugins can read and/or modify it during initialization. -
language : String | LanguageConfig
module:core/editor/editorconfig~EditorConfig#language
The language of the editor UI and its content.
Note: You do not have to specify this option if your build is optimized for one UI language or if it is the default language (English is the default language for CDN builds), unless you want to change the language of your content.
Simple usage (change the language of the UI and the content):
ClassicEditor .create( document.querySelector( '#editor' ), { // The UI of the editor as well as its content will be in German. language: 'de' } ) .then( editor => { console.log( editor ); } ) .catch( error => { console.error( error ); } );
Use different languages for the UI and the content using the configuration syntax:
ClassicEditor .create( document.querySelector( '#editor' ), { language: { // The UI will be in English. ui: 'en', // But the content will be edited in Arabic. content: 'ar' } } ) .then( editor => { console.log( editor ); } ) .catch( error => { console.error( error ); } );
The language of the content has an impact on the editing experience, for instance it affects screen readers and spell checkers. It is also particularly useful for typing in certain languages (e.g. right–to–left ones) because it changes the default alignment of the text.
The language codes are defined in the ISO 639-1 standard.
You need to add the corresponding translation file for the new UI language to work. Translation files are available on CDN for predefined builds:
`<script src="https://cdn.ckeditor.com/ckeditor5/[version.number]/[distribution]/lang/[lang].js"></script>`
But you can add them manually by coping from the
node_modules/@ckeditor/ckeditor5-build-[name]/build/lang/[lang].js'
.Check the UI language guide for more information about the localization options and translation process.
-
licenseKey : String
module:core/editor/editorconfig~EditorConfig#licenseKey
The license key for the CKEditor 5 premium features.
If you do not have a key yet, please contact us or order a trial.
-
link : LinkConfig
module:core/editor/editorconfig~EditorConfig#link
-
list : ListConfig
module:core/editor/editorconfig~EditorConfig#list
The configuration of the
List
feature and theDocumentList
feature.Read more in
ListConfig
. -
locale : LocaleConfig
module:core/editor/editorconfig~EditorConfig#locale
The editor localization configuration.
For setting the editor language see
editor.config.language
. -
mediaEmbed : MediaEmbedConfig
module:core/editor/editorconfig~EditorConfig#mediaEmbed
-
mention : MentionConfig
module:core/editor/editorconfig~EditorConfig#mention
-
minimap : MinimapConfig
module:core/editor/editorconfig~EditorConfig#minimap
The configuration of the minimap feature. Introduced by the
Minimap
feature.Read more in
MinimapConfig
. -
pagination : PaginationConfig
module:core/editor/editorconfig~EditorConfig#pagination
The configuration of the pagination feature. It is used by the pagination feature from the
@ckeditor/ckeditor5-pagination
package.Read more in
PaginationConfig
. -
placeholder : String
module:core/editor/editorconfig~EditorConfig#placeholder
Specifies the text displayed in the editor when there is no content (editor is empty). It is intended to help users locate the editor in the application (form) and prompt them to input the content. Work similarly as to the native DOM
placeholder
attribute used by inputs.const config = { placeholder: 'Type some text...' };
The placeholder text is displayed as a pseudo–element of an empty paragraph in the editor content. The paragraph has the
.ck-placeholder
CSS class and thedata-placeholder
attribute.<p data-placeholder="Type some text..." class="ck-placeholder"> ::before </p>
Note: Placeholder text can also be set using the
placeholder
attribute if a<textarea>
is passed to thecreate()
method, e.g.ClassicEditor.create()
.Note: This configuration has precedence over the value of the
placeholder
attribute of a<textarea>
element passed to thecreate()
method.See the "Editor placeholder" guide for more information and live examples.
-
plugins : Array.<(String | Function)>
module:core/editor/editorconfig~EditorConfig#plugins
The list of plugins to load.
If you use an editor build you can define the list of plugins to load using the names of plugins that are available:
const config = { plugins: [ 'Bold', 'Italic', 'Typing', 'Enter', ... ] };
You can check the list of plugins available in a build using this snippet:
ClassicEditor.builtinPlugins.map( plugin => plugin.pluginName );
If you use an editor creator directly (imported from a package like
@ckeditor/ckeditor5-editor-classic
) or you want to load additional plugins which were not included in a build you use, then you need to specify the plugins using their constructors:// A preset of plugins is a plugin as well. import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; // The bold plugin. import Bold from '@ckeditor/ckeditor5-editor-basic-styles/src/bold'; const config = { plugins: [ Essentials, Bold ] };
Note: To load additional plugins, you should use the
extraPlugins
configuration. To narrow the list of loaded plugins, use theremovePlugins
configuration. -
removePlugins : Array.<(String | Function)>
module:core/editor/editorconfig~EditorConfig#removePlugins
The list of plugins which should not be loaded despite being available in an editor build.
const config = { removePlugins: [ 'Bold', 'Italic' ] };
Note: Be careful when removing plugins using
config.removePlugins
from CKEditor builds. If removed plugins were providing toolbar buttons, the default toolbar configuration included in a build will become invalid. In such case you need to provide the updated toolbar configuration. -
restrictedEditing : RestrictedEditingModeConfig
module:core/editor/editorconfig~EditorConfig#restrictedEditing
The configuration of the restricted editing mode feature. Introduced by the
RestrictedEditingMode
feature.Read more in
RestrictedEditingModeConfig
. -
revisionHistory : RevisionHistoryConfig
module:core/editor/editorconfig~EditorConfig#revisionHistory
The configuration of the revision history feature. Introduced by the
RevisionHistory
feature. -
sidebar : SidebarConfig
module:core/editor/editorconfig~EditorConfig#sidebar
The configuration of the sidebar feature. Introduced by the
Sidebar
feature.Read more in
SidebarConfig
. -
simpleUpload : SimpleUploadConfig
module:core/editor/editorconfig~EditorConfig#simpleUpload
-
specialCharacters : SpecialCharactersConfig
module:core/editor/editorconfig~EditorConfig#specialCharacters
-
style : StyleConfig
module:core/editor/editorconfig~EditorConfig#style
-
table : TableConfig
module:core/editor/editorconfig~EditorConfig#table
-
title : TitleConfig
module:core/editor/editorconfig~EditorConfig#title
-
toolbar : Array.<String> | Object
module:core/editor/editorconfig~EditorConfig#toolbar
The editor toolbar configuration.
Simple format (specifies only toolbar items):
const config = { toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ] };
Extended format:
const config = { toolbar: { items: [ 'bold', 'italic', '|', 'undo', 'redo', '-', 'numberedList', 'bulletedList' ], shouldNotGroupWhenFull: true } };
Options which can be set using the extended format:
-
toolbar.items
– An array of toolbar item names. The components (buttons, dropdowns, etc.) which can be used as toolbar items are defined ineditor.ui.componentFactory
and can be listed using the following snippet:Array.from( editor.ui.componentFactory.names() );
You can also use
'|'
to create a separator between groups of items:toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
or
'-'
to make a line break and render items in multiple lines:toolbar: [ 'bold', 'italic', '-', 'undo', 'redo' ]
Line break will work only in the extended format when
shouldNotGroupWhenFull
option is set totrue
.Note: To save space in your toolbar, you can group several items into a dropdown:
toolbar: [ { label: 'Basic styles', icon: 'text', items: [ 'bold', 'italic', ... ] }, '|', 'undo', 'redo' ]
The code above will create a "Basic styles" dropdown with a "text" icon containing the "bold" and "italic" buttons. You can customize the look of the dropdown by setting the
withText
,icon
, andtooltip
properties:-
Displaying a label
For instance, to hide the icon and to display the label only, you can use the following configuration:
{ label: 'Basic styles', // Show the textual label of the drop-down. Note that the "icon" property is not configured. withText: true, items: [ 'bold', 'italic', ... ] }
-
Selecting an icon
You can use one of the common icons provided by the editor (
'bold'
,'plus'
,'text'
,'importExport'
,'alignLeft'
,'paragraph'
,'threeVerticalDots'
):{ label: '...', // A "plus" sign icon works best for content insertion tools. icon: 'plus', items: [ ... ] }
If no icon is specified,
'threeVerticalDots'
will be used as a default:// No icon specified, using a default one. { label: 'Default icon', items: [ ... ] }
If
icon: false
is configured, no icon will be displayed at all and the text label will show up instead:// This drop-down has no icon. The text label will be displayed instead. { label: 'No icon', icon: false, items: [ ... ] }
You can also set a custom icon for the drop-down by passing an SVG string:
{ label: '...', // If you want your icon to change the color dynamically (e.g. when the dropdown opens), avoid fill="..." // and stroke="..." styling attributes. Use solid shapes and avoid paths with strokes. icon: '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">...</svg>', items: [ ... ] }
-
Customizing the tooltip
By default, the tooltip of the button shares its text with the label. You can customize it to better describe your dropdown using the
tooltip
property (learn more):{ label: 'Drop-down label', tooltip: 'Custom tooltip of the drop-down', icon: '...', items: [ ... ] }
-
-
toolbar.viewportTopOffset
(deprecated) – The offset (in pixels) from the top of the viewport used when positioning a sticky toolbar. Useful when a page with which the editor is being integrated has some other sticky or fixed elements (e.g. the top menu). Thanks to setting the toolbar offset the toolbar will not be positioned underneath or above the page's UI.This property has been deprecated and will be removed in the future versions of CKEditor. Please use
EditorConfig#ui.viewportOffset
instead. -
toolbar.shouldNotGroupWhenFull
– When set totrue
, the toolbar will stop grouping items and let them wrap to the next line if there is not enough space to display them in a single row.
-
-
trackChanges : TrackChangesConfig
module:core/editor/editorconfig~EditorConfig#trackChanges
The configuration of the track changes feature. It is introduced by the
TrackChanges
feature.Read more in
TrackChangesConfig
. -
typing : TypingConfig
module:core/editor/editorconfig~EditorConfig#typing
The configuration of the typing features. Used by the features from the
@ckeditor/ckeditor5-typing
package.Read more in
TypingConfig
. -
ui : Object
module:core/editor/editorconfig~EditorConfig#ui
The editor UI configuration.
ClassicEditor .create( document.querySelector( '#editor' ), { ui: { ... } } ) .then( ... ) .catch( ... );
Options which can be set using the UI config:
-
ui.viewportOffset
– The offset (in pixels) of the viewport from every direction used when positioning a sticky toolbar or other absolutely positioned UI elements. Useful when a page with which the editor is being integrated has some other sticky or fixed elements (e.g. the top menu). Thanks to setting the UI viewport offset the toolbar and other contextual balloons will not be positioned underneath or above the page's UI.ui: { viewportOffset: { top: 10, right: 10, bottom: 10, left: 10 } }
Note: If you want to modify the viewport offset in runtime (after editor was created), you can do that by overriding
editor.ui.viewportOffset
.
-
-
updateSourceElementOnDestroy : Boolean
module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy
Enables updating the source element after the editor destroy.
Enabling this option might have some security implications, as the editor doesn't have control over all data in the output.
Be careful, especially while using Markdown, General HTML Support or HTML embed features.
-
wordCount : WordCountConfig
module:core/editor/editorconfig~EditorConfig#wordCount
The configuration of the word count feature. It is introduced by the
WordCount
feature.Read more in
WordCountConfig
.
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.