Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Passing writer to highlight methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonkups committed Feb 14, 2018
1 parent 27c7906 commit f63f2a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/conversion/downcast-converters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
};
}
Expand Down Expand Up @@ -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 ) ) {
Expand Down
12 changes: 4 additions & 8 deletions tests/conversion/downcast-converters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f63f2a1

Please sign in to comment.