浏览代码

Make downcast conversion helpers protected.

Maciej Gołaszewski 7 年之前
父节点
当前提交
13dddc335e

+ 10 - 16
packages/ckeditor5-engine/src/conversion/conversion.js

@@ -10,12 +10,6 @@
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
 import {
-	downcastElementToElement,
-	downcastAttributeToElement,
-	downcastAttributeToAttribute
-} from './downcast-converters';
-
-import {
 	upcastElementToElement,
 	upcastElementToAttribute,
 	upcastAttributeToAttribute
@@ -40,12 +34,12 @@ import {
  * method:
  *
  *		// Add a converter to editing downcast and data downcast.
- *		editor.conversion.for( 'downcast' ).add( downcastElementToElement( config ) );
+ *		editor.conversion.for( 'downcast' ).for( 'downcast' ).elementToElement( config ) );
  *
  *		// Add a converter to the data pipepline only:
- *		editor.conversion.for( 'dataDowncast' ).add( downcastElementToElement( dataConversionConfig ) );
+ *		editor.conversion.for( 'dataDowncast' ).for( 'downcast' ).elementToElement( dataConversionConfig ) );
  *		// And a slightly different one for the editing pipeline:
- *		editor.conversion.for( 'editingDowncast' ).add( downcastElementToElement( editingConversionConfig ) );
+ *		editor.conversion.for( 'editingDowncast' ).for( 'downcast' ).elementToElement( editingConversionConfig ) );
  *
  * The functions used in `add()` calls are one-way converters (i.e. you need to remember yourself to add
  * a converter in the other direction, if your feature requires that). They are also called "conversion helpers".
@@ -127,9 +121,9 @@ export default class Conversion {
 	 *
 	 * For downcast (model-to-view conversion), these are:
 	 *
-	 * * {@link module:engine/conversion/downcast-converters~downcastElementToElement Downcast element-to-element converter},
-	 * * {@link module:engine/conversion/downcast-converters~downcastAttributeToElement Downcast attribute-to-element converter},
-	 * * {@link module:engine/conversion/downcast-converters~downcastAttributeToAttribute Downcast attribute-to-attribute converter}.
+	 * * {@link module:engine/conversion/downcast-converters~_downcastElementToElement Downcast element-to-element converter},
+	 * * {@link module:engine/conversion/downcast-converters~_downcastAttributeToElement Downcast attribute-to-element converter},
+	 * * {@link module:engine/conversion/downcast-converters~_downcastAttributeToAttribute Downcast attribute-to-attribute converter}.
 	 *
 	 * For upcast (view-to-model conversion), these are:
 	 *
@@ -143,7 +137,7 @@ export default class Conversion {
 	 *		const config = { model: 'paragraph', view: 'p' };
 	 *
 	 *		// Add converters to proper dispatchers using conversion helpers.
-	 *		conversion.for( 'downcast' ).add( downcastElementToElement( config ) );
+	 *		conversion.for( 'downcast' ).for( 'downcast' ).elementToElement( config ) );
 	 *		conversion.for( 'upcast' ).add( upcastElementToElement( config ) );
 	 *
 	 * An example of providing a custom conversion helper that uses a custom converter function:
@@ -243,7 +237,7 @@ export default class Conversion {
 	 */
 	elementToElement( definition ) {
 		// Set up downcast converter.
-		this.for( 'downcast' ).add( downcastElementToElement( definition ) );
+		this.for( 'downcast' ).elementToElement( definition );
 
 		// Set up upcast converter.
 		for ( const { model, view } of _getAllUpcastDefinitions( definition ) ) {
@@ -416,7 +410,7 @@ export default class Conversion {
 	 */
 	attributeToElement( definition ) {
 		// Set up downcast converter.
-		this.for( 'downcast' ).add( downcastAttributeToElement( definition ) );
+		this.for( 'downcast' ).attributeToElement( definition );
 
 		// Set up upcast converter.
 		for ( const { model, view } of _getAllUpcastDefinitions( definition ) ) {
@@ -542,7 +536,7 @@ export default class Conversion {
 	 */
 	attributeToAttribute( definition ) {
 		// Set up downcast converter.
-		this.for( 'downcast' ).add( downcastAttributeToAttribute( definition ) );
+		this.for( 'downcast' ).attributeToAttribute( definition );
 
 		// Set up upcast converter.
 		for ( const { model, view } of _getAllUpcastDefinitions( definition ) ) {

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

@@ -24,11 +24,11 @@ import { cloneDeep } from 'lodash-es';
  *
  * This conversion results in creating a view element. For example, model `<paragraph>Foo</paragraph>` becomes `<p>Foo</p>` in the view.
  *
- *		downcastElementToElement( { model: 'paragraph', view: 'p' } );
+ *		_downcastElementToElement( { model: 'paragraph', view: 'p' } );
  *
- *		downcastElementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
+ *		_downcastElementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
  *
- *		downcastElementToElement( {
+ *		_downcastElementToElement( {
  *			model: 'fancyParagraph',
  *			view: {
  *				name: 'p',
@@ -36,7 +36,7 @@ import { cloneDeep } from 'lodash-es';
  *			}
  *		} );
  *
- *		downcastElementToElement( {
+ *		_downcastElementToElement( {
  *			model: 'heading',
  *			view: ( modelElement, viewWriter ) => viewWriter.createContainerElement( 'h' + modelElement.getAttribute( 'level' ) )
  *		} );
@@ -44,6 +44,7 @@ import { cloneDeep } from 'lodash-es';
  * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
  * to the conversion process.
  *
+ * @protected
  * @param {Object} config Conversion configuration.
  * @param {String} config.model The name of the model element to convert.
  * @param {module:engine/view/elementdefinition~ElementDefinition|Function} config.view A view element definition or a function
@@ -51,7 +52,7 @@ import { cloneDeep } from 'lodash-es';
  * as parameters and returns a view container element.
  * @returns {Function} Conversion helper.
  */
-export function downcastElementToElement( config ) {
+export function _downcastElementToElement( config ) {
 	config = cloneDeep( config );
 
 	config.view = _normalizeToElementConfig( config.view, 'container' );
@@ -67,11 +68,11 @@ export function downcastElementToElement( config ) {
  * This conversion results in wrapping view nodes with a view attribute element. For example, a model text node with
  * `"Foo"` as data and the `bold` attribute becomes `<strong>Foo</strong>` in the view.
  *
- *		downcastAttributeToElement( { model: 'bold', view: 'strong' } );
+ *		_downcastAttributeToElement( { model: 'bold', view: 'strong' } );
  *
- *		downcastAttributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
+ *		_downcastAttributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
  *
- *		downcastAttributeToElement( {
+ *		_downcastAttributeToElement( {
  *			model: 'invert',
  *			view: {
  *				name: 'span',
@@ -79,7 +80,7 @@ export function downcastElementToElement( config ) {
  *			}
  *		} );
  *
- *		downcastAttributeToElement( {
+ *		_downcastAttributeToElement( {
  *			model: {
  *				key: 'fontSize',
  *				values: [ 'big', 'small' ]
@@ -100,14 +101,14 @@ export function downcastElementToElement( config ) {
  *			}
  *		} );
  *
- *		downcastAttributeToElement( {
+ *		_downcastAttributeToElement( {
  *			model: 'bold',
  *				view: ( modelAttributeValue, viewWriter ) => {
  *				return viewWriter.createAttributeElement( 'span', { style: 'font-weight:' + modelAttributeValue } );
  *			}
  *		} );
  *
- *		downcastAttributeToElement( {
+ *		_downcastAttributeToElement( {
  *			model: {
  *				key: 'color',
  *				name: '$text'
@@ -120,6 +121,7 @@ export function downcastElementToElement( config ) {
  * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
  * to the conversion process.
  *
+ * @protected
  * @param {Object} config Conversion configuration.
  * @param {String|Object} config.model The key of the attribute to convert from or a `{ key, values }` object. `values` is an array
  * of `String`s with possible values if the model attribute is an enumerable.
@@ -130,7 +132,7 @@ export function downcastElementToElement( config ) {
  * @param {module:utils/priorities~PriorityString} [config.converterPriority='normal'] Converter priority.
  * @returns {Function} Conversion helper.
  */
-export function downcastAttributeToElement( config ) {
+export function _downcastAttributeToElement( config ) {
 	config = cloneDeep( config );
 
 	const modelKey = config.model.key ? config.model.key : config.model;
@@ -161,11 +163,11 @@ export function downcastAttributeToElement( config ) {
  * This conversion results in adding an attribute to a view node, basing on an attribute from a model node. For example,
  * `<image src='foo.jpg'></image>` is converted to `<img src='foo.jpg'></img>`.
  *
- *		downcastAttributeToAttribute( { model: 'source', view: 'src' } );
+ *		_downcastAttributeToAttribute( { model: 'source', view: 'src' } );
  *
- *		downcastAttributeToAttribute( { model: 'source', view: 'href', converterPriority: 'high' } );
+ *		_downcastAttributeToAttribute( { model: 'source', view: 'href', converterPriority: 'high' } );
  *
- *		downcastAttributeToAttribute( {
+ *		_downcastAttributeToAttribute( {
  *			model: {
  *				name: 'image',
  *				key: 'source'
@@ -173,7 +175,7 @@ export function downcastAttributeToElement( config ) {
  *			view: 'src'
  *		} );
  *
- *		downcastAttributeToAttribute( {
+ *		_downcastAttributeToAttribute( {
  *			model: {
  *				name: 'styled',
  *				values: [ 'dark', 'light' ]
@@ -190,7 +192,7 @@ export function downcastAttributeToElement( config ) {
  *			}
  *		} );
  *
- *		downcastAttributeToAttribute( {
+ *		_downcastAttributeToAttribute( {
  *			model: 'styled',
  *			view: modelAttributeValue => ( { key: 'class', value: 'styled-' + modelAttributeValue } )
  *		} );
@@ -198,6 +200,7 @@ export function downcastAttributeToElement( config ) {
  * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
  * to the conversion process.
  *
+ * @protected
  * @param {Object} config Conversion configuration.
  * @param {String|Object} config.model The key of the attribute to convert from or a `{ key, values, [ name ] }` object describing
  * the attribute key, possible values and, optionally, an element name to convert from.
@@ -209,7 +212,7 @@ export function downcastAttributeToElement( config ) {
  * @param {module:utils/priorities~PriorityString} [config.converterPriority='normal'] Converter priority.
  * @returns {Function} Conversion helper.
  */
-export function downcastAttributeToAttribute( config ) {
+export function _downcastAttributeToAttribute( config ) {
 	config = cloneDeep( config );
 
 	const modelKey = config.model.key ? config.model.key : config.model;
@@ -241,11 +244,11 @@ export function downcastAttributeToAttribute( config ) {
  * is collapsed, only one element is created. For example, model marker set like this: `<paragraph>F[oo b]ar</paragraph>`
  * becomes `<p>F<span data-marker="search"></span>oo b<span data-marker="search"></span>ar</p>` in the view.
  *
- *		downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
+ *		_downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
  *
- *		downcastMarkerToElement( { model: 'search', view: 'search-result', converterPriority: 'high' } );
+ *		_downcastMarkerToElement( { model: 'search', view: 'search-result', converterPriority: 'high' } );
  *
- *		downcastMarkerToElement( {
+ *		_downcastMarkerToElement( {
  *			model: 'search',
  *			view: {
  *				name: 'span',
@@ -255,7 +258,7 @@ export function downcastAttributeToAttribute( config ) {
  *			}
  *		} );
  *
- *		downcastMarkerToElement( {
+ *		_downcastMarkerToElement( {
  *			model: 'search',
  *			view: ( markerData, viewWriter ) => {
  *			return viewWriter.createUIElement( 'span', { 'data-marker': 'search', 'data-start': markerData.isOpening } );
@@ -273,6 +276,7 @@ export function downcastAttributeToAttribute( config ) {
  *
  * See {@link module:engine/conversion/conversion~Conversion#for} to learn how to add a converter to the conversion process.
  *
+ * @protected
  * @param {Object} config Conversion configuration.
  * @param {String} config.model The name of the model marker (or model marker group) to convert.
  * @param {module:engine/view/elementdefinition~ElementDefinition|Function} config.view A view element definition or a function
@@ -280,7 +284,7 @@ export function downcastAttributeToAttribute( config ) {
  * @param {module:utils/priorities~PriorityString} [config.converterPriority='normal'] Converter priority.
  * @returns {Function} Conversion helper.
  */
-export function downcastMarkerToElement( config ) {
+export function _downcastMarkerToElement( config ) {
 	config = cloneDeep( config );
 
 	config.view = _normalizeToElementConfig( config.view, 'ui' );
@@ -333,6 +337,7 @@ export function downcastMarkerToElement( config ) {
  *
  * See {@link module:engine/conversion/conversion~Conversion#for} to learn how to add a converter to the conversion process.
  *
+ * @protected
  * @param {Object} config Conversion configuration.
  * @param {String} config.model The name of the model marker (or model marker group) to convert.
  * @param {module:engine/conversion/downcast-converters~HighlightDescriptor|Function} config.view A highlight descriptor
@@ -340,7 +345,7 @@ export function downcastMarkerToElement( config ) {
  * @param {module:utils/priorities~PriorityString} [config.converterPriority='normal'] Converter priority.
  * @returns {Function} Conversion helper.
  */
-export function downcastMarkerToHighlight( config ) {
+export function _downcastMarkerToHighlight( config ) {
 	return dispatcher => {
 		dispatcher.on( 'addMarker:' + config.model, highlightText( config.view ), { priority: config.converterPriority || 'normal' } );
 		dispatcher.on( 'addMarker:' + config.model, highlightElement( config.view ), { priority: config.converterPriority || 'normal' } );
@@ -694,7 +699,7 @@ export function changeAttribute( attributeCreator ) {
 			 * by {@link module:engine/conversion/conversion~Conversion#attributeToAttribute `Attribute to Attribute converter`}.
 			 * In most cases it is caused by converters misconfiguration when only "generic" converter is defined:
 			 *
-			 *		editor.conversion.for( 'downcast' ).add( downcastAttributeToAttribute( {
+			 *		editor.conversion.for( 'downcast' ).attributeToAttribute( {
 			 *			model: 'attribute-name',
 			 *			view: 'attribute-name'
 			 *		} ) );
@@ -710,7 +715,7 @@ export function changeAttribute( attributeCreator ) {
 			 * {@link module:engine/conversion/conversion~Conversion#attributeToElement `Attribute to Element converter`}
 			 * with higher {@link module:utils/priorities~PriorityString priority} must also be defined:
 			 *
-			 *		conversion.for( 'downcast' ).add( downcastAttributeToElement( {
+			 *		conversion.for( 'downcast' ).attributeToElement( {
 			 *			model: {
 			 *				key: 'attribute-name',
 			 *				name: '$text'
@@ -1144,7 +1149,7 @@ export const helpers = {
 	 * as parameters and returns a view container element.
 	 */
 	elementToElement( config ) {
-		return this.add( downcastElementToElement( config ) );
+		return this.add( _downcastElementToElement( config ) );
 	},
 
 	/**
@@ -1218,7 +1223,7 @@ export const helpers = {
 	 * @param {module:utils/priorities~PriorityString} [config.converterPriority='normal'] Converter priority.
 	 */
 	attributeToElement( config ) {
-		return this.add( downcastAttributeToElement( config ) );
+		return this.add( _downcastAttributeToElement( config ) );
 	},
 
 	/**
@@ -1277,7 +1282,7 @@ export const helpers = {
 	 * @returns {Function} Conversion helper.
 	 */
 	attributeToAttribute( config ) {
-		return this.add( downcastAttributeToAttribute( config ) );
+		return this.add( _downcastAttributeToAttribute( config ) );
 	},
 
 	/**
@@ -1328,7 +1333,7 @@ export const helpers = {
 	 * @returns {Function} Conversion helper.
 	 */
 	markerToElement( config ) {
-		return this.add( downcastMarkerToElement( config ) );
+		return this.add( _downcastMarkerToElement( config ) );
 	},
 
 	/**
@@ -1386,6 +1391,6 @@ export const helpers = {
 	 * @returns {Function} Conversion helper.
 	 */
 	markerToHighlight( config ) {
-		return this.add( downcastMarkerToHighlight( config ) );
+		return this.add( _downcastMarkerToHighlight( config ) );
 	}
 };

+ 16 - 16
packages/ckeditor5-engine/tests/controller/datacontroller.js

@@ -24,9 +24,9 @@ import {
 } from '../../src/conversion/upcast-converters';
 
 import {
-	downcastElementToElement,
-	downcastAttributeToElement,
-	downcastMarkerToHighlight
+	_downcastElementToElement,
+	_downcastAttributeToElement,
+	_downcastMarkerToHighlight
 } from '../../src/conversion/downcast-converters';
 
 describe( 'DataController', () => {
@@ -285,7 +285,7 @@ describe( 'DataController', () => {
 			schema.register( 'paragraph', { inheritAllFrom: '$block' } );
 			setData( model, '<paragraph>foo</paragraph>' );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
 
 			expect( data.get() ).to.equal( '<p>foo</p>' );
 		} );
@@ -294,7 +294,7 @@ describe( 'DataController', () => {
 			schema.register( 'paragraph', { inheritAllFrom: '$block' } );
 			setData( model, '<paragraph></paragraph>' );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
 
 			expect( data.get() ).to.equal( '<p>&nbsp;</p>' );
 		} );
@@ -303,7 +303,7 @@ describe( 'DataController', () => {
 			schema.register( 'paragraph', { inheritAllFrom: '$block' } );
 			setData( model, '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
 
 			expect( data.get() ).to.equal( '<p>foo</p><p>bar</p>' );
 		} );
@@ -319,7 +319,7 @@ describe( 'DataController', () => {
 			schema.register( 'paragraph', { inheritAllFrom: '$block' } );
 			setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
 
 			expect( data.get() ).to.equal( '<p>foobar</p>' );
 		} );
@@ -328,8 +328,8 @@ describe( 'DataController', () => {
 			schema.register( 'paragraph', { inheritAllFrom: '$block' } );
 			setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
-			downcastAttributeToElement( { model: 'bold', view: 'strong' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastAttributeToElement( { model: 'bold', view: 'strong' } )( data.downcastDispatcher );
 
 			expect( data.get() ).to.equal( '<p>foo<strong>bar</strong></p>' );
 		} );
@@ -341,8 +341,8 @@ describe( 'DataController', () => {
 			setData( model, '<paragraph>foo</paragraph>', { rootName: 'main' } );
 			setData( model, 'Bar', { rootName: 'title' } );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
-			downcastAttributeToElement( { model: 'bold', view: 'strong' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastAttributeToElement( { model: 'bold', view: 'strong' } )( data.downcastDispatcher );
 
 			expect( data.get() ).to.equal( '<p>foo</p>' );
 			expect( data.get( 'main' ) ).to.equal( '<p>foo</p>' );
@@ -358,7 +358,7 @@ describe( 'DataController', () => {
 			schema.extend( '$block', { allowIn: 'div' } );
 			schema.extend( 'div', { allowIn: '$root' } );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
 		} );
 
 		it( 'should stringify a content of an element', () => {
@@ -382,7 +382,7 @@ describe( 'DataController', () => {
 			schema.extend( '$block', { allowIn: 'div' } );
 			schema.extend( 'div', { allowIn: '$root' } );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( data.downcastDispatcher );
 		} );
 
 		it( 'should convert a content of an element', () => {
@@ -403,7 +403,7 @@ describe( 'DataController', () => {
 			const modelElement = parseModel( '<div><paragraph>foobar</paragraph></div>', schema );
 			const modelRoot = model.document.getRoot();
 
-			downcastMarkerToHighlight( { model: 'marker:a', view: { classes: 'a' } } )( data.downcastDispatcher );
+			_downcastMarkerToHighlight( { model: 'marker:a', view: { classes: 'a' } } )( data.downcastDispatcher );
 
 			model.change( writer => {
 				writer.insert( modelElement, modelRoot, 0 );
@@ -421,8 +421,8 @@ describe( 'DataController', () => {
 			const modelElement = parseModel( '<div><paragraph>foo</paragraph><paragraph>bar</paragraph></div>', schema );
 			const modelRoot = model.document.getRoot();
 
-			downcastMarkerToHighlight( { model: 'marker:a', view: { classes: 'a' } } )( data.downcastDispatcher );
-			downcastMarkerToHighlight( { model: 'marker:b', view: { classes: 'b' } } )( data.downcastDispatcher );
+			_downcastMarkerToHighlight( { model: 'marker:a', view: { classes: 'a' } } )( data.downcastDispatcher );
+			_downcastMarkerToHighlight( { model: 'marker:b', view: { classes: 'b' } } )( data.downcastDispatcher );
 
 			const modelP1 = modelElement.getChild( 0 );
 			const modelP2 = modelElement.getChild( 1 );

+ 4 - 5
packages/ckeditor5-engine/tests/controller/editingcontroller.js

@@ -14,8 +14,7 @@ import View from '../../src/view/view';
 import Mapper from '../../src/conversion/mapper';
 import DowncastDispatcher from '../../src/conversion/downcastdispatcher';
 
-import { downcastElementToElement, downcastMarkerToHighlight } from '../../src/conversion/downcast-converters';
-
+import { _downcastElementToElement, _downcastMarkerToHighlight } from '../../src/conversion/downcast-converters';
 import Model from '../../src/model/model';
 import ModelPosition from '../../src/model/position';
 import ModelRange from '../../src/model/range';
@@ -91,9 +90,9 @@ describe( 'EditingController', () => {
 			model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
 			model.schema.register( 'div', { inheritAllFrom: '$block' } );
 
-			downcastElementToElement( { model: 'paragraph', view: 'p' } )( editing.downcastDispatcher );
-			downcastElementToElement( { model: 'div', view: 'div' } )( editing.downcastDispatcher );
-			downcastMarkerToHighlight( { model: 'marker', view: {} } )( editing.downcastDispatcher );
+			_downcastElementToElement( { model: 'paragraph', view: 'p' } )( editing.downcastDispatcher );
+			_downcastElementToElement( { model: 'div', view: 'div' } )( editing.downcastDispatcher );
+			_downcastMarkerToHighlight( { model: 'marker', view: {} } )( editing.downcastDispatcher );
 
 			// Note: The below code is highly overcomplicated due to #455.
 			model.change( writer => {

+ 50 - 46
packages/ckeditor5-engine/tests/conversion/downcast-converters.js

@@ -21,7 +21,11 @@ import log from '@ckeditor/ckeditor5-utils/src/log';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 import {
-	downcastElementToElement, downcastAttributeToElement, downcastAttributeToAttribute, downcastMarkerToElement, downcastMarkerToHighlight,
+	_downcastElementToElement,
+	_downcastAttributeToElement,
+	_downcastAttributeToAttribute,
+	_downcastMarkerToElement,
+	_downcastMarkerToHighlight,
 	insertElement, insertUIElement, changeAttribute, wrap, removeUIElement,
 	highlightElement, highlightText, removeHighlight, createViewElementFromHighlightDescriptor
 } from '../../src/conversion/downcast-converters';
@@ -48,9 +52,9 @@ describe( 'downcast-helpers', () => {
 		conversion.register( { name: 'downcast', dispatcher: controller.downcastDispatcher } );
 	} );
 
-	describe( 'downcastElementToElement', () => {
+	describe( '_downcastElementToElement', () => {
 		it( 'config.view is a string', () => {
-			const helper = downcastElementToElement( { model: 'paragraph', view: 'p' } );
+			const helper = _downcastElementToElement( { model: 'paragraph', view: 'p' } );
 
 			conversion.for( 'downcast' ).add( helper );
 
@@ -62,8 +66,8 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'can be overwritten using converterPriority', () => {
-			const helperA = downcastElementToElement( { model: 'paragraph', view: 'p' } );
-			const helperB = downcastElementToElement( { model: 'paragraph', view: 'foo', converterPriority: 'high' } );
+			const helperA = _downcastElementToElement( { model: 'paragraph', view: 'p' } );
+			const helperB = _downcastElementToElement( { model: 'paragraph', view: 'foo', converterPriority: 'high' } );
 
 			conversion.for( 'downcast' ).add( helperA ).add( helperB );
 
@@ -75,7 +79,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a view element definition', () => {
-			const helper = downcastElementToElement( {
+			const helper = _downcastElementToElement( {
 				model: 'fancyParagraph',
 				view: {
 					name: 'p',
@@ -93,7 +97,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a function', () => {
-			const helper = downcastElementToElement( {
+			const helper = _downcastElementToElement( {
 				model: 'heading',
 				view: ( modelElement, viewWriter ) => viewWriter.createContainerElement( 'h' + modelElement.getAttribute( 'level' ) )
 			} );
@@ -108,9 +112,9 @@ describe( 'downcast-helpers', () => {
 		} );
 	} );
 
-	describe( 'downcastAttributeToElement', () => {
+	describe( '_downcastAttributeToElement', () => {
 		it( 'config.view is a string', () => {
-			const helper = downcastAttributeToElement( { model: 'bold', view: 'strong' } );
+			const helper = _downcastAttributeToElement( { model: 'bold', view: 'strong' } );
 
 			conversion.for( 'downcast' ).add( helper );
 
@@ -122,8 +126,8 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'can be overwritten using converterPriority', () => {
-			const helperA = downcastAttributeToElement( { model: 'bold', view: 'strong' } );
-			const helperB = downcastAttributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
+			const helperA = _downcastAttributeToElement( { model: 'bold', view: 'strong' } );
+			const helperB = _downcastAttributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
 
 			conversion.for( 'downcast' ).add( helperA ).add( helperB );
 
@@ -135,7 +139,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a view element definition', () => {
-			const helper = downcastAttributeToElement( {
+			const helper = _downcastAttributeToElement( {
 				model: 'invert',
 				view: {
 					name: 'span',
@@ -154,7 +158,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view allows specifying the element\'s priority', () => {
-			const helper = downcastAttributeToElement( {
+			const helper = _downcastAttributeToElement( {
 				model: 'invert',
 				view: {
 					name: 'span',
@@ -172,7 +176,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'model attribute value is enum', () => {
-			const helper = downcastAttributeToElement( {
+			const helper = _downcastAttributeToElement( {
 				model: {
 					key: 'fontSize',
 					values: [ 'big', 'small' ]
@@ -218,7 +222,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a function', () => {
-			const helper = downcastAttributeToElement( {
+			const helper = _downcastAttributeToElement( {
 				model: 'bold',
 				view: ( modelAttributeValue, viewWriter ) => {
 					return viewWriter.createAttributeElement( 'span', { style: 'font-weight:' + modelAttributeValue } );
@@ -235,7 +239,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.model.name is given', () => {
-			const helper = downcastAttributeToElement( {
+			const helper = _downcastAttributeToElement( {
 				model: {
 					key: 'color',
 					name: '$text'
@@ -247,7 +251,7 @@ describe( 'downcast-helpers', () => {
 
 			conversion.for( 'downcast' )
 				.add( helper )
-				.add( downcastElementToElement( {
+				.add( _downcastElementToElement( {
 					model: 'smiley',
 					view: ( modelElement, viewWriter ) => {
 						return viewWriter.createEmptyElement( 'img', {
@@ -266,15 +270,15 @@ describe( 'downcast-helpers', () => {
 		} );
 	} );
 
-	describe( 'downcastAttributeToAttribute', () => {
+	describe( '_downcastAttributeToAttribute', () => {
 		testUtils.createSinonSandbox();
 
 		beforeEach( () => {
-			conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'image', view: 'img' } ) );
+			conversion.for( 'downcast' ).add( _downcastElementToElement( { model: 'image', view: 'img' } ) );
 		} );
 
 		it( 'config.view is a string', () => {
-			const helper = downcastAttributeToAttribute( { model: 'source', view: 'src' } );
+			const helper = _downcastAttributeToAttribute( { model: 'source', view: 'src' } );
 
 			conversion.for( 'downcast' ).add( helper );
 
@@ -292,8 +296,8 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'can be overwritten using converterPriority', () => {
-			const helperA = downcastAttributeToAttribute( { model: 'source', view: 'href' } );
-			const helperB = downcastAttributeToAttribute( { model: 'source', view: 'src', converterPriority: 'high' } );
+			const helperA = _downcastAttributeToAttribute( { model: 'source', view: 'href' } );
+			const helperB = _downcastAttributeToAttribute( { model: 'source', view: 'src', converterPriority: 'high' } );
 
 			conversion.for( 'downcast' ).add( helperA ).add( helperB );
 
@@ -305,9 +309,9 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'model element name specified', () => {
-			conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
+			conversion.for( 'downcast' ).add( _downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
 
-			const helper = downcastAttributeToAttribute( {
+			const helper = _downcastAttributeToAttribute( {
 				model: {
 					name: 'image',
 					key: 'source'
@@ -331,9 +335,9 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is an object, model attribute value is enum', () => {
-			conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
+			conversion.for( 'downcast' ).add( _downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
 
-			const helper = downcastAttributeToAttribute( {
+			const helper = _downcastAttributeToAttribute( {
 				model: {
 					key: 'styled',
 					values: [ 'dark', 'light' ]
@@ -372,9 +376,9 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is an object, model attribute value is enum, view has style', () => {
-			conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
+			conversion.for( 'downcast' ).add( _downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
 
-			const helper = downcastAttributeToAttribute( {
+			const helper = _downcastAttributeToAttribute( {
 				model: {
 					key: 'align',
 					values: [ 'right', 'center' ]
@@ -417,9 +421,9 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is an object, only name and key are provided', () => {
-			conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
+			conversion.for( 'downcast' ).add( _downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
 
-			const helper = downcastAttributeToAttribute( {
+			const helper = _downcastAttributeToAttribute( {
 				model: {
 					name: 'paragraph',
 					key: 'class'
@@ -452,7 +456,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a function', () => {
-			const helper = downcastAttributeToAttribute( {
+			const helper = _downcastAttributeToAttribute( {
 				model: 'styled',
 				view: attributeValue => ( { key: 'class', value: 'styled-' + attributeValue } )
 			} );
@@ -470,9 +474,9 @@ describe( 'downcast-helpers', () => {
 		it( 'config.view and config.model as strings in generic conversion (elements only)', () => {
 			const logSpy = testUtils.sinon.spy( log, 'warn' );
 
-			conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
+			conversion.for( 'downcast' ).add( _downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
 
-			conversion.for( 'downcast' ).add( downcastAttributeToAttribute( { model: 'test', view: 'test' } ) );
+			conversion.for( 'downcast' ).add( _downcastAttributeToAttribute( { model: 'test', view: 'test' } ) );
 
 			model.change( writer => {
 				writer.insertElement( 'paragraph', { test: '1' }, modelRoot, 0 );
@@ -493,9 +497,9 @@ describe( 'downcast-helpers', () => {
 		it( 'config.view and config.model as strings in generic conversion (elements + text)', () => {
 			const logSpy = testUtils.sinon.spy( log, 'warn' );
 
-			conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
+			conversion.for( 'downcast' ).add( _downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
 
-			conversion.for( 'downcast' ).add( downcastAttributeToAttribute( { model: 'test', view: 'test' } ) );
+			conversion.for( 'downcast' ).add( _downcastAttributeToAttribute( { model: 'test', view: 'test' } ) );
 
 			model.change( writer => {
 				writer.insertElement( 'paragraph', modelRoot, 0 );
@@ -517,9 +521,9 @@ describe( 'downcast-helpers', () => {
 		} );
 	} );
 
-	describe( 'downcastMarkerToElement', () => {
+	describe( '_downcastMarkerToElement', () => {
 		it( 'config.view is a string', () => {
-			const helper = downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
+			const helper = _downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
 
 			conversion.for( 'downcast' ).add( helper );
 
@@ -534,8 +538,8 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'can be overwritten using converterPriority', () => {
-			const helperA = downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
-			const helperB = downcastMarkerToElement( { model: 'search', view: 'search', converterPriority: 'high' } );
+			const helperA = _downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
+			const helperB = _downcastMarkerToElement( { model: 'search', view: 'search', converterPriority: 'high' } );
 
 			conversion.for( 'downcast' ).add( helperA ).add( helperB );
 
@@ -549,7 +553,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a view element definition', () => {
-			const helper = downcastMarkerToElement( {
+			const helper = _downcastMarkerToElement( {
 				model: 'search',
 				view: {
 					name: 'span',
@@ -571,7 +575,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a function', () => {
-			const helper = downcastMarkerToElement( {
+			const helper = _downcastMarkerToElement( {
 				model: 'search',
 				view: ( data, viewWriter ) => {
 					return viewWriter.createUIElement( 'span', { 'data-marker': 'search', 'data-start': data.isOpening } );
@@ -590,9 +594,9 @@ describe( 'downcast-helpers', () => {
 		} );
 	} );
 
-	describe( 'downcastMarkerToHighlight', () => {
+	describe( '_downcastMarkerToHighlight', () => {
 		it( 'config.view is a highlight descriptor', () => {
-			const helper = downcastMarkerToHighlight( { model: 'comment', view: { classes: 'comment' } } );
+			const helper = _downcastMarkerToHighlight( { model: 'comment', view: { classes: 'comment' } } );
 
 			conversion.for( 'downcast' ).add( helper );
 
@@ -606,8 +610,8 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'can be overwritten using converterPriority', () => {
-			const helperA = downcastMarkerToHighlight( { model: 'comment', view: { classes: 'comment' } } );
-			const helperB = downcastMarkerToHighlight( { model: 'comment', view: { classes: 'new-comment' }, converterPriority: 'high' } );
+			const helperA = _downcastMarkerToHighlight( { model: 'comment', view: { classes: 'comment' } } );
+			const helperB = _downcastMarkerToHighlight( { model: 'comment', view: { classes: 'new-comment' }, converterPriority: 'high' } );
 
 			conversion.for( 'downcast' ).add( helperA ).add( helperB );
 
@@ -621,7 +625,7 @@ describe( 'downcast-helpers', () => {
 		} );
 
 		it( 'config.view is a function', () => {
-			const helper = downcastMarkerToHighlight( {
+			const helper = _downcastMarkerToHighlight( {
 				model: 'comment',
 				view: data => {
 					const commentType = data.markerName.split( ':' )[ 1 ];

+ 2 - 6
packages/ckeditor5-engine/tests/tickets/699.js

@@ -12,10 +12,6 @@ import {
 	upcastElementToElement
 } from '../../src/conversion/upcast-converters';
 
-import {
-	downcastElementToElement
-} from '../../src/conversion/downcast-converters';
-
 import { getData as getModelData } from '../../src/dev-utils/model';
 import { getData as getViewData } from '../../src/dev-utils/view';
 
@@ -54,10 +50,10 @@ function WidgetPlugin( editor ) {
 	} );
 	schema.extend( 'widget', { allowIn: '$root' } );
 
-	editor.conversion.for( 'downcast' ).add( downcastElementToElement( {
+	editor.conversion.for( 'downcast' ).elementToElement( {
 		model: 'widget',
 		view: 'widget'
-	} ) );
+	} );
 
 	editor.conversion.for( 'upcast' ).add( upcastElementToElement( {
 		model: 'widget',