Blocks
Provides methods that allows manipulate with Blocks
clear — removes all Blocks and creates new empty initial type Block
render — render with new content data
delete — removes Block by index
swap — deprecated swaps two Blocks with passed indexes
move — move a block from position to another
getById — returns Block API for Block instance by Block Id
getBlockByIndex — returns Block API for Block instance by index
getCurrentBlockIndex — returns focused Block index
getBlocksCount — returns number of rendered Blocks
stretchBlock — stretch Block's content
insert — inserts new Block
update — updates Block data by its id
composeBlockData — Creates data of an empty block with a passed type
getBlockByElement — Returns Block API object by any child html element
Clears Editor's content. Method removes all Blocks and inserts new initial empty Block
This method has no arguments
Method does not return anything
Method removes all Blocks and fills with new passed JSON data
OutputData
|
Data that have the same format as output data of Editor.js |
Promise<void>
|
Returns nothing but allows to continue sequence |
Method removes Block with index. If index is not passed, current Block will be removed
Number
|
index of Block that needs to be deleted |
Method does not return anything
Note that Blocks below will be shifted up
Method swaps two Blocks
Number
|
First Block index |
Number
|
Second Block index |
Method does not return anything
The method moves block from the passed index to another one.
Number
|
Destination index |
Number
|
Index of Block to move. By default, it's the index of the current block. |
Method does not return anything
Returns BlockAPI object by Block id
String
|
Id of Block that will be returned |
BlockAPI
|
Block API object for Block instance |
Method returns Block HTML content by index
Number
|
Index of Block that will be returned |
BlockAPI
|
Block API object for Block instance |
Method returns index of current Block
This method has no arguments
Number
|
Index of currently focused Block |
Method returns number of Blocks
This method has no arguments
Number
|
Count of rendered Blocks |
Method allow Plugins to use 100% space of Block content. For example, to stretch images
Number
|
index of Block that will be full-width |
Boolean
|
state of stretching |
Method inserts new Block with pasted type and data.
String
|
New Block type |
Object
|
New Block data |
Object
|
Config for new Block's Tool |
Number
|
Position for block. By default, it will inserted after current Block |
Boolean
|
Need to set focus or not. |
Method does not return anything
Method inserts new Block after focused Block and sets new focus
This method has no arguments
Method does not return anything
Method updates a Block data by its id
String
|
Id of the Block to update |
Object
|
The new data for a Block |
Method does not return anything
The method creates data of an empty block with a passed type.
String
|
Block Tool name |
Promise<BlockToolData>
|
Object with Tool output data |
Returns Block API object by any child html element.
HTMLElement
|
html element |
BlockAPI
|
API of the block associated with specified HTML element |