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

Commit

Permalink
Remove Position, Range, Selection imports from engine/model.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Oct 15, 2018
1 parent 025e212 commit d639db9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions src/highlightcommand.js
Expand Up @@ -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}
Expand Down Expand Up @@ -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 ) {
Expand Down
10 changes: 4 additions & 6 deletions tests/highlightcommand.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand Down

0 comments on commit d639db9

Please sign in to comment.