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

Docs: Improved API docs for the create() method.

Piotrek Koszuliński 7 лет назад
Родитель
Сommit
48013ae9a4
1 измененных файлов с 19 добавлено и 6 удалено
  1. 19 6
      packages/ckeditor5-editor-classic/src/classiceditor.js

+ 19 - 6
packages/ckeditor5-editor-classic/src/classiceditor.js

@@ -54,9 +54,8 @@ export default class ClassicEditor extends Editor {
 	 * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`} method instead.
 	 *
 	 * @protected
-	 * @param {HTMLElement} elementOrData The DOM element that will be the source for the created editor.
-	 * The data will be loaded from it and loaded back to it once the editor is destroyed. If data is provided, `editor.element`
-	 * should be added manually to the DOM after the editor is initialized.  For more information see
+	 * @param {HTMLElement|String} elementOrData The DOM element that will be the source for the created editor
+	 * or editor's initial data. For more information see
 	 * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
 	 * @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration.
 	 */
@@ -133,7 +132,7 @@ export default class ClassicEditor extends Editor {
 	 *				console.error( err.stack );
 	 *			} );
 	 *
-	 * Creating instance when using initial data instead of DOM element:
+	 * Creating instance when using initial data instead of a DOM element:
 	 *
 	 *		import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 	 *		import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
@@ -156,8 +155,22 @@ export default class ClassicEditor extends Editor {
 	 *				console.error( err.stack );
 	 *			} );
 	 *
-	 * @param {HTMLElement} element The DOM element that will be the source for the created editor.
-	 * The data will be loaded from it and loaded back to it once the editor is destroyed.
+	 * @param {HTMLElement|String} elementOrData The DOM element that will be the source for the created editor
+	 * or editor's initial data.
+	 *
+	 * If an element is passed, then it contents will be automatically
+	 * {@link module:editor-classic/classiceditor~ClassicEditor#setData loaded} to the editor on startup
+	 * and  the editor element will replace the passed element in the DOM (the original one will be hidden and editor
+	 * will be injected next to it).
+	 *
+	 * Moreover, the data will be set back to the original element once the editor is destroyed and
+	 * (if the element is a `<textarea>`) when a form in which this element is contained is submitted (which ensures
+	 * automatic integration with native web forms).
+	 *
+	 * If a data is passed, a detached editor will be created. It means that you need to insert it into the DOM manually
+	 * (by accessing the {@link module:editor-classic/classiceditor~ClassicEditor#element `editor.element`} property).
+	 *
+	 * See the examples above to learn more.
 	 * @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration.
 	 * @returns {Promise} A promise resolved once the editor is ready.
 	 * The promise returns the created {@link module:editor-classic/classiceditor~ClassicEditor} instance.