8
0
Просмотр исходного кода

Renamed `BEFORE` and `AFTER` to lower case.

Oskar Wrobel 9 лет назад
Родитель
Сommit
448990ca4a

+ 1 - 1
packages/ckeditor5-engine/src/model/composer/modifyselection.js

@@ -49,7 +49,7 @@ export default function modifySelection( selection, options = {} ) {
 
 	// 3. We're entering an element, so let's consume it fully.
 	if ( value.type == ( isForward ? 'elementStart' : 'elementEnd' ) ) {
-		selection.setFocus( value.item, isForward ? 'AFTER' : 'BEFORE' );
+		selection.setFocus( value.item, isForward ? 'after' : 'before' );
 
 		return;
 	}

+ 13 - 13
packages/ckeditor5-engine/src/model/position.js

@@ -152,16 +152,16 @@ export default class Position {
 				return 'SAME';
 
 			case 'PREFIX':
-				return 'BEFORE';
+				return 'before';
 
 			case 'EXTENSION':
-				return 'AFTER';
+				return 'after';
 
 			default:
 				if ( this.path[ result ] < otherPosition.path[ result ] ) {
-					return 'BEFORE';
+					return 'before';
 				} else {
-					return 'AFTER';
+					return 'after';
 				}
 		}
 	}
@@ -324,7 +324,7 @@ export default class Position {
 	 * @returns {Boolean} True if this position is after given position.
 	 */
 	isAfter( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'AFTER';
+		return this.compareWith( otherPosition ) == 'after';
 	}
 
 	/**
@@ -359,7 +359,7 @@ export default class Position {
 	 * @returns {Boolean} True if this position is before given position.
 	 */
 	isBefore( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'BEFORE';
+		return this.compareWith( otherPosition ) == 'before';
 	}
 
 	/**
@@ -389,12 +389,12 @@ export default class Position {
 			case 'SAME':
 				return true;
 
-			case 'BEFORE':
+			case 'before':
 				left = Position.createFromPosition( this );
 				right = Position.createFromPosition( otherPosition );
 				break;
 
-			case 'AFTER':
+			case 'after':
 				left = Position.createFromPosition( otherPosition );
 				right = Position.createFromPosition( this );
 				break;
@@ -449,7 +449,7 @@ export default class Position {
 	 * * a {@link engine.model.Position position},
 	 * * parent element and offset (offset defaults to `0`),
 	 * * parent element and `'END'` (sets selection at the end of that element),
-	 * * node and `'BEFORE'` or `'AFTER'` (sets selection before or after the given node).
+	 * * node and `'before'` or `'after'` (sets selection before or after the given node).
 	 *
 	 * This method is a shortcut to other constructors such as:
 	 *
@@ -459,7 +459,7 @@ export default class Position {
 	 * * {@link engine.model.Position.createFromPosition}.
 	 *
 	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
-	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
+	 * @param {Number|'END'|'before'|'after'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
 	static createAt( nodeOrPosition, offset ) {
@@ -472,9 +472,9 @@ export default class Position {
 
 			if ( offset == 'END' ) {
 				offset = node.getChildCount();
-			} else if ( offset == 'BEFORE' ) {
+			} else if ( offset == 'before' ) {
 				return this.createBefore( node );
-			} else if ( offset == 'AFTER' ) {
+			} else if ( offset == 'after' ) {
 				return this.createAfter( node );
 			} else if ( !offset ) {
 				offset = 0;
@@ -641,7 +641,7 @@ export default class Position {
 }
 
 /**
- * A flag indicating whether this position is `'BEFORE'` or `'AFTER'` or `'SAME'` as given position.
+ * A flag indicating whether this position is `'before'` or `'after'` or `'SAME'` as given position.
  * If positions are in different roots `'DIFFERENT'` flag is returned.
  *
  * @typedef {String} engine.model.PositionRelation

+ 3 - 3
packages/ckeditor5-engine/src/model/selection.js

@@ -306,7 +306,7 @@ export default class Selection {
 	 *
 	 * @fires engine.model.Selection#change:range
 	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
-	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
+	 * @param {Number|'END'|'before'|'after'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
 	collapse( nodeOrPosition, offset ) {
@@ -323,7 +323,7 @@ export default class Selection {
 	 *
 	 * @fires engine.model.Selection#change:range
 	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
-	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
+	 * @param {Number|'END'|'before'|'after'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
 	setFocus( nodeOrPosition, offset ) {
@@ -348,7 +348,7 @@ export default class Selection {
 			this._popRange();
 		}
 
-		if ( newFocus.compareWith( anchor ) == 'BEFORE' ) {
+		if ( newFocus.compareWith( anchor ) == 'before' ) {
 			this.addRange( new Range( newFocus, anchor ), true );
 		} else {
 			this.addRange( new Range( anchor, newFocus ) );

+ 7 - 7
packages/ckeditor5-engine/src/view/position.js

@@ -106,7 +106,7 @@ export default class Position {
 	 * @returns {Boolean} Returns `true` if this position is before given position.
 	 */
 	isBefore( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'BEFORE';
+		return this.compareWith( otherPosition ) == 'before';
 	}
 
 	/**
@@ -120,7 +120,7 @@ export default class Position {
 	 * @returns {Boolean} Returns `true` if this position is after given position.
 	 */
 	isAfter( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'AFTER';
+		return this.compareWith( otherPosition ) == 'after';
 	}
 
 	/**
@@ -137,7 +137,7 @@ export default class Position {
 
 		// If positions have same parent.
 		if ( this.parent === otherPosition.parent ) {
-			return this.offset - otherPosition.offset < 0 ? 'BEFORE' : 'AFTER';
+			return this.offset - otherPosition.offset < 0 ? 'before' : 'after';
 		}
 
 		// Get path from root to position's parent element.
@@ -175,17 +175,17 @@ export default class Position {
 		if ( commonAncestor === this.parent ) {
 			const index = this.offset - nextAncestor2.getIndex();
 
-			return index <= 0 ? 'BEFORE' : 'AFTER';
+			return index <= 0 ? 'before' : 'after';
 		} else if ( commonAncestor === otherPosition.parent ) {
 			const index = nextAncestor1.getIndex() - otherPosition.offset;
 
-			return index < 0 ? 'BEFORE' : 'AFTER';
+			return index < 0 ? 'before' : 'after';
 		}
 
 		const index = nextAncestor1.getIndex() - nextAncestor2.getIndex();
 
 		// Compare indexes of next ancestors inside common one.
-		return index < 0 ? 'BEFORE' : 'AFTER';
+		return index < 0 ? 'before' : 'after';
 	}
 
 	/**
@@ -269,7 +269,7 @@ export default class Position {
 }
 
 /**
- * A flag indicating whether this position is `'BEFORE'` or `'AFTER'` or `'SAME'` as given position.
+ * A flag indicating whether this position is `'before'` or `'after'` or `'SAME'` as given position.
  * If positions are in different roots `'DIFFERENT'` flag is returned.
  *
  * @typedef {String} engine.view.PositionRelation

+ 1 - 1
packages/ckeditor5-engine/src/view/renderer.js

@@ -89,7 +89,7 @@ export default class Renderer {
 
 		/**
 		 * Position of the inline {@link engine.view.filler filler}.
-		 * It should always be put BEFORE the text which contains filler.
+		 * It should always be put before the text which contains filler.
 		 *
 		 * @private
 		 * @member {engine.view.Position} engine.view.Renderer#_inlineFillerPosition

+ 2 - 2
packages/ckeditor5-engine/tests/_utils-tests/model.js

@@ -198,7 +198,7 @@ describe( 'model test utils', () => {
 			} );
 
 			it( 'writes selection collapsed at the text left boundary', () => {
-				selection.collapse( elA, 'AFTER' );
+				selection.collapse( elA, 'after' );
 
 				expect( stringify( root, selection ) ).to.equal(
 					'<a></a><selection />foo<$text bold=true>bar</$text><b></b>'
@@ -206,7 +206,7 @@ describe( 'model test utils', () => {
 			} );
 
 			it( 'writes selection collapsed at the text right boundary', () => {
-				selection.collapse( elB, 'BEFORE' );
+				selection.collapse( elB, 'before' );
 
 				expect( stringify( root, selection ) ).to.equal(
 					'<a></a>foo<$text bold=true>bar</$text><selection bold=true /><b></b>'

+ 8 - 8
packages/ckeditor5-engine/tests/model/position.js

@@ -166,11 +166,11 @@ describe( 'position', () => {
 		it( 'should create positions from node and flag', () => {
 			expect( Position.createAt( root, 'END' ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
 
-			expect( Position.createAt( p, 'BEFORE' ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
-			expect( Position.createAt( a, 'BEFORE' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
+			expect( Position.createAt( p, 'before' ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
+			expect( Position.createAt( a, 'before' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
 
-			expect( Position.createAt( p, 'AFTER' ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
-			expect( Position.createAt( a, 'AFTER' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
+			expect( Position.createAt( p, 'after' ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
+			expect( Position.createAt( a, 'after' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
 
 			expect( Position.createAt( ul, 'END' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
 		} );
@@ -469,18 +469,18 @@ describe( 'position', () => {
 			expect( position.compareWith( compared ) ).to.equal( 'SAME' );
 		} );
 
-		it( 'should return BEFORE if the position is before compared one', () => {
+		it( 'should return before if the position is before compared one', () => {
 			const position = new Position( root, [ 1, 2, 3 ] );
 			const compared = new Position( root, [ 1, 3 ] );
 
-			expect( position.compareWith( compared ) ).to.equal( 'BEFORE' );
+			expect( position.compareWith( compared ) ).to.equal( 'before' );
 		} );
 
-		it( 'should return AFTER if the position is after compared one', () => {
+		it( 'should return after if the position is after compared one', () => {
 			const position = new Position( root, [ 1, 2, 3, 4 ] );
 			const compared = new Position( root, [ 1, 2, 3 ] );
 
-			expect( position.compareWith( compared ) ).to.equal( 'AFTER' );
+			expect( position.compareWith( compared ) ).to.equal( 'after' );
 		} );
 
 		it( 'should return DIFFERENT if positions are in different roots', () => {

+ 2 - 2
packages/ckeditor5-engine/tests/model/selection.js

@@ -216,7 +216,7 @@ describe( 'Selection', () => {
 		} );
 
 		it( 'sets selection before the specified element', () => {
-			selection.collapse( root.getChild( 1 ), 'BEFORE' );
+			selection.collapse( root.getChild( 1 ), 'before' );
 
 			expect( selection ).to.have.property( 'isCollapsed', true );
 
@@ -226,7 +226,7 @@ describe( 'Selection', () => {
 		} );
 
 		it( 'sets selection after the specified element', () => {
-			selection.collapse( root.getChild( 1 ), 'AFTER' );
+			selection.collapse( root.getChild( 1 ), 'after' );
 
 			expect( selection ).to.have.property( 'isCollapsed', true );
 

+ 4 - 4
packages/ckeditor5-engine/tests/view/position.js

@@ -265,20 +265,20 @@ describe( 'Position', () => {
 			expect( position.compareWith( compared ) ).to.equal( 'SAME' );
 		} );
 
-		it( 'should return BEFORE if the position is before compared one', () => {
+		it( 'should return before if the position is before compared one', () => {
 			const root = new Node();
 			const position = new Position( root, 0 );
 			const compared = new Position( root, 1 );
 
-			expect( position.compareWith( compared ) ).to.equal( 'BEFORE' );
+			expect( position.compareWith( compared ) ).to.equal( 'before' );
 		} );
 
-		it( 'should return AFTER if the position is after compared one', () => {
+		it( 'should return after if the position is after compared one', () => {
 			const root = new Node();
 			const position = new Position( root, 4 );
 			const compared = new Position( root, 1 );
 
-			expect( position.compareWith( compared ) ).to.equal( 'AFTER' );
+			expect( position.compareWith( compared ) ).to.equal( 'after' );
 		} );
 
 		it( 'should return DIFFERENT if positions are in different roots', () => {