diff --git a/src/commands/view/SelectComponent.js b/src/commands/view/SelectComponent.js index b74809bd3..f650a3bbc 100644 --- a/src/commands/view/SelectComponent.js +++ b/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(); diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 87a55e380..e12f3298f 100644 --- a/src/editor/model/Editor.js +++ b/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() {