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

Commit

Permalink
Merge branch 'master' into t/1161
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Oct 11, 2017
2 parents c5f7e36 + 5f020b0 commit bdc2410
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 34 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# These files will be ignored by Git and by our linting tools:
# gulp lint
# gulp lint-staged

node_modules/
22 changes: 0 additions & 22 deletions gulpfile.js

This file was deleted.

19 changes: 16 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -42,5 +42,18 @@
"lang",
"src",
"theme"
],
"scripts": {
"lint": "eslint --quiet '**/*.js'",
"precommit": "lint-staged"
},
"lint-staged": {
"**/*.js": [
"eslint --quiet"
]
},
"eslintIgnore": [
"src/lib/**",
"packages/**"
]
}
5 changes: 4 additions & 1 deletion src/dev-utils/enableenginedebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion src/model/operation/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/model/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
19 changes: 19 additions & 0 deletions tests/dev-utils/enableenginedebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions tests/model/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
} );
} );
Expand Down

0 comments on commit bdc2410

Please sign in to comment.