I'm using EditorJs but it is giving me this warning in the console
«blocks.stretchBlock()» is deprecated and will be removed in the next major release. Please use the «BlockAPI» instead.
How can I use «BlockAPI»
in EditorJs?
Here is my EditorJs init:
const editor = new EditorJS({
tools: {
header: Header,
list: List,
image: Image,
embed: {
class: Embed,
config: {
services: {
youtube: true
}
}
},
},
})
Block API is passed via constructor props in block
prop. You have to get it from there and set it to your block's property.
It should look something like this:
class CustomBlock {
private data;
private block;
constructor({
data,
block
}) {
this.data = data;
this.block = block;
}
toggleStretched() {
this.block.stretched = !!this.data.stretched;
}
// Rest of the block implementation
}
It seems that the official docs aren't up-to-date, however I found this file with a description of Block API.