瀏覽代碼

Renamed model to view converters: convertElementsInsideMarker to highlightElements and convertTextsInsideMarker to highlightTexts.

Szymon Kupś 8 年之前
父節點
當前提交
dc889156de

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

@@ -15,8 +15,8 @@ import {
 	removeUIElement,
 	wrapItem,
 	unwrapItem,
-	convertTextsInsideMarker,
-	convertElementsInsideMarker
+	highlightTexts,
+	highlightElements
 } from './model-to-view-converters';
 
 import { convertSelectionAttribute, convertSelectionMarker } from './model-selection-to-view-converters';
@@ -326,11 +326,11 @@ class ModelConverterBuilder {
 
 		for ( const dispatcher of this._dispatchers ) {
 			// Separate converters for converting texts and elements inside marker's range.
-			dispatcher.on( 'addMarker:' + this._from.name, convertTextsInsideMarker( highlightDescriptor ), { priority } );
-			dispatcher.on( 'addMarker:' + this._from.name, convertElementsInsideMarker( highlightDescriptor ), { priority } );
+			dispatcher.on( 'addMarker:' + this._from.name, highlightTexts( highlightDescriptor ), { priority } );
+			dispatcher.on( 'addMarker:' + this._from.name, highlightElements( highlightDescriptor ), { priority } );
 
-			dispatcher.on( 'removeMarker:' + this._from.name, convertTextsInsideMarker( highlightDescriptor ), { priority } );
-			dispatcher.on( 'removeMarker:' + this._from.name, convertElementsInsideMarker( highlightDescriptor ), { priority } );
+			dispatcher.on( 'removeMarker:' + this._from.name, highlightTexts( highlightDescriptor ), { priority } );
+			dispatcher.on( 'removeMarker:' + this._from.name, highlightElements( highlightDescriptor ), { priority } );
 
 			dispatcher.on( 'selectionMarker:' + this._from.name, convertSelectionMarker( highlightDescriptor ), { priority } );
 		}

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

@@ -412,7 +412,7 @@ export function remove() {
  * @param {module:engine/conversion/buildmodelconverter~HighlightDescriptor|Function} highlightDescriptor
  * @return {Function}
  */
-export function convertTextsInsideMarker( highlightDescriptor ) {
+export function highlightTexts( highlightDescriptor ) {
 	return ( evt, data, consumable, conversionApi ) => {
 		const descriptor = typeof highlightDescriptor == 'function' ?
 			highlightDescriptor( data, consumable, conversionApi ) :
@@ -445,7 +445,7 @@ export function convertTextsInsideMarker( highlightDescriptor ) {
  * {@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
  * 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~highlightTexts} method which uses default priority of
  * {@link module:engine/view/attributeelement~AttributeElement}.
  * 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.
@@ -453,7 +453,7 @@ export function convertTextsInsideMarker( highlightDescriptor ) {
  * @param {module:engine/conversion/buildmodelconverter~HighlightDescriptor|Function} highlightDescriptor
  * @return {Function}
  */
-export function convertElementsInsideMarker( highlightDescriptor ) {
+export function highlightElements( highlightDescriptor ) {
 	return ( evt, data, consumable, conversionApi ) => {
 		const descriptor = typeof highlightDescriptor == 'function' ?
 			highlightDescriptor( data, consumable, conversionApi ) :

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

@@ -29,8 +29,8 @@ import {
 	insertElement,
 	insertText,
 	wrapItem,
-	convertTextsInsideMarker,
-	convertElementsInsideMarker
+	highlightTexts,
+	highlightElements
 } from '../../src/conversion/model-to-view-converters';
 
 import { stringify as stringifyView } from '../../src/dev-utils/view';
@@ -60,10 +60,10 @@ describe( 'model-selection-to-view-converters', () => {
 		dispatcher.on( 'insert:$text', insertText() );
 		dispatcher.on( 'addAttribute:bold', wrapItem( new ViewAttributeElement( 'strong' ) ) );
 
-		dispatcher.on( 'addMarker:marker', convertTextsInsideMarker( highlightDescriptor ) );
-		dispatcher.on( 'addMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
-		dispatcher.on( 'removeMarker:marker', convertTextsInsideMarker( highlightDescriptor ) );
-		dispatcher.on( 'removeMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
+		dispatcher.on( 'addMarker:marker', highlightTexts( highlightDescriptor ) );
+		dispatcher.on( 'addMarker:marker', highlightElements( highlightDescriptor ) );
+		dispatcher.on( 'removeMarker:marker', highlightTexts( highlightDescriptor ) );
+		dispatcher.on( 'removeMarker:marker', highlightElements( highlightDescriptor ) );
 
 		// Default selection converters.
 		dispatcher.on( 'selection', clearAttributes(), { priority: 'low' } );

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

@@ -28,8 +28,8 @@ import {
 	unwrapItem,
 	remove,
 	removeUIElement,
-	convertTextsInsideMarker,
-	convertElementsInsideMarker,
+	highlightTexts,
+	highlightElements,
 	highlightDescriptorToAttributeElement
 } from '../../src/conversion/model-to-view-converters';
 
@@ -82,7 +82,7 @@ describe( 'model-to-view-converters', () => {
 		return result;
 	}
 
-	describe( 'convertTextsInsideMarker()', () => {
+	describe( 'highlightTexts()', () => {
 		let modelElement1, modelElement2, markerRange;
 		const highlightDescriptor = {
 			class: 'highlight-class',
@@ -105,8 +105,8 @@ describe( 'model-to-view-converters', () => {
 		} );
 
 		it( 'should wrap and unwrap text nodes', () => {
-			dispatcher.on( 'addMarker:marker', convertTextsInsideMarker( highlightDescriptor ) );
-			dispatcher.on( 'removeMarker:marker', convertTextsInsideMarker( highlightDescriptor ) );
+			dispatcher.on( 'addMarker:marker', highlightTexts( highlightDescriptor ) );
+			dispatcher.on( 'removeMarker:marker', highlightTexts( highlightDescriptor ) );
 			dispatcher.convertInsertion( markerRange );
 
 			modelDoc.markers.set( 'marker', markerRange );
@@ -131,10 +131,10 @@ describe( 'model-to-view-converters', () => {
 		it( 'should not convert marker on elements already consumed', () => {
 			const newDescriptor = { class: 'override-class' };
 
-			dispatcher.on( 'addMarker:marker', convertTextsInsideMarker( highlightDescriptor ) );
-			dispatcher.on( 'addMarker:marker', convertTextsInsideMarker( newDescriptor ), { priority: 'high' } );
-			dispatcher.on( 'removeMarker:marker', convertTextsInsideMarker( highlightDescriptor ) );
-			dispatcher.on( 'removeMarker:marker', convertTextsInsideMarker( newDescriptor ), { priority: 'high' } );
+			dispatcher.on( 'addMarker:marker', highlightTexts( highlightDescriptor ) );
+			dispatcher.on( 'addMarker:marker', highlightTexts( newDescriptor ), { priority: 'high' } );
+			dispatcher.on( 'removeMarker:marker', highlightTexts( highlightDescriptor ) );
+			dispatcher.on( 'removeMarker:marker', highlightTexts( newDescriptor ), { priority: 'high' } );
 			dispatcher.convertInsertion( markerRange );
 
 			modelDoc.markers.set( 'marker', markerRange );
@@ -157,8 +157,8 @@ describe( 'model-to-view-converters', () => {
 		} );
 
 		it( 'should do nothing if descriptor is not provided', () => {
-			dispatcher.on( 'addMarker:marker', convertTextsInsideMarker( () => null ) );
-			dispatcher.on( 'removeMarker:marker', convertTextsInsideMarker( () => null ) );
+			dispatcher.on( 'addMarker:marker', highlightTexts( () => null ) );
+			dispatcher.on( 'removeMarker:marker', highlightTexts( () => null ) );
 
 			dispatcher.convertInsertion( markerRange );
 
@@ -171,7 +171,7 @@ describe( 'model-to-view-converters', () => {
 		} );
 	} );
 
-	describe( 'convertElementsInsideMarker()', () => {
+	describe( 'highlightElements()', () => {
 		let modelElement1, modelElement2, markerRange;
 		const highlightDescriptor = {
 			class: 'highlight-class',
@@ -194,8 +194,8 @@ describe( 'model-to-view-converters', () => {
 		} );
 
 		it( 'should use addHighlight and removeHighlight on elements and not convert children nodes', () => {
-			dispatcher.on( 'addMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
-			dispatcher.on( 'removeMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
+			dispatcher.on( 'addMarker:marker', highlightElements( highlightDescriptor ) );
+			dispatcher.on( 'removeMarker:marker', highlightElements( highlightDescriptor ) );
 			dispatcher.on( 'insert:paragraph', insertElement( data => {
 				// Use special converter only for first paragraph.
 				if ( data.item == modelElement2 ) {
@@ -242,11 +242,11 @@ describe( 'model-to-view-converters', () => {
 		it( 'should not convert marker on elements already consumed', () => {
 			const newDescriptor = { class: 'override-class' };
 
-			dispatcher.on( 'addMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
-			dispatcher.on( 'removeMarker:marker', convertElementsInsideMarker( highlightDescriptor ) );
+			dispatcher.on( 'addMarker:marker', highlightElements( highlightDescriptor ) );
+			dispatcher.on( 'removeMarker:marker', highlightElements( highlightDescriptor ) );
 
-			dispatcher.on( 'addMarker:marker', convertElementsInsideMarker( newDescriptor ), { priority: 'high' } );
-			dispatcher.on( 'removeMarker:marker', convertElementsInsideMarker( newDescriptor ), { priority: 'high' } );
+			dispatcher.on( 'addMarker:marker', highlightElements( newDescriptor ), { priority: 'high' } );
+			dispatcher.on( 'removeMarker:marker', highlightElements( newDescriptor ), { priority: 'high' } );
 
 			dispatcher.on( 'insert:paragraph', insertElement( () => {
 				const element = new ViewContainerElement( 'p' );
@@ -277,8 +277,8 @@ describe( 'model-to-view-converters', () => {
 		} );
 
 		it( 'should do nothing if descriptor is not provided', () => {
-			dispatcher.on( 'addMarker:marker', convertElementsInsideMarker( () => null ) );
-			dispatcher.on( 'removeMarker:marker', convertElementsInsideMarker( () => null ) );
+			dispatcher.on( 'addMarker:marker', highlightElements( () => null ) );
+			dispatcher.on( 'removeMarker:marker', highlightElements( () => null ) );
 
 			dispatcher.convertInsertion( markerRange );