This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Allow to pass initial data to the editor constructor #73
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3015814
Allow to pass data to the constructor instaead of element to replace.
szymonkups 5af49aa
Added tests checking data initialization.
szymonkups 633b5d3
Improved documentation.
szymonkups f38aec7
Improved manual test with data initialization.
szymonkups 3232bfb
Removed unused CSS class.
szymonkups 8a7ea54
Appending editor to the container in data initialization manual test.
szymonkups ffdede7
Minor improvements for the manual test.
216cd88
Merge branch 'master' into t/72
Reinmar a9497d2
Docs: Improved API docs for the create() method.
Reinmar 674c3b0
Renamed editor.element to editor.sourceElement and implemented the Ed…
51cdeee
Simplified the code and docs. Added more tests.
22b6f4f
Merge branch 'master' into t/72
4a13075
Merge branch 'master' into t/72
c210e56
Fixed broken promises chain (editor.data.init() returns a promise).
46d2f71
Used better variable name.
6df6ba9
More API docs polish.
Reinmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its contents