Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Allow to pass initial data to the editor constructor #73

Merged
merged 16 commits into from
Jul 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/classiceditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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';
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its contents

* {@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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"editor element" -> link to the new property

* will be injected next to it).
*
* Moreover, the data will be set back to the original element once the editor is destroyed and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original => source

* (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.
Expand Down