Browse Source

Make restricted editing exception marker span outer most in the view.

Maciej Gołaszewski 6 years ago
parent
commit
ab2f14df44

+ 2 - 1
packages/ckeditor5-restricted-editing/src/restrictedediting.js

@@ -45,7 +45,8 @@ export default class RestrictedEditing extends Plugin {
 			model: 'restricted-editing-exception',
 			view: {
 				name: 'span',
-				classes: 'ck-restricted-editing-exception'
+				classes: 'ck-restricted-editing-exception',
+				priority: -10
 			}
 		} );
 	}

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

@@ -107,6 +107,25 @@ describe( 'RestrictedEditing', () => {
 				expect( editor.getData() ).to.equal( expectedView );
 				expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( expectedView );
 			} );
+
+			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>' );
+
+				const paragraph = model.document.getRoot().getChild( 0 );
+
+				model.change( writer => {
+					writer.addMarker( 'restricted-editing-exception:1', {
+						range: writer.createRange( writer.createPositionAt( paragraph, 0 ), writer.createPositionAt( paragraph, 'end' ) ),
+						usingOperation: true,
+						affectsData: true
+					} );
+				} );
+
+				const expectedView = '<p><span class="ck-restricted-editing-exception"><b>foo bar baz</b></span></p>';
+				expect( editor.getData() ).to.equal( expectedView );
+				expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( expectedView );
+			} );
 		} );
 	} );
 } );