我正在使用EditorJs,但是它在控制台中给了我这个警告
«blocks.stretchBlock()» is deprecated and will be removed in the next major release. Please use the «BlockAPI» instead.
如何在EditorJs中使用«BlockAPI»?
这是我的EditorJs:
const editor = new EditorJS({
tools: {
header: Header,
list: List,
image: Image,
embed: {
class: Embed,
config: {
services: {
youtube: true
}
}
},
},
})发布于 2021-10-11 17:10:01
块API通过block支柱中的构造器道具传递。你必须从那里得到它并将它设置为你街区的财产。
它应该是这样的:
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
}官方文档似乎并不是最新的,但是我找到了带有块API描述的这个文件。
https://stackoverflow.com/questions/67207169
复制相似问题