const BlockManager = (editor, opts = {}) => {
  editor.on('load', () => {
    const blockManager = editor.BlockManager;

    // 更改图层元素Body对应名称
    editor.DomComponents.getWrapper().set('custom-name', "图层主体");

    // 收起组件分组，只展开第一个分组
    const categories = blockManager.getCategories();
    categories.forEach(category => category.set('open', false));
    categories.first().set('open', true);

    // 遍历画布中的节点，去掉 TEXT NODE，前面板是不该出现这类节点的
    const $wrapper = editor.DomComponents.getWrapper().getEl();

    if ($wrapper) {
      $wrapper.childNodes.forEach(function (node) {
        if (`${node.nodeType}` === '3') {
          node.remove();
        }
      })
    }

    editor.select(editor.DomComponents.getWrapper())
    editor.LayerManager.render();
  })
};

export default BlockManager;
