Sfoglia il codice sorgente

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

Maciej Gołaszewski 7 anni fa
parent
commit
e77e44e146

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

@@ -19,11 +19,11 @@
     "@ckeditor/ckeditor5-block-quote": "^10.1.0",
     "@ckeditor/ckeditor5-build-balloon": "^11.1.0",
     "@ckeditor/ckeditor5-cloud-services": "^10.1.0",
+    "@ckeditor/ckeditor5-easy-image": "^10.0.3",
     "@ckeditor/ckeditor5-editor-balloon": "^11.0.1",
     "@ckeditor/ckeditor5-editor-classic": "^11.0.1",
     "@ckeditor/ckeditor5-engine": "^11.0.0",
     "@ckeditor/ckeditor5-enter": "^10.1.2",
-    "@ckeditor/ckeditor5-easy-image": "^10.0.3",
     "@ckeditor/ckeditor5-essentials": "^10.1.2",
     "@ckeditor/ckeditor5-heading": "^10.1.0",
     "@ckeditor/ckeditor5-image": "^11.0.0",

+ 1 - 2
packages/ckeditor5-ui/tests/manual/balloontoolbar/balloontoolbar.js

@@ -8,7 +8,6 @@
 import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import BalloonToolbar from '../../../src/toolbar/balloon/balloontoolbar';
-import Range from '@ckeditor/ckeditor5-engine/src/model/range';
 
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
@@ -23,7 +22,7 @@ ClassicEditor
 
 		balloonToolbar.on( 'show', evt => {
 			const selectionRange = editor.model.document.selection.getFirstRange();
-			const blockRange = Range.createOn( editor.model.document.getRoot().getChild( 0 ) );
+			const blockRange = editor.model.createRangeOn( editor.model.document.getRoot().getChild( 0 ) );
 
 			if ( selectionRange.containsRange( blockRange ) || selectionRange.isIntersecting( blockRange ) ) {
 				evt.stop();

+ 5 - 6
packages/ckeditor5-ui/tests/manual/blocktoolbar/blocktoolbar.js

@@ -16,9 +16,6 @@ import HeadingButtonsUI from '@ckeditor/ckeditor5-heading/src/headingbuttonsui';
 import ParagraphButtonUI from '@ckeditor/ckeditor5-paragraph/src/paragraphbuttonui';
 import BlockToolbar from '../../../src/toolbar/block/blocktoolbar';
 
-import Position from '@ckeditor/ckeditor5-engine/src/model/position';
-import Range from '@ckeditor/ckeditor5-engine/src/model/range';
-
 BalloonEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [ Essentials, List, Paragraph, Heading, Image, ImageCaption, HeadingButtonsUI, ParagraphButtonUI, BlockToolbar ],
@@ -59,7 +56,7 @@ function createExternalChangesSimulator( editor ) {
 
 	function insertNewLine( path ) {
 		model.enqueueChange( 'transparent', writer => {
-			writer.insertElement( 'paragraph', new Position( model.document.getRoot(), path ) );
+			writer.insertElement( 'paragraph', writer.createPositionFromPath( model.document.getRoot(), path ) );
 		} );
 
 		return Promise.resolve();
@@ -67,7 +64,7 @@ function createExternalChangesSimulator( editor ) {
 
 	function type( path, text ) {
 		return new Promise( resolve => {
-			let position = new Position( model.document.getRoot(), path );
+			let position = model.createPositionFromPath( model.document.getRoot(), path );
 			let index = 0;
 
 			function typing() {
@@ -94,7 +91,9 @@ function createExternalChangesSimulator( editor ) {
 
 	function removeElement( path ) {
 		model.enqueueChange( 'transparent', writer => {
-			writer.remove( Range.createFromPositionAndShift( new Position( model.document.getRoot(), path ), 1 ) );
+			const start = writer.createPositionFromPath( model.document.getRoot(), path );
+
+			writer.remove( writer.createRange( start, start.getShiftedBy( 1 ) ) );
 		} );
 
 		return Promise.resolve();

+ 5 - 6
packages/ckeditor5-ui/tests/manual/contextualballoon/externalchanges.js

@@ -9,9 +9,6 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'
 import BalloonToolbar from '../../../src/toolbar/balloon/balloontoolbar';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 
-import Position from '@ckeditor/ckeditor5-engine/src/model/position';
-import Range from '@ckeditor/ckeditor5-engine/src/model/range';
-
 // Editor for the external insert.
 ClassicEditor
 	.create( document.querySelector( '#editor-insert' ), {
@@ -57,7 +54,7 @@ function startExternalInsert( editor ) {
 
 	function type( path, text ) {
 		return new Promise( resolve => {
-			let position = new Position( model.document.getRoot(), path );
+			let position = model.createPositionFromPath( model.document.getRoot(), path );
 			let index = 0;
 
 			function typing() {
@@ -85,7 +82,7 @@ function startExternalInsert( editor ) {
 	function insertNewLine( path ) {
 		return wait( 200 ).then( () => {
 			model.enqueueChange( 'transparent', writer => {
-				writer.insertElement( 'paragraph', new Position( model.document.getRoot(), path ) );
+				writer.insertElement( 'paragraph', writer.createPositionFromPath( model.document.getRoot(), path ) );
 			} );
 
 			return Promise.resolve();
@@ -109,7 +106,9 @@ function startExternalDelete( editor ) {
 
 	wait( 3000 ).then( () => {
 		model.enqueueChange( 'transparent', writer => {
-			writer.remove( Range.createFromPositionAndShift( new Position( model.document.getRoot(), [ 1 ] ), 1 ) );
+			const start = writer.createPositionFromPath( model.document.getRoot(), [ 1 ] );
+
+			writer.remove( writer.createRange( start, start.getShiftedBy( 1 ) ) );
 		} );
 	} );
 }

+ 5 - 6
packages/ckeditor5-ui/tests/manual/tickets/198/1.js

@@ -9,9 +9,6 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import BalloonToolbar from '../../../../src/toolbar/balloon/balloontoolbar';
 
-import Position from '@ckeditor/ckeditor5-engine/src/model/position';
-import Range from '@ckeditor/ckeditor5-engine/src/model/range';
-
 // Editor for the external insert.
 ClassicEditor
 	.create( document.querySelector( '#editor-insert' ), {
@@ -57,7 +54,7 @@ function startExternalInsert( editor ) {
 
 	function type( path, text ) {
 		return new Promise( resolve => {
-			let position = new Position( model.document.getRoot(), path );
+			let position = model.createPositionFromPath( model.document.getRoot(), path );
 			let index = 0;
 
 			function typing() {
@@ -85,7 +82,7 @@ function startExternalInsert( editor ) {
 	function insertNewLine( path ) {
 		return wait( 200 ).then( () => {
 			model.enqueueChange( 'transparent', writer => {
-				writer.insertElement( 'paragraph', new Position( model.document.getRoot(), path ) );
+				writer.insertElement( 'paragraph', writer.createPositionFromPath( model.document.getRoot(), path ) );
 			} );
 
 			return Promise.resolve();
@@ -109,7 +106,9 @@ function startExternalDelete( editor ) {
 
 	wait( 3000 ).then( () => {
 		model.enqueueChange( 'transparent', writer => {
-			writer.remove( Range.createFromPositionAndShift( new Position( model.document.getRoot(), [ 1 ] ), 1 ) );
+			const start = writer.createPositionFromPath( model.document.getRoot(), [ 1 ] );
+
+			writer.remove( writer.createRange( start, start.getShiftedBy( 1 ) ) );
 		} );
 	} );
 }