Преглед на файлове

Added: Test cases with a range inside a block.

Mgsy преди 7 години
родител
ревизия
3d4c224e78

+ 56 - 0
packages/ckeditor5-engine/tests/model/operation/transform/attribute.js

@@ -376,6 +376,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text into div in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
+				kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
+
+				john.setAttribute( 'bold', true );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><$text bold="true">Foo</$text></paragraph>' +
+					'<paragraph><div>Bar</div></paragraph>'
+				);
+			} );
+
 			it( 'element into blockQuote in same path #1', () => {
 				john.setData( '<paragraph>[Foo]</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph>]' );
@@ -407,6 +422,18 @@ describe( 'transform', () => {
 					'</blockQuote>'
 				);
 			} );
+
+			it( 'text into div in same path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.setAttribute( 'bold', true );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients( '<paragraph><div><$text bold="true">Foo</$text></div></paragraph>' );
+			} );
 		} );
 
 		describe( 'by unwrap', () => {
@@ -440,6 +467,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
+				kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
+
+				john.setAttribute( 'bold', true );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><$text bold="true">Foo</$text></paragraph>' +
+					'<blockQuote>Bar</blockQuote>'
+				);
+			} );
+
 			it( 'element in same path #1', () => {
 				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -465,6 +507,20 @@ describe( 'transform', () => {
 
 				expectClients( '<paragraph bold="true">Foo</paragraph>' );
 			} );
+
+			it( 'text in same path', () => {
+				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.setAttribute( 'bold', true );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote><$text bold="true">Foo</$text></blockQuote>'
+				);
+			} );
 		} );
 
 		describe( 'by split', () => {

+ 90 - 0
packages/ckeditor5-engine/tests/model/operation/transform/marker.js

@@ -488,6 +488,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
+				kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
+
+				john.setMarker( 'm1' );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><m1:start></m1:start>Foo<m1:end></m1:end></paragraph>' +
+					'<paragraph><div>Bar</div></paragraph>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<paragraph>[Foo]</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph>]' );
@@ -504,6 +519,18 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.setMarker( 'm1' );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients( '<paragraph><div><m1:start></m1:start>Foo<m1:end></m1:end></div></paragraph>' );
+			} );
+
 			it( 'element in same path, then undo', () => {
 				john.setData( '<paragraph>[Foo]</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph>]' );
@@ -523,6 +550,22 @@ describe( 'transform', () => {
 					'</blockQuote>'
 				);
 			} );
+
+			it( 'text in same path, then undo', () => {
+				john.setData( '<paragraph>[Foo]</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.setMarker( 'm1' );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				john.undo();
+
+				syncClients();
+
+				expectClients( '<paragraph><div>Foo</div></paragraph>' );
+			} );
 		} );
 
 		describe( 'by unwrap', () => {
@@ -541,6 +584,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
+				kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
+
+				john.setMarker( 'm1' );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><m1:start></m1:start>Foo<m1:end></m1:end></paragraph>' +
+					'<blockQuote>Bar</blockQuote>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -555,6 +613,20 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path', () => {
+				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.setMarker( 'm1' );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote><m1:start></m1:start>Foo<m1:end></m1:end></blockQuote>'
+				);
+			} );
+
 			it( 'element in same path, then undo', () => {
 				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -572,6 +644,24 @@ describe( 'transform', () => {
 					'<paragraph>Foo</paragraph>'
 				);
 			} );
+
+			it( 'text in same path, then undo', () => {
+				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.setMarker( 'm1' );
+				kate.unwrap();
+
+				syncClients();
+
+				john.undo();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote>Foo</blockQuote>'
+				);
+			} );
 		} );
 
 		describe( 'by split', () => {

+ 71 - 0
packages/ckeditor5-engine/tests/model/operation/transform/move.js

@@ -192,6 +192,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>F[oo]</paragraph><paragraph>Bar</paragraph>' );
+				kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
+
+				john.move( [ 0, 0 ] );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients(
+					'<paragraph>ooF</paragraph>' +
+					'<paragraph><div>Bar</div></paragraph>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<paragraph>F[oo]</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph>]' );
@@ -208,6 +223,18 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path', () => {
+				john.setData( '<paragraph>F[oo]</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.move( [ 0, 0 ] );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients( '<paragraph>oo<div>F</div></paragraph>' );
+			} );
+
 			it( 'element while moving', () => {
 				john.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
@@ -225,6 +252,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'element while moving', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
+
+				john.move( [ 1, 0 ] );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><div></div></paragraph>' +
+					'<paragraph>FooBar</paragraph>'
+				);
+			} );
+
 			it( 'intersecting wrap', () => {
 				john.setData( '<paragraph>F[oo]</paragraph><paragraph>Bar</paragraph>' );
 				kate.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
@@ -272,6 +314,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>F[oo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
+				kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
+
+				john.move( [ 0, 0 ] );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<paragraph>ooF</paragraph>' +
+					'<blockQuote>Bar</blockQuote>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<blockQuote><paragraph>F[oo]</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -285,6 +342,20 @@ describe( 'transform', () => {
 					'<paragraph>ooF</paragraph>'
 				);
 			} );
+
+			it( 'text in same path', () => {
+				john.setData( '<blockQuote><paragraph>F[oo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.move( [ 0, 0, 0 ] );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote>ooF</blockQuote>'
+				);
+			} );
 		} );
 
 		describe( 'by split', () => {

+ 84 - 2
packages/ckeditor5-engine/tests/model/operation/transform/remove.js

@@ -124,6 +124,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
+				kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
+
+				john.remove();
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients(
+					'<paragraph></paragraph>' +
+					'<paragraph><div>Bar</div></paragraph>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<paragraph>[Foo]</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph>]' );
@@ -138,6 +153,18 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path', () => {
+				john.setData( '<paragraph>[Foo] Bar</paragraph>' );
+				kate.setData( '<paragraph>[Foo Bar]</paragraph>' );
+
+				john.remove();
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients( '<paragraph><div> Bar</div></paragraph>' );
+			} );
+
 			it( 'element while removing', () => {
 				john.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );
 				kate.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );
@@ -163,8 +190,6 @@ describe( 'transform', () => {
 
 				syncClients();
 
-				// Actual content:
-				// <paragraph>Foo</paragraph><paragraph>Bar</paragraph><blockQuote></blockQuote>
 				expectClients(
 					'<paragraph>Foo</paragraph>' +
 					'<blockQuote>' +
@@ -172,6 +197,34 @@ describe( 'transform', () => {
 					'</blockQuote>'
 				);
 			} );
+
+			it( 'text while removing', () => {
+				john.setData( '<paragraph>[Foo]</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.remove();
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients( '<paragraph></paragraph>' );
+			} );
+
+			it( 'text while removing, then undo', () => {
+				john.setData( '<paragraph>[Foo]</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.remove();
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				john.undo();
+
+				syncClients();
+
+				expectClients( '<paragraph><div>Foo</div></paragraph>' );
+			} );
 		} );
 
 		describe( 'by unwrap', () => {
@@ -190,6 +243,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
+				kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
+
+				john.remove();
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<paragraph></paragraph>' +
+					'<blockQuote>Bar</blockQuote>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -204,6 +272,20 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path', () => {
+				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.remove();
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote></blockQuote>'
+				);
+			} );
+
 			it( 'element while removing', () => {
 				john.setData( '<paragraph>Foo</paragraph><blockQuote>[<paragraph>Bar</paragraph>]</blockQuote>' );
 				kate.setData( '<paragraph>Foo</paragraph><blockQuote>[<paragraph>Bar</paragraph>]</blockQuote>' );

+ 59 - 5
packages/ckeditor5-engine/tests/model/operation/transform/rename.js

@@ -129,15 +129,15 @@ describe( 'transform', () => {
 			} );
 
 			it( 'the same element', () => {
-				john.setData( '<blockQuote>[]<paragraph>Foo Bar</paragraph></blockQuote>' );
-				kate.setData( '<blockQuote>[]<paragraph>Foo Bar</paragraph></blockQuote>' );
+				john.setData( '<blockQuote><paragraph>[]Foo Bar</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[]Foo Bar</paragraph></blockQuote>' );
 
-				john.rename( 'blockQuote2' );
-				kate.rename( 'blockQuote3' );
+				john.rename( 'heading1' );
+				kate.rename( 'heading2' );
 
 				syncClients();
 
-				expectClients( '<blockQuote2><paragraph>Foo Bar</paragraph></blockQuote2>' );
+				expectClients( '<blockQuote><heading1>Foo Bar</heading1></blockQuote>' );
 			} );
 		} );
 
@@ -218,6 +218,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[]Foo</paragraph><paragraph>Bar</paragraph>' );
+				kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
+
+				john.rename( 'heading1' );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients(
+					'<heading1>Foo</heading1>' +
+					'<paragraph><div>Bar</div></paragraph>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<paragraph>[]Foo</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph>]' );
@@ -229,6 +244,18 @@ describe( 'transform', () => {
 
 				expectClients( '<blockQuote><heading1>Foo</heading1></blockQuote>' );
 			} );
+
+			it( 'text in same path', () => {
+				john.setData( '<paragraph>[]Foo</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.rename( 'heading1' );
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients( '<heading1><div>Foo</div></heading1>' );
+			} );
 		} );
 
 		describe( 'by unwrap', () => {
@@ -247,6 +274,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>F[]oo</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
+				kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
+
+				john.rename( 'heading1' );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<heading1>Foo</heading1>' +
+					'<blockQuote>Bar</blockQuote>'
+				);
+			} );
+
 			it( 'element in same path', () => {
 				john.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -260,6 +302,18 @@ describe( 'transform', () => {
 					'<heading1>Foo</heading1>'
 				);
 			} );
+
+			it( 'text in same path', () => {
+				john.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.rename( 'heading1' );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients( '<blockQuote>Foo</blockQuote>' );
+			} );
 		} );
 
 		describe( 'by merge', () => {