@@ -12,11 +12,11 @@ import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
1212
1313import Mapper from '../conversion/mapper' ;
1414
15- import ModelConversionDispatcher from '../conversion/modelconversiondispatcher ' ;
16- import { insertText } from '../conversion/model-to-view -converters' ;
15+ import DowncastDispatcher from '../conversion/downcastdispatcher ' ;
16+ import { insertText } from '../conversion/downcast -converters' ;
1717
18- import ViewConversionDispatcher from '../conversion/viewconversiondispatcher ' ;
19- import { convertText , convertToModelFragment } from '../conversion/view-to-model -converters' ;
18+ import UpcastDispatcher from '../conversion/upcastdispatcher ' ;
19+ import { convertText , convertToModelFragment } from '../conversion/upcast -converters' ;
2020
2121import ViewDocumentFragment from '../view/documentfragment' ;
2222
@@ -26,11 +26,11 @@ import ModelRange from '../model/range';
2626 * Controller for the data pipeline. The data pipeline controls how data is retrieved from the document
2727 * and set inside it. Hence, the controller features two methods which allow to {@link ~DataController#get get}
2828 * and {@link ~DataController#set set} data of the {@link ~DataController#model model}
29- * using the given:
29+ * using given:
3030 *
3131 * * {@link module:engine/dataprocessor/dataprocessor~DataProcessor data processor},
32- * * { @link module:engine/conversion/modelconversiondispatcher~ModelConversionDispatcher model to view} and
33- * * { @link module:engine/conversion/viewconversiondispatcher~ViewConversionDispatcher view to model} converters.
32+ * * downcast converters,
33+ * * upcast converters.
3434 *
3535 * @mixes module:utils/observablemixin~ObservableMixin
3636 */
@@ -62,44 +62,30 @@ export default class DataController {
6262 /**
6363 * Mapper used for the conversion. It has no permanent bindings, because they are created when getting data and
6464 * cleared directly after the data are converted. However, the mapper is defined as a class property, because
65- * it needs to be passed to the `ModelConversionDispatcher ` as a conversion API.
65+ * it needs to be passed to the `DowncastDispatcher ` as a conversion API.
6666 *
6767 * @member {module:engine/conversion/mapper~Mapper}
6868 */
6969 this . mapper = new Mapper ( ) ;
7070
7171 /**
72- * Model-to-view conversion dispatcher used by the {@link #get get method}.
73- * To attach the model-to-view converter to the data pipeline you need to add a listener to this property:
74- *
75- * data.modelToView( 'insert:$element', customInsertConverter );
76- *
77- * Or use {@link module:engine/conversion/buildmodelconverter~ModelConverterBuilder}:
78- *
79- * buildModelConverter().for( data.modelToView ).fromAttribute( 'bold' ).toElement( 'b' );
72+ * Downcast dispatcher used by the {@link #get get method}. Downcast converters should be attached to it.
8073 *
8174 * @readonly
82- * @member {module:engine/conversion/modelconversiondispatcher~ModelConversionDispatcher }
75+ * @member {module:engine/conversion/downcastdispatcher~DowncastDispatcher }
8376 */
84- this . modelToView = new ModelConversionDispatcher ( this . model , {
77+ this . downcastDispatcher = new DowncastDispatcher ( this . model , {
8578 mapper : this . mapper
8679 } ) ;
87- this . modelToView . on ( 'insert:$text' , insertText ( ) , { priority : 'lowest' } ) ;
80+ this . downcastDispatcher . on ( 'insert:$text' , insertText ( ) , { priority : 'lowest' } ) ;
8881
8982 /**
90- * View-to-model conversion dispatcher used by the {@link #set set method}.
91- * To attach the view-to-model converter to the data pipeline you need to add a listener to this property:
92- *
93- * data.viewToModel( 'element', customElementConverter );
94- *
95- * Or use {@link module:engine/conversion/buildviewconverter~ViewConverterBuilder}:
96- *
97- * buildViewConverter().for( data.viewToModel ).fromElement( 'b' ).toAttribute( 'bold', 'true' );
83+ * Upcast dispatcher used by the {@link #set set method}. Upcast converters should be attached to it.
9884 *
9985 * @readonly
100- * @member {module:engine/conversion/viewconversiondispatcher~ViewConversionDispatcher }
86+ * @member {module:engine/conversion/upcastdispatcher~UpcastDispatcher }
10187 */
102- this . viewToModel = new ViewConversionDispatcher ( this . model , {
88+ this . upcastDispatcher = new UpcastDispatcher ( this . model , {
10389 schema : model . schema
10490 } ) ;
10591
@@ -108,13 +94,13 @@ export default class DataController {
10894 // Note that if there is no default converter for the element it will be skipped, for instance `<b>foo</b>` will be
10995 // converted to nothing. We add `convertToModelFragment` as a last converter so it converts children of that
11096 // element to the document fragment so `<b>foo</b>` will be converted to `foo` if there is no converter for `<b>`.
111- this . viewToModel . on ( 'text' , convertText ( ) , { priority : 'lowest' } ) ;
112- this . viewToModel . on ( 'element' , convertToModelFragment ( ) , { priority : 'lowest' } ) ;
113- this . viewToModel . on ( 'documentFragment' , convertToModelFragment ( ) , { priority : 'lowest' } ) ;
97+ this . upcastDispatcher . on ( 'text' , convertText ( ) , { priority : 'lowest' } ) ;
98+ this . upcastDispatcher . on ( 'element' , convertToModelFragment ( ) , { priority : 'lowest' } ) ;
99+ this . upcastDispatcher . on ( 'documentFragment' , convertToModelFragment ( ) , { priority : 'lowest' } ) ;
114100 }
115101
116102 /**
117- * Returns the model's data converted by the {@link #modelToView model-to-view converters } and
103+ * Returns the model's data converted by downcast dispatchers attached to {@link #downcastDispatcher } and
118104 * formatted by the {@link #processor data processor}.
119105 *
120106 * @param {String } [rootName='main'] Root name.
@@ -127,9 +113,8 @@ export default class DataController {
127113
128114 /**
129115 * Returns the content of the given {@link module:engine/model/element~Element model's element} or
130- * {@link module:engine/model/documentfragment~DocumentFragment model document fragment} converted by the
131- * {@link #modelToView model-to-view converters} and formatted by the
132- * {@link #processor data processor}.
116+ * {@link module:engine/model/documentfragment~DocumentFragment model document fragment} converted by the downcast converters
117+ * attached to {@link #downcastDispatcher} and formatted by the {@link #processor data processor}.
133118 *
134119 * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment } modelElementOrFragment
135120 * Element whose content will be stringified.
@@ -145,8 +130,8 @@ export default class DataController {
145130
146131 /**
147132 * Returns the content of the given {@link module:engine/model/element~Element model element} or
148- * {@link module:engine/model/documentfragment~DocumentFragment model document fragment} converted by the
149- * {@link #modelToView model-to-view converters } to a
133+ * {@link module:engine/model/documentfragment~DocumentFragment model document fragment} converted by the downcast
134+ * converters attached to {@link #downcastDispatcher } to a
150135 * {@link module:engine/view/documentfragment~DocumentFragment view document fragment}.
151136 *
152137 * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment } modelElementOrFragment
@@ -160,15 +145,15 @@ export default class DataController {
160145 const viewDocumentFragment = new ViewDocumentFragment ( ) ;
161146 this . mapper . bindElements ( modelElementOrFragment , viewDocumentFragment ) ;
162147
163- this . modelToView . convertInsert ( modelRange ) ;
148+ this . downcastDispatcher . convertInsert ( modelRange ) ;
164149
165150 if ( ! modelElementOrFragment . is ( 'documentFragment' ) ) {
166151 // Then, if a document element is converted, convert markers.
167152 // From all document markers, get those, which "intersect" with the converter element.
168153 const markers = _getMarkersRelativeToElement ( modelElementOrFragment ) ;
169154
170155 for ( const [ name , range ] of markers ) {
171- this . modelToView . convertMarkerAdd ( name , range ) ;
156+ this . downcastDispatcher . convertMarkerAdd ( name , range ) ;
172157 }
173158 }
174159
@@ -180,7 +165,7 @@ export default class DataController {
180165
181166 /**
182167 * Sets input data parsed by the {@link #processor data processor} and
183- * converted by the {@link #viewToModel view-to-model converters}.
168+ * converted by the {@link #upcastDispatcher view-to-model converters}.
184169 *
185170 * This method also creates a batch with all the changes applied. If all you need is to parse data, use
186171 * the {@link #parse} method.
@@ -204,13 +189,13 @@ export default class DataController {
204189 }
205190
206191 /**
207- * Returns the data parsed by the {@link #processor data processor} and then
208- * converted by the {@link #viewToModel view-to-model converters }.
192+ * Returns the data parsed by the {@link #processor data processor} and then converted by upcast converters
193+ * attached to the {@link #upcastDispatcher }.
209194 *
210195 * @see #set
211196 * @param {String } data Data to parse.
212197 * @param {module:engine/model/schema~SchemaContextDefinition } [context='$root'] Base context in which the view will
213- * be converted to the model. See: {@link module:engine/conversion/viewconversiondispatcher~ViewConversionDispatcher #convert}.
198+ * be converted to the model. See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher #convert}.
214199 * @returns {module:engine/model/documentfragment~DocumentFragment } Parsed data.
215200 */
216201 parse ( data , context = '$root' ) {
@@ -224,19 +209,19 @@ export default class DataController {
224209 /**
225210 * Returns the result of the given {@link module:engine/view/element~Element view element} or
226211 * {@link module:engine/view/documentfragment~DocumentFragment view document fragment} converted by the
227- * {@link #viewToModel view-to-model converters}, wrapped by {module:engine/model/documentfragment~DocumentFragment}.
212+ * {@link #upcastDispatcher view-to-model converters}, wrapped by {module:engine/model/documentfragment~DocumentFragment}.
228213 *
229214 * When marker elements were converted during the conversion process, it will be set as a document fragment's
230215 * {@link module:engine/model/documentfragment~DocumentFragment#markers static markers map}.
231216 *
232217 * @param {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment } viewElementOrFragment
233218 * Element or document fragment whose content will be converted.
234219 * @param {module:engine/model/schema~SchemaContextDefinition } [context='$root'] Base context in which the view will
235- * be converted to the model. See: {@link module:engine/conversion/viewconversiondispatcher~ViewConversionDispatcher #convert}.
220+ * be converted to the model. See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher #convert}.
236221 * @returns {module:engine/model/documentfragment~DocumentFragment } Output document fragment.
237222 */
238223 toModel ( viewElementOrFragment , context = '$root' ) {
239- return this . viewToModel . convert ( viewElementOrFragment , context ) ;
224+ return this . upcastDispatcher . convert ( viewElementOrFragment , context ) ;
240225 }
241226
242227 /**
@@ -247,7 +232,7 @@ export default class DataController {
247232
248233mix ( DataController , ObservableMixin ) ;
249234
250- // Helper function for converting part of a model to view .
235+ // Helper function for downcast conversion .
251236//
252237// Takes a document element (element that is added to a model document) and checks which markers are inside it
253238// and which markers are containing it. If the marker is intersecting with element, the intersection is returned.
0 commit comments