Kaynağa Gözat

Tests: Trying to pindown the source of the problem.

Marek Lewandowski 6 yıl önce
ebeveyn
işleme
5463b57578

+ 55 - 4
packages/ckeditor5-remove-format/tests/integration.js

@@ -77,16 +77,67 @@ describe( 'RemoveFormat', () => {
 		} );
 	} );
 
-	describe( 'Handles correctly known issues', () => {
-		it( 'doesn\'t break after removing subsequently applied style', () => {
+	describe.only( 'Handles correctly known issues', () => {
+		it( 'doesn\'t break after removing format from attribute wrapped around another attribute', () => {
 			// https://github.com/ckeditor/ckeditor5-remove-format/pull/1#pullrequestreview-220515609
-			setModelData( model, '<paragraph>f[o<$text bold="true">ob</$text>a]r</paragraph>' );
+			// setModelData( model, '<paragraph>f[o<$text bold="true">ob</$text>a]r</paragraph>' );
 
-			editor.execute( 'underline' );
+			// editor.execute( 'underline' );
+
+			setModelData( model, '<paragraph>' +
+					'f[<$text underline="true">o</$text>' +
+					'<$text underline="true" bold="true">ob</$text>' +
+					'<$text underline="true">a</$text>]r' +
+				'</paragraph>' );
+			// editor.execute( 'underline' );
 
 			editor.execute( 'removeFormat' );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>foobar</paragraph>' );
 		} );
 	} );
+
+	describe.only( 'Test external bug', () => {
+		it( 'sel rem attr', () => {
+			setModelData( model, '<paragraph>' +
+					'f[<$text underline="true">o</$text>' +
+					'<$text underline="true" bold="true">ob</$text>' +
+					'<$text underline="true">a</$text>]r' +
+				'</paragraph>' );
+
+			model.change( writer => {
+				const modelRoot = model.document.getRoot();
+				// const itemInQuestion = modelRoot.getChild( 0 ).getChild( 1 );
+
+				for ( const item of model.document.selection.getFirstRange() ) {
+					// console.log( item );
+					// console.log( 'has', item.item.hasAttribute( 'bold' ) );
+					writer.removeAttribute( 'bold', item.item );
+					writer.removeAttribute( 'underline', item.item );
+
+				}
+
+				// for ( const i of [ 1, 2, 3 ] ) {
+				// 	writer.removeAttribute( 'underline', modelRoot.getChild( 0 ).getChild( i ) );
+				// 	writer.removeAttribute( 'bold', modelRoot.getChild( 0 ).getChild( i ) );
+				// }
+
+				// for ( const item of modelRoot ) {
+				// 	console.log( item );
+				// }
+				// debugger;
+
+				// writer.removeAttribute( 'underline', itemInQuestion );
+				// writer.removeAttribute( 'bold', itemInQuestion );
+			} );
+
+			// model.createRange( 0 )
+
+			// editor.execute( 'underline' );
+
+			// editor.execute( 'removeFormat' );
+
+			expect( getModelData( model ) ).to.equal( '<paragraph>f[ooba]r</paragraph>' );
+		} );
+	} );
 } );

+ 1 - 15
packages/ckeditor5-remove-format/tests/manual/removeformat.html

@@ -1,20 +1,6 @@
 <div id="editor">
 	<p>
-		Paragraph with
-		<strong>bold</strong>
-		,
-		<em>emphasize</em>
-		and some
-		<mark class="pen-red">text marked red</mark>
-		.
+		fo<strong>ob</strong>ar
 	</p>
 
-	<figure class="image">
-		<img src="assets/sample.png" alt="Autumn fields">
-		<figcaption>Autumn <em>fields</em> by Aleksander Nowodzi&#x144;ski</figcaption>
-	</figure>
-
-	<p>
-		<a href="#">Links</a> are not removed.
-	</p>
 </div>