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

Moved engine initilization to the editor class.

Piotrek Koszuliński 9 лет назад
Родитель
Сommit
2aeb3ed39e
2 измененных файлов с 17 добавлено и 16 удалено
  1. 1 14
      src/creator/standardcreator.js
  2. 16 2
      src/editor.js

+ 1 - 14
src/creator/standardcreator.js

@@ -6,11 +6,7 @@
 'use strict';
 
 import Creator from './creator.js';
-import Document from '../engine/model/document.js';
-import DataController from '../engine/datacontroller.js';
-import EditingController from '../engine/editingcontroller.js';
 import HtmlDataProcessor from '../engine/dataprocessor/htmldataprocessor.js';
-import KeystrokeHandler from '../keystrokehandler.js';
 
 /**
  * Standard creator for browser environment.
@@ -32,10 +28,7 @@ export default class StandardCreator extends Creator {
 	constructor( editor, dataProcessor = new HtmlDataProcessor() ) {
 		super( editor );
 
-		editor.document = new Document();
-		editor.editing = new EditingController( editor.document );
-		editor.data = new DataController( editor.document, dataProcessor );
-		editor.keystrokes = new KeystrokeHandler( editor );
+		editor.data.processor = dataProcessor;
 
 		/**
 		 * The elements replaced by {@link ckeditor5.creator.StandardCreator#_replaceElement} and their replacements.
@@ -47,14 +40,8 @@ export default class StandardCreator extends Creator {
 	}
 
 	destroy() {
-		const editor = this.editor;
-
 		super.destroy();
 
-		editor.document.destroy();
-		editor.editing.destroy();
-		editor.data.destroy();
-
 		this._restoreElements();
 	}
 

+ 16 - 2
src/editor.js

@@ -9,8 +9,13 @@ import ObservableMixin from './utils/observablemixin.js';
 import Config from './utils/config.js';
 import PluginCollection from './plugincollection.js';
 import EditableCollection from './editablecollection.js';
-import CKEditorError from './utils/ckeditorerror.js';
 import Locale from './utils/locale.js';
+import KeystrokeHandler from './keystrokehandler.js';
+import EditingController from './engine/editingcontroller.js';
+import DataController from './engine/datacontroller.js';
+import Document from './engine/model/document.js';
+
+import CKEditorError from './utils/ckeditorerror.js';
 import isArray from './utils/lib/lodash/isArray.js';
 import nth from './utils/nth.js';
 import mix from './utils/mix.js';
@@ -103,6 +108,7 @@ export default class Editor {
 		 * @readonly
 		 * @member {engine.model.Document} ckeditor5.Editor#document
 		 */
+		this.document = new Document();
 
 		/**
 		 * Instance of the {@link engine.EditingController editing controller}.
@@ -112,6 +118,7 @@ export default class Editor {
 		 * @readonly
 		 * @member {engine.EditingController} ckeditor5.Editor#editing
 		 */
+		this.editing = new EditingController( this.document );
 
 		/**
 		 * Instance of the {@link engine.DataController data controller}.
@@ -121,6 +128,7 @@ export default class Editor {
 		 * @readonly
 		 * @member {engine.DataController} ckeditor5.Editor#data
 		 */
+		this.data = new DataController( this.document );
 
 		/**
 		 * Instance of the {@link ckeditor5.KeystrokeHandler}.
@@ -130,6 +138,7 @@ export default class Editor {
 		 * @readonly
 		 * @member {engine.treecontroller.DataController} ckeditor5.Editor#keystrokes
 		 */
+		this.keystrokes = new KeystrokeHandler( this );
 
 		/**
 		 * The chosen creator.
@@ -245,7 +254,12 @@ export default class Editor {
 			.then( () => {
 				return this._creator && this._creator.destroy();
 			} )
-			.then( () => this.editables.destroy() );
+			.then( () => this.editables.destroy() )
+			.then( () => {
+				this.document.destroy();
+				this.editing.destroy();
+				this.data.destroy();
+			} );
 	}
 
 	/**