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

Commit

Permalink
Changed: baseVersion was moved to be the last argument in `MarkerOp…
Browse files Browse the repository at this point in the history
…eration` constructor.
  • Loading branch information
scofalik committed Sep 5, 2018
1 parent 9c18308 commit 3b90260
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/model/operation/markeroperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default class MarkerOperation extends Operation {
* @param {module:engine/model/range~Range} oldRange Marker range before the change.
* @param {module:engine/model/range~Range} newRange Marker range after the change.
* @param {module:engine/model/markercollection~MarkerCollection} markers Marker collection on which change should be executed.
* @param {Number|null} baseVersion Document {@link module:engine/model/document~Document#version} on which operation
* @param {Boolean} affectsData Specifies whether the marker operation affects the data produced by the data pipeline
* (is persisted in the editor's data).
* @param {Number|null} baseVersion Document {@link module:engine/model/document~Document#version} on which operation
* can be applied or `null` if the operation operates on detached (non-document) tree.
*/
constructor( name, oldRange, newRange, markers, baseVersion, affectsData ) {
constructor( name, oldRange, newRange, markers, affectsData, baseVersion ) {
super( baseVersion );

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ export default class MarkerOperation extends Operation {
* @returns {module:engine/model/operation/markeroperation~MarkerOperation} Clone of this operation.
*/
clone() {
return new MarkerOperation( this.name, this.oldRange, this.newRange, this._markers, this.baseVersion, this.affectsData );
return new MarkerOperation( this.name, this.oldRange, this.newRange, this._markers, this.affectsData, this.baseVersion );
}

/**
Expand All @@ -91,7 +91,7 @@ export default class MarkerOperation extends Operation {
* @returns {module:engine/model/operation/markeroperation~MarkerOperation}
*/
getReversed() {
return new MarkerOperation( this.name, this.newRange, this.oldRange, this._markers, this.baseVersion + 1, this.affectsData );
return new MarkerOperation( this.name, this.newRange, this.oldRange, this._markers, this.affectsData, this.baseVersion + 1 );
}

/**
Expand Down Expand Up @@ -142,8 +142,8 @@ export default class MarkerOperation extends Operation {
json.oldRange ? Range.fromJSON( json.oldRange, document ) : null,
json.newRange ? Range.fromJSON( json.newRange, document ) : null,
document.model.markers,
json.baseVersion,
json.affectsData
json.affectsData,
json.baseVersion
);
}
}
2 changes: 1 addition & 1 deletion src/model/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ function applyMarkerOperation( writer, name, oldRange, newRange, affectsData ) {
const model = writer.model;
const doc = model.document;

const operation = new MarkerOperation( name, oldRange, newRange, model.markers, doc.version, affectsData );
const operation = new MarkerOperation( name, oldRange, newRange, model.markers, affectsData, doc.version );

writer.batch.addOperation( operation );
model.applyOperation( operation );
Expand Down
2 changes: 1 addition & 1 deletion tests/dev-utils/enableenginedebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe( 'debug tools', () => {
} );

it( 'MarkerOperation', () => {
const op = new MarkerOperation( 'marker', null, ModelRange.createIn( modelRoot ), modelDoc.markers, 0 );
const op = new MarkerOperation( 'marker', null, ModelRange.createIn( modelRoot ), modelDoc.markers, false, 0 );

expect( op.toString() ).to.equal( 'MarkerOperation( 0 ): "marker": null -> main [ 0 ] - [ 6 ]' );

Expand Down
28 changes: 14 additions & 14 deletions tests/model/operation/markeroperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ describe( 'MarkerOperation', () => {
} );

it( 'should have property type equal to "marker"', () => {
const op = new MarkerOperation( 'name', null, range, model.markers, 0, true );
const op = new MarkerOperation( 'name', null, range, model.markers, true, 0 );
expect( op.type ).to.equal( 'marker' );
} );

it( 'should add marker to document marker collection', () => {
sinon.spy( model.markers, '_set' );

model.applyOperation(
new MarkerOperation( 'name', null, range, model.markers, doc.version, true )
new MarkerOperation( 'name', null, range, model.markers, true, doc.version )
);

expect( doc.version ).to.equal( 1 );
Expand All @@ -42,15 +42,15 @@ describe( 'MarkerOperation', () => {

it( 'should update marker in document marker collection', () => {
model.applyOperation(
new MarkerOperation( 'name', null, range, model.markers, doc.version, true )
new MarkerOperation( 'name', null, range, model.markers, true, doc.version )
);

const range2 = Range.createFromParentsAndOffsets( root, 0, root, 3 );

sinon.spy( model.markers, '_set' );

model.applyOperation(
new MarkerOperation( 'name', range, range2, model.markers, doc.version, true )
new MarkerOperation( 'name', range, range2, model.markers, true, doc.version )
);

expect( doc.version ).to.equal( 2 );
Expand All @@ -60,13 +60,13 @@ describe( 'MarkerOperation', () => {

it( 'should remove marker from document marker collection', () => {
model.applyOperation(
new MarkerOperation( 'name', null, range, model.markers, doc.version, true )
new MarkerOperation( 'name', null, range, model.markers, true, doc.version )
);

sinon.spy( model.markers, '_remove' );

model.applyOperation(
new MarkerOperation( 'name', range, null, model.markers, doc.version, true )
new MarkerOperation( 'name', range, null, model.markers, true, doc.version )
);

expect( doc.version ).to.equal( 2 );
Expand All @@ -78,7 +78,7 @@ describe( 'MarkerOperation', () => {
sinon.spy( model.markers, 'fire' );

model.applyOperation(
new MarkerOperation( 'name', null, null, model.markers, doc.version, true )
new MarkerOperation( 'name', null, null, model.markers, true, doc.version )
);

expect( model.markers.fire.notCalled ).to.be.true;
Expand All @@ -92,7 +92,7 @@ describe( 'MarkerOperation', () => {
sinon.spy( model.markers, 'fire' );

model.applyOperation(
new MarkerOperation( 'name', range, range, model.markers, doc.version, false )
new MarkerOperation( 'name', range, range, model.markers, false, doc.version )
);

expect( model.markers.fire.notCalled ).to.be.true;
Expand All @@ -101,10 +101,10 @@ describe( 'MarkerOperation', () => {
it( 'should return MarkerOperation with swapped ranges as reverse operation', () => {
const range2 = Range.createFromParentsAndOffsets( root, 0, root, 3 );

const op1 = new MarkerOperation( 'name', null, range, model.markers, doc.version, true );
const op1 = new MarkerOperation( 'name', null, range, model.markers, true, doc.version );
const reversed1 = op1.getReversed();

const op2 = new MarkerOperation( 'name', range, range2, model.markers, doc.version, true );
const op2 = new MarkerOperation( 'name', range, range2, model.markers, true, doc.version );
const reversed2 = op2.getReversed();

expect( reversed1 ).to.be.an.instanceof( MarkerOperation );
Expand All @@ -124,7 +124,7 @@ describe( 'MarkerOperation', () => {
} );

it( 'should create a MarkerOperation with the same parameters when cloned', () => {
const op = new MarkerOperation( 'name', null, range, model.markers, 0, true );
const op = new MarkerOperation( 'name', null, range, model.markers, true, 0 );
const clone = op.clone();

expect( clone ).to.be.an.instanceof( MarkerOperation );
Expand All @@ -133,7 +133,7 @@ describe( 'MarkerOperation', () => {

describe( 'toJSON', () => {
it( 'should create proper serialized object', () => {
const op = new MarkerOperation( 'name', null, range, model.markers, doc.version, true );
const op = new MarkerOperation( 'name', null, range, model.markers, true, doc.version );
const serialized = op.toJSON();

expect( serialized ).to.deep.equal( {
Expand All @@ -149,7 +149,7 @@ describe( 'MarkerOperation', () => {

describe( 'fromJSON', () => {
it( 'should create proper MarkerOperation from json object #1', () => {
const op = new MarkerOperation( 'name', null, range, model.markers, doc.version, true );
const op = new MarkerOperation( 'name', null, range, model.markers, true, doc.version );

const serialized = op.toJSON();
const deserialized = MarkerOperation.fromJSON( serialized, doc );
Expand All @@ -159,7 +159,7 @@ describe( 'MarkerOperation', () => {

it( 'should create proper MarkerOperation from json object #2', () => {
// Gotta love 100% CC.
const op = new MarkerOperation( 'name', range, null, model.markers, doc.version, true );
const op = new MarkerOperation( 'name', range, null, model.markers, true, doc.version );

const serialized = op.toJSON();
const deserialized = MarkerOperation.fromJSON( serialized, doc );
Expand Down
18 changes: 9 additions & 9 deletions tests/model/operation/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ describe( 'transform', () => {
describe( 'by MarkerOperation', () => {
it( 'no position update', () => {
const newRange = new Range( new Position( root, [ 0, 2, 0 ] ), new Position( root, [ 0, 2, 4 ] ) );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, false, 0 );

const transOp = transform( op, transformBy );

Expand Down Expand Up @@ -896,7 +896,7 @@ describe( 'transform', () => {
describe( 'by MarkerOperation', () => {
it( 'no position update', () => {
const newRange = new Range( new Position( root, [ 0, 2, 0 ] ), new Position( root, [ 0, 2, 8 ] ) );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, false, 0 );

const transOp = transform( op, transformBy );

Expand Down Expand Up @@ -1994,7 +1994,7 @@ describe( 'transform', () => {
describe( 'by MarkerOperation', () => {
it( 'no position update', () => {
const newRange = new Range( new Position( root, [ 2, 2, 3 ] ), new Position( root, [ 2, 2, 8 ] ) );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, false, 0 );

const transOp = transform( op, transformBy );

Expand Down Expand Up @@ -2131,7 +2131,7 @@ describe( 'transform', () => {
describe( 'by MarkerOperation', () => {
it( 'no position update', () => {
const newRange = new Range( new Position( root, [ 0, 2, 0 ] ), new Position( root, [ 0, 2, 8 ] ) );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, false, 0 );

const transOp = transform( op, transformBy );

Expand Down Expand Up @@ -2254,7 +2254,7 @@ describe( 'transform', () => {
describe( 'by MarkerOperation', () => {
it( 'no operation update', () => {
const newRange = new Range( new Position( root, [ 0, 2, 0 ] ), new Position( root, [ 0, 2, 8 ] ) );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'name', null, newRange, model.markers, false, 0 );

const transOp = transform( op, transformBy );

Expand Down Expand Up @@ -2422,7 +2422,7 @@ describe( 'transform', () => {
beforeEach( () => {
oldRange = Range.createFromParentsAndOffsets( root, 1, root, 4 );
newRange = Range.createFromParentsAndOffsets( root, 10, root, 12 );
op = new MarkerOperation( 'name', oldRange, newRange, model.markers, 0 );
op = new MarkerOperation( 'name', oldRange, newRange, model.markers, false, 0 );

expected = {
name: 'name',
Expand Down Expand Up @@ -2571,7 +2571,7 @@ describe( 'transform', () => {

describe( 'by MarkerOperation', () => {
it( 'different marker name: no operation update', () => {
const transformBy = new MarkerOperation( 'otherName', oldRange, newRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'otherName', oldRange, newRange, model.markers, false, 0 );

const transOp = transform( op, transformBy );

Expand All @@ -2581,7 +2581,7 @@ describe( 'transform', () => {

it( 'same marker name and is important: convert to NoOperation', () => {
const anotherRange = Range.createFromParentsAndOffsets( root, 2, root, 2 );
const transformBy = new MarkerOperation( 'name', oldRange, anotherRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'name', oldRange, anotherRange, model.markers, false, 0 );

const transOp = transform( op, transformBy );

Expand All @@ -2593,7 +2593,7 @@ describe( 'transform', () => {

it( 'same marker name and is less important: update oldRange parameter', () => {
const anotherRange = Range.createFromParentsAndOffsets( root, 2, root, 2 );
const transformBy = new MarkerOperation( 'name', oldRange, anotherRange, model.markers, 0 );
const transformBy = new MarkerOperation( 'name', oldRange, anotherRange, model.markers, false, 0 );

const transOp = transform( op, transformBy, strongContext );

Expand Down
2 changes: 1 addition & 1 deletion tests/model/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ describe( 'Position', () => {
describe( 'by MarkerOperation', () => {
it( 'nothing should change', () => {
const op = new MarkerOperation(
'marker', null, Range.createFromParentsAndOffsets( root, 1, root, 6 ), model.markers, 1, true
'marker', null, Range.createFromParentsAndOffsets( root, 1, root, 6 ), model.markers, true, 1
);
const transformed = pos.getTransformedByOperation( op );

Expand Down
2 changes: 1 addition & 1 deletion tests/model/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ describe( 'Range', () => {
describe( 'by MarkerOperation', () => {
it( 'nothing should change', () => {
const op = new MarkerOperation(
'marker', null, Range.createFromParentsAndOffsets( root, 1, root, 6 ), model.markers, 1, true
'marker', null, Range.createFromParentsAndOffsets( root, 1, root, 6 ), model.markers, true, 1
);

const transformed = range.getTransformedByOperation( op );
Expand Down
4 changes: 2 additions & 2 deletions tests/tickets/1323.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ describe( 'Bug ckeditor5-engine@1323', () => {

model.change( () => {
// Add marker.
model.applyOperation( new MarkerOperation( 'name', null, range, model.markers, 0 ) );
model.applyOperation( new MarkerOperation( 'name', null, range, model.markers, false, 0 ) );

// Remove marker.
model.applyOperation( new MarkerOperation( 'name', range, null, model.markers, 1 ) );
model.applyOperation( new MarkerOperation( 'name', range, null, model.markers, false, 1 ) );

sinon.assert.notCalled( spy );
} );
Expand Down

0 comments on commit 3b90260

Please sign in to comment.