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

Merge branch 'master' into t/1161

Piotrek Koszuliński 8 лет назад
Родитель
Сommit
10cfc7af88

+ 0 - 4
packages/ckeditor5-engine/.gitignore

@@ -1,5 +1 @@
-# These files will be ignored by Git and by our linting tools:
-#	gulp lint
-#	gulp lint-staged
-
 node_modules/

+ 0 - 22
packages/ckeditor5-engine/gulpfile.js

@@ -1,22 +0,0 @@
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* eslint-env node */
-
-'use strict';
-
-const gulp = require( 'gulp' );
-const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' );
-const options = {
-	// Files ignored by `gulp lint` task.
-	// Files from .gitignore will be added automatically during task execution.
-	ignoredFiles: [
-		'src/lib/**'
-	]
-};
-
-gulp.task( 'lint', () => ckeditor5Lint.lint( options ) );
-gulp.task( 'lint-staged', () => ckeditor5Lint.lintStaged( options ) );
-gulp.task( 'pre-commit', [ 'lint-staged' ] );

+ 16 - 3
packages/ckeditor5-engine/package.json

@@ -10,7 +10,6 @@
     "@ckeditor/ckeditor5-utils": "^1.0.0-alpha.1"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-dev-lint": "^3.1.4",
     "@ckeditor/ckeditor5-basic-styles": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-core": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-editor-classic": "^1.0.0-alpha.1",
@@ -22,9 +21,10 @@
     "@ckeditor/ckeditor5-typing": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-undo": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-widget": "^1.0.0-alpha.1",
+    "eslint": "^4.8.0",
     "eslint-config-ckeditor5": "^1.0.6",
-    "gulp": "^3.9.1",
-    "guppy-pre-commit": "^0.4.0"
+    "husky": "^0.14.3",
+    "lint-staged": "^4.2.3"
   },
   "engines": {
     "node": ">=6.0.0",
@@ -42,5 +42,18 @@
     "lang",
     "src",
     "theme"
+  ],
+  "scripts": {
+    "lint": "eslint --quiet '**/*.js'",
+    "precommit": "lint-staged"
+  },
+  "lint-staged": {
+    "**/*.js": [
+      "eslint --quiet"
+    ]
+  },
+  "eslintIgnore": [
+    "src/lib/**",
+    "packages/**"
   ]
 }

+ 4 - 1
packages/ckeditor5-engine/src/dev-utils/enableenginedebug.js

@@ -382,7 +382,10 @@ function enableLoggingTools() {
 
 	MergeDelta.prototype.toString = function() {
 		return getClassName( this ) + `( ${ this.baseVersion } ): ` +
-			this.position.toString();
+			( this.position ?
+				this.position.toString() :
+				`(move from ${ this.operations[ 0 ].sourcePosition })`
+			);
 	};
 
 	MoveDelta.prototype.toString = function() {

+ 3 - 1
packages/ckeditor5-engine/src/model/operation/transform.js

@@ -342,7 +342,9 @@ const ot = {
 		InsertOperation( a, b, context ) {
 			// Create range from MoveOperation properties and transform it by insertion.
 			let range = Range.createFromPositionAndShift( a.sourcePosition, a.howMany );
-			range = range._getTransformedByInsertion( b.position, b.nodes.maxOffset, false, a.isSticky && !context.forceNotSticky )[ 0 ];
+			const includeB = a.isSticky && !context.forceNotSticky;
+
+			range = range._getTransformedByInsertion( b.position, b.nodes.maxOffset, false, includeB )[ 0 ];
 
 			// Check whether there is a forced order of nodes or use `context.isStrong` flag for conflict resolving.
 			const insertBefore = context.insertBefore === undefined ? !context.isStrong : context.insertBefore;

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

@@ -615,7 +615,7 @@ export default class Range {
 		} else {
 			const range = Range.createFromRange( this );
 
-			const insertBeforeStart = range.isCollapsed ? true : !isSticky;
+			const insertBeforeStart = !isSticky;
 			const insertBeforeEnd = range.isCollapsed ? true : isSticky;
 
 			range.start = range.start._getTransformedByInsertion( insertPosition, howMany, insertBeforeStart );

+ 19 - 0
packages/ckeditor5-engine/tests/dev-utils/enableenginedebug.js

@@ -397,6 +397,25 @@ describe( 'debug tools', () => {
 				expect( log.calledWithExactly( delta.toString() ) ).to.be.true;
 			} );
 
+			it( 'MergeDelta - NoOperation as second operation', () => {
+				const otherRoot = modelDoc.createRoot( '$root', 'otherRoot' );
+				const firstEle = new ModelElement( 'paragraph' );
+				const removedEle = new ModelElement( 'paragraph', null, [ new ModelText( 'foo' ) ] );
+
+				otherRoot.appendChildren( [ firstEle, removedEle ] );
+
+				const delta = new MergeDelta();
+				const move = new MoveOperation( ModelPosition.createAt( removedEle, 0 ), 3, ModelPosition.createAt( firstEle, 0 ), 0 );
+
+				delta.addOperation( move );
+				delta.addOperation( new NoOperation( 1 ) );
+
+				expect( delta.toString() ).to.equal( 'MergeDelta( 0 ): (move from otherRoot [ 1, 0 ])' );
+
+				delta.log();
+				expect( log.calledWithExactly( delta.toString() ) ).to.be.true;
+			} );
+
 			it( 'MoveDelta', () => {
 				const delta = new MoveDelta();
 				const move1 = new MoveOperation( ModelPosition.createAt( modelRoot, 0 ), 1, ModelPosition.createAt( modelRoot, 3 ), 0 );

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

@@ -572,11 +572,11 @@ describe( 'Range', () => {
 			expect( transformed[ 0 ].end.path ).to.deep.equal( [ 4, 4 ] );
 		} );
 
-		it( 'should move after inserted nodes if the range is collapsed and isSticky is true', () => {
+		it( 'should expand range after inserted nodes if the range is collapsed and isSticky is true', () => {
 			const range = new Range( new Position( root, [ 3, 2 ] ), new Position( root, [ 3, 2 ] ) );
 			const transformed = range._getTransformedByInsertion( new Position( root, [ 3, 2 ] ), 3, false, true );
 
-			expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 5 ] );
+			expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 2 ] );
 			expect( transformed[ 0 ].end.path ).to.deep.equal( [ 3, 5 ] );
 		} );
 	} );