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;
name: string
|
Tool's name
|
config: ToolConfig
|
Tool's config passed on Editor's initialisation
|
holder: HTMLElement
|
Block's content holder HTMLDivElement
|
isEmpty: boolean
|
Indicates if Block's content is empty
|
selected: boolean
|
Indicates if Block is selected
|
stretched: boolean
|
Indicates if Block is stretched
|
stretched(isStretched: boolean)
|
Changes Block stretched state
|
call(methodName: string, param?: object): void
|
Method to call Tool's instance methods (eg. save , validate , render , etc.)
|
save(): Promise<void|SavedData>
|
Returns Promise which resolves to saved Block data with meta
|
validate(data: BlockToolData): Promise<boolean>
|
Calls Tool's validate method and returns Promise which resolves to boolean value. Equivalent to call('validate', data)
|