diff --git a/package.json b/package.json index f28577a..26866bc 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ ], "dependencies": { "@ckeditor/ckeditor5-core": "^11.0.1", - "@ckeditor/ckeditor5-engine": "^11.0.0", "@ckeditor/ckeditor5-ui": "^11.1.0" }, "devDependencies": { "@ckeditor/ckeditor5-block-quote": "^10.1.0", "@ckeditor/ckeditor5-cloud-services": "^10.1.0", "@ckeditor/ckeditor5-editor-classic": "^11.0.1", + "@ckeditor/ckeditor5-engine": "^11.0.0", "@ckeditor/ckeditor5-enter": "^10.1.2", "@ckeditor/ckeditor5-heading": "^10.1.0", "@ckeditor/ckeditor5-image": "^11.0.0", diff --git a/src/highlightcommand.js b/src/highlightcommand.js index 32ed91a..3c45858 100644 --- a/src/highlightcommand.js +++ b/src/highlightcommand.js @@ -8,7 +8,6 @@ */ import Command from '@ckeditor/ckeditor5-core/src/command'; -import Range from '@ckeditor/ckeditor5-engine/src/model/range'; /** * The highlight command. It is used by the {@link module:highlight/highlightediting~HighlightEditing highlight feature} @@ -74,7 +73,7 @@ export default class HighlightCommand extends Command { const highlightStart = position.getLastMatchingPosition( isSameHighlight, { direction: 'backward' } ); const highlightEnd = position.getLastMatchingPosition( isSameHighlight ); - const highlightRange = new Range( highlightStart, highlightEnd ); + const highlightRange = writer.createRange( highlightStart, highlightEnd ); // Then depending on current value... if ( !highlighter || this.value === highlighter ) { diff --git a/tests/highlightcommand.js b/tests/highlightcommand.js index d81e22f..40b4be9 100644 --- a/tests/highlightcommand.js +++ b/tests/highlightcommand.js @@ -8,8 +8,6 @@ import HighlightCommand from './../src/highlightcommand'; import Command from '@ckeditor/ckeditor5-core/src/command'; import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor'; import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; -import Position from '@ckeditor/ckeditor5-engine/src/model/position'; -import Range from '@ckeditor/ckeditor5-engine/src/model/range'; describe( 'HighlightCommand', () => { let editor, model, doc, root, command; @@ -132,10 +130,10 @@ describe( 'HighlightCommand', () => { model.change( writer => { // Simulate clicking right arrow key by changing selection ranges. - writer.setSelection( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 2 ] ) ) ] ); + writer.setSelection( [ writer.createRange( writer.createPositionAt( root.getNodeByPath( [ 0 ] ), 2 ) ) ] ); // Get back to previous selection. - writer.setSelection( [ new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 1 ] ) ) ] ); + writer.setSelection( [ writer.createRange( writer.createPositionAt( root.getNodeByPath( [ 0 ] ), 1 ) ) ] ); } ); expect( command.value ).to.be.undefined; @@ -154,14 +152,14 @@ describe( 'HighlightCommand', () => { // Attribute should be stored. // Simulate clicking somewhere else in the editor. model.change( writer => { - writer.setSelection( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 2 ] ) ) ] ); + writer.setSelection( [ writer.createRange( writer.createPositionAt( root.getNodeByPath( [ 0 ] ), 2 ) ) ] ); } ); expect( command.value ).to.be.undefined; // Go back to where attribute was stored. model.change( writer => { - writer.setSelection( [ new Range( new Position( root, [ 1, 0 ] ), new Position( root, [ 1, 0 ] ) ) ] ); + writer.setSelection( [ writer.createRange( writer.createPositionAt( root.getNodeByPath( [ 1 ] ), 0 ) ) ] ); } ); // Attribute should be restored.