BlockAPI

BlockAPI

BlockAPI provides methods and properties to work with Block instance. You can access BlockAPI object inside Tool or using `getBlockByIndex` method.

class MyTool { constructor({ block }) { this.block = block; } getBlockHolder() { return this.block.holder; } } ... const editor = new EditorJS(); const block = editor.getBlockByIndex(0); const holder = block.holder;
stretched(isStretched: boolean) Changes Block stretched state

Allows to say Editor that Block was changed. Used to manually trigger the Editor's 'onChange' callback

Can be useful for Block changes invisible to the Editor's core.

class MyBlockTool { constructor({ data, block }){ this.data this.blockAPI = block } changeSomeDataProperty() { this.data['some-property'] = 'some-value' // Tell Editor to know that block was changed this.blockAPI.dispatchChange() } }