Configuration
This page contains guide for Editor.js tunings.
To initialize the Editor with previously saved data, pass it through the data
property:
Format of the data
object should be the same as returned by Editor saving.
Editor.js needs a bit time to initialize. It is an asynchronous action so it won't block execution of your main script.
If you need to know when editor instance is ready you can use one of the following ways:
It must be a function:
After you create a new
object, it will contain EditorJS
property. It is a Promise object that will be resolved when the Editor is ready for work and rejected otherwise. If there is an error during initialization the isReady
promise will be rejected with an error message.
isReady
You can use
to keep your code looking more clear:
async/await
Similar to onReady
callback, you can use the onChange
callback to handle any modifications inside the Editor:
The editor's onChange
callback accepts CustomEvent
describing what happened with the Block. (Available since 2.23.0)
This CustomEvent
has:
type
|
string |
Mutation type (Added , Removed , Moved , Changed )
|
details.target
|
BlockAPI | changed Block API |
details.*
|
any | Additional data |
By default, Editor.js contains Paragraph Block included in a bundle. This Block is called «default»: it will be appended after Enter
key pressing and with an empty Editor. Also, it accepts paste patterns that allow rendering other Blocks by pasted URLs.
There is the ability to change the default Block for your own. Use the defaultBlock
option for this:
The name of the default Block should be equal to one of Tool`s keys passed by tools
option.
Pass autofocus
option if you want to set a Caret to the Editor after initialization:
Pass the placeholder
option if you want to set a custom placeholder:
The editor outputs some information to the console. You can configure how much information you want to see. You can provide log level via logLevel
property:
Here is available levels:
Value | Description |
VERBOSE
|
Show all messages (default) |
INFO
|
Show info and debug messages |
WARN
|
Show only warn messages |
ERROR
|
Show only error messages |
Editor.js provides an API for Internationalization that allows localizing all UI texts of the editor's core and plugins.
To create localization of the editor.js you need to provide the i18n
option with the messages
dictionary. The messages
object should contain the ui
, toolNames
, tools
and the blockTunes
sections.
See detailed description of the i18n config here: https://editorjs.io/internationalization
Since the 2.19.0 version, Editor.js can be initialized in the read-only mode. That means that users won't have the ability to change the document content.
To initialize this mode, pass the readOnly: true
option via Editor Config:
You can also toggle the read-only mode on the fly using an API method:
You can specify the common order of Inline tools using the inlineToolbar
property.
The common inlineToolbar
property can be overridden by the tool's inlineToolbar
property.
If you have connected any Block Tunes, you need to specify them in tunes
property
If you want to enable Tune for particular Tool you can specify it in Tool configuration: