Procházet zdrojové kódy

Improved CC after changes to LinkEditing plugin.

Szymon Kupś před 8 roky
rodič
revize
87d1173d07
1 změnil soubory, kde provedl 36 přidání a 0 odebrání
  1. 36 0
      packages/ckeditor5-link/tests/linkediting.js

+ 36 - 0
packages/ckeditor5-link/tests/linkediting.js

@@ -226,5 +226,41 @@ describe( 'LinkEditing', () => {
 			expect( marker.getStart().path ).to.deep.equal( [ 1, 0 ] );
 			expect( marker.getEnd().path ).to.deep.equal( [ 1, 2 ] );
 		} );
+
+		it( 'should remove marker when selection is moved out from the link', () => {
+			setModelData( model,
+				'<paragraph>foo <$text linkHref="url">li{}nk</$text> baz</paragraph>'
+			);
+
+			expect( getViewData( view ) ).to.equal(
+				'<p>foo <span class="ck-link_selected"><a href="url">li{}nk</a></span> baz</p>'
+			);
+
+			expect( model.markers.has( 'linkBoundaries' ) ).to.be.true;
+			model.change( writer => writer.setSelection( model.document.getRoot().getChild( 0 ), 0 ) );
+
+			expect( model.markers.has( 'linkBoundaries' ) ).to.be.false;
+			expect( getViewData( view ) ).to.equal(
+				'<p>{}foo <a href="url">link</a> baz</p>'
+			);
+		} );
+
+		it( 'should work correctly when selection is moved inside link', () => {
+			setModelData( model,
+				'<paragraph>foo <$text linkHref="url">li{}nk</$text> baz</paragraph>'
+			);
+
+			expect( getViewData( view ) ).to.equal(
+				'<p>foo <span class="ck-link_selected"><a href="url">li{}nk</a></span> baz</p>'
+			);
+
+			expect( model.markers.has( 'linkBoundaries' ) ).to.be.true;
+			model.change( writer => writer.setSelection( model.document.getRoot().getChild( 0 ), 5 ) );
+
+			expect( model.markers.has( 'linkBoundaries' ) ).to.be.true;
+			expect( getViewData( view ) ).to.equal(
+				'<p>foo <span class="ck-link_selected"><a href="url">l{}ink</a></span> baz</p>'
+			);
+		} );
 	} );
 } );