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 40
T/ckeditor5/1243: Unify widget insertion #1545
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7cd3f5e
Docs: Fix code samples in model/selection.
jodator 97cb888
Changed: The insertContent() should accept position & range.
jodator 4c233e5
Internal: Remove default parameter from `model.insertContent()` calls.
jodator b91dc3b
Use `Selection` class instead of `DocumentSelection` to check if `ins…
jodator e0ba244
The insertContent() function should also work with DocumentSelection.
jodator f18462a
Docs: Update `insertContent()` documentation.
jodator b00ca26
Docs: Move documentation about changing selection to `model.insertCon…
jodator dcb0c54
Docs: Improve the model.insertContent() sample docs.
jodator 6163265
Docs: Add more examples to the `model.insertContent()`. Reword descri…
jodator abfff1f
Tests: Use writer.insertText in some insertContent() tests.
jodator 259bd57
Small fixes in docs.
6e779db
Docs: Update wording on model.insertContent() docs.
jodator 63e4f18
Docs: Use more human readable code examples for model.insertContent().
jodator aa31f0f
Docs: Add default values to the selectable in insertContent().
jodator e95e695
Merge branch 'master' into t/ckeditor5/1243
jodator 3cb0b59
Docs: Add information about `insertContent` event params.
jodator 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 |
---|---|---|
|
@@ -275,12 +275,12 @@ export default class Model { | |
* | ||
* // insertContent() doesn't have to be used in a change() block. It can, though, | ||
* // so this code could be moved to the callback defined above. | ||
* editor.model.insertContent( docFrag, editor.model.document.selection ); | ||
* editor.model.insertContent( docFrag ); | ||
* | ||
* Using `insertContent()` with HTML string converted to a model document fragment (similar to the pasting mechanism): | ||
* | ||
* // You can create your own HtmlDataProcessor instance or use editor.data.processor | ||
* // if you haven't overriden the default one (which is HtmlDataProcessor instance). | ||
* // if you haven't overridden the default one (which is HtmlDataProcessor instance). | ||
* const htmlDP = new HtmlDataProcessor(); | ||
* | ||
* // Convert an HTML string to a view document fragment. | ||
|
@@ -296,15 +296,43 @@ export default class Model { | |
* // which has a loosened schema. | ||
* const modelFragment = editor.data.toModel( viewFragment ); | ||
* | ||
* editor.model.insertContent( modelFragment, editor.model.document.selection ); | ||
* editor.model.insertContent( modelFragment ); | ||
* | ||
* By default this method will use the document selection but it can also be used with a position, range or selection instance. | ||
* | ||
* // Insert text at the current document selection position. | ||
* editor.model.change( writer => { | ||
* editor.model.insertContent( writer.createText( 'x' ) ); | ||
* } ); | ||
* | ||
* // Insert text at given position - document selection will not be modified. | ||
* editor.model.change( writer => { | ||
* editor.model.insertContent( writer.createText( 'x' ), Position.createAt( doc.getRoot(), 2 ) ); | ||
* } ); | ||
* | ||
* If an instance of {module:engine/model/selection~Selection} is passed as `selectable` | ||
* it will be moved to the target position (where the document selection should be moved after the insertion). | ||
* | ||
* // Insert text replacing given selection instance. | ||
* const selection = new Selection( paragraph, 'in' ); | ||
* | ||
* editor.model.change( writer => { | ||
* editor.model.insertContent( writer.createText( 'x' ), selection ); | ||
* | ||
* // insertContent() modifies the passed selection instance so it can be used to set the document selection. | ||
* // Note: This is not necessary when you passed document selection to insertContent(). | ||
* writer.setSelection( selection ); | ||
* } ); | ||
* | ||
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. Sample with range/position is missing. |
||
* @fires insertContent | ||
* @param {module:engine/model/documentfragment~DocumentFragment|module:engine/model/item~Item} content The content to insert. | ||
* @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection} selection | ||
* Selection into which the content should be inserted. | ||
* @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection| | ||
* module:engine/model/position~Position|module:engine/model/element~Element| | ||
* Iterable.<module:engine/model/range~Range>|module:engine/model/range~Range|null} [selectable=model.document.selection] | ||
* Selection into which the content should be inserted. If not provided the current model document selection will be used. | ||
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. You can add a note that if you use a selection object, it will be modified and you will be able to get the insertion selection. |
||
*/ | ||
insertContent( content, selection ) { | ||
insertContent( this, content, selection ); | ||
insertContent( content, selectable ) { | ||
insertContent( this, content, selectable ); | ||
} | ||
|
||
/** | ||
|
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
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
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
Oops, something went wrong.
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.