Browse Source

Adjust destroy in headless mode

pull/3671/head
Artur Arseniev 5 years ago
parent
commit
f38c3cc0e6
  1. 5
      src/commands/view/SelectComponent.js
  2. 13
      src/editor/model/Editor.js

5
src/commands/view/SelectComponent.js

@ -5,7 +5,8 @@ import {
off,
getUnitFromValue,
isTaggableNode,
getViewEl
getViewEl,
hasWin
} from 'utils/mixins';
import { isVisible, isDoc } from 'utils/dom';
import ToolbarView from 'dom_components/view/ToolbarView';
@ -746,11 +747,13 @@ export default {
},
run(editor) {
if (!hasWin()) return;
this.editor = editor && editor.get('Editor');
this.enable();
},
stop(ed, sender, opts = {}) {
if (!hasWin()) return;
const { em, editor } = this;
this.onHovered(); // force to hide toolbar
this.stopSelectComponent();

13
src/editor/model/Editor.js

@ -10,7 +10,7 @@ import {
import $ from 'cash-dom';
import Backbone from 'backbone';
import Extender from 'utils/extender';
import { getModel } from 'utils/mixins';
import { getModel, hasWin } from 'utils/mixins';
import Selected from './Selected';
Backbone.$ = $;
@ -786,7 +786,7 @@ export default Backbone.Model.extend({
* Destroy editor
*/
destroyAll() {
const { config } = this;
const { config, view } = this;
const editor = this.getEditor();
const { editors = [] } = config.grapesjs || {};
this.stopDefault();
@ -794,7 +794,7 @@ export default Backbone.Model.extend({
.slice()
.reverse()
.forEach(mod => mod.destroy());
this.view.remove();
view && view.remove();
this.stopListening();
this.clear({ silent: true });
this.destroyed = 1;
@ -802,9 +802,10 @@ export default Backbone.Model.extend({
i => (this[i] = {})
);
editors.splice(editors.indexOf(editor), 1);
$(config.el)
.empty()
.attr(this.attrsOrig);
hasWin() &&
$(config.el)
.empty()
.attr(this.attrsOrig);
},
getEditing() {

Loading…
Cancel
Save