Browse Source

Up editor clean

pull/4134/head
Artur Arseniev 5 years ago
parent
commit
a7ec7c7812
  1. 22
      src/editor/index.js

22
src/editor/index.js

@ -61,7 +61,7 @@ import html from 'utils/html';
export default (config = {}, opts = {}) => { export default (config = {}, opts = {}) => {
const { $ } = opts; const { $ } = opts;
const c = { let c = {
...defaults, ...defaults,
...config, ...config,
}; };
@ -87,7 +87,7 @@ export default (config = {}, opts = {}) => {
init(opts = {}) { init(opts = {}) {
em.init(this, { ...c, ...opts }); em.init(this, { ...c, ...opts });
[ this.modules = [
'I18n', 'I18n',
'Utils', 'Utils',
'Config', 'Config',
@ -121,7 +121,9 @@ export default (config = {}, opts = {}) => {
['Styles', 'StyleManager'], ['Styles', 'StyleManager'],
'DeviceManager', 'DeviceManager',
['Devices', 'DeviceManager'], ['Devices', 'DeviceManager'],
].forEach(prop => { ];
this.modules.forEach(prop => {
if (Array.isArray(prop)) { if (Array.isArray(prop)) {
this[prop[0]] = em.get(prop[1]); this[prop[0]] = em.get(prop[1]);
} else { } else {
@ -649,7 +651,19 @@ export default (config = {}, opts = {}) => {
* Destroy the editor * Destroy the editor
*/ */
destroy() { destroy() {
return em.destroyAll(); if (!em) return;
em.destroyAll();
this.modules.forEach(prop => {
if (Array.isArray(prop)) {
this[prop[0]] = 0;
} else {
this[prop] = 0;
}
});
this.modules = 0;
editorView = 0;
em = 0;
c = 0;
}, },
/** /**

Loading…
Cancel
Save