diff --git a/src/dom_components/index.js b/src/dom_components/index.js index 7ba751e1b..00599bd02 100644 --- a/src/dom_components/index.js +++ b/src/dom_components/index.js @@ -400,9 +400,8 @@ export default () => { * @return {this} */ clear(opts = {}) { - this.getComponents() - .map(i => i) - .forEach(i => i.remove(opts)); + const components = this.getComponents(); + components?.filter(Boolean).forEach(i => i.remove(opts)); return this; }, diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 965721adc..20cb82cf2 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -225,9 +225,7 @@ export default class EditorModel extends Model { } if (Mod.storageKey && Mod.store && Mod.load) { - // Components should be loaded before CSS due to reset - const mth = ['domComponents', 'pageManager'].indexOf(name) >= 0 ? 'unshift' : 'push'; - this.get('storables')[mth](Mod); + this.get('storables').push(Mod); } cfg.em = this; @@ -654,7 +652,9 @@ export default class EditorModel extends Model { } loadData(data = {}) { - this.get('storables').forEach(module => module.load(data)); + const storableModules = this.get('storables'); + storableModules.forEach(module => module.clear()); + storableModules.forEach(module => module.load(data)); return data; }