Przeglądaj źródła

Passing writer to highlight methods.

Szymon Kupś 8 lat temu
rodzic
commit
d5de59ff18

+ 2 - 2
packages/ckeditor5-engine/src/conversion/downcast-converters.js

@@ -899,7 +899,7 @@ export function highlightElement( highlightDescriptor ) {
 				consumable.consume( value.item, evt.name );
 			}
 
-			viewElement.getCustomProperty( 'addHighlight' )( viewElement, descriptor );
+			viewElement.getCustomProperty( 'addHighlight' )( viewElement, descriptor, conversionApi.writer );
 		}
 	};
 }
@@ -947,7 +947,7 @@ export function removeHighlight( highlightDescriptor ) {
 		// First, iterate through all items and remove highlight from those container elements that have custom highlight handling.
 		for ( const item of items ) {
 			if ( item.is( 'containerElement' ) && item.getCustomProperty( 'removeHighlight' ) ) {
-				item.getCustomProperty( 'removeHighlight' )( item, descriptor.id );
+				item.getCustomProperty( 'removeHighlight' )( item, descriptor.id, conversionApi.writer );
 
 				// If container element had custom handling, remove all it's children from further processing.
 				for ( const descendant of ViewRange.createIn( item ) ) {

+ 4 - 8
packages/ckeditor5-engine/tests/conversion/downcast-converters.js

@@ -1302,16 +1302,12 @@ describe( 'downcast-converters', () => {
 				dispatcher.on( 'insert:div', insertElement( () => {
 					const viewContainer = new ViewContainerElement( 'div' );
 
-					viewContainer._setCustomProperty( 'addHighlight', ( element, descriptor ) => {
-						controller.view.change( writer => {
-							writer.addClass( descriptor.class, element );
-						} );
+					viewContainer._setCustomProperty( 'addHighlight', ( element, descriptor, writer ) => {
+						writer.addClass( descriptor.class, element );
 					} );
 
-					viewContainer._setCustomProperty( 'removeHighlight', element => {
-						controller.view.change( writer => {
-							writer.setAttribute( 'class', '', element );
-						} );
+					viewContainer._setCustomProperty( 'removeHighlight', ( element, id, writer ) => {
+						writer.setAttribute( 'class', '', element );
 					} );
 
 					return viewContainer;