8
0
Просмотр исходного кода

Merge branch 'master' into t/ckeditor5/746

# Conflicts:
#	tests/decouplededitor.js
Maciej Gołaszewski 6 лет назад
Родитель
Сommit
ae28a89611

+ 1 - 3
packages/ckeditor5-editor-decoupled/.travis.yml

@@ -28,6 +28,4 @@ after_script:
 - ckeditor5-dev-tests-notify-travis-status
 - ckeditor5-dev-tests-notify-travis-status
 env:
 env:
   global:
   global:
-  - secure: czAq3wmkippaXuAaoiibg+6vtcfF6ylU6QgzLIABhegKQaOARSB6Cae7WeveCBKu03aiVxWSTzPtAkNnq4qGK8mxEh012r1F50zKBInR9QiEB8HHkiUrkO2cVt21hX/PzdCJ+Ys4Cjthm1xsQwZ8vrfXsZnyahkQCzLxqkQR7mYNiQGPRaGvxaJmgMlfNNgoRFO7KzcmTNX9OeU+4k2BJOuua8NuoZx01aCktaC6qGpYLFE9Kj+oDpWMcQXp8y20hIDeY7GOh2zRDlQqXQV9FslxOykHE0uJ2dRa6Wvf65PTQknrpkBLHQgdaIM0e/E4+xtKMxl7676P1gbpQAntyCD8QybE3N+ldJqrOzzLmQ5hTxKjHxzU3/rtXqowRCtJS1a9/gV6ABbE3PKzfBi1fhkx7uyzc84owKTuR8VMTuXwPqjAuBbbD2Limv1GbS+Of6VPlaM7FGg22ZIjWr5H/kEIydvB9+9ffIOCjwi+5LObss1MiqZTn6tYwJvq6ELTj4a/6rXF4r2G4GLqPfheNxad3FXrTGsT2BYkrp8J1YiNwHVPnaec16S8tzRS7dQjKQiTinp/3wtOsdJ87XY+Z0wKFwv1nvn9wFWpTLo2Lh9a1grxW05HvrrKr0MIwlVdieHHsjtaBMYbwS1WtIoOMA1znsghM6ZPUVGzYX5mn5w=
-  - secure: VJkWZMdkuuvwdHMyhJdTiJ9jjAtuVOQn7sQjpBAPzfLyjE7DliaS0gYHz5KG8RLs1Qn99ShNMr6PXcuZ7tMVF4YMSLU4AHh4+wg+EYXxWDbiiz3AbSPa2ScRVQrqayEdvdHv77ydPSXRj7wY2wWzpSQml6zdPHNhLRi9czKxPmehEloZKZfBiJY9/CmeiIF/Fv1KK/OsuOgafyOOG/ffJeqiI4agYW8PgxrMRl71YITl9IOWDZw093x4AqlXFG8JUxYk0JqiSJDWJCSxID7A/12lOe/ExsPPRQ69EKXMsMxsVLKhNlHpo3GHMXO0bf461Y0Y/1exCbeKP+F2ILaBJOKxhPD6ulWLTBcB/58XV/ke8G8cwYyFKl3nNxcejK1bR8fE9/4q+vsjnCTNq4tJxRN1RW324uC7AbL8f/Mur5TIWUGftmjhFLU+bjKkuTADhbwB9XYU2KhmAN96fpEvQ4RIz4/nIs9dbfKY/Hj2YAyblfXeWLMPxmhOXTScR7dkw+TWDiU2gUCw2MjU8AyOhB3Iwenxgpe+jGObvt+zPZz8UWgyJYb+KtZsNlmr+vvISa5m+jAukOcY2afH0tH/mMvwdXntLH7A+X40BWrP/14cA609clyw5ou5Jaxo+XPVX0GAsR/B99NkJbUGLKUgGP4fWf3WfGra1WVZZ9PKmuo=
-  - secure: gQW55I/KFJuv7j1QYLCd7iYJEWV0SvefD5YrGypKQZoL2EQLSRNhrviqcnGZcGuGX0/5epgbQuttjYPXcJCAxDFt7X40yPBaCvnDnQlp63loJ+1aMc+bGQ9OdCBrLvwIL1ushi7zzP/T119M35ahF+RhvBOVi0TCRhGvkZBFbDQTR6J8fdAD5lQE2LabiZduGJ+xqOiJkEl9tv8ndv9GmX0/4kryAkhxGWrH/O2IsInM9zzNoK1Hpe5OPBmJQFLgPTUYeHbnXVAhkbm/3/myNdKY1ZLARXouv7zzQ/FFw/e/mUd85VAH47nQASvC0uGm0nHde98Sie67jMn/iOReRJkN/USxGSafCicNH7ln7IxgfRubhWvK+RVZlh5eRF9l8K7LSFSFQqHmZjfjr5cg0zDd4LMr3rCspy3c7QJakbltXL2pCS3ixX8suY7KG5JpygL2NAmj08lXcw9FQiB4VXFP5qVIXGFNYE+hCb3LJwxbBnKEG1IBj71h61w7XiVcdy50QeRTi+a2DqgoHzeEwVGFtGzSxgsHfAwhY/iXb9atfBBwjue+VE398AOZ6lL4dPExV7/PlKv3AV5JLPD/5U9y7WhswbFyYgBUhLe/nl6m2DYSCyyVg3Hgzh18Vv7+lmjP6z9MZ0KQ6jsrb0RFPBpDL70KliVh1pgXgmAQXuE=
+  - secure: p5e8M1c1LWXAe1PtFKOMFXx27hWavMUUqrLCW1J0AzoQMhj0TRHzsz/2o77CzJ6y011mnF48ZVTlZ8ZtzCUQtC/q7v/qr7Qod9+3KDGGg1Trc8Qn2FhUPEHRYag4s/xhO1AzOGcLoFTWwVwLvaKBCArBCcjrOh70uT05k4nYRmV0wEwbe2XL9F1dTiUdd+iH1VBADW57R5tFoxFlM+OH0e0qLZUiv4iAvxkSJjlMzi/lvw1aWI8fOBRehitvB4c0Li9pjR9Qdr4el8tfqq0g+yMXu5op7eW4r9gEvP+X9pORi2stSSRjlEJpFG9Tw7gOLjBTKRXFs9+2eQ0lzwQUd2QcE7U0i2aC0c53xrYbqGLmfm8lu1RU/Pa7bqoiG+KWtxTLqUNQowTLvAhvdBUcwA5DAhqqiudoqRUiShrda9Zo+GNzLCIALPpHP/mp+mBa+ob3zlaHvODd5ZYO0vnLr6rZOitwR4+Yvq7odW5FJUb3hkuTU1if0nsk0D5A4VkmoZBVinxxkKfodB0GGJxYMkjmNBd9v8zDRUCR6XkoB6XGz/EgPOZFj5S4NcGq7lnV+3oeNUb36IzaglSCgjgXpwa/tXMJDaG27oZ8ZtCJ+EDMKs+FBejIrFPuY2W1Rv5cxzQIvnYlbfvg1c3BjEIc9u08rBMlnWa95hrEDM2qnLQ=

+ 17 - 0
packages/ckeditor5-editor-decoupled/CHANGELOG.md

@@ -1,6 +1,23 @@
 Changelog
 Changelog
 =========
 =========
 
 
+## [12.2.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.2.0...v12.2.1) (2019-07-10)
+
+Internal changes only (updated dependencies, documentation, etc.).
+
+
+## [12.2.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.1.1...v12.2.0) (2019-07-04)
+
+### Features
+
+* `DecoupledEditor.create()` will throw an error, when a `<textarea>` element is used. ([af4daea](https://github.com/ckeditor/ckeditor5-editor-decoupled/commit/af4daea))
+
+
+## [12.1.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.1.0...v12.1.1) (2019-06-05)
+
+Internal changes only (updated dependencies, documentation, etc.).
+
+
 ## [12.1.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.0.0...v12.1.0) (2019-04-10)
 ## [12.1.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.0.0...v12.1.0) (2019-04-10)
 
 
 ### Features
 ### Features

+ 0 - 1
packages/ckeditor5-editor-decoupled/README.md

@@ -4,7 +4,6 @@ CKEditor 5 decoupled editor implementation
 [![Join the chat at https://gitter.im/ckeditor/ckeditor5](https://badges.gitter.im/ckeditor/ckeditor5.svg)](https://gitter.im/ckeditor/ckeditor5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
 [![Join the chat at https://gitter.im/ckeditor/ckeditor5](https://badges.gitter.im/ckeditor/ckeditor5.svg)](https://gitter.im/ckeditor/ckeditor5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
 [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-editor-decoupled.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled)
 [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-editor-decoupled.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled)
 [![Build Status](https://travis-ci.org/ckeditor/ckeditor5-editor-decoupled.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-editor-decoupled)
 [![Build Status](https://travis-ci.org/ckeditor/ckeditor5-editor-decoupled.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-editor-decoupled)
-[![BrowserStack Status](https://automate.browserstack.com/automate/badge.svg?badge_key=d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)](https://automate.browserstack.com/public-build/d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)
 [![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-editor-decoupled/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-editor-decoupled?branch=master)
 [![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-editor-decoupled/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-editor-decoupled?branch=master)
 <br>
 <br>
 [![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-editor-decoupled/status.svg)](https://david-dm.org/ckeditor/ckeditor5-editor-decoupled)
 [![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-editor-decoupled/status.svg)](https://david-dm.org/ckeditor/ckeditor5-editor-decoupled)

+ 12 - 12
packages/ckeditor5-editor-decoupled/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "@ckeditor/ckeditor5-editor-decoupled",
   "name": "@ckeditor/ckeditor5-editor-decoupled",
-  "version": "12.1.0",
+  "version": "12.2.1",
   "description": "Decoupled editor implementation for CKEditor 5.",
   "description": "Decoupled editor implementation for CKEditor 5.",
   "keywords": [
   "keywords": [
     "ckeditor",
     "ckeditor",
@@ -9,21 +9,21 @@
     "ckeditor5-editor"
     "ckeditor5-editor"
   ],
   ],
   "dependencies": {
   "dependencies": {
-    "@ckeditor/ckeditor5-core": "^12.1.0",
-    "@ckeditor/ckeditor5-engine": "^13.1.0",
-    "@ckeditor/ckeditor5-ui": "^12.1.0",
-    "@ckeditor/ckeditor5-utils": "^12.1.0",
+    "@ckeditor/ckeditor5-core": "^12.2.1",
+    "@ckeditor/ckeditor5-engine": "^13.2.1",
+    "@ckeditor/ckeditor5-ui": "^13.0.2",
+    "@ckeditor/ckeditor5-utils": "^13.0.1",
     "lodash-es": "^4.17.10"
     "lodash-es": "^4.17.10"
   },
   },
   "devDependencies": {
   "devDependencies": {
-    "@ckeditor/ckeditor5-basic-styles": "^11.1.0",
-    "@ckeditor/ckeditor5-enter": "^11.0.1",
-    "@ckeditor/ckeditor5-heading": "^11.0.1",
-    "@ckeditor/ckeditor5-paragraph": "^11.0.1",
-    "@ckeditor/ckeditor5-typing": "^12.0.1",
-    "@ckeditor/ckeditor5-undo": "^11.0.1",
+    "@ckeditor/ckeditor5-basic-styles": "^11.1.3",
+    "@ckeditor/ckeditor5-enter": "^11.0.4",
+    "@ckeditor/ckeditor5-heading": "^11.0.4",
+    "@ckeditor/ckeditor5-paragraph": "^11.0.4",
+    "@ckeditor/ckeditor5-typing": "^12.1.1",
+    "@ckeditor/ckeditor5-undo": "^11.0.4",
     "eslint": "^5.5.0",
     "eslint": "^5.5.0",
-    "eslint-config-ckeditor5": "^1.0.11",
+    "eslint-config-ckeditor5": "^2.0.0",
     "husky": "^1.3.1",
     "husky": "^1.3.1",
     "lint-staged": "^7.0.0"
     "lint-staged": "^7.0.0"
   },
   },

+ 11 - 2
packages/ckeditor5-editor-decoupled/src/decouplededitor.js

@@ -217,6 +217,14 @@ export default class DecoupledEditor extends Editor {
 	 */
 	 */
 	static create( sourceElementOrData, config = {} ) {
 	static create( sourceElementOrData, config = {} ) {
 		return new Promise( resolve => {
 		return new Promise( resolve => {
+			const isHTMLElement = isElement( sourceElementOrData );
+
+			if ( isHTMLElement && sourceElementOrData.tagName === 'TEXTAREA' ) {
+				// Documented in core/editor/editor.js
+				throw new CKEditorError(
+					'editor-wrong-element: This type of editor cannot be initialized inside <textarea> element.', null );
+			}
+
 			const editor = new this( sourceElementOrData, config );
 			const editor = new this( sourceElementOrData, config );
 
 
 			resolve(
 			resolve(
@@ -225,11 +233,12 @@ export default class DecoupledEditor extends Editor {
 						editor.ui.init();
 						editor.ui.init();
 					} )
 					} )
 					.then( () => {
 					.then( () => {
-						if ( !isElement( sourceElementOrData ) && config.initialData ) {
+						if ( !isHTMLElement && config.initialData ) {
 							// Documented in core/editor/editorconfig.jdoc.
 							// Documented in core/editor/editorconfig.jdoc.
 							throw new CKEditorError(
 							throw new CKEditorError(
 								'editor-create-initial-data: ' +
 								'editor-create-initial-data: ' +
-								'The config.initialData option cannot be used together with initial data passed in Editor.create().'
+								'The config.initialData option cannot be used together with initial data passed in Editor.create().',
+								null
 							);
 							);
 						}
 						}
 
 

+ 1 - 1
packages/ckeditor5-editor-decoupled/src/decouplededitorui.js

@@ -66,7 +66,7 @@ export default class DecoupledEditorUI extends EditorUI {
 
 
 		// Register the editable UI view in the editor. A single editor instance can aggregate multiple
 		// Register the editable UI view in the editor. A single editor instance can aggregate multiple
 		// editable areas (roots) but the decoupled editor has only one.
 		// editable areas (roots) but the decoupled editor has only one.
-		this._editableElements.set( editable.name, editableElement );
+		this.setEditableElement( editable.name, editableElement );
 
 
 		// Let the global focus tracker know that the editable UI element is focusable and
 		// Let the global focus tracker know that the editable UI element is focusable and
 		// belongs to the editor. From now on, the focus tracker will sustain the editor focus
 		// belongs to the editor. From now on, the focus tracker will sustain the editor focus

+ 35 - 6
packages/ckeditor5-editor-decoupled/tests/decouplededitor.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
  */
 
 
-/* globals document, setTimeout */
+/* globals document, setTimeout, console */
 
 
 import DecoupledEditorUI from '../src/decouplededitorui';
 import DecoupledEditorUI from '../src/decouplededitorui';
 import DecoupledEditorUIView from '../src/decouplededitoruiview';
 import DecoupledEditorUIView from '../src/decouplededitoruiview';
@@ -18,11 +18,11 @@ import DataApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/dataapimixin
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 
 
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import log from '@ckeditor/ckeditor5-utils/src/log';
 
 
 import { describeMemoryUsage, testMemoryUsage } from '@ckeditor/ckeditor5-core/tests/_utils/memory';
 import { describeMemoryUsage, testMemoryUsage } from '@ckeditor/ckeditor5-core/tests/_utils/memory';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
+import { assertCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 const editorData = '<p><strong>foo</strong> bar</p>';
 const editorData = '<p><strong>foo</strong> bar</p>';
 
 
@@ -32,7 +32,7 @@ describe( 'DecoupledEditor', () => {
 	testUtils.createSinonSandbox();
 	testUtils.createSinonSandbox();
 
 
 	beforeEach( () => {
 	beforeEach( () => {
-		testUtils.sinon.stub( log, 'warn' ).callsFake( () => {} );
+		testUtils.sinon.stub( console, 'warn' ).callsFake( () => {} );
 	} );
 	} );
 
 
 	describe( 'constructor()', () => {
 	describe( 'constructor()', () => {
@@ -144,9 +144,38 @@ describe( 'DecoupledEditor', () => {
 			DecoupledEditor.create( '<p>Hello world!</p>', {
 			DecoupledEditor.create( '<p>Hello world!</p>', {
 				initialData: '<p>I am evil!</p>',
 				initialData: '<p>I am evil!</p>',
 				plugins: [ Paragraph ]
 				plugins: [ Paragraph ]
-			} ).catch( () => {
-				done();
-			} );
+			} )
+				.then(
+					() => {
+						expect.fail( 'Decoupled editor should throw an error when both initial data are passed' );
+					},
+					err => {
+						assertCKEditorError( err,
+							// eslint-disable-next-line max-len
+							/^editor-create-initial-data: The config\.initialData option cannot be used together with initial data passed in Editor\.create\(\)\./,
+							null
+						);
+					}
+				)
+				.then( done )
+				.catch( done );
+		} );
+
+		it( 'throws error if it is initialized in textarea', done => {
+			DecoupledEditor.create( document.createElement( 'textarea' ) )
+				.then(
+					() => {
+						expect.fail( 'Decoupled editor should throw an error when is initialized in textarea.' );
+					},
+					err => {
+						assertCKEditorError( err,
+							/^editor-wrong-element: This type of editor cannot be initialized inside <textarea> element\./,
+							null
+						);
+					}
+				)
+				.then( done )
+				.catch( done );
 		} );
 		} );
 
 
 		function test( getElementOrData ) {
 		function test( getElementOrData ) {

+ 2 - 2
packages/ckeditor5-editor-decoupled/tests/decouplededitorui.js

@@ -15,7 +15,7 @@ import DecoupledEditorUIView from '../src/decouplededitoruiview';
 
 
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
+import { assertBinding } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 import { isElement } from 'lodash-es';
 import { isElement } from 'lodash-es';
 
 
 describe( 'DecoupledEditorUI', () => {
 describe( 'DecoupledEditorUI', () => {
@@ -67,7 +67,7 @@ describe( 'DecoupledEditorUI', () => {
 			} );
 			} );
 
 
 			it( 'binds view.editable#isFocused', () => {
 			it( 'binds view.editable#isFocused', () => {
-				utils.assertBinding(
+				assertBinding(
 					view.editable,
 					view.editable,
 					{ isFocused: false },
 					{ isFocused: false },
 					[
 					[

+ 2 - 2
packages/ckeditor5-editor-decoupled/tests/manual/decouplededitor-editable.js

@@ -13,7 +13,7 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
 import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
 import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
 import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
-import testUtils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
+import { createObserver } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 let editor, editable, observer;
 let editor, editable, observer;
 
 
@@ -32,7 +32,7 @@ function initEditor() {
 			window.editor = editor = newEditor;
 			window.editor = editor = newEditor;
 			window.editable = editable = editor.editing.view.document.getRoot();
 			window.editable = editable = editor.editing.view.document.getRoot();
 
 
-			observer = testUtils.createObserver();
+			observer = createObserver();
 			observer.observe( 'Editable', editable, [ 'isFocused' ] );
 			observer.observe( 'Editable', editable, [ 'isFocused' ] );
 		} )
 		} )
 		.catch( err => {
 		.catch( err => {

+ 8 - 4
packages/ckeditor5-editor-decoupled/tests/manual/memory.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
  */
 
 
-/* globals console:false, document, window */
+/* globals console, document */
 
 
 import DecoupledEditor from '../../src/decouplededitor';
 import DecoupledEditor from '../../src/decouplededitor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
@@ -17,6 +17,8 @@ const editorData = '<h2>Hello world</h2><p>This is the decoupled editor.</p><img
  * - add event listeners with () => {} methods which reference other
  * - add event listeners with () => {} methods which reference other
  */
  */
 function initEditor() {
 function initEditor() {
+	let editor;
+
 	DecoupledEditor
 	DecoupledEditor
 		.create( editorData, {
 		.create( editorData, {
 			plugins: [ ArticlePluginSet ],
 			plugins: [ ArticlePluginSet ],
@@ -53,7 +55,7 @@ function initEditor() {
 			}
 			}
 		} )
 		} )
 		.then( newEditor => {
 		.then( newEditor => {
-			window.editor = newEditor;
+			editor = newEditor;
 
 
 			document.querySelector( '.toolbar-container' ).appendChild( newEditor.ui.view.toolbar.element );
 			document.querySelector( '.toolbar-container' ).appendChild( newEditor.ui.view.toolbar.element );
 			document.querySelector( '.editable-container' ).appendChild( newEditor.ui.view.editable.element );
 			document.querySelector( '.editable-container' ).appendChild( newEditor.ui.view.editable.element );
@@ -65,8 +67,10 @@ function initEditor() {
 		} );
 		} );
 
 
 	function destroyEditor() {
 	function destroyEditor() {
-		window.editor.destroy().then( () => console.log( 'Editor was destroyed' ) );
-		window.editor = null;
+		editor.destroy().then( () => console.log( 'Editor was destroyed' ) );
+		editor.ui.view.toolbar.element.remove();
+		editor.ui.view.editable.element.remove();
+		editor = null;
 		document.getElementById( 'destroyEditor' ).removeEventListener( 'click', destroyEditor );
 		document.getElementById( 'destroyEditor' ).removeEventListener( 'click', destroyEditor );
 	}
 	}
 }
 }