Explorar o código

Remove Position, Range, Selection imports from engine/model.

Maciej Gołaszewski %!s(int64=7) %!d(string=hai) anos
pai
achega
1a62aed40e

+ 1 - 1
packages/ckeditor5-highlight/package.json

@@ -11,13 +11,13 @@
   ],
   ],
   "dependencies": {
   "dependencies": {
     "@ckeditor/ckeditor5-core": "^11.0.1",
     "@ckeditor/ckeditor5-core": "^11.0.1",
-    "@ckeditor/ckeditor5-engine": "^11.0.0",
     "@ckeditor/ckeditor5-ui": "^11.1.0"
     "@ckeditor/ckeditor5-ui": "^11.1.0"
   },
   },
   "devDependencies": {
   "devDependencies": {
     "@ckeditor/ckeditor5-block-quote": "^10.1.0",
     "@ckeditor/ckeditor5-block-quote": "^10.1.0",
     "@ckeditor/ckeditor5-cloud-services": "^10.1.0",
     "@ckeditor/ckeditor5-cloud-services": "^10.1.0",
     "@ckeditor/ckeditor5-editor-classic": "^11.0.1",
     "@ckeditor/ckeditor5-editor-classic": "^11.0.1",
+    "@ckeditor/ckeditor5-engine": "^11.0.0",
     "@ckeditor/ckeditor5-enter": "^10.1.2",
     "@ckeditor/ckeditor5-enter": "^10.1.2",
     "@ckeditor/ckeditor5-heading": "^10.1.0",
     "@ckeditor/ckeditor5-heading": "^10.1.0",
     "@ckeditor/ckeditor5-image": "^11.0.0",
     "@ckeditor/ckeditor5-image": "^11.0.0",

+ 1 - 2
packages/ckeditor5-highlight/src/highlightcommand.js

@@ -8,7 +8,6 @@
  */
  */
 
 
 import Command from '@ckeditor/ckeditor5-core/src/command';
 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}
  * 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 highlightStart = position.getLastMatchingPosition( isSameHighlight, { direction: 'backward' } );
 					const highlightEnd = position.getLastMatchingPosition( isSameHighlight );
 					const highlightEnd = position.getLastMatchingPosition( isSameHighlight );
 
 
-					const highlightRange = new Range( highlightStart, highlightEnd );
+					const highlightRange = writer.createRange( highlightStart, highlightEnd );
 
 
 					// Then depending on current value...
 					// Then depending on current value...
 					if ( !highlighter || this.value === highlighter ) {
 					if ( !highlighter || this.value === highlighter ) {

+ 4 - 6
packages/ckeditor5-highlight/tests/highlightcommand.js

@@ -8,8 +8,6 @@ import HighlightCommand from './../src/highlightcommand';
 import Command from '@ckeditor/ckeditor5-core/src/command';
 import Command from '@ckeditor/ckeditor5-core/src/command';
 import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
 import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
 import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 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', () => {
 describe( 'HighlightCommand', () => {
 	let editor, model, doc, root, command;
 	let editor, model, doc, root, command;
@@ -132,10 +130,10 @@ describe( 'HighlightCommand', () => {
 
 
 					model.change( writer => {
 					model.change( writer => {
 						// Simulate clicking right arrow key by changing selection ranges.
 						// 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.
 						// 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;
 					expect( command.value ).to.be.undefined;
@@ -154,14 +152,14 @@ describe( 'HighlightCommand', () => {
 					// Attribute should be stored.
 					// Attribute should be stored.
 					// Simulate clicking somewhere else in the editor.
 					// Simulate clicking somewhere else in the editor.
 					model.change( writer => {
 					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;
 					expect( command.value ).to.be.undefined;
 
 
 					// Go back to where attribute was stored.
 					// Go back to where attribute was stored.
 					model.change( writer => {
 					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.
 					// Attribute should be restored.