Răsfoiți Sursa

Aligned manual tests with engine chamges.

Oskar Wróbel 8 ani în urmă
părinte
comite
b3dded31a9

+ 9 - 13
packages/ckeditor5-ui/tests/manual/contextualballoon/externalchanges.js

@@ -9,8 +9,6 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'
 import ContextualToolbar from '../../../src/toolbar/contextual/contextualtoolbar';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 
-import Element from '@ckeditor/ckeditor5-engine/src/model/element';
-import Text from '@ckeditor/ckeditor5-engine/src/model/text';
 import Position from '@ckeditor/ckeditor5-engine/src/model/position';
 import Range from '@ckeditor/ckeditor5-engine/src/model/range';
 
@@ -55,18 +53,17 @@ function wait( delay ) {
 }
 
 function startExternalInsert( editor ) {
-	const document = editor.document;
-	const bath = document.batch( 'transparent' );
+	const model = editor.model;
 
 	function type( path, text ) {
 		return new Promise( resolve => {
-			let position = new Position( document.getRoot(), path );
+			let position = new Position( model.document.getRoot(), path );
 			let index = 0;
 
 			function typing() {
 				wait( 40 ).then( () => {
-					document.enqueueChanges( () => {
-						bath.insert( position, new Text( text[ index ] ) );
+					model.enqueueChange( 'transparent', writer => {
+						writer.insertText( text[ index ], position );
 						position = position.getShiftedBy( 1 );
 
 						const nextLetter = text[ ++index ];
@@ -87,8 +84,8 @@ function startExternalInsert( editor ) {
 
 	function insertNewLine( path ) {
 		return wait( 200 ).then( () => {
-			document.enqueueChanges( () => {
-				bath.insert( new Position( document.getRoot(), path ), new Element( 'paragraph' ) );
+			model.enqueueChange( 'transparent', writer => {
+				writer.insertElement( 'paragraph', new Position( model.document.getRoot(), path ) );
 			} );
 
 			return Promise.resolve();
@@ -108,12 +105,11 @@ function startExternalInsert( editor ) {
 }
 
 function startExternalDelete( editor ) {
-	const document = editor.document;
-	const bath = document.batch( 'transparent' );
+	const model = editor.model;
 
 	wait( 3000 ).then( () => {
-		document.enqueueChanges( () => {
-			bath.remove( Range.createFromPositionAndShift( new Position( document.getRoot(), [ 1 ] ), 1 ) );
+		model.enqueueChange( 'transparent', writer => {
+			writer.remove( Range.createFromPositionAndShift( new Position( model.document.getRoot(), [ 1 ] ), 1 ) );
 		} );
 	} );
 }

+ 2 - 2
packages/ckeditor5-ui/tests/manual/contextualtoolbar/contextualtoolbar.js

@@ -22,8 +22,8 @@ ClassicEditor
 		const contextualToolbar = editor.plugins.get( 'ContextualToolbar' );
 
 		contextualToolbar.on( 'show', evt => {
-			const selectionRange = editor.document.selection.getFirstRange();
-			const blockRange = Range.createOn( editor.document.getRoot().getChild( 0 ) );
+			const selectionRange = editor.model.document.selection.getFirstRange();
+			const blockRange = Range.createOn( editor.model.document.getRoot().getChild( 0 ) );
 
 			if ( selectionRange.containsRange( blockRange ) || selectionRange.isIntersecting( blockRange ) ) {
 				evt.stop();

+ 9 - 13
packages/ckeditor5-ui/tests/manual/tickets/198/1.js

@@ -9,8 +9,6 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import ContextualToolbar from '../../../../src/toolbar/contextual/contextualtoolbar';
 
-import Element from '@ckeditor/ckeditor5-engine/src/model/element';
-import Text from '@ckeditor/ckeditor5-engine/src/model/text';
 import Position from '@ckeditor/ckeditor5-engine/src/model/position';
 import Range from '@ckeditor/ckeditor5-engine/src/model/range';
 
@@ -55,18 +53,17 @@ function wait( delay ) {
 }
 
 function startExternalInsert( editor ) {
-	const document = editor.document;
-	const bath = document.batch( 'transparent' );
+	const model = editor.model;
 
 	function type( path, text ) {
 		return new Promise( resolve => {
-			let position = new Position( document.getRoot(), path );
+			let position = new Position( model.document.getRoot(), path );
 			let index = 0;
 
 			function typing() {
 				wait( 40 ).then( () => {
-					document.enqueueChanges( () => {
-						bath.insert( position, new Text( text[ index ] ) );
+					model.enqueueChange( 'transparent', writer => {
+						writer.insertText( text[ index ], position );
 						position = position.getShiftedBy( 1 );
 
 						const nextLetter = text[ ++index ];
@@ -87,8 +84,8 @@ function startExternalInsert( editor ) {
 
 	function insertNewLine( path ) {
 		return wait( 200 ).then( () => {
-			document.enqueueChanges( () => {
-				bath.insert( new Position( document.getRoot(), path ), new Element( 'paragraph' ) );
+			model.enqueueChange( 'transparent', writer => {
+				writer.insertElement( 'paragraph', new Position( model.document.getRoot(), path ) );
 			} );
 
 			return Promise.resolve();
@@ -108,12 +105,11 @@ function startExternalInsert( editor ) {
 }
 
 function startExternalDelete( editor ) {
-	const document = editor.document;
-	const bath = document.batch( 'transparent' );
+	const model = editor.model;
 
 	wait( 3000 ).then( () => {
-		document.enqueueChanges( () => {
-			bath.remove( Range.createFromPositionAndShift( new Position( document.getRoot(), [ 1 ] ), 1 ) );
+		model.enqueueChange( 'transparent', writer => {
+			writer.remove( Range.createFromPositionAndShift( new Position( model.document.getRoot(), [ 1 ] ), 1 ) );
 		} );
 	} );
 }