Piotrek Koszuliński 9 年 前
コミット
ffbab9ff84
2 ファイル変更43 行追加17 行削除
  1. 8 9
      src/editor/editor.js
  2. 35 8
      src/editor/standardeditor.js

+ 8 - 9
src/editor/editor.js

@@ -17,9 +17,11 @@ import isArray from '../utils/lib/lodash/isArray.js';
 import mix from '../utils/mix.js';
 
 /**
- * Represents a single editor instance.
+ * Class representing a basic editor. It contains a base architecture, without much additional logic.
  *
- * @memberOf ckeditor5
+ * See also {@link ckeditor5.editor.StandardEditor}.
+ *
+ * @memberOf ckeditor5.editor
  * @mixes utils.EmitterMixin
  */
 export default class Editor {
@@ -85,7 +87,7 @@ export default class Editor {
 	}
 
 	/**
-	 * TODO
+	 * Loads and initilizes plugins specified in `config.features`.
 	 *
 	 * @returns {Promise} A promise which resolves once the initialization is completed.
 	 */
@@ -115,21 +117,18 @@ export default class Editor {
 	}
 
 	/**
-	 * Destroys the editor instance, releasing all resources used by it. If the editor replaced an element, the
-	 * element will be recovered.
+	 * Destroys the editor instance, releasing all resources used by it.
 	 *
-	 * @fires ckeditor5.Editor#destroy
+	 * @fires ckeditor5.editor.Editor#destroy
 	 * @returns {Promise} A promise that resolves once the editor instance is fully destroyed.
 	 */
 	destroy() {
 		this.fire( 'destroy' );
 		this.stopListening();
 
-		// Note: The destruction order should be the reverse of the initialization order.
 		return Promise.resolve()
 			.then( () => {
 				this.document.destroy();
-				this.editing.destroy();
 				this.data.destroy();
 			} );
 	}
@@ -162,5 +161,5 @@ mix( Editor, EmitterMixin );
  * Fired when this editor instance is destroyed. The editor at this point is not usable and this event should be used to
  * perform the clean-up in any plugin.
  *
- * @event ckeditor5.Editor#destroy
+ * @event ckeditor5.editor.Editor#destroy
  */

+ 35 - 8
src/editor/standardeditor.js

@@ -14,22 +14,28 @@ import getDataFromElement from '../utils/dom/getdatafromelement.js';
 import setDataInElement from '../utils/dom/setdatainelement.js';
 
 /**
- * Represents a single editor instance.
+ * Class representing a typical browser-based editor. It handles a single source element and
+ * uses {@link engine.EditingController}.
  *
- * @memberOf ckeditor5
- * @mixes utils.ObservaleMixin
+ * @memberOf ckeditor5.editor
  */
 export default class StandardEditor extends Editor {
 	/**
-	 * Creates a new instance of the Editor class.
+	 * Creates a new instance of the standard editor.
 	 *
-	 * @param {HTMLElement} [element] The DOM element that will be the source
+	 * @param {HTMLElement} element The DOM element that will be the source
 	 * for the created editor.
 	 * @param {Object} config The editor config.
 	 */
 	constructor( element, config ) {
 		super( config );
 
+		/**
+		 * The element on which the editor has been initialized.
+		 *
+		 * @readonly
+		 * @member {HTMLElement} ckeditor5.editor.StandardEditor#element
+		 */
 		this.element = element;
 
 		/**
@@ -49,6 +55,15 @@ export default class StandardEditor extends Editor {
 		this.keystrokes = new KeystrokeHandler( this );
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	destroy() {
+		return Promise.resolve()
+			.then( () => this.editing.destroy() )
+			.then( super.destroy() );
+	}
+
 	/**
 	 * Sets the data in the editor's main root.
 	 *
@@ -57,7 +72,7 @@ export default class StandardEditor extends Editor {
 	setData( data ) {
 		if ( !this.data ) {
 			/**
-			 * Data controller has not been defined yet, so methds like {@link ckeditor5.editor.StandardEditor#setData} and
+			 * Data controller has not been defined yet, so methods like {@link ckeditor5.editor.StandardEditor#setData} and
 			 * {@link ckeditor5.editor.StandardEditor#getData} cannot be used.
 			 *
 			 * @error editor-no-datacontroller
@@ -80,16 +95,28 @@ export default class StandardEditor extends Editor {
 	}
 
 	/**
-	 * Updates the {@link ckeditor5.Editor#element editor element}'s content with the data.
+	 * Updates the {@link ckeditor5.editor.StandardEditor#element editor element}'s content with the data.
 	 */
 	updateEditorElement() {
 		setDataInElement( this.element, this.getData() );
 	}
 
 	/**
-	 * Loads the data from the {@link ckeditor5.Editor#element editor element} to the main root.
+	 * Loads the data from the {@link ckeditor5.editor.StandardEditor#element editor element} to the main root.
 	 */
 	loadDataFromEditorElement() {
 		this.setData( getDataFromElement( this.element ) );
 	}
+
+	/**
+	 * Creates a standard editor instance.
+	 *
+	 * @abstract
+	 * @static
+	 * @method #create
+	 * @param {HTMLElement} element See {@link ckeditor5.editor.StandardEditor}'s param.
+	 * @param {Object} config See {@link ckeditor5.editor.StandardEditor}'s param.
+	 * @returns {Promise} Promise resolved once editor is ready.
+	 * @returns {ckeditor5.editor.StandardEditor} return.editor The editor instance.
+	 */
 }