Browse Source

Destroy RTE module when `editor.destroy` is called (#2471)

Destroy RTE module when `editor.destroy` is called
pull/2475/head
Artur Arseniev 7 years ago
committed by GitHub
parent
commit
3464b1bf67
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dist/css/grapes.min.css
  2. 4
      src/editor/model/Editor.js
  3. 12
      src/rich_text_editor/index.js
  4. 9
      src/rich_text_editor/model/RichTextEditor.js

2
dist/css/grapes.min.css

File diff suppressed because one or more lines are too long

4
src/editor/model/Editor.js

@ -656,7 +656,8 @@ export default Backbone.Model.extend({
UndoManager, UndoManager,
Panels, Panels,
Canvas, Canvas,
Keymaps Keymaps,
RichTextEditor
} = this.attributes; } = this.attributes;
DomComponents.clear(); DomComponents.clear();
CssComposer.clear(); CssComposer.clear();
@ -664,6 +665,7 @@ export default Backbone.Model.extend({
Panels.getPanels().reset(); Panels.getPanels().reset();
Canvas.getCanvasView().remove(); Canvas.getCanvasView().remove();
Keymaps.removeAll(); Keymaps.removeAll();
RichTextEditor.destroy();
this.view.remove(); this.view.remove();
this.stopListening(); this.stopListening();
$(this.config.el) $(this.config.el)

12
src/rich_text_editor/index.js

@ -83,6 +83,16 @@ export default () => {
return this; return this;
}, },
destroy() {
const { customRte } = this;
globalRte && globalRte.destroy();
customRte && customRte.destroy && customRte.destroy();
toolbar = 0;
globalRte = 0;
this.actionbar = 0;
this.actions = 0;
},
/** /**
* Post render callback * Post render callback
* @param {View} ev * @param {View} ev
@ -105,7 +115,7 @@ export default () => {
const pfx = this.pfx; const pfx = this.pfx;
const actionbarContainer = toolbar; const actionbarContainer = toolbar;
const actionbar = this.actionbar; const actionbar = this.actionbar;
const actions = this.actions || config.actions; const actions = this.actions || [...config.actions];
const classes = { const classes = {
actionbar: `${pfx}actionbar`, actionbar: `${pfx}actionbar`,
button: `${pfx}action`, button: `${pfx}action`,

9
src/rich_text_editor/model/RichTextEditor.js

@ -126,6 +126,15 @@ export default class RichTextEditor {
return this; return this;
} }
destroy() {
this.el = 0;
this.doc = 0;
this.actionbar = 0;
this.settings = {};
this.classes = {};
this.actions = [];
}
setEl(el) { setEl(el) {
this.el = el; this.el = el;
this.doc = el.ownerDocument; this.doc = el.ownerDocument;

Loading…
Cancel
Save