@@ -80,7 +80,7 @@ export function getData( view, options = {} ) {
8080getData . _stringify = stringify ;
8181
8282/**
83- * Sets the content of the {@link module:engine/view/document~Document document} provided as an HTML-like string.
83+ * Sets the content of a view {@link module:engine/view/document~Document document} provided as an HTML-like string.
8484 *
8585 * @param {module:engine/view/view~View } view
8686 * @param {String } data An HTML-like string to write into the document.
@@ -111,44 +111,47 @@ setData._parse = parse;
111111
112112/**
113113 * Converts view elements to HTML-like string representation.
114+ *
114115 * A root element can be provided as {@link module:engine/view/text~Text text}:
115116 *
116- * const text = new Text ( 'foobar' );
117+ * const text = downcastWriter.createText ( 'foobar' );
117118 * stringify( text ); // 'foobar'
118119 *
119120 * or as an {@link module:engine/view/element~Element element}:
120121 *
121- * const element = new Element ( 'p', null, new Text ( 'foobar' ) );
122+ * const element = downcastWriter.createElement ( 'p', null, downcastWriter.createText ( 'foobar' ) );
122123 * stringify( element ); // '<p>foobar</p>'
123124 *
124125 * or as a {@link module:engine/view/documentfragment~DocumentFragment document fragment}:
125126 *
126- * const text = new Text ( 'foobar' );
127- * const b = new Element ( 'b', { name: 'test' }, text );
128- * const p = new Element ( 'p', { style: 'color:red;' } );
129- * const fragment = new DocumentFragment ( [ p, b ] );
127+ * const text = downcastWriter.createText ( 'foobar' );
128+ * const b = downcastWriter.createElement ( 'b', { name: 'test' }, text );
129+ * const p = downcastWriter.createElement ( 'p', { style: 'color:red;' } );
130+ * const fragment = downcastWriter.createDocumentFragment ( [ p, b ] );
130131 *
131132 * stringify( fragment ); // '<p style="color:red;"></p><b name="test">foobar</b>'
132133 *
133134 * Additionally, a {@link module:engine/view/documentselection~DocumentSelection selection} instance can be provided.
134- * Ranges from the selection will then be included in output data.
135+ * Ranges from the selection will then be included in the output data.
135136 * If a range position is placed inside the element node, it will be represented with `[` and `]`:
136137 *
137- * const text = new Text ( 'foobar' );
138- * const b = new Element ( 'b', null, text );
139- * const p = new Element ( 'p', null, b );
140- * const selection = new Selection (
141- * Range._createFromParentsAndOffsets ( p, 0, p, 1 )
138+ * const text = downcastWriter.createText ( 'foobar' );
139+ * const b = downcastWriter.createElement ( 'b', null, text );
140+ * const p = downcastWriter.createElement ( 'p', null, b );
141+ * const selection = downcastWriter.createSelection (
142+ * downcastWriter.createRangeIn ( p )
142143 * );
143144 *
144145 * stringify( p, selection ); // '<p>[<b>foobar</b>]</p>'
145146 *
146147 * If a range is placed inside the text node, it will be represented with `{` and `}`:
147148 *
148- * const text = new Text( 'foobar' );
149- * const b = new Element( 'b', null, text );
150- * const p = new Element( 'p', null, b );
151- * const selection = new Selection( Range._createFromParentsAndOffsets( text, 1, text, 5 ) );
149+ * const text = downcastWriter.createText( 'foobar' );
150+ * const b = downcastWriter.createElement( 'b', null, text );
151+ * const p = downcastWriter.createElement( 'p', null, b );
152+ * const selection = downcastWriter.createSelection(
153+ * downcastWriter.createRange( downcastWriter.createPositionAt( text, 1 ), downcastWriter.createPositionAt( text, 5 ) )
154+ * );
152155 *
153156 * stringify( p, selection ); // '<p><b>f{ooba}r</b></p>'
154157 *
@@ -159,10 +162,10 @@ setData._parse = parse;
159162 *
160163 * Multiple ranges are supported:
161164 *
162- * const text = new Text ( 'foobar' );
163- * const selection = new Selection ( [
164- * Range._createFromParentsAndOffsets( text, 0, text, 1 ) ),
165- * Range._createFromParentsAndOffsets( text, 3, text, 5 ) )
165+ * const text = downcastWriter.createText ( 'foobar' );
166+ * const selection = downcastWriter.createSelection ( [
167+ * downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) ),
168+ * downcastWriter.createRange( downcastWriter.createPositionAt( text, 3 ), downcastWriter.createPositionAt( text, 5 ) )
166169 * ] );
167170 *
168171 * stringify( text, selection ); // '{f}oo{ba}r'
@@ -172,9 +175,9 @@ setData._parse = parse;
172175 * is provided, it will be converted to a selection containing this range. If a position instance is provided, it will
173176 * be converted to a selection containing one range collapsed at this position.
174177 *
175- * const text = new Text ( 'foobar' );
176- * const range = Range._createFromParentsAndOffsets( text, 0, text, 1 );
177- * const position = new Position ( text, 3 );
178+ * const text = downcastWriter.createText ( 'foobar' );
179+ * const range = downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) );
180+ * const position = downcastWriter.createPositionAt ( text, 3 );
178181 *
179182 * stringify( text, range ); // '{f}oobar'
180183 * stringify( text, position ); // 'foo{}bar'
@@ -186,10 +189,10 @@ setData._parse = parse;
186189 * {@link module:engine/view/emptyelement~EmptyElement empty elements}
187190 * and {@link module:engine/view/uielement~UIElement UI elements}:
188191 *
189- * const attribute = new AttributeElement ( 'b' );
190- * const container = new ContainerElement ( 'p' );
191- * const empty = new EmptyElement ( 'img' );
192- * const ui = new UIElement ( 'span' );
192+ * const attribute = downcastWriter.createAttributeElement ( 'b' );
193+ * const container = downcastWriter.createContainerElement ( 'p' );
194+ * const empty = downcastWriter.createEmptyElement ( 'img' );
195+ * const ui = downcastWriter.createUIElement ( 'span' );
193196 * getData( attribute, null, { showType: true } ); // '<attribute:b></attribute:b>'
194197 * getData( container, null, { showType: true } ); // '<container:p></container:p>'
195198 * getData( empty, null, { showType: true } ); // '<empty:img></empty:img>'
@@ -198,14 +201,14 @@ setData._parse = parse;
198201 * If `options.showPriority` is set to `true`, a priority will be displayed for all
199202 * {@link module:engine/view/attributeelement~AttributeElement attribute elements}.
200203 *
201- * const attribute = new AttributeElement ( 'b' );
204+ * const attribute = downcastWriter.createAttributeElement ( 'b' );
202205 * attribute._priority = 20;
203206 * getData( attribute, null, { showPriority: true } ); // <b view-priority="20"></b>
204207 *
205208 * If `options.showAttributeElementId` is set to `true`, the attribute element's id will be displayed for all
206209 * {@link module:engine/view/attributeelement~AttributeElement attribute elements} that have it set.
207210 *
208- * const attribute = new AttributeElement ( 'span' );
211+ * const attribute = downcastWriter.createAttributeElement ( 'span' );
209212 * attribute._id = 'marker:foo';
210213 * getData( attribute, null, { showAttributeElementId: true } ); // <span view-id="marker:foo"></span>
211214 *
@@ -249,7 +252,7 @@ export function stringify( node, selectionOrPositionOrRange = null, options = {}
249252}
250253
251254/**
252- * Parses an HTML-like string and returns view tree nodes .
255+ * Parses an HTML-like string and returns a view tree.
253256 * A simple string will be converted to a {@link module:engine/view/text~Text text} node:
254257 *
255258 * parse( 'foobar' ); // Returns an instance of text.
0 commit comments