@ckeditor/ckeditor5-engine 36.0.1 → 37.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +1 -1
  2. package/package.json +24 -23
  3. package/src/controller/datacontroller.d.ts +331 -0
  4. package/src/controller/datacontroller.js +62 -109
  5. package/src/controller/editingcontroller.d.ts +98 -0
  6. package/src/controller/editingcontroller.js +22 -46
  7. package/src/conversion/conversion.d.ts +476 -0
  8. package/src/conversion/conversion.js +328 -347
  9. package/src/conversion/conversionhelpers.d.ts +26 -0
  10. package/src/conversion/conversionhelpers.js +1 -5
  11. package/src/conversion/downcastdispatcher.d.ts +547 -0
  12. package/src/conversion/downcastdispatcher.js +74 -152
  13. package/src/conversion/downcasthelpers.d.ts +1226 -0
  14. package/src/conversion/downcasthelpers.js +843 -762
  15. package/src/conversion/mapper.d.ts +499 -0
  16. package/src/conversion/mapper.js +84 -99
  17. package/src/conversion/modelconsumable.d.ts +201 -0
  18. package/src/conversion/modelconsumable.js +96 -99
  19. package/src/conversion/upcastdispatcher.d.ts +492 -0
  20. package/src/conversion/upcastdispatcher.js +73 -100
  21. package/src/conversion/upcasthelpers.d.ts +499 -0
  22. package/src/conversion/upcasthelpers.js +406 -373
  23. package/src/conversion/viewconsumable.d.ts +177 -0
  24. package/src/conversion/viewconsumable.js +157 -162
  25. package/src/dataprocessor/basichtmlwriter.d.ts +18 -0
  26. package/src/dataprocessor/basichtmlwriter.js +0 -9
  27. package/src/dataprocessor/dataprocessor.d.ts +61 -0
  28. package/src/dataprocessor/htmldataprocessor.d.ts +76 -0
  29. package/src/dataprocessor/htmldataprocessor.js +6 -28
  30. package/src/dataprocessor/htmlwriter.d.ts +16 -0
  31. package/src/dataprocessor/xmldataprocessor.d.ts +90 -0
  32. package/src/dataprocessor/xmldataprocessor.js +8 -40
  33. package/src/dev-utils/model.d.ts +124 -0
  34. package/src/dev-utils/model.js +41 -38
  35. package/src/dev-utils/operationreplayer.d.ts +51 -0
  36. package/src/dev-utils/operationreplayer.js +6 -14
  37. package/src/dev-utils/utils.d.ts +37 -0
  38. package/src/dev-utils/utils.js +5 -18
  39. package/src/dev-utils/view.d.ts +319 -0
  40. package/src/dev-utils/view.js +205 -226
  41. package/src/index.d.ts +105 -0
  42. package/src/index.js +1 -0
  43. package/src/model/batch.d.ts +106 -0
  44. package/src/model/differ.d.ts +329 -0
  45. package/src/model/document.d.ts +245 -0
  46. package/src/model/document.js +1 -1
  47. package/src/model/documentfragment.d.ts +196 -0
  48. package/src/model/documentfragment.js +2 -2
  49. package/src/model/documentselection.d.ts +420 -0
  50. package/src/model/element.d.ts +165 -0
  51. package/src/model/history.d.ts +114 -0
  52. package/src/model/item.d.ts +14 -0
  53. package/src/model/liveposition.d.ts +77 -0
  54. package/src/model/liverange.d.ts +102 -0
  55. package/src/model/markercollection.d.ts +335 -0
  56. package/src/model/model.d.ts +812 -0
  57. package/src/model/model.js +59 -30
  58. package/src/model/node.d.ts +256 -0
  59. package/src/model/nodelist.d.ts +91 -0
  60. package/src/model/operation/attributeoperation.d.ts +98 -0
  61. package/src/model/operation/detachoperation.d.ts +55 -0
  62. package/src/model/operation/insertoperation.d.ts +85 -0
  63. package/src/model/operation/markeroperation.d.ts +86 -0
  64. package/src/model/operation/mergeoperation.d.ts +95 -0
  65. package/src/model/operation/moveoperation.d.ts +91 -0
  66. package/src/model/operation/nooperation.d.ts +33 -0
  67. package/src/model/operation/operation.d.ts +89 -0
  68. package/src/model/operation/operationfactory.d.ts +18 -0
  69. package/src/model/operation/renameoperation.d.ts +78 -0
  70. package/src/model/operation/rootattributeoperation.d.ts +97 -0
  71. package/src/model/operation/rootattributeoperation.js +1 -1
  72. package/src/model/operation/splitoperation.d.ts +104 -0
  73. package/src/model/operation/transform.d.ts +100 -0
  74. package/src/model/operation/utils.d.ts +71 -0
  75. package/src/model/position.d.ts +539 -0
  76. package/src/model/position.js +1 -1
  77. package/src/model/range.d.ts +458 -0
  78. package/src/model/range.js +1 -1
  79. package/src/model/rootelement.d.ts +40 -0
  80. package/src/model/schema.d.ts +1176 -0
  81. package/src/model/schema.js +15 -15
  82. package/src/model/selection.d.ts +472 -0
  83. package/src/model/text.d.ts +66 -0
  84. package/src/model/text.js +0 -2
  85. package/src/model/textproxy.d.ts +144 -0
  86. package/src/model/treewalker.d.ts +186 -0
  87. package/src/model/treewalker.js +19 -10
  88. package/src/model/typecheckable.d.ts +255 -0
  89. package/src/model/utils/autoparagraphing.d.ts +37 -0
  90. package/src/model/utils/deletecontent.d.ts +58 -0
  91. package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
  92. package/src/model/utils/getselectedcontent.d.ts +30 -0
  93. package/src/model/utils/insertcontent.d.ts +46 -0
  94. package/src/model/utils/insertcontent.js +2 -12
  95. package/src/model/utils/insertobject.d.ts +44 -0
  96. package/src/model/utils/insertobject.js +3 -14
  97. package/src/model/utils/modifyselection.d.ts +48 -0
  98. package/src/model/utils/selection-post-fixer.d.ts +65 -0
  99. package/src/model/writer.d.ts +726 -0
  100. package/src/model/writer.js +6 -4
  101. package/src/view/attributeelement.d.ts +108 -0
  102. package/src/view/attributeelement.js +25 -69
  103. package/src/view/containerelement.d.ts +49 -0
  104. package/src/view/containerelement.js +10 -43
  105. package/src/view/datatransfer.d.ts +75 -0
  106. package/src/view/document.d.ts +184 -0
  107. package/src/view/document.js +15 -84
  108. package/src/view/documentfragment.d.ts +150 -0
  109. package/src/view/documentfragment.js +40 -81
  110. package/src/view/documentselection.d.ts +219 -0
  111. package/src/view/documentselection.js +75 -121
  112. package/src/view/domconverter.d.ts +620 -0
  113. package/src/view/domconverter.js +159 -276
  114. package/src/view/downcastwriter.d.ts +804 -0
  115. package/src/view/downcastwriter.js +336 -380
  116. package/src/view/editableelement.d.ts +52 -0
  117. package/src/view/editableelement.js +9 -49
  118. package/src/view/element.d.ts +466 -0
  119. package/src/view/element.js +150 -222
  120. package/src/view/elementdefinition.d.ts +87 -0
  121. package/src/view/emptyelement.d.ts +41 -0
  122. package/src/view/emptyelement.js +11 -44
  123. package/src/view/filler.d.ts +111 -0
  124. package/src/view/filler.js +24 -21
  125. package/src/view/item.d.ts +14 -0
  126. package/src/view/matcher.d.ts +486 -0
  127. package/src/view/matcher.js +247 -218
  128. package/src/view/node.d.ts +160 -0
  129. package/src/view/node.js +26 -100
  130. package/src/view/observer/arrowkeysobserver.d.ts +41 -0
  131. package/src/view/observer/arrowkeysobserver.js +0 -13
  132. package/src/view/observer/bubblingemittermixin.d.ts +166 -0
  133. package/src/view/observer/bubblingemittermixin.js +36 -25
  134. package/src/view/observer/bubblingeventinfo.d.ts +47 -0
  135. package/src/view/observer/bubblingeventinfo.js +3 -29
  136. package/src/view/observer/clickobserver.d.ts +43 -0
  137. package/src/view/observer/clickobserver.js +9 -19
  138. package/src/view/observer/compositionobserver.d.ts +82 -0
  139. package/src/view/observer/compositionobserver.js +13 -42
  140. package/src/view/observer/domeventdata.d.ts +50 -0
  141. package/src/view/observer/domeventdata.js +5 -30
  142. package/src/view/observer/domeventobserver.d.ts +69 -0
  143. package/src/view/observer/domeventobserver.js +19 -21
  144. package/src/view/observer/fakeselectionobserver.d.ts +46 -0
  145. package/src/view/observer/fakeselectionobserver.js +2 -15
  146. package/src/view/observer/focusobserver.d.ts +82 -0
  147. package/src/view/observer/focusobserver.js +14 -40
  148. package/src/view/observer/inputobserver.d.ts +86 -0
  149. package/src/view/observer/inputobserver.js +18 -64
  150. package/src/view/observer/keyobserver.d.ts +67 -0
  151. package/src/view/observer/keyobserver.js +8 -42
  152. package/src/view/observer/mouseobserver.d.ts +89 -0
  153. package/src/view/observer/mouseobserver.js +8 -28
  154. package/src/view/observer/mutationobserver.d.ts +82 -0
  155. package/src/view/observer/mutationobserver.js +7 -37
  156. package/src/view/observer/observer.d.ts +84 -0
  157. package/src/view/observer/observer.js +12 -25
  158. package/src/view/observer/selectionobserver.d.ts +143 -0
  159. package/src/view/observer/selectionobserver.js +9 -99
  160. package/src/view/observer/tabobserver.d.ts +42 -0
  161. package/src/view/observer/tabobserver.js +0 -14
  162. package/src/view/placeholder.d.ts +85 -0
  163. package/src/view/placeholder.js +26 -43
  164. package/src/view/position.d.ts +189 -0
  165. package/src/view/position.js +36 -83
  166. package/src/view/range.d.ts +279 -0
  167. package/src/view/range.js +79 -122
  168. package/src/view/rawelement.d.ts +73 -0
  169. package/src/view/rawelement.js +34 -48
  170. package/src/view/renderer.d.ts +265 -0
  171. package/src/view/renderer.js +105 -193
  172. package/src/view/rooteditableelement.d.ts +41 -0
  173. package/src/view/rooteditableelement.js +12 -40
  174. package/src/view/selection.d.ts +375 -0
  175. package/src/view/selection.js +79 -153
  176. package/src/view/styles/background.d.ts +33 -0
  177. package/src/view/styles/background.js +14 -12
  178. package/src/view/styles/border.d.ts +43 -0
  179. package/src/view/styles/border.js +58 -48
  180. package/src/view/styles/margin.d.ts +29 -0
  181. package/src/view/styles/margin.js +13 -11
  182. package/src/view/styles/padding.d.ts +29 -0
  183. package/src/view/styles/padding.js +13 -11
  184. package/src/view/styles/utils.d.ts +93 -0
  185. package/src/view/styles/utils.js +22 -48
  186. package/src/view/stylesmap.d.ts +675 -0
  187. package/src/view/stylesmap.js +249 -244
  188. package/src/view/text.d.ts +74 -0
  189. package/src/view/text.js +16 -46
  190. package/src/view/textproxy.d.ts +97 -0
  191. package/src/view/textproxy.js +10 -59
  192. package/src/view/treewalker.d.ts +195 -0
  193. package/src/view/treewalker.js +43 -106
  194. package/src/view/typecheckable.d.ts +401 -0
  195. package/src/view/uielement.d.ts +96 -0
  196. package/src/view/uielement.js +28 -62
  197. package/src/view/upcastwriter.d.ts +328 -0
  198. package/src/view/upcastwriter.js +124 -134
  199. package/src/view/view.d.ts +327 -0
  200. package/src/view/view.js +79 -150
@@ -11,7 +11,7 @@ import DowncastHelpers from './downcasthelpers';
11
11
  /**
12
12
  * A utility class that helps add converters to upcast and downcast dispatchers.
13
13
  *
14
- * We recommend reading the {@glink framework/guides/deep-dive/conversion/intro editor conversion} guide first to
14
+ * We recommend reading the {@glink framework/deep-dive/conversion/intro editor conversion} guide first to
15
15
  * understand the core concepts of the conversion mechanisms.
16
16
  *
17
17
  * An instance of the conversion manager is available in the
@@ -28,14 +28,16 @@ import DowncastHelpers from './downcasthelpers';
28
28
  * To add a converter to a specific group, use the {@link module:engine/conversion/conversion~Conversion#for `for()`}
29
29
  * method:
30
30
  *
31
- * // Add a converter to editing downcast and data downcast.
32
- * editor.conversion.for( 'downcast' ).elementToElement( config ) );
31
+ * ```ts
32
+ * // Add a converter to editing downcast and data downcast.
33
+ * editor.conversion.for( 'downcast' ).elementToElement( config ) );
33
34
  *
34
- * // Add a converter to the data pipepline only:
35
- * editor.conversion.for( 'dataDowncast' ).elementToElement( dataConversionConfig ) );
35
+ * // Add a converter to the data pipepline only:
36
+ * editor.conversion.for( 'dataDowncast' ).elementToElement( dataConversionConfig ) );
36
37
  *
37
- * // And a slightly different one for the editing pipeline:
38
- * editor.conversion.for( 'editingDowncast' ).elementToElement( editingConversionConfig ) );
38
+ * // And a slightly different one for the editing pipeline:
39
+ * editor.conversion.for( 'editingDowncast' ).elementToElement( editingConversionConfig ) );
40
+ * ```
39
41
  *
40
42
  * See {@link module:engine/conversion/conversion~Conversion#for `for()`} method documentation to learn more about
41
43
  * available conversion helpers and how to use your custom ones.
@@ -55,18 +57,10 @@ import DowncastHelpers from './downcasthelpers';
55
57
  export default class Conversion {
56
58
  /**
57
59
  * Creates a new conversion instance.
58
- *
59
- * @param {module:engine/conversion/downcastdispatcher~DowncastDispatcher|
60
- * Array.<module:engine/conversion/downcastdispatcher~DowncastDispatcher>} downcastDispatchers
61
- * @param {module:engine/conversion/upcastdispatcher~UpcastDispatcher|
62
- * Array.<module:engine/conversion/upcastdispatcher~UpcastDispatcher>} upcastDispatchers
63
60
  */
64
61
  constructor(downcastDispatchers, upcastDispatchers) {
65
62
  /**
66
63
  * Maps dispatchers group name to ConversionHelpers instances.
67
- *
68
- * @private
69
- * @member {Map.<String,module:engine/conversion/conversionhelpers~ConversionHelpers>}
70
64
  */
71
65
  this._helpers = new Map();
72
66
  // Define default 'downcast' & 'upcast' dispatchers groups. Those groups are always available as two-way converters needs them.
@@ -78,16 +72,17 @@ export default class Conversion {
78
72
  /**
79
73
  * Define an alias for registered dispatcher.
80
74
  *
81
- * const conversion = new Conversion(
82
- * [ dataDowncastDispatcher, editingDowncastDispatcher ],
83
- * upcastDispatcher
84
- * );
75
+ * ```ts
76
+ * const conversion = new Conversion(
77
+ * [ dataDowncastDispatcher, editingDowncastDispatcher ],
78
+ * upcastDispatcher
79
+ * );
85
80
  *
86
- * conversion.addAlias( 'dataDowncast', dataDowncastDispatcher );
81
+ * conversion.addAlias( 'dataDowncast', dataDowncastDispatcher );
82
+ * ```
87
83
  *
88
- * @param {String} alias An alias of a dispatcher.
89
- * @param {module:engine/conversion/downcastdispatcher~DowncastDispatcher|
90
- * module:engine/conversion/upcastdispatcher~UpcastDispatcher} dispatcher Dispatcher which should have an alias.
84
+ * @param alias An alias of a dispatcher.
85
+ * @param dispatcher Dispatcher which should have an alias.
91
86
  */
92
87
  addAlias(alias, dispatcher) {
93
88
  const isDowncast = this._downcast.includes(dispatcher);
@@ -115,12 +110,14 @@ export default class Conversion {
115
110
  *
116
111
  * The `for()` chain comes with a set of conversion helpers which you can use like this:
117
112
  *
118
- * editor.conversion.for( 'downcast' )
119
- * .elementToElement( config1 ) // Adds an element-to-element downcast converter.
120
- * .attributeToElement( config2 ); // Adds an attribute-to-element downcast converter.
113
+ * ```ts
114
+ * editor.conversion.for( 'downcast' )
115
+ * .elementToElement( config1 ) // Adds an element-to-element downcast converter.
116
+ * .attributeToElement( config2 ); // Adds an attribute-to-element downcast converter.
121
117
  *
122
- * editor.conversion.for( 'upcast' )
123
- * .elementToAttribute( config3 ); // Adds an element-to-attribute upcast converter.
118
+ * editor.conversion.for( 'upcast' )
119
+ * .elementToAttribute( config3 ); // Adds an element-to-attribute upcast converter.
120
+ * ```
124
121
  *
125
122
  * Refer to the documentation of built-in conversion helpers to learn about their configuration options.
126
123
  *
@@ -143,25 +140,28 @@ export default class Conversion {
143
140
  *
144
141
  * If you need to implement an atypical converter, you can do so by calling:
145
142
  *
146
- * editor.conversion.for( direction ).add( customHelper );
143
+ * ```ts
144
+ * editor.conversion.for( direction ).add( customHelper );
145
+ * ```
147
146
  *
148
147
  * The `.add()` method takes exactly one parameter, which is a function. This function should accept one parameter that
149
148
  * is a dispatcher instance. The function should add an actual converter to the passed dispatcher instance.
150
149
  *
151
150
  * Example:
152
151
  *
153
- * editor.conversion.for( 'upcast' ).add( dispatcher => {
154
- * dispatcher.on( 'element:a', ( evt, data, conversionApi ) => {
155
- * // Do something with a view <a> element.
156
- * } );
157
- * } );
152
+ * ```ts
153
+ * editor.conversion.for( 'upcast' ).add( dispatcher => {
154
+ * dispatcher.on( 'element:a', ( evt, data, conversionApi ) => {
155
+ * // Do something with a view <a> element.
156
+ * } );
157
+ * } );
158
+ * ```
158
159
  *
159
160
  * Refer to the documentation of {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher}
160
161
  * and {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher} to learn how to write
161
162
  * custom converters.
162
163
  *
163
- * @param {String} groupName The name of dispatchers group to add the converters to.
164
- * @returns {module:engine/conversion/downcasthelpers~DowncastHelpers|module:engine/conversion/upcasthelpers~UpcastHelpers}
164
+ * @param groupName The name of dispatchers group to add the converters to.
165
165
  */
166
166
  for(groupName) {
167
167
  if (!this._helpers.has(groupName)) {
@@ -178,72 +178,73 @@ export default class Conversion {
178
178
  * Sets up converters between the model and the view that convert a model element to a view element (and vice versa).
179
179
  * For example, the model `<paragraph>Foo</paragraph>` is turned into `<p>Foo</p>` in the view.
180
180
  *
181
- * // A simple conversion from the `paragraph` model element to the `<p>` view element (and vice versa).
182
- * editor.conversion.elementToElement( { model: 'paragraph', view: 'p' } );
183
- *
184
- * // Override other converters by specifying a converter definition with a higher priority.
185
- * editor.conversion.elementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
186
- *
187
- * // View specified as an object instead of a string.
188
- * editor.conversion.elementToElement( {
189
- * model: 'fancyParagraph',
190
- * view: {
191
- * name: 'p',
192
- * classes: 'fancy'
193
- * }
194
- * } );
195
- *
196
- * // Use `upcastAlso` to define other view elements that should also be converted to a `paragraph` element.
197
- * editor.conversion.elementToElement( {
198
- * model: 'paragraph',
199
- * view: 'p',
200
- * upcastAlso: [
201
- * 'div',
202
- * {
203
- * // Any element with the `display: block` style.
204
- * styles: {
205
- * display: 'block'
206
- * }
207
- * }
208
- * ]
209
- * } );
210
- *
211
- * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
212
- * editor.conversion.elementToElement( {
213
- * model: 'heading',
214
- * view: 'h2',
215
- * // Convert "heading-like" paragraphs to headings.
216
- * upcastAlso: viewElement => {
217
- * const fontSize = viewElement.getStyle( 'font-size' );
218
- *
219
- * if ( !fontSize ) {
220
- * return null;
221
- * }
222
- *
223
- * const match = fontSize.match( /(\d+)\s*px/ );
224
- *
225
- * if ( !match ) {
226
- * return null;
227
- * }
228
- *
229
- * const size = Number( match[ 1 ] );
230
- *
231
- * if ( size > 26 ) {
232
- * // Returned value can be an object with the matched properties.
233
- * // These properties will be "consumed" during the conversion.
234
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
235
- *
236
- * return { name: true, styles: [ 'font-size' ] };
237
- * }
238
- *
239
- * return null;
240
- * }
241
- * } );
181
+ * ```ts
182
+ * // A simple conversion from the `paragraph` model element to the `<p>` view element (and vice versa).
183
+ * editor.conversion.elementToElement( { model: 'paragraph', view: 'p' } );
184
+ *
185
+ * // Override other converters by specifying a converter definition with a higher priority.
186
+ * editor.conversion.elementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
187
+ *
188
+ * // View specified as an object instead of a string.
189
+ * editor.conversion.elementToElement( {
190
+ * model: 'fancyParagraph',
191
+ * view: {
192
+ * name: 'p',
193
+ * classes: 'fancy'
194
+ * }
195
+ * } );
196
+ *
197
+ * // Use `upcastAlso` to define other view elements that should also be converted to a `paragraph` element.
198
+ * editor.conversion.elementToElement( {
199
+ * model: 'paragraph',
200
+ * view: 'p',
201
+ * upcastAlso: [
202
+ * 'div',
203
+ * {
204
+ * // Any element with the `display: block` style.
205
+ * styles: {
206
+ * display: 'block'
207
+ * }
208
+ * }
209
+ * ]
210
+ * } );
211
+ *
212
+ * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
213
+ * editor.conversion.elementToElement( {
214
+ * model: 'heading',
215
+ * view: 'h2',
216
+ * // Convert "heading-like" paragraphs to headings.
217
+ * upcastAlso: viewElement => {
218
+ * const fontSize = viewElement.getStyle( 'font-size' );
219
+ *
220
+ * if ( !fontSize ) {
221
+ * return null;
222
+ * }
223
+ *
224
+ * const match = fontSize.match( /(\d+)\s*px/ );
225
+ *
226
+ * if ( !match ) {
227
+ * return null;
228
+ * }
229
+ *
230
+ * const size = Number( match[ 1 ] );
231
+ *
232
+ * if ( size > 26 ) {
233
+ * // Returned value can be an object with the matched properties.
234
+ * // These properties will be "consumed" during the conversion.
235
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
236
+ *
237
+ * return { name: true, styles: [ 'font-size' ] };
238
+ * }
239
+ *
240
+ * return null;
241
+ * }
242
+ * } );
243
+ * ```
242
244
  *
243
245
  * `definition.model` is a `String` with a model element name to convert from or to.
244
- * See {@link module:engine/conversion/conversion~ConverterDefinition} to learn about other parameters.
245
246
  *
246
- * @param {module:engine/conversion/conversion~ConverterDefinition} definition The converter definition.
247
+ * @param definition The converter definition.
247
248
  */
248
249
  elementToElement(definition) {
249
250
  // Set up downcast converter.
@@ -262,159 +263,160 @@ export default class Conversion {
262
263
  * Sets up converters between the model and the view that convert a model attribute to a view element (and vice versa).
263
264
  * For example, a model text node with `"Foo"` as data and the `bold` attribute will be turned to `<strong>Foo</strong>` in the view.
264
265
  *
265
- * // A simple conversion from the `bold=true` attribute to the `<strong>` view element (and vice versa).
266
- * editor.conversion.attributeToElement( { model: 'bold', view: 'strong' } );
267
- *
268
- * // Override other converters by specifying a converter definition with a higher priority.
269
- * editor.conversion.attributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
270
- *
271
- * // View specified as an object instead of a string.
272
- * editor.conversion.attributeToElement( {
273
- * model: 'bold',
274
- * view: {
275
- * name: 'span',
276
- * classes: 'bold'
277
- * }
278
- * } );
279
- *
280
- * // Use `config.model.name` to define the conversion only from a given node type, `$text` in this case.
281
- * // The same attribute on different elements may then be handled by a different converter.
282
- * editor.conversion.attributeToElement( {
283
- * model: {
284
- * key: 'textDecoration',
285
- * values: [ 'underline', 'lineThrough' ],
286
- * name: '$text'
287
- * },
288
- * view: {
289
- * underline: {
290
- * name: 'span',
291
- * styles: {
292
- * 'text-decoration': 'underline'
293
- * }
294
- * },
295
- * lineThrough: {
296
- * name: 'span',
297
- * styles: {
298
- * 'text-decoration': 'line-through'
299
- * }
300
- * }
301
- * }
302
- * } );
303
- *
304
- * // Use `upcastAlso` to define other view elements that should also be converted to the `bold` attribute.
305
- * editor.conversion.attributeToElement( {
306
- * model: 'bold',
307
- * view: 'strong',
308
- * upcastAlso: [
309
- * 'b',
310
- * {
311
- * name: 'span',
312
- * classes: 'bold'
313
- * },
314
- * {
315
- * name: 'span',
316
- * styles: {
317
- * 'font-weight': 'bold'
318
- * }
319
- * },
320
- * viewElement => {
321
- * const fontWeight = viewElement.getStyle( 'font-weight' );
322
- *
323
- * if ( viewElement.is( 'element', 'span' ) && fontWeight && /\d+/.test() && Number( fontWeight ) > 500 ) {
324
- * // Returned value can be an object with the matched properties.
325
- * // These properties will be "consumed" during the conversion.
326
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
327
- *
328
- * return {
329
- * name: true,
330
- * styles: [ 'font-weight' ]
331
- * };
332
- * }
333
- * }
334
- * ]
335
- * } );
336
- *
337
- * // Conversion from and to a model attribute key whose value is an enum (`fontSize=big|small`).
338
- * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
339
- * editor.conversion.attributeToElement( {
340
- * model: {
341
- * key: 'fontSize',
342
- * values: [ 'big', 'small' ]
343
- * },
344
- * view: {
345
- * big: {
346
- * name: 'span',
347
- * styles: {
348
- * 'font-size': '1.2em'
349
- * }
350
- * },
351
- * small: {
352
- * name: 'span',
353
- * styles: {
354
- * 'font-size': '0.8em'
355
- * }
356
- * }
357
- * },
358
- * upcastAlso: {
359
- * big: viewElement => {
360
- * const fontSize = viewElement.getStyle( 'font-size' );
361
- *
362
- * if ( !fontSize ) {
363
- * return null;
364
- * }
365
- *
366
- * const match = fontSize.match( /(\d+)\s*px/ );
367
- *
368
- * if ( !match ) {
369
- * return null;
370
- * }
371
- *
372
- * const size = Number( match[ 1 ] );
373
- *
374
- * if ( viewElement.is( 'element', 'span' ) && size > 10 ) {
375
- * // Returned value can be an object with the matched properties.
376
- * // These properties will be "consumed" during the conversion.
377
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
378
- *
379
- * return { name: true, styles: [ 'font-size' ] };
380
- * }
381
- *
382
- * return null;
383
- * },
384
- * small: viewElement => {
385
- * const fontSize = viewElement.getStyle( 'font-size' );
386
- *
387
- * if ( !fontSize ) {
388
- * return null;
389
- * }
390
- *
391
- * const match = fontSize.match( /(\d+)\s*px/ );
392
- *
393
- * if ( !match ) {
394
- * return null;
395
- * }
396
- *
397
- * const size = Number( match[ 1 ] );
398
- *
399
- * if ( viewElement.is( 'element', 'span' ) && size < 10 ) {
400
- * // Returned value can be an object with the matched properties.
401
- * // These properties will be "consumed" during the conversion.
402
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
403
- *
404
- * return { name: true, styles: [ 'font-size' ] };
405
- * }
406
- *
407
- * return null;
408
- * }
409
- * }
410
- * } );
266
+ * ```ts
267
+ * // A simple conversion from the `bold=true` attribute to the `<strong>` view element (and vice versa).
268
+ * editor.conversion.attributeToElement( { model: 'bold', view: 'strong' } );
269
+ *
270
+ * // Override other converters by specifying a converter definition with a higher priority.
271
+ * editor.conversion.attributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
272
+ *
273
+ * // View specified as an object instead of a string.
274
+ * editor.conversion.attributeToElement( {
275
+ * model: 'bold',
276
+ * view: {
277
+ * name: 'span',
278
+ * classes: 'bold'
279
+ * }
280
+ * } );
281
+ *
282
+ * // Use `config.model.name` to define the conversion only from a given node type, `$text` in this case.
283
+ * // The same attribute on different elements may then be handled by a different converter.
284
+ * editor.conversion.attributeToElement( {
285
+ * model: {
286
+ * key: 'textDecoration',
287
+ * values: [ 'underline', 'lineThrough' ],
288
+ * name: '$text'
289
+ * },
290
+ * view: {
291
+ * underline: {
292
+ * name: 'span',
293
+ * styles: {
294
+ * 'text-decoration': 'underline'
295
+ * }
296
+ * },
297
+ * lineThrough: {
298
+ * name: 'span',
299
+ * styles: {
300
+ * 'text-decoration': 'line-through'
301
+ * }
302
+ * }
303
+ * }
304
+ * } );
305
+ *
306
+ * // Use `upcastAlso` to define other view elements that should also be converted to the `bold` attribute.
307
+ * editor.conversion.attributeToElement( {
308
+ * model: 'bold',
309
+ * view: 'strong',
310
+ * upcastAlso: [
311
+ * 'b',
312
+ * {
313
+ * name: 'span',
314
+ * classes: 'bold'
315
+ * },
316
+ * {
317
+ * name: 'span',
318
+ * styles: {
319
+ * 'font-weight': 'bold'
320
+ * }
321
+ * },
322
+ * viewElement => {
323
+ * const fontWeight = viewElement.getStyle( 'font-weight' );
324
+ *
325
+ * if ( viewElement.is( 'element', 'span' ) && fontWeight && /\d+/.test() && Number( fontWeight ) > 500 ) {
326
+ * // Returned value can be an object with the matched properties.
327
+ * // These properties will be "consumed" during the conversion.
328
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
329
+ *
330
+ * return {
331
+ * name: true,
332
+ * styles: [ 'font-weight' ]
333
+ * };
334
+ * }
335
+ * }
336
+ * ]
337
+ * } );
338
+ *
339
+ * // Conversion from and to a model attribute key whose value is an enum (`fontSize=big|small`).
340
+ * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
341
+ * editor.conversion.attributeToElement( {
342
+ * model: {
343
+ * key: 'fontSize',
344
+ * values: [ 'big', 'small' ]
345
+ * },
346
+ * view: {
347
+ * big: {
348
+ * name: 'span',
349
+ * styles: {
350
+ * 'font-size': '1.2em'
351
+ * }
352
+ * },
353
+ * small: {
354
+ * name: 'span',
355
+ * styles: {
356
+ * 'font-size': '0.8em'
357
+ * }
358
+ * }
359
+ * },
360
+ * upcastAlso: {
361
+ * big: viewElement => {
362
+ * const fontSize = viewElement.getStyle( 'font-size' );
363
+ *
364
+ * if ( !fontSize ) {
365
+ * return null;
366
+ * }
367
+ *
368
+ * const match = fontSize.match( /(\d+)\s*px/ );
369
+ *
370
+ * if ( !match ) {
371
+ * return null;
372
+ * }
373
+ *
374
+ * const size = Number( match[ 1 ] );
375
+ *
376
+ * if ( viewElement.is( 'element', 'span' ) && size > 10 ) {
377
+ * // Returned value can be an object with the matched properties.
378
+ * // These properties will be "consumed" during the conversion.
379
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
380
+ *
381
+ * return { name: true, styles: [ 'font-size' ] };
382
+ * }
383
+ *
384
+ * return null;
385
+ * },
386
+ * small: viewElement => {
387
+ * const fontSize = viewElement.getStyle( 'font-size' );
388
+ *
389
+ * if ( !fontSize ) {
390
+ * return null;
391
+ * }
392
+ *
393
+ * const match = fontSize.match( /(\d+)\s*px/ );
394
+ *
395
+ * if ( !match ) {
396
+ * return null;
397
+ * }
398
+ *
399
+ * const size = Number( match[ 1 ] );
400
+ *
401
+ * if ( viewElement.is( 'element', 'span' ) && size < 10 ) {
402
+ * // Returned value can be an object with the matched properties.
403
+ * // These properties will be "consumed" during the conversion.
404
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
405
+ *
406
+ * return { name: true, styles: [ 'font-size' ] };
407
+ * }
408
+ *
409
+ * return null;
410
+ * }
411
+ * }
412
+ * } );
413
+ * ```
411
414
  *
412
415
  * The `definition.model` parameter specifies which model attribute should be converted from or to. It can be a `{ key, value }` object
413
416
  * describing the attribute key and value to convert or a `String` specifying just the attribute key (in such a case
414
417
  * `value` is set to `true`).
415
- * See {@link module:engine/conversion/conversion~ConverterDefinition} to learn about other parameters.
416
418
  *
417
- * @param {module:engine/conversion/conversion~ConverterDefinition} definition The converter definition.
419
+ * @param definition The converter definition.
418
420
  */
419
421
  attributeToElement(definition) {
420
422
  // Set up downcast converter.
@@ -436,75 +438,77 @@ export default class Conversion {
436
438
  * To convert the text attributes,
437
439
  * the {@link module:engine/conversion/conversion~Conversion#attributeToElement `attributeToElement converter`}should be set up.
438
440
  *
439
- * // A simple conversion from the `source` model attribute to the `src` view attribute (and vice versa).
440
- * editor.conversion.attributeToAttribute( { model: 'source', view: 'src' } );
441
- *
442
- * // Attribute values are strictly specified.
443
- * editor.conversion.attributeToAttribute( {
444
- * model: {
445
- * name: 'imageInline',
446
- * key: 'aside',
447
- * values: [ 'aside' ]
448
- * },
449
- * view: {
450
- * aside: {
451
- * name: 'img',
452
- * key: 'class',
453
- * value: [ 'aside', 'half-size' ]
454
- * }
455
- * }
456
- * } );
457
- *
458
- * // Set the style attribute.
459
- * editor.conversion.attributeToAttribute( {
460
- * model: {
461
- * name: 'imageInline',
462
- * key: 'aside',
463
- * values: [ 'aside' ]
464
- * },
465
- * view: {
466
- * aside: {
467
- * name: 'img',
468
- * key: 'style',
469
- * value: {
470
- * float: 'right',
471
- * width: '50%',
472
- * margin: '5px'
473
- * }
474
- * }
475
- * }
476
- * } );
477
- *
478
- * // Conversion from and to a model attribute key whose value is an enum (`align=right|center`).
479
- * // Use `upcastAlso` to define other view elements that should also be converted to the `align=right` attribute.
480
- * editor.conversion.attributeToAttribute( {
481
- * model: {
482
- * key: 'align',
483
- * values: [ 'right', 'center' ]
484
- * },
485
- * view: {
486
- * right: {
487
- * key: 'class',
488
- * value: 'align-right'
489
- * },
490
- * center: {
491
- * key: 'class',
492
- * value: 'align-center'
493
- * }
494
- * },
495
- * upcastAlso: {
496
- * right: {
497
- * styles: {
498
- * 'text-align': 'right'
499
- * }
500
- * },
501
- * center: {
502
- * styles: {
503
- * 'text-align': 'center'
504
- * }
505
- * }
506
- * }
507
- * } );
441
+ * ```ts
442
+ * // A simple conversion from the `source` model attribute to the `src` view attribute (and vice versa).
443
+ * editor.conversion.attributeToAttribute( { model: 'source', view: 'src' } );
444
+ *
445
+ * // Attribute values are strictly specified.
446
+ * editor.conversion.attributeToAttribute( {
447
+ * model: {
448
+ * name: 'imageInline',
449
+ * key: 'aside',
450
+ * values: [ 'aside' ]
451
+ * },
452
+ * view: {
453
+ * aside: {
454
+ * name: 'img',
455
+ * key: 'class',
456
+ * value: [ 'aside', 'half-size' ]
457
+ * }
458
+ * }
459
+ * } );
460
+ *
461
+ * // Set the style attribute.
462
+ * editor.conversion.attributeToAttribute( {
463
+ * model: {
464
+ * name: 'imageInline',
465
+ * key: 'aside',
466
+ * values: [ 'aside' ]
467
+ * },
468
+ * view: {
469
+ * aside: {
470
+ * name: 'img',
471
+ * key: 'style',
472
+ * value: {
473
+ * float: 'right',
474
+ * width: '50%',
475
+ * margin: '5px'
476
+ * }
477
+ * }
478
+ * }
479
+ * } );
480
+ *
481
+ * // Conversion from and to a model attribute key whose value is an enum (`align=right|center`).
482
+ * // Use `upcastAlso` to define other view elements that should also be converted to the `align=right` attribute.
483
+ * editor.conversion.attributeToAttribute( {
484
+ * model: {
485
+ * key: 'align',
486
+ * values: [ 'right', 'center' ]
487
+ * },
488
+ * view: {
489
+ * right: {
490
+ * key: 'class',
491
+ * value: 'align-right'
492
+ * },
493
+ * center: {
494
+ * key: 'class',
495
+ * value: 'align-center'
496
+ * }
497
+ * },
498
+ * upcastAlso: {
499
+ * right: {
500
+ * styles: {
501
+ * 'text-align': 'right'
502
+ * }
503
+ * },
504
+ * center: {
505
+ * styles: {
506
+ * 'text-align': 'center'
507
+ * }
508
+ * }
509
+ * }
510
+ * } );
511
+ * ```
508
512
  *
509
513
  * The `definition.model` parameter specifies which model attribute should be converted from and to.
510
514
  * It can be a `{ key, [ values ], [ name ] }` object or a `String`, which will be treated like `{ key: definition.model }`.
@@ -532,12 +536,11 @@ export default class Conversion {
532
536
  * **Note:** `definition.model` and `definition.view` form should be mirrored, so the same types of parameters should
533
537
  * be given in both parameters.
534
538
  *
535
- * @param {Object} definition The converter definition.
536
- * @param {String|Object} definition.model The model attribute to convert from and to.
537
- * @param {String|Object} definition.view The view attribute to convert from and to.
538
- * @param {module:engine/view/matcher~MatcherPattern|Array.<module:engine/view/matcher~MatcherPattern>} [definition.upcastAlso]
539
- * Any view element matching `definition.upcastAlso` will also be converted to the given model attribute. `definition.upcastAlso`
540
- * is used only if `config.model.values` is specified.
539
+ * @param definition The converter definition.
540
+ * @param definition.model The model attribute to convert from and to.
541
+ * @param definition.view The view attribute to convert from and to.
542
+ * @param definition.upcastAlso Any view element matching `definition.upcastAlso` will also be converted to the given model attribute.
543
+ * `definition.upcastAlso` is used only if `config.model.values` is specified.
541
544
  */
542
545
  attributeToAttribute(definition) {
543
546
  // Set up downcast converter.
@@ -554,12 +557,7 @@ export default class Conversion {
554
557
  /**
555
558
  * Creates and caches conversion helpers for given dispatchers group.
556
559
  *
557
- * @private
558
- * @param {Object} options
559
- * @param {String} options.name Group name.
560
- * @param {Array.<module:engine/conversion/downcastdispatcher~DowncastDispatcher|
561
- * module:engine/conversion/upcastdispatcher~UpcastDispatcher>} options.dispatchers
562
- * @param {Boolean} options.isDowncast
560
+ * @param options.name Group name.
563
561
  */
564
562
  _createConversionHelpers({ name, dispatchers, isDowncast }) {
565
563
  if (this._helpers.has(name)) {
@@ -577,26 +575,9 @@ export default class Conversion {
577
575
  }
578
576
  }
579
577
  /**
580
- * Defines how the model should be converted from and to the view.
581
- *
582
- * @typedef {Object} module:engine/conversion/conversion~ConverterDefinition
583
- *
584
- * @property {*} [model] The model conversion definition. Describes the model element or model attribute to convert. This parameter differs
585
- * for different functions that accept `ConverterDefinition`. See the description of the function to learn how to set it.
586
- * @property {module:engine/view/elementdefinition~ElementDefinition|Object} view The definition of the view element to convert from and
587
- * to. If `model` describes multiple values, `view` is an object that assigns these values (`view` object keys) to view element definitions
588
- * (`view` object values).
589
- * @property {module:engine/view/matcher~MatcherPattern|Array.<module:engine/view/matcher~MatcherPattern>} [upcastAlso]
590
- * Any view element matching `upcastAlso` will also be converted to the model. If `model` describes multiple values, `upcastAlso`
591
- * is an object that assigns these values (`upcastAlso` object keys) to {@link module:engine/view/matcher~MatcherPattern}s
592
- * (`upcastAlso` object values).
593
- * @property {module:utils/priorities~PriorityString} [converterPriority] The converter priority.
578
+ * Helper function that creates a joint array out of an item passed in `definition.view` and items passed in
579
+ * `definition.upcastAlso`.
594
580
  */
595
- // Helper function that creates a joint array out of an item passed in `definition.view` and items passed in
596
- // `definition.upcastAlso`.
597
- //
598
- // @param {module:engine/conversion/conversion~ConverterDefinition} definition
599
- // @returns {Array} Array containing view definitions.
600
581
  function* _getAllUpcastDefinitions(definition) {
601
582
  if (definition.model.values) {
602
583
  for (const value of definition.model.values) {