src/block_manager/index.js
/**
     * Initialize module. Automatically called with a new instance of the editor
     * @param {Object} config Configurations
     * @return {this}
     * @private
     */
Initialize module. Automatically called with a new instance of the editor
@param {Object} config Configurations
@return {this}
@private
Initialize module . Automatically called with a new instance of the editor @param { Object } config Configurations @return { this } @private
init(config) {
      c = config || {};
      const em = c.em;
      for (let name in defaults) {
        if (!(name in c)) {
          c[name] = defaults[name];
        }
      }
      blocks = new Blocks([]);
      blocksVisible = new Blocks([]);
      categories = new BlockCategories();
      blocksView = new BlocksView(
        {
          collection: blocksVisible,
          categories
        },
        c
      );
      blocks.listenTo(blocks, 'add', model => {
        blocksVisible.add(model);
        em && em.trigger('block:add', model);
      });
      blocks.listenTo(blocks, 'remove', model => {
        blocksVisible.remove(model);
        em && em.trigger('block:remove', model);
      });
      blocks.listenTo(blocks, 'reset', coll => {
        blocksVisible.reset(coll.models);
      });
      return this;
    }
init ( config ) { c = config || { } ; const em = c . em ; for ( let name in defaults ) { if ( ! ( name in c ) ) { c [ name ] = defaults [ name ] ; } } blocks = new Blocks ( [ ] ) ; blocksVisible = new Blocks ( [ ] ) ; categories = new BlockCategories ( ) ; blocksView = new BlocksView ( { collection : blocksVisible , categories } , c ) ; blocks . listenTo ( blocks , 'add' , model => { blocksVisible . add ( model ) ; em && em . trigger ( 'block:add' , model ) ; } ) ; blocks . listenTo ( blocks , 'remove' , model => { blocksVisible . remove ( model ) ; em && em . trigger ( 'block:remove' , model ) ; } ) ; blocks . listenTo ( blocks , 'reset' , coll => { blocksVisible . reset ( coll . models ) ; } ) ; return this ; }
Initialize module.
Initialize module .
// Global blocks collection // Setup the sync between the global and public collections