Browse Source

Init canvas model in postLoad

pull/5270/head
Artur Arseniev 3 years ago
parent
commit
ca2eaeefdc
  1. 2
      src/canvas/index.ts
  2. 3
      src/editor/model/Editor.ts
  3. 5
      src/pages/index.ts

2
src/canvas/index.ts

@ -95,7 +95,7 @@ export default class CanvasModule extends Module<CanvasConfig> {
return this;
}
onLoad() {
postLoad() {
this.model.init();
}

3
src/editor/model/Editor.ts

@ -348,7 +348,8 @@ export default class EditorModel extends Model {
undoManager: false,
});
// We only need to load a few modules
['PageManager', 'Canvas'].forEach(key => shallow.get(key).onLoad());
shallow.Pages.onLoad();
shallow.Canvas.postLoad();
this.set('shallow', shallow);
}

5
src/pages/index.ts

@ -135,9 +135,10 @@ export default class PageManager extends ItemManagerModule<PageManagerConfig, Pa
}
onLoad() {
const { pages } = this;
const { pages, config, em } = this;
const opt = { silent: true };
pages.add(this.config.pages?.map(page => new Page(page, { em: this.em, config: this.config })) || [], opt);
const configPages = config.pages?.map(page => new Page(page, { em, config })) || [];
pages.add(configPages, opt);
const mainPage = !pages.length ? this.add({ type: typeMain }, opt) : this.getMain();
mainPage && this.select(mainPage, opt);
}

Loading…
Cancel
Save