EditorJs 警告“«blocks.stretchBlock()» 已弃用,将在下一个主要版本中删除。请改用 «BlockAPI»。”
EditorJs warning "«blocks.stretchBlock()» is deprecated and will be removed in the next major release. Please use the «BlockAPI» instead."
我正在使用 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
}
}
},
},
})
块API通过block
prop中的constructor props传递。您必须从那里获取它并将其设置为您所在街区的 属性.
它应该看起来像这样:
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
}
官方文档似乎不是最新的,但我发现 this file 对块 API 的描述。
我正在使用 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
}
}
},
},
})
块API通过block
prop中的constructor props传递。您必须从那里获取它并将其设置为您所在街区的 属性.
它应该看起来像这样:
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
}
官方文档似乎不是最新的,但我发现 this file 对块 API 的描述。