Core API
This page lists the reference documentation for Editor.js API's. You can access it both from the Editor instance or from the Plugins constructor:
const editor = EditorJS()
editor.blocks.clear()
class MyTool {
constructor({ api }){
this.api = api
this.api.blocks.clear()
}
}
Methods for creating, inserting and removing Blocks
clear
|
removes all Blocks and creates new empty initial Block |
render
|
creates UI of inserting Block |
delete
|
removes Block by index |
swap
|
deprecated swaps two Blocks by indexes |
move
|
move Block to passed index |
getBlockByIndex
|
returns Block HTML content by index |
getCurrentBlockIndex
|
returns focused Block index |
getBlocksCount
|
returns count of Blocks |
stretchBlock
|
stretches Block's content |
insert
|
inserts new Block after focused Block |
Methods for getting information about Selection inside the Editor.js workspace
findParentTag
|
looks ahead from selection and finds passed tag with class name |
expandToTag
|
expands selection to the passed tag |
Methods for Toolbar manipulation
Methods for cleaning data
clean
|
method cleans up taint string with passed rules |
Methods for caret manipulations inside the Editor.js workspace
setToFirstBlock
|
sets caret to the first Block |
setToLastBlock
|
sets caret to the last Block |
setToPreviousBlock
|
sets caret to the previous Block |
setToNextBlock
|
sets caret to the next Block |
setToBlock
|
sets caret to the Block |
focus
|
focus Editor |
Methods that wraps native JavaScript addEventListener
Methods for saving data
save
|
returns saved data |
Editor`s instance has «shorthands» for some of API methods. You can call them directly:
const editor = new EditorJS();
editor.clear();