Parcourir la source

Renamed `TEXT` to lower case.

Oskar Wrobel il y a 9 ans
Parent
commit
91be76201f

+ 1 - 1
packages/ckeditor5-engine/src/model/element.js

@@ -190,7 +190,7 @@ export default class Element extends Node {
 		let text = '';
 
 		for ( let value of Range.createFromElement( this ) ) {
-			if ( value.type == 'TEXT' ) {
+			if ( value.type == 'text' ) {
 				text += value.item.text;
 			}
 		}

+ 1 - 1
packages/ckeditor5-engine/src/model/liveselection.js

@@ -295,7 +295,7 @@ export default class LiveSelection extends Selection {
 			for ( let item of range ) {
 				// This is not an optimal solution because of https://github.com/ckeditor/ckeditor5-engine/issues/454.
 				// It can be done better by using `break;` instead of checking `attrs === null`.
-				if ( item.type == 'TEXT' && attrs === null ) {
+				if ( item.type == 'text' && attrs === null ) {
 					attrs = item.item.getAttributes();
 				}
 			}

+ 4 - 4
packages/ckeditor5-engine/src/model/treewalker.js

@@ -222,7 +222,7 @@ export default class TreeWalker {
 				position.offset = offset;
 				this.position = position;
 
-				return formatReturnValue( 'TEXT', textProxy, previousPosition, position, charactersCount );
+				return formatReturnValue( 'text', textProxy, previousPosition, position, charactersCount );
 			}
 		} else {
 			// `node` is not set, we reached the end of current `parent`.
@@ -303,7 +303,7 @@ export default class TreeWalker {
 				position.offset = offset;
 				this.position = position;
 
-				return formatReturnValue( 'TEXT', textFragment, previousPosition, position, charactersCount );
+				return formatReturnValue( 'text', textFragment, previousPosition, position, charactersCount );
 			}
 		} else {
 			// `node` is not set, we reached the beginning of current `parent`.
@@ -332,7 +332,7 @@ function formatReturnValue( type, item, previousPosition, nextPosition, length )
 /**
  * Type of the step made by {@link engine.model.TreeWalker}.
  * Possible values: `'elementStart'` if walker is at the beginning of a node, `'elementEnd'` if walker is at the end of node,
- * `'CHARACTER'` if walker traversed over a character, or `'TEXT'` if walker traversed over multiple characters (available in
+ * `'CHARACTER'` if walker traversed over a character, or `'text'` if walker traversed over multiple characters (available in
  * character merging mode, see {@link engine.model.TreeWalker#constructor}).
  *
  * @typedef {String} engine.model.TreeWalkerValueType
@@ -357,7 +357,7 @@ function formatReturnValue( type, item, previousPosition, nextPosition, length )
  * the position after the item.
  * * Backward iteration: For `'elementEnd'` it is last position inside element. For all other types it is the position
  * before the item.
- * @property {Number} [length] Length of the item. For `'elementStart'` and `'CHARACTER'` it is 1. For `'TEXT'` it is
+ * @property {Number} [length] Length of the item. For `'elementStart'` and `'CHARACTER'` it is 1. For `'text'` it is
  * the length of the text. For `'elementEnd'` it is undefined.
  */
 

+ 6 - 6
packages/ckeditor5-engine/src/view/treewalker.js

@@ -217,7 +217,7 @@ export default class TreeWalker {
 
 				this.position = position;
 
-				return this._formatReturnValue( 'TEXT', item, previousPosition, position, charactersCount );
+				return this._formatReturnValue( 'text', item, previousPosition, position, charactersCount );
 			}
 		} else if ( typeof node == 'string' ) {
 			let textLength;
@@ -236,7 +236,7 @@ export default class TreeWalker {
 			position.offset += textLength;
 			this.position = position;
 
-			return this._formatReturnValue( 'TEXT', textProxy, previousPosition, position, textLength );
+			return this._formatReturnValue( 'text', textProxy, previousPosition, position, textLength );
 		} else {
 			// `node` is not set, we reached the end of current `parent`.
 			position = Position.createAfter( parent );
@@ -323,7 +323,7 @@ export default class TreeWalker {
 
 				this.position = position;
 
-				return this._formatReturnValue( 'TEXT', item, previousPosition, position, charactersCount );
+				return this._formatReturnValue( 'text', item, previousPosition, position, charactersCount );
 			}
 		} else if ( typeof node == 'string' ) {
 			let textLength;
@@ -343,7 +343,7 @@ export default class TreeWalker {
 
 			this.position = position;
 
-			return this._formatReturnValue( 'TEXT', textProxy, previousPosition, position, textLength );
+			return this._formatReturnValue( 'text', textProxy, previousPosition, position, textLength );
 		} else {
 			// `node` is not set, we reached the beginning of current `parent`.
 			position = Position.createBefore( parent );
@@ -409,7 +409,7 @@ export default class TreeWalker {
 /**
  * Type of the step made by {@link engine.view.TreeWalker}.
  * Possible values: `'elementStart'` if walker is at the beginning of a node, `'elementEnd'` if walker is at the end
- * of node, or `'TEXT'` if walker traversed over single and multiple characters.
+ * of node, or `'text'` if walker traversed over single and multiple characters.
  * For {@link engine.view.Text} `elementStart` and `elementEnd` is not returned.
  *
  * @typedef {String} engine.view.TreeWalkerValueType
@@ -436,7 +436,7 @@ export default class TreeWalker {
  * before the item.
  * * If the position is at the beginning or at the end of the {@link engine.view.Text} it is always moved from the
  * inside of the Text to its parent just before or just after Text.
- * @property {Number} [length] Length of the item. For `'elementStart'` it is 1. For `'TEXT'` it is
+ * @property {Number} [length] Length of the item. For `'elementStart'` it is 1. For `'text'` it is
  * the length of the text. For `'elementEnd'` it is undefined.
  */
 

+ 14 - 14
packages/ckeditor5-engine/tests/model/treewalker.js

@@ -79,11 +79,11 @@ describe( 'TreeWalker', () => {
 				{ type: 'elementStart', item: img1 },
 				{ type: 'elementEnd', item: img1 },
 				{ type: 'elementStart', item: paragraph },
-				{ type: 'TEXT', text: 'ba', attrs: [ [ 'bold', true ] ] },
-				{ type: 'TEXT', text: 'r', attrs: [] },
+				{ type: 'text', text: 'ba', attrs: [ [ 'bold', true ] ] },
+				{ type: 'text', text: 'r', attrs: [] },
 				{ type: 'elementStart', item: img2 },
 				{ type: 'elementEnd', item: img2 },
-				{ type: 'TEXT', text: 'x', attrs: [] },
+				{ type: 'text', text: 'x', attrs: [] },
 				{ type: 'elementEnd', item: paragraph }
 			];
 		} );
@@ -159,8 +159,8 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{ type: 'elementStart', item: paragraph },
-					{ type: 'TEXT', text: 'ba', attrs: [ [ 'bold', true ] ] },
-					{ type: 'TEXT', text: 'r', attrs: [] },
+					{ type: 'text', text: 'ba', attrs: [ [ 'bold', true ] ] },
+					{ type: 'text', text: 'r', attrs: [] },
 					{ type: 'elementStart', item: img2 },
 					{ type: 'elementEnd', item: img2 }
 				];
@@ -197,8 +197,8 @@ describe( 'TreeWalker', () => {
 
 			before( () => {
 				expected = [
-					{ type: 'TEXT', text: 'a', attrs: [ [ 'bold', true ] ] },
-					{ type: 'TEXT', text: 'r', attrs: [] },
+					{ type: 'text', text: 'a', attrs: [ [ 'bold', true ] ] },
+					{ type: 'text', text: 'r', attrs: [] },
 					{ type: 'elementStart', item: img2 },
 					{ type: 'elementEnd', item: img2 }
 				];
@@ -241,7 +241,7 @@ describe( 'TreeWalker', () => {
 					{ type: 'elementStart', item: img1 },
 					{ type: 'elementEnd', item: img1 },
 					{ type: 'elementStart', item: paragraph },
-					{ type: 'TEXT', text: 'b', attrs: [ [ 'bold', true ] ] }
+					{ type: 'text', text: 'b', attrs: [ [ 'bold', true ] ] }
 				];
 
 				range = new Range( rootBeginning, new Position( root, [ 1, 1 ] ) );
@@ -278,7 +278,7 @@ describe( 'TreeWalker', () => {
 		describe( 'custom start position', () => {
 			it( 'should iterating from the start position', () => {
 				let expected = [
-					{ type: 'TEXT', text: 'r', attrs: [] },
+					{ type: 'text', text: 'r', attrs: [] },
 					{ type: 'elementStart', item: img2 },
 					{ type: 'elementEnd', item: img2 }
 				];
@@ -301,7 +301,7 @@ describe( 'TreeWalker', () => {
 
 			it( 'should iterating from the start position going backward', () => {
 				let expected = [
-					{ type: 'TEXT', text: 'r', attrs: [] },
+					{ type: 'text', text: 'r', attrs: [] },
 					{ type: 'elementStart', item: img2 },
 					{ type: 'elementEnd', item: img2 }
 				];
@@ -459,10 +459,10 @@ describe( 'TreeWalker', () => {
 				expected = [
 					{ type: 'elementStart', item: img1 },
 					{ type: 'elementStart', item: paragraph },
-					{ type: 'TEXT', text: 'ba', attrs: [ [ 'bold', true ] ] },
-					{ type: 'TEXT', text: 'r', attrs: [] },
+					{ type: 'text', text: 'ba', attrs: [ [ 'bold', true ] ] },
+					{ type: 'text', text: 'r', attrs: [] },
 					{ type: 'elementStart', item: img2 },
-					{ type: 'TEXT', text: 'x', attrs: [] }
+					{ type: 'text', text: 'x', attrs: [] }
 				];
 			} );
 
@@ -547,7 +547,7 @@ describe( 'TreeWalker', () => {
 function expectValue( value, expected, options ) {
 	expect( value.type ).to.equal( expected.type );
 
-	if ( value.type == 'TEXT' ) {
+	if ( value.type == 'text' ) {
 		expectText( value, expected, options );
 	} else if ( value.type == 'CHARACTER' ) {
 		expectCharacter( value, expected, options );

+ 33 - 33
packages/ckeditor5-engine/tests/view/treewalker.js

@@ -106,7 +106,7 @@ describe( 'TreeWalker', () => {
 					nextPosition: new Position( bold, 0 )
 				},
 				{
-					type: 'TEXT',
+					type: 'text',
 					text: 'abcd',
 					previousPosition: new Position( bold, 0 ),
 					nextPosition: new Position( bold, 1 )
@@ -118,7 +118,7 @@ describe( 'TreeWalker', () => {
 					nextPosition: new Position( paragraph, 1 )
 				},
 				{
-					type: 'TEXT',
+					type: 'text',
 					text: 'y',
 					previousPosition: new Position( paragraph, 1 ),
 					nextPosition: new Position( paragraph, 2 )
@@ -136,7 +136,7 @@ describe( 'TreeWalker', () => {
 					nextPosition: new Position( paragraph, 3 )
 				},
 				{
-					type: 'TEXT',
+					type: 'text',
 					text: 'x',
 					previousPosition: new Position( paragraph, 3 ),
 					nextPosition: new Position( paragraph, 4 )
@@ -240,7 +240,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'abcd',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( bold, 1 )
@@ -252,7 +252,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -303,7 +303,7 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'bcd',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( bold, 1 )
@@ -315,7 +315,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -394,7 +394,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'ab',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 2 )
@@ -438,7 +438,7 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'bc',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 3 )
@@ -480,7 +480,7 @@ describe( 'TreeWalker', () => {
 			it( 'should iterating from the start position', () => {
 				let expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -517,7 +517,7 @@ describe( 'TreeWalker', () => {
 			it( 'should iterating from the start position going backward', () => {
 				let expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'bcd',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( bold, 1 )
@@ -529,7 +529,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -585,25 +585,25 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'a',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'b',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 2 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'c',
 						previousPosition: new Position( textAbcd, 2 ),
 						nextPosition: new Position( textAbcd, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'd',
 						previousPosition: new Position( textAbcd, 3 ),
 						nextPosition: new Position( bold, 1 )
@@ -615,7 +615,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -633,7 +633,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( paragraph, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'x',
 						previousPosition: new Position( paragraph, 3 ),
 						nextPosition: new Position( paragraph, 4 )
@@ -680,25 +680,25 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'a',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'b',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 2 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'c',
 						previousPosition: new Position( textAbcd, 2 ),
 						nextPosition: new Position( textAbcd, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'd',
 						previousPosition: new Position( textAbcd, 3 ),
 						nextPosition: new Position( bold, 1 )
@@ -710,7 +710,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -822,13 +822,13 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'abcd',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -840,7 +840,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'x',
 						previousPosition: new Position( paragraph, 3 ),
 						nextPosition: new Position( paragraph, 4 )
@@ -899,31 +899,31 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'a',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'b',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 2 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'c',
 						previousPosition: new Position( textAbcd, 2 ),
 						nextPosition: new Position( textAbcd, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'd',
 						previousPosition: new Position( textAbcd, 3 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -935,7 +935,7 @@ describe( 'TreeWalker', () => {
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'x',
 						previousPosition: new Position( paragraph, 3 ),
 						nextPosition: new Position( paragraph, 4 )
@@ -992,7 +992,7 @@ function expectValue( value, expected, options = {} ) {
 	expect( value.previousPosition ).to.deep.equal( expectedPreviousPosition );
 	expect( value.nextPosition ).to.deep.equal( expectedNextPosition );
 
-	if ( value.type == 'TEXT' ) {
+	if ( value.type == 'text' ) {
 		expectText( value, expected );
 	} else if ( value.type == 'elementStart' ) {
 		expectStart( value, expected );