diff --git a/src/editor/index.js b/src/editor/index.js index d3a9f0b6f..2e9f9ff2c 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -95,15 +95,14 @@ */ import $ from 'cash-dom'; -export default config => { - var c = config || {}, - defaults = require('./config/config'), - EditorModel = require('./model/Editor'), - EditorView = require('./view/EditorView'); - - for (var name in defaults) { - if (!(name in c)) c[name] = defaults[name]; - } +export default (config = {}) => { + const defaults = require('./config/config'); + const EditorModel = require('./model/Editor'); + const EditorView = require('./view/EditorView'); + const c = { + ...defaults, + ...config + }; c.pStylePrefix = c.stylePrefix; var em = new EditorModel(c); diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 46eee6005..0a3245670 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -173,18 +173,23 @@ module.exports = Backbone.Model.extend({ * @private */ loadModule(moduleName) { - var c = this.config; - var Mod = new moduleName(); - var name = Mod.name.charAt(0).toLowerCase() + Mod.name.slice(1); - var cfg = c[name] || c[Mod.name] || {}; - cfg.pStylePrefix = c.pStylePrefix || ''; + const { config } = this; + const Mod = new moduleName(); + const name = Mod.name.charAt(0).toLowerCase() + Mod.name.slice(1); + const cfgParent = !isUndefined(config[name]) + ? config[name] + : config[Mod.name]; + const cfg = cfgParent || {}; + const sm = this.get('StorageManager'); + cfg.pStylePrefix = config.pStylePrefix || ''; - // Check if module is storable - var sm = this.get('StorageManager'); + if (!isUndefined(cfgParent) && !cfgParent) { + cfg._disable = 1; + } if (Mod.storageKey && Mod.store && Mod.load && sm) { cfg.stm = sm; - var storables = this.get('storables'); + const storables = this.get('storables'); storables.push(Mod); this.set('storables', storables); } diff --git a/src/storage_manager/index.js b/src/storage_manager/index.js index 45dffd703..77e3caba9 100644 --- a/src/storage_manager/index.js +++ b/src/storage_manager/index.js @@ -71,14 +71,10 @@ module.exports = () => { * } * ... */ - init(config) { - c = config || {}; + init(config = {}) { + c = { ...defaults, ...config }; em = c.em; - - for (var name in defaults) { - if (!(name in c)) c[name] = defaults[name]; - } - + if (c._disable) c.type = 0; defaultStorages.remote = new RemoteStorage(c); defaultStorages.local = new LocalStorage(c); c.currentStorage = c.type;