首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EditorJs警告“«blocks.stretchBlock()”被废弃,并将在下一个主要版本中删除。请使用BlockAPI代替。

EditorJs警告“«blocks.stretchBlock()”被废弃,并将在下一个主要版本中删除。请使用BlockAPI代替。
EN

Stack Overflow用户
提问于 2021-04-22 05:20:04
回答 1查看 856关注 0票数 3

我正在使用EditorJs,但是它在控制台中给了我这个警告

«blocks.stretchBlock()» is deprecated and will be removed in the next major release. Please use the «BlockAPI» instead.

如何在EditorJs中使用«BlockAPI»

这是我的EditorJs:

代码语言:javascript
复制
const editor = new EditorJS({
  tools: {
    header: Header,
    list: List,
    image: Image,
    embed: {
      class: Embed,
      config: {
        services: {
          youtube: true
        }
      }
    },
  },
})
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-11 17:10:01

块API通过block支柱中的构造器道具传递。你必须从那里得到它并将它设置为你街区的财产。

它应该是这样的:

代码语言:javascript
复制
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描述的这个文件

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67207169

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档