Browse Source

Load blocks data on init

pull/3905/head
Artur Arseniev 4 years ago
parent
commit
dc3e91443a
  1. 6
      src/block_manager/index.js
  2. 21
      src/commands/view/OpenBlocks.js

6
src/block_manager/index.js

@ -104,6 +104,7 @@ export default () => {
blocksVisible = new Blocks([]);
categories = new Categories();
this.all = blocks;
blocks.add(c.blocks);
this.__initListen();
// Setup the sync between the global and public collections
@ -211,11 +212,6 @@ export default () => {
return c;
},
onLoad() {
const blocks = this.getAll();
!blocks.length && blocks.reset(c.blocks);
},
postRender() {
const collection = blocksVisible;
blocksView = new BlocksView({ collection, categories }, c);

21
src/commands/view/OpenBlocks.js

@ -1,27 +1,40 @@
import { isFunction } from 'underscore';
import { createEl } from '../../utils/dom';
export default {
open() {
const { container, editor, bm } = this;
const { container, editor, bm, config } = this;
const { custom } = config;
if (isFunction(custom.open)) {
return custom.open(bm.__customData());
}
if (this.firstRender) {
const id = 'views-container';
const pn = editor.Panels;
const panels = pn.getPanel(id) || pn.addPanel({ id });
panels.set('appendContent', container).trigger('change:appendContent');
if (!bm.getConfig().custom) container.appendChild(bm.render());
if (!custom) container.appendChild(bm.render());
}
if (container) container.style.display = 'block';
},
close() {
const { container } = this;
const { container, config } = this;
const { custom } = config;
if (isFunction(custom.close)) {
return custom.close(this.bm.__customData());
}
if (container) container.style.display = 'none';
},
run(editor, sender) {
const bm = editor.Blocks;
this.config = bm.getConfig();
this.firstRender = !this.container;
this.container = this.container || createEl('div');
this.editor = editor;
@ -31,7 +44,7 @@ export default {
container
});
if (bm.getConfig().custom) {
if (this.config.custom) {
bm.__trgCustom();
}

Loading…
Cancel
Save