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
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
Clear
Clear Editor's content. Method removes all Blocks and inserts new initial empty Block
Parameters
This method has no arguments
Return value
Method does not return anything
Example
Render
Method removes all Blocks and fills with new passed JSON data
Parameters
OutputData
|
Data that have the same format as output data of Editor.js |
Return value
Promise<void>
|
Returns nothing but allows to continue sequence |
Example
Delete
Method removes Block with index. If index is not passed, current Block will be removed
Parameters
Number
|
index of Block that needs to be deleted |
Return value
Method does not return anything
Note that Blocks below will be shifted up
Example
Swap
Method swaps two Blocks
Parameters
Number
|
First Block index |
Number
|
Second Block index |
Return value
Method does not return anything
Example
move
The method moves block from the passed index to another one.
Parameters
Number
|
Destination index |
Number
|
Index of Block to move. By default, it's the index of the current block. |
Return value
Method does not return anything
Example
getBlockByIndex
Method returns Block HTML content by index
Parameters
Number
|
Index of Block that will be returned |
Return value
BlockAPI
|
Block API object for Block instance |
Example
getCurrentBlockIndex
Method returns index of current Block
Parameters
This method has no arguments
Return value
Number
|
Index of currently focused Block |
Example
getBlocksCount
Method returns number of Blocks
Parameters
This method has no arguments
Return value
Number
|
Count of rendered Blocks |
Example
stretchBlock
Method allow Plugins to use 100% space of Block content. For example, to stretch images
Parameters
Number
|
index of Block that will be full-width |
Boolean
|
state of stretching |
Return value
Example
insert
Method inserts new Block with pasted type and data.
Parameters
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. |
Return value
Method does not return anything
insertNewBlock
Method inserts new Block after focused Block and sets new focus
Parameters
This method has no arguments
Return value
Method does not return anything