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() } }

Blocks

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 swaps two Blocks by indexes
getBlockByIndex returns Block HTML content by index
getCurrentBlockIndex returns focused Block index
getBlocksCount returns count of Blocks
stretchBlock stretches Block's content
insertBlock inserts new Block after focused Block

Selection

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

Toolbar

Methods for Toolbar manipulation

open shows Toolbar
close hides Toolbar

Sanitizer

Methods for cleaning data

clean method cleans up taint string with passed rules 

Caret

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

Listeners

Methods that wraps native JavaScript addEventListener

on add DOM event listener
off remove DOM event listener

Saver

Methods for saving data

save returns saved data