Browse Source

Changed setHighlight to addHighlight.

Szymon Kupś 8 years ago
parent
commit
db97c629bc

+ 5 - 5
packages/ckeditor5-engine/src/conversion/buildmodelconverter.js

@@ -280,16 +280,16 @@ class ModelConverterBuilder {
 	 * * each {@link module:engine/view/text~Text view text node} in the marker's range will be wrapped with `span`
 	 * * each {@link module:engine/view/text~Text view text node} in the marker's range will be wrapped with `span`
 	 * {@link module:engine/view/attributeelement~AttributeElement},
 	 * {@link module:engine/view/attributeelement~AttributeElement},
 	 * * each {@link module:engine/view/containerelement~ContainerElement container view element} in the marker's
 	 * * each {@link module:engine/view/containerelement~ContainerElement container view element} in the marker's
-	 * range can handle highlighting individually by providing `setHighlight` and `removeHighlight`
+	 * range can handle highlighting individually by providing `addHighlight` and `removeHighlight`
 	 * custom properties:
 	 * custom properties:
 	 *
 	 *
-	 *		viewElement.setCustomProperty( 'setHighlight', ( element, descriptor ) => {} );
+	 *		viewElement.setCustomProperty( 'addHighlight', ( element, descriptor ) => {} );
 	 *		viewElement.setCustomProperty( 'removeHighlight', ( element, descriptor ) => {} );
 	 *		viewElement.setCustomProperty( 'removeHighlight', ( element, descriptor ) => {} );
 	 *
 	 *
 	 * {@link module:engine/conversion/buildmodelconverter~HighlightDescriptor} will be used to create
 	 * {@link module:engine/conversion/buildmodelconverter~HighlightDescriptor} will be used to create
-	 * spans over text nodes and also will be provided to `setHighlight` and `removeHighlight` methods
+	 * spans over text nodes and also will be provided to `addHighlight` and `removeHighlight` methods
 	 * each time highlight should be set or removed from view elements.
 	 * each time highlight should be set or removed from view elements.
-	 * NOTE: When `setHighlight` and `removeHighlight` custom properties are present, converter assumes
+	 * NOTE: When `addHighlight` and `removeHighlight` custom properties are present, converter assumes
 	 * that element itself is taking care of presenting highlight on its child nodes, so it won't convert them.
 	 * that element itself is taking care of presenting highlight on its child nodes, so it won't convert them.
 	 *
 	 *
 	 * Highlight descriptor can be provided as plain object:
 	 * Highlight descriptor can be provided as plain object:
@@ -436,7 +436,7 @@ export default function buildModelConverter() {
  * @typedef HighlightDescriptor
  * @typedef HighlightDescriptor
  * Object describing how content highlight should be created in the view. Each text node contained in highlight
  * Object describing how content highlight should be created in the view. Each text node contained in highlight
  * will be wrapped with `span` element with CSS class, attributes and priority described by this object. Each element
  * will be wrapped with `span` element with CSS class, attributes and priority described by this object. Each element
- * can handle displaying highlight separately by providing `setHighlight` and `removeHighlight` custom
+ * can handle displaying highlight separately by providing `addHighlight` and `removeHighlight` custom
  * properties.
  * properties.
  *
  *
  * @property {String} class CSS class that will be added to `span`
  * @property {String} class CSS class that will be added to `span`

+ 3 - 3
packages/ckeditor5-engine/src/conversion/model-to-view-converters.js

@@ -441,13 +441,13 @@ export function convertTextsInsideMarker( highlightDescriptor ) {
 
 
 /**
 /**
  * Function factory, creates converter that converts all elements inside marker's range. Converter checks if element has
  * Function factory, creates converter that converts all elements inside marker's range. Converter checks if element has
- * functions stored under `setHighlight` and `removeHighlight` custom properties and calls them passing
+ * functions stored under `addHighlight` and `removeHighlight` custom properties and calls them passing
  * {@link module:engine/conversion/buildmodelconverter~HighlightDescriptor}. In such case converter will consume
  * {@link module:engine/conversion/buildmodelconverter~HighlightDescriptor}. In such case converter will consume
  * all element's children, assuming that they were handled by element itself. If highlight descriptor will not provide
  * all element's children, assuming that they were handled by element itself. If highlight descriptor will not provide
  * priority, priority 10 will be used as default, to be compliant with
  * priority, priority 10 will be used as default, to be compliant with
  * {@link module:engine/conversion/model-to-view-converters~convertTextsInsideMarker} method which uses default priority of
  * {@link module:engine/conversion/model-to-view-converters~convertTextsInsideMarker} method which uses default priority of
  * {@link module:engine/view/attributeelement~AttributeElement}.
  * {@link module:engine/view/attributeelement~AttributeElement}.
- * When `setHighlight` and `removeHighlight` custom properties are not present, element is not converted
+ * When `addHighlight` and `removeHighlight` custom properties are not present, element is not converted
  * in any special way. This means that converters will proceed to convert element's child nodes.
  * in any special way. This means that converters will proceed to convert element's child nodes.
  *
  *
  * @param {module:engine/conversion/buildmodelconverter~HighlightDescriptor|Function} highlightDescriptor
  * @param {module:engine/conversion/buildmodelconverter~HighlightDescriptor|Function} highlightDescriptor
@@ -475,7 +475,7 @@ export function convertElementsInsideMarker( highlightDescriptor ) {
 
 
 		const viewElement = conversionApi.mapper.toViewElement( modelItem );
 		const viewElement = conversionApi.mapper.toViewElement( modelItem );
 		const addMarker = evt.name.split( ':' )[ 0 ] == 'addMarker';
 		const addMarker = evt.name.split( ':' )[ 0 ] == 'addMarker';
-		const highlightHandlingMethod = addMarker ? 'setHighlight' : 'removeHighlight';
+		const highlightHandlingMethod = addMarker ? 'addHighlight' : 'removeHighlight';
 
 
 		if ( viewElement && viewElement.getCustomProperty( highlightHandlingMethod ) ) {
 		if ( viewElement && viewElement.getCustomProperty( highlightHandlingMethod ) ) {
 			// Consume element itself.
 			// Consume element itself.

+ 3 - 3
packages/ckeditor5-engine/tests/conversion/model-to-view-converters.js

@@ -193,7 +193,7 @@ describe( 'model-to-view-converters', () => {
 			markerRange = ModelRange.createIn( modelRoot );
 			markerRange = ModelRange.createIn( modelRoot );
 		} );
 		} );
 
 
-		it( 'should use setHighlight and removeHighlight on elements and not convert children nodes', () => {
+		it( 'should use addHighlight and removeHighlight on elements and not convert children nodes', () => {
 			dispatcher.on( 'addMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
 			dispatcher.on( 'addMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
 			dispatcher.on( 'removeMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
 			dispatcher.on( 'removeMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
 			dispatcher.on( 'insert:paragraph', insertElement( data => {
 			dispatcher.on( 'insert:paragraph', insertElement( data => {
@@ -204,7 +204,7 @@ describe( 'model-to-view-converters', () => {
 
 
 				const viewContainer = new ViewContainerElement( 'p' );
 				const viewContainer = new ViewContainerElement( 'p' );
 
 
-				viewContainer.setCustomProperty( 'setHighlight', ( element, descriptor ) => {
+				viewContainer.setCustomProperty( 'addHighlight', ( element, descriptor ) => {
 					element.addClass( 'highlight-own-class' );
 					element.addClass( 'highlight-own-class' );
 
 
 					expect( descriptor ).to.equal( highlightDescriptor );
 					expect( descriptor ).to.equal( highlightDescriptor );
@@ -250,7 +250,7 @@ describe( 'model-to-view-converters', () => {
 
 
 			dispatcher.on( 'insert:paragraph', insertElement( () => {
 			dispatcher.on( 'insert:paragraph', insertElement( () => {
 				const element = new ViewContainerElement( 'p' );
 				const element = new ViewContainerElement( 'p' );
-				element.setCustomProperty( 'setHighlight', ( element, data ) => element.addClass( data.class ) );
+				element.setCustomProperty( 'addHighlight', ( element, data ) => element.addClass( data.class ) );
 				element.setCustomProperty( 'removeHighlight', ( element, data ) => element.removeClass( data.class ) );
 				element.setCustomProperty( 'removeHighlight', ( element, data ) => element.removeClass( data.class ) );
 
 
 				return element;
 				return element;