8
0
Pārlūkot izejas kodu

Remove unnecessary check in marker highlighting.

Maciej Gołaszewski 6 gadi atpakaļ
vecāks
revīzija
171776f2a3

+ 1 - 7
packages/ckeditor5-restricted-editing/src/restrictededitingmodeediting.js

@@ -158,13 +158,7 @@ export default class RestrictedEditingModeEditing extends Plugin {
 				return;
 			}
 
-			const markerNameToElements = editor.editing.mapper.markerNameToElements( marker.name );
-
-			if ( !markerNameToElements ) {
-				return;
-			}
-
-			for ( const viewElement of markerNameToElements ) {
+			for ( const viewElement of editor.editing.mapper.markerNameToElements( marker.name ) ) {
 				writer.addClass( HIGHLIGHT_CLASS, viewElement );
 				highlightedMarkers.add( viewElement );
 			}

+ 19 - 0
packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js

@@ -116,6 +116,25 @@ describe( 'RestrictedEditingModeEditing', () => {
 				expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( expectedView );
 			} );
 
+			it( 'should convert collapsed model marker to <span>', () => {
+				setModelData( model, '<paragraph>foo bar baz</paragraph>' );
+
+				const paragraph = model.document.getRoot().getChild( 0 );
+
+				model.change( writer => {
+					writer.addMarker( 'restricted-editing-exception:1', {
+						range: writer.createRange( writer.createPositionAt( paragraph, 4 ), writer.createPositionAt( paragraph, 4 ) ),
+						usingOperation: true,
+						affectsData: true
+					} );
+				} );
+
+				expect( editor.getData() ).to.equal( '<p>foo <span class="ck-restricted-editing-exception"></span>bar baz</p>' );
+				expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal(
+					'<p>foo <span class="ck-restricted-editing-exception ck-restricted-editing-exception_collapsed"></span>bar baz</p>'
+				);
+			} );
+
 			it( 'converted <span> should be the outermost attribute element', () => {
 				editor.conversion.for( 'downcast' ).attributeToElement( { model: 'bold', view: 'b' } );
 				setModelData( model, '<paragraph><$text bold="true">foo bar baz</$text></paragraph>' );