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

Commit

Permalink
Docs: Move documentation about changing selection to `model.insertCon…
Browse files Browse the repository at this point in the history
…tent()` from `insertContent()`.
  • Loading branch information
jodator committed Sep 14, 2018
1 parent f18462a commit b00ca26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
13 changes: 13 additions & 0 deletions src/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@ export default class Model {
*
* editor.model.insertContent( modelFragment, editor.model.document.selection );
*
* If an instance of {module:engine/model/selection~Selection} is passed as `selectable` it will be modified
* to the insertion selection (equal to a range to be selected after insertion).
*
* // Insert text replacing given selection instance.
* const selection = new Selection( new Position( doc.getRoot(), [ 2 ] ), new Position( doc.getRoot(), [ 5 ] ) );
*
* editor.model.change( ( writer ) => {
* editor.model.insertContent( model, writer.createText( 'x' ), selection );
*
* // The selection contains a range to be selected - ie can be used to set selection.
* writer.setSelection( selection );
* } );
*
* @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|
Expand Down
22 changes: 0 additions & 22 deletions src/model/utils/insertcontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,9 @@ import Selection from '../selection';
* Inserts content into the editor (specified selection) as one would expect the paste
* functionality to work.
*
* // Insert text at current document selection position.
* model.change( () => {
* insertContent( model, new Text( 'x' ) ); // equal to insertContent( model, new Text( 'x' ), editor.model.document.selection );
* } );
*
* // Insert text at some position - model's selection will not be modified.
* model.change( () => {
* insertContent( model, new Text( 'x' ), new Position( doc.getRoot(), [ 2 ] ) );
* } );
*
* If an instance of {module:engine/model/selection~Selection} is passed as `selectable` it will be modified
* to the insertion selection (equal to a range to be selected after insertion).
*
* // Insert text replacing given selection instance.
* const selection = new Selection( new Position( doc.getRoot(), [ 2 ] ), new Position( doc.getRoot(), [ 5 ] ) );
*
* model.change( () => {
* insertContent( model, new Text( 'x' ), selection );
* } );
*
* // The selection contains a range to be selected - ie can be used to set selection.
* model.change( ( writer ) => {
* writer.setSelection( selection );
* } );
*
* **Note:** Use {@link module:engine/model/model~Model#insertContent} instead of this function.
* This function is only exposed to be reusable in algorithms which change the {@link module:engine/model/model~Model#insertContent}
* method's behavior.
Expand Down

0 comments on commit b00ca26

Please sign in to comment.