import loadCommonBlocks from "./common";
import loadControlBlocks from './control';
import loadTableBlocks from './table';
import loadReserveBlocks from './reserve';
import loadEchartsBlocks from './echarts';
import loadMaterialBlocks from './materials';
import loadMapBlocks from './maps';
import loadMediumBlocks from './medium';
import loadFormBlocks from './form';
import linkTrait from '../feature/traits/link'
import imageSelectorTrait from '../feature/traits/imageSelector'
import csvDownloadTrait from '../feature/traits/csvDownload';
import hideTrait from '../feature/traits/hide';
import authorInfoTrait from '../feature/traits/authorInfo';
import textareaTrait from '../feature/traits/textarea';
import keyValueTrait from '../feature/traits/keyValue';
import switchTrait from '../feature/traits/switch';
import components from './components';

export default (grapesjs) => {
  grapesjs.plugins.add("plugin-sp-blocks", (editor, options = {}) => {
    [
      components,
      loadCommonBlocks,
      loadControlBlocks,
      loadTableBlocks,
      loadMediumBlocks,
      loadEchartsBlocks,
      loadReserveBlocks,
      loadMaterialBlocks,
      loadMapBlocks,
      loadFormBlocks
    ].forEach(loader => loader(editor, options));
  });
  grapesjs.plugins.add("plugin-sp-traits", (editor, options = {}) => {
    [
      linkTrait,
      imageSelectorTrait,
      textareaTrait,
      keyValueTrait,
      switchTrait,
      csvDownloadTrait,
      hideTrait,
      authorInfoTrait
    ].forEach(loader => loader(editor, options));
  });
};
