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

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 (203) hide show
  1. package/README.md +1 -1
  2. package/package.json +25 -24
  3. package/src/controller/datacontroller.d.ts +331 -0
  4. package/src/controller/datacontroller.js +72 -116
  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 +503 -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 +369 -0
  24. package/src/conversion/viewconsumable.js +139 -173
  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 +108 -0
  42. package/src/index.js +4 -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 +246 -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 +885 -0
  57. package/src/model/model.js +59 -81
  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/mergeoperation.js +1 -1
  66. package/src/model/operation/moveoperation.d.ts +91 -0
  67. package/src/model/operation/nooperation.d.ts +33 -0
  68. package/src/model/operation/operation.d.ts +89 -0
  69. package/src/model/operation/operationfactory.d.ts +18 -0
  70. package/src/model/operation/renameoperation.d.ts +78 -0
  71. package/src/model/operation/rootattributeoperation.d.ts +97 -0
  72. package/src/model/operation/rootattributeoperation.js +1 -1
  73. package/src/model/operation/splitoperation.d.ts +104 -0
  74. package/src/model/operation/splitoperation.js +1 -1
  75. package/src/model/operation/transform.d.ts +100 -0
  76. package/src/model/operation/utils.d.ts +71 -0
  77. package/src/model/operation/utils.js +1 -1
  78. package/src/model/position.d.ts +539 -0
  79. package/src/model/position.js +1 -1
  80. package/src/model/range.d.ts +458 -0
  81. package/src/model/range.js +1 -1
  82. package/src/model/rootelement.d.ts +40 -0
  83. package/src/model/schema.d.ts +1176 -0
  84. package/src/model/schema.js +19 -19
  85. package/src/model/selection.d.ts +472 -0
  86. package/src/model/text.d.ts +66 -0
  87. package/src/model/text.js +0 -2
  88. package/src/model/textproxy.d.ts +144 -0
  89. package/src/model/treewalker.d.ts +186 -0
  90. package/src/model/treewalker.js +19 -10
  91. package/src/model/typecheckable.d.ts +285 -0
  92. package/src/model/utils/autoparagraphing.d.ts +37 -0
  93. package/src/model/utils/deletecontent.d.ts +58 -0
  94. package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
  95. package/src/model/utils/getselectedcontent.d.ts +30 -0
  96. package/src/model/utils/insertcontent.d.ts +46 -0
  97. package/src/model/utils/insertcontent.js +2 -12
  98. package/src/model/utils/insertobject.d.ts +44 -0
  99. package/src/model/utils/insertobject.js +3 -14
  100. package/src/model/utils/modifyselection.d.ts +48 -0
  101. package/src/model/utils/selection-post-fixer.d.ts +65 -0
  102. package/src/model/writer.d.ts +823 -0
  103. package/src/model/writer.js +6 -61
  104. package/src/view/attributeelement.d.ts +108 -0
  105. package/src/view/attributeelement.js +25 -69
  106. package/src/view/containerelement.d.ts +49 -0
  107. package/src/view/containerelement.js +10 -43
  108. package/src/view/datatransfer.d.ts +75 -0
  109. package/src/view/document.d.ts +184 -0
  110. package/src/view/document.js +15 -84
  111. package/src/view/documentfragment.d.ts +149 -0
  112. package/src/view/documentfragment.js +39 -81
  113. package/src/view/documentselection.d.ts +306 -0
  114. package/src/view/documentselection.js +42 -143
  115. package/src/view/domconverter.d.ts +650 -0
  116. package/src/view/domconverter.js +157 -283
  117. package/src/view/downcastwriter.d.ts +996 -0
  118. package/src/view/downcastwriter.js +259 -426
  119. package/src/view/editableelement.d.ts +52 -0
  120. package/src/view/editableelement.js +9 -49
  121. package/src/view/element.d.ts +468 -0
  122. package/src/view/element.js +150 -222
  123. package/src/view/elementdefinition.d.ts +87 -0
  124. package/src/view/emptyelement.d.ts +41 -0
  125. package/src/view/emptyelement.js +11 -44
  126. package/src/view/filler.d.ts +111 -0
  127. package/src/view/filler.js +24 -21
  128. package/src/view/item.d.ts +14 -0
  129. package/src/view/matcher.d.ts +486 -0
  130. package/src/view/matcher.js +247 -218
  131. package/src/view/node.d.ts +163 -0
  132. package/src/view/node.js +26 -100
  133. package/src/view/observer/arrowkeysobserver.d.ts +41 -0
  134. package/src/view/observer/arrowkeysobserver.js +0 -13
  135. package/src/view/observer/bubblingemittermixin.d.ts +166 -0
  136. package/src/view/observer/bubblingemittermixin.js +36 -25
  137. package/src/view/observer/bubblingeventinfo.d.ts +47 -0
  138. package/src/view/observer/bubblingeventinfo.js +3 -29
  139. package/src/view/observer/clickobserver.d.ts +43 -0
  140. package/src/view/observer/clickobserver.js +9 -19
  141. package/src/view/observer/compositionobserver.d.ts +82 -0
  142. package/src/view/observer/compositionobserver.js +13 -42
  143. package/src/view/observer/domeventdata.d.ts +50 -0
  144. package/src/view/observer/domeventdata.js +5 -30
  145. package/src/view/observer/domeventobserver.d.ts +69 -0
  146. package/src/view/observer/domeventobserver.js +19 -21
  147. package/src/view/observer/fakeselectionobserver.d.ts +43 -0
  148. package/src/view/observer/fakeselectionobserver.js +0 -16
  149. package/src/view/observer/focusobserver.d.ts +82 -0
  150. package/src/view/observer/focusobserver.js +14 -40
  151. package/src/view/observer/inputobserver.d.ts +86 -0
  152. package/src/view/observer/inputobserver.js +18 -64
  153. package/src/view/observer/keyobserver.d.ts +66 -0
  154. package/src/view/observer/keyobserver.js +8 -42
  155. package/src/view/observer/mouseobserver.d.ts +89 -0
  156. package/src/view/observer/mouseobserver.js +8 -28
  157. package/src/view/observer/mutationobserver.d.ts +82 -0
  158. package/src/view/observer/mutationobserver.js +7 -37
  159. package/src/view/observer/observer.d.ts +84 -0
  160. package/src/view/observer/observer.js +12 -25
  161. package/src/view/observer/selectionobserver.d.ts +144 -0
  162. package/src/view/observer/selectionobserver.js +17 -107
  163. package/src/view/observer/tabobserver.d.ts +42 -0
  164. package/src/view/observer/tabobserver.js +0 -14
  165. package/src/view/placeholder.d.ts +85 -0
  166. package/src/view/placeholder.js +26 -43
  167. package/src/view/position.d.ts +189 -0
  168. package/src/view/position.js +36 -83
  169. package/src/view/range.d.ts +279 -0
  170. package/src/view/range.js +79 -122
  171. package/src/view/rawelement.d.ts +73 -0
  172. package/src/view/rawelement.js +34 -48
  173. package/src/view/renderer.d.ts +265 -0
  174. package/src/view/renderer.js +105 -193
  175. package/src/view/rooteditableelement.d.ts +41 -0
  176. package/src/view/rooteditableelement.js +12 -40
  177. package/src/view/selection.d.ts +375 -0
  178. package/src/view/selection.js +79 -153
  179. package/src/view/styles/background.d.ts +33 -0
  180. package/src/view/styles/background.js +14 -12
  181. package/src/view/styles/border.d.ts +43 -0
  182. package/src/view/styles/border.js +58 -48
  183. package/src/view/styles/margin.d.ts +29 -0
  184. package/src/view/styles/margin.js +13 -11
  185. package/src/view/styles/padding.d.ts +29 -0
  186. package/src/view/styles/padding.js +13 -11
  187. package/src/view/styles/utils.d.ts +93 -0
  188. package/src/view/styles/utils.js +22 -48
  189. package/src/view/stylesmap.d.ts +675 -0
  190. package/src/view/stylesmap.js +249 -244
  191. package/src/view/text.d.ts +74 -0
  192. package/src/view/text.js +16 -46
  193. package/src/view/textproxy.d.ts +97 -0
  194. package/src/view/textproxy.js +10 -59
  195. package/src/view/treewalker.d.ts +195 -0
  196. package/src/view/treewalker.js +43 -106
  197. package/src/view/typecheckable.d.ts +448 -0
  198. package/src/view/uielement.d.ts +96 -0
  199. package/src/view/uielement.js +29 -63
  200. package/src/view/upcastwriter.d.ts +417 -0
  201. package/src/view/upcastwriter.js +86 -157
  202. package/src/view/view.d.ts +417 -0
  203. package/src/view/view.js +47 -175
@@ -30,92 +30,34 @@ import HtmlDataProcessor from '../dataprocessor/htmldataprocessor';
30
30
  * An instance of the data controller is always available in the {@link module:core/editor/editor~Editor#data `editor.data`}
31
31
  * property:
32
32
  *
33
- * editor.data.get( { rootName: 'customRoot' } ); // -> '<p>Hello!</p>'
34
- *
35
- * @mixes module:utils/emittermixin~EmitterMixin
33
+ * ```ts
34
+ * editor.data.get( { rootName: 'customRoot' } ); // -> '<p>Hello!</p>'
35
+ * ```
36
36
  */
37
37
  export default class DataController extends EmitterMixin() {
38
38
  /**
39
39
  * Creates a data controller instance.
40
40
  *
41
- * @param {module:engine/model/model~Model} model Data model.
42
- * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
41
+ * @param model Data model.
42
+ * @param stylesProcessor The styles processor instance.
43
43
  */
44
44
  constructor(model, stylesProcessor) {
45
45
  super();
46
- /**
47
- * Data model.
48
- *
49
- * @readonly
50
- * @member {module:engine/model/model~Model}
51
- */
52
46
  this.model = model;
53
- /**
54
- * Mapper used for the conversion. It has no permanent bindings, because these are created while getting data and
55
- * ae cleared directly after the data are converted. However, the mapper is defined as a class property, because
56
- * it needs to be passed to the `DowncastDispatcher` as a conversion API.
57
- *
58
- * @readonly
59
- * @member {module:engine/conversion/mapper~Mapper}
60
- */
61
47
  this.mapper = new Mapper();
62
- /**
63
- * Downcast dispatcher used by the {@link #get get method}. Downcast converters should be attached to it.
64
- *
65
- * @readonly
66
- * @member {module:engine/conversion/downcastdispatcher~DowncastDispatcher}
67
- */
68
48
  this.downcastDispatcher = new DowncastDispatcher({
69
49
  mapper: this.mapper,
70
50
  schema: model.schema
71
51
  });
72
52
  this.downcastDispatcher.on('insert:$text', insertText(), { priority: 'lowest' });
73
53
  this.downcastDispatcher.on('insert', insertAttributesAndChildren(), { priority: 'lowest' });
74
- /**
75
- * Upcast dispatcher used by the {@link #set set method}. Upcast converters should be attached to it.
76
- *
77
- * @readonly
78
- * @member {module:engine/conversion/upcastdispatcher~UpcastDispatcher}
79
- */
80
54
  this.upcastDispatcher = new UpcastDispatcher({
81
55
  schema: model.schema
82
56
  });
83
- /**
84
- * The view document used by the data controller.
85
- *
86
- * @readonly
87
- * @member {module:engine/view/document~Document}
88
- */
89
57
  this.viewDocument = new ViewDocument(stylesProcessor);
90
- /**
91
- * Styles processor used during the conversion.
92
- *
93
- * @readonly
94
- * @member {module:engine/view/stylesmap~StylesProcessor}
95
- */
96
58
  this.stylesProcessor = stylesProcessor;
97
- /**
98
- * Data processor used specifically for HTML conversion.
99
- *
100
- * @readonly
101
- * @member {module:engine/dataprocessor/htmldataprocessor~HtmlDataProcessor} #htmlProcessor
102
- */
103
59
  this.htmlProcessor = new HtmlDataProcessor(this.viewDocument);
104
- /**
105
- * Data processor used during the conversion.
106
- * Same instance as {@link #htmlProcessor} by default. Can be replaced at run time to handle different format, e.g. XML or Markdown.
107
- *
108
- * @member {module:engine/dataprocessor/dataprocessor~DataProcessor} #processor
109
- */
110
60
  this.processor = this.htmlProcessor;
111
- /**
112
- * The view downcast writer just for data conversion purposes, i.e. to modify
113
- * the {@link #viewDocument}.
114
- *
115
- * @private
116
- * @readonly
117
- * @member {module:engine/view/downcastwriter~DowncastWriter}
118
- */
119
61
  this._viewWriter = new ViewDowncastWriter(this.viewDocument);
120
62
  // Define default converters for text and elements.
121
63
  //
@@ -146,23 +88,26 @@ export default class DataController extends EmitterMixin() {
146
88
  * formatted by the {@link #processor data processor}.
147
89
  *
148
90
  * @fires get
149
- * @param {Object} [options] Additional configuration for the retrieved data. `DataController` provides two optional
91
+ * @param options Additional configuration for the retrieved data. `DataController` provides two optional
150
92
  * properties: `rootName` and `trim`. Other properties of this object are specified by various editor features.
151
- * @param {String} [options.rootName='main'] Root name.
152
- * @param {String} [options.trim='empty'] Whether returned data should be trimmed. This option is set to `empty` by default,
93
+ * @param options.rootName Root name. Default 'main'.
94
+ * @param options.trim Whether returned data should be trimmed. This option is set to `empty` by default,
153
95
  * which means whenever editor content is considered empty, an empty string will be returned. To turn off trimming completely
154
96
  * use `'none'`. In such cases the exact content will be returned (for example a `<p>&nbsp;</p>` for an empty editor).
155
- * @returns {String} Output data.
97
+ * @returns Output data.
156
98
  */
157
99
  get(options = {}) {
158
100
  const { rootName = 'main', trim = 'empty' } = options;
159
101
  if (!this._checkIfRootsExists([rootName])) {
160
102
  /**
161
- * Cannot get data from a non-existing root. This error is thrown when {@link #get DataController#get() method}
103
+ * Cannot get data from a non-existing root. This error is thrown when
104
+ * {@link module:engine/controller/datacontroller~DataController#get `DataController#get()` method}
162
105
  * is called with a non-existent root name. For example, if there is an editor instance with only `main` root,
163
- * calling {@link #get} like:
106
+ * calling {@link module:engine/controller/datacontroller~DataController#get} like:
164
107
  *
165
- * data.get( { rootName: 'root2' } );
108
+ * ```ts
109
+ * data.get( { rootName: 'root2' } );
110
+ * ```
166
111
  *
167
112
  * will throw this error.
168
113
  *
@@ -181,10 +126,9 @@ export default class DataController extends EmitterMixin() {
181
126
  * {@link module:engine/model/documentfragment~DocumentFragment model document fragment} converted by the downcast converters
182
127
  * attached to the {@link #downcastDispatcher} and formatted by the {@link #processor data processor}.
183
128
  *
184
- * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} modelElementOrFragment
185
- * The element whose content will be stringified.
186
- * @param {Object} [options] Additional configuration passed to the conversion process.
187
- * @returns {String} Output data.
129
+ * @param modelElementOrFragment The element whose content will be stringified.
130
+ * @param options Additional configuration passed to the conversion process.
131
+ * @returns Output data.
188
132
  */
189
133
  stringify(modelElementOrFragment, options = {}) {
190
134
  // Model -> view.
@@ -199,11 +143,10 @@ export default class DataController extends EmitterMixin() {
199
143
  * {@link module:engine/view/documentfragment~DocumentFragment view document fragment}.
200
144
  *
201
145
  * @fires toView
202
- * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} modelElementOrFragment
203
- * Element or document fragment whose content will be converted.
204
- * @param {Object} [options={}] Additional configuration that will be available through the
146
+ * @param modelElementOrFragment Element or document fragment whose content will be converted.
147
+ * @param options Additional configuration that will be available through the
205
148
  * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi#options} during the conversion process.
206
- * @returns {module:engine/view/documentfragment~DocumentFragment} Output view DocumentFragment.
149
+ * @returns Output view DocumentFragment.
207
150
  */
208
151
  toView(modelElementOrFragment, options = {}) {
209
152
  const viewDocument = this.viewDocument;
@@ -230,21 +173,25 @@ export default class DataController extends EmitterMixin() {
230
173
  * converted by the {@link #upcastDispatcher view-to-model converters}.
231
174
  * Initial data can be only set to a document whose {@link module:engine/model/document~Document#version} is equal 0.
232
175
  *
233
- * **Note** This method is {@link module:utils/observablemixin~ObservableMixin#decorate decorated} which is
176
+ * **Note** This method is {@link module:utils/observablemixin~Observable#decorate decorated} which is
234
177
  * used by e.g. collaborative editing plugin that syncs remote data on init.
235
178
  *
236
179
  * When data is passed as a string, it is initialized on the default `main` root:
237
180
  *
238
- * dataController.init( '<p>Foo</p>' ); // Initializes data on the `main` root only, as no other is specified.
181
+ * ```ts
182
+ * dataController.init( '<p>Foo</p>' ); // Initializes data on the `main` root only, as no other is specified.
183
+ * ```
239
184
  *
240
185
  * To initialize data on a different root or multiple roots at once, an object containing `rootName` - `data` pairs should be passed:
241
186
  *
242
- * dataController.init( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Initializes data on both the `main` and `title` roots.
187
+ * ```ts
188
+ * dataController.init( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Initializes data on both the `main` and `title` roots.
189
+ * ```
243
190
  *
244
191
  * @fires init
245
- * @param {String|Object.<String,String>} data Input data as a string or an object containing the `rootName` - `data`
192
+ * @param data Input data as a string or an object containing the `rootName` - `data`
246
193
  * pairs to initialize data on multiple roots at once.
247
- * @returns {Promise} Promise that is resolved after the data is set on the editor.
194
+ * @returns Promise that is resolved after the data is set on the editor.
248
195
  */
249
196
  init(data) {
250
197
  if (this.model.document.version) {
@@ -266,11 +213,14 @@ export default class DataController extends EmitterMixin() {
266
213
  }
267
214
  if (!this._checkIfRootsExists(Object.keys(initialData))) {
268
215
  /**
269
- * Cannot init data on a non-existent root. This error is thrown when {@link #init DataController#init() method}
216
+ * Cannot init data on a non-existent root. This error is thrown when
217
+ * {@link module:engine/controller/datacontroller~DataController#init DataController#init() method}
270
218
  * is called with non-existent root name. For example, if there is an editor instance with only `main` root,
271
- * calling {@link #init} like:
219
+ * calling {@link module:engine/controller/datacontroller~DataController#init} like:
272
220
  *
273
- * data.init( { main: '<p>Foo</p>', root2: '<p>Bar</p>' } );
221
+ * ```ts
222
+ * data.init( { main: '<p>Foo</p>', root2: '<p>Bar</p>' } );
223
+ * ```
274
224
  *
275
225
  * will throw this error.
276
226
  *
@@ -297,21 +247,27 @@ export default class DataController extends EmitterMixin() {
297
247
  *
298
248
  * When data is passed as a string it is set on the default `main` root:
299
249
  *
300
- * dataController.set( '<p>Foo</p>' ); // Sets data on the `main` root, as no other is specified.
250
+ * ```ts
251
+ * dataController.set( '<p>Foo</p>' ); // Sets data on the `main` root, as no other is specified.
252
+ * ```
301
253
  *
302
254
  * To set data on a different root or multiple roots at once, an object containing `rootName` - `data` pairs should be passed:
303
255
  *
304
- * dataController.set( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Sets data on the `main` and `title` roots as specified.
256
+ * ```ts
257
+ * dataController.set( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Sets data on the `main` and `title` roots as specified.
258
+ * ```
305
259
  *
306
260
  * To set the data with a preserved undo stack and add the change to the undo stack, set `{ isUndoable: true }` as a `batchType` option.
307
261
  *
308
- * dataController.set( '<p>Foo</p>', { batchType: { isUndoable: true } } );
262
+ * ```ts
263
+ * dataController.set( '<p>Foo</p>', { batchType: { isUndoable: true } } );
264
+ * ```
309
265
  *
310
266
  * @fires set
311
- * @param {String|Object.<String,String>} data Input data as a string or an object containing the `rootName` - `data`
267
+ * @param data Input data as a string or an object containing the `rootName` - `data`
312
268
  * pairs to set data on multiple roots at once.
313
- * @param {Object} [options={}] Options for setting data.
314
- * @param {Object} [options.batchType] The batch type that will be used to create a batch for the changes applied by this method.
269
+ * @param options Options for setting data.
270
+ * @param options.batchType The batch type that will be used to create a batch for the changes applied by this method.
315
271
  * By default, the batch will be set as {@link module:engine/model/batch~Batch#isUndoable not undoable} and the undo stack will be
316
272
  * cleared after the new data is applied (all undo steps will be removed). If the batch type `isUndoable` flag is be set to `true`,
317
273
  * the undo stack will be preserved instead and not cleared when new data is applied.
@@ -326,11 +282,14 @@ export default class DataController extends EmitterMixin() {
326
282
  }
327
283
  if (!this._checkIfRootsExists(Object.keys(newData))) {
328
284
  /**
329
- * Cannot set data on a non-existent root. This error is thrown when the {@link #set DataController#set() method}
285
+ * Cannot set data on a non-existent root. This error is thrown when the
286
+ * {@link module:engine/controller/datacontroller~DataController#set DataController#set() method}
330
287
  * is called with non-existent root name. For example, if there is an editor instance with only the default `main` root,
331
- * calling {@link #set} like:
288
+ * calling {@link module:engine/controller/datacontroller~DataController#set} like:
332
289
  *
333
- * data.set( { main: '<p>Foo</p>', root2: '<p>Bar</p>' } );
290
+ * ```ts
291
+ * data.set( { main: '<p>Foo</p>', root2: '<p>Bar</p>' } );
292
+ * ```
334
293
  *
335
294
  * will throw this error.
336
295
  *
@@ -354,10 +313,10 @@ export default class DataController extends EmitterMixin() {
354
313
  * attached to the {@link #upcastDispatcher}.
355
314
  *
356
315
  * @see #set
357
- * @param {String} data Data to parse.
358
- * @param {module:engine/model/schema~SchemaContextDefinition} [context='$root'] Base context in which the view will
359
- * be converted to the model. See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
360
- * @returns {module:engine/model/documentfragment~DocumentFragment} Parsed data.
316
+ * @param data Data to parse.
317
+ * @param context Base context in which the view will be converted to the model.
318
+ * See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
319
+ * @returns Parsed data.
361
320
  */
362
321
  parse(data, context = '$root') {
363
322
  // data -> view
@@ -374,11 +333,10 @@ export default class DataController extends EmitterMixin() {
374
333
  * {@link module:engine/model/documentfragment~DocumentFragment#markers static markers map}.
375
334
  *
376
335
  * @fires toModel
377
- * @param {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment} viewElementOrFragment
378
- * The element or document fragment whose content will be converted.
379
- * @param {module:engine/model/schema~SchemaContextDefinition} [context='$root'] Base context in which the view will
380
- * be converted to the model. See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
381
- * @returns {module:engine/model/documentfragment~DocumentFragment} Output document fragment.
336
+ * @param viewElementOrFragment The element or document fragment whose content will be converted.
337
+ * @param context Base context in which the view will be converted to the model.
338
+ * See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
339
+ * @returns Output document fragment.
382
340
  */
383
341
  toModel(viewElementOrFragment, context = '$root') {
384
342
  return this.model.change(writer => {
@@ -394,8 +352,6 @@ export default class DataController extends EmitterMixin() {
394
352
  * * border: {@link module:engine/view/styles/border~addBorderRules}
395
353
  * * margin: {@link module:engine/view/styles/margin~addMarginRules}
396
354
  * * padding: {@link module:engine/view/styles/padding~addPaddingRules}
397
- *
398
- * @param {Function} callback
399
355
  */
400
356
  addStyleProcessorRules(callback) {
401
357
  callback(this.stylesProcessor);
@@ -408,8 +364,7 @@ export default class DataController extends EmitterMixin() {
408
364
  * The raw data can be later accessed by the {@link module:engine/view/element~Element#getCustomProperty view element custom property}
409
365
  * `"$rawContent"`.
410
366
  *
411
- * @param {module:engine/view/matcher~MatcherPattern} pattern Pattern matching all view elements whose content should
412
- * be treated as a raw data.
367
+ * @param pattern Pattern matching all view elements whose content should be treated as a raw data.
413
368
  */
414
369
  registerRawContentMatcher(pattern) {
415
370
  // No need to register the pattern if both the `htmlProcessor` and `processor` are the same instances.
@@ -427,9 +382,8 @@ export default class DataController extends EmitterMixin() {
427
382
  /**
428
383
  * Checks whether all provided root names are actually existing editor roots.
429
384
  *
430
- * @private
431
- * @param {Array.<String>} rootNames Root names to check.
432
- * @returns {Boolean} Whether all provided root names are existing editor roots.
385
+ * @param rootNames Root names to check.
386
+ * @returns Whether all provided root names are existing editor roots.
433
387
  */
434
388
  _checkIfRootsExists(rootNames) {
435
389
  for (const rootName of rootNames) {
@@ -440,11 +394,13 @@ export default class DataController extends EmitterMixin() {
440
394
  return true;
441
395
  }
442
396
  }
443
- // Helper function for downcast conversion.
444
- //
445
- // Takes a document element (element that is added to a model document) and checks which markers are inside it. If the marker is collapsed
446
- // at element boundary, it is considered as contained inside the element and marker range is returned. Otherwise, if the marker is
447
- // intersecting with the element, the intersection is returned.
397
+ /**
398
+ * Helper function for downcast conversion.
399
+ *
400
+ * Takes a document element (element that is added to a model document) and checks which markers are inside it. If the marker is collapsed
401
+ * at element boundary, it is considered as contained inside the element and marker range is returned. Otherwise, if the marker is
402
+ * intersecting with the element, the intersection is returned.
403
+ */
448
404
  function _getMarkersRelativeToElement(element) {
449
405
  const result = [];
450
406
  const doc = element.root.document;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import View from '../view/view';
6
+ import Mapper from '../conversion/mapper';
7
+ import DowncastDispatcher from '../conversion/downcastdispatcher';
8
+ import type { default as Model } from '../model/model';
9
+ import type ModelItem from '../model/item';
10
+ import type { Marker } from '../model/markercollection';
11
+ import type { StylesProcessor } from '../view/stylesmap';
12
+ declare const EditingController_base: {
13
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
14
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
15
+ };
16
+ /**
17
+ * A controller for the editing pipeline. The editing pipeline controls the {@link ~EditingController#model model} rendering,
18
+ * including selection handling. It also creates the {@link ~EditingController#view view} which builds a
19
+ * browser-independent virtualization over the DOM elements. The editing controller also attaches default converters.
20
+ */
21
+ export default class EditingController extends EditingController_base {
22
+ /**
23
+ * Editor model.
24
+ */
25
+ readonly model: Model;
26
+ /**
27
+ * Editing view controller.
28
+ */
29
+ readonly view: View;
30
+ /**
31
+ * A mapper that describes the model-view binding.
32
+ */
33
+ readonly mapper: Mapper;
34
+ /**
35
+ * Downcast dispatcher that converts changes from the model to the {@link #view editing view}.
36
+ */
37
+ readonly downcastDispatcher: DowncastDispatcher;
38
+ /**
39
+ * Creates an editing controller instance.
40
+ *
41
+ * @param model Editing model.
42
+ * @param stylesProcessor The styles processor instance.
43
+ */
44
+ constructor(model: Model, stylesProcessor: StylesProcessor);
45
+ /**
46
+ * Removes all event listeners attached to the `EditingController`. Destroys all objects created
47
+ * by `EditingController` that need to be destroyed.
48
+ */
49
+ destroy(): void;
50
+ /**
51
+ * Calling this method will refresh the marker by triggering the downcast conversion for it.
52
+ *
53
+ * Reconverting the marker is useful when you want to change its {@link module:engine/view/element~Element view element}
54
+ * without changing any marker data. For instance:
55
+ *
56
+ * ```ts
57
+ * let isCommentActive = false;
58
+ *
59
+ * model.conversion.markerToHighlight( {
60
+ * model: 'comment',
61
+ * view: data => {
62
+ * const classes = [ 'comment-marker' ];
63
+ *
64
+ * if ( isCommentActive ) {
65
+ * classes.push( 'comment-marker--active' );
66
+ * }
67
+ *
68
+ * return { classes };
69
+ * }
70
+ * } );
71
+ *
72
+ * // ...
73
+ *
74
+ * // Change the property that indicates if marker is displayed as active or not.
75
+ * isCommentActive = true;
76
+ *
77
+ * // Reconverting will downcast and synchronize the marker with the new isCommentActive state value.
78
+ * editor.editing.reconvertMarker( 'comment' );
79
+ * ```
80
+ *
81
+ * **Note**: If you want to reconvert a model item, use {@link #reconvertItem} instead.
82
+ *
83
+ * @param markerOrName Name of a marker to update, or a marker instance.
84
+ */
85
+ reconvertMarker(markerOrName: Marker | string): void;
86
+ /**
87
+ * Calling this method will downcast a model item on demand (by requesting a refresh in the {@link module:engine/model/differ~Differ}).
88
+ *
89
+ * You can use it if you want the view representation of a specific item updated as a response to external modifications. For instance,
90
+ * when the view structure depends not only on the associated model data but also on some external state.
91
+ *
92
+ * **Note**: If you want to reconvert a model marker, use {@link #reconvertMarker} instead.
93
+ *
94
+ * @param item Item to refresh.
95
+ */
96
+ reconvertItem(item: ModelItem): void;
97
+ }
98
+ export {};
@@ -17,45 +17,19 @@ import { convertSelectionChange } from '../conversion/upcasthelpers';
17
17
  * A controller for the editing pipeline. The editing pipeline controls the {@link ~EditingController#model model} rendering,
18
18
  * including selection handling. It also creates the {@link ~EditingController#view view} which builds a
19
19
  * browser-independent virtualization over the DOM elements. The editing controller also attaches default converters.
20
- *
21
- * @mixes module:utils/observablemixin~ObservableMixin
22
20
  */
23
21
  export default class EditingController extends ObservableMixin() {
24
22
  /**
25
23
  * Creates an editing controller instance.
26
24
  *
27
- * @param {module:engine/model/model~Model} model Editing model.
28
- * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
25
+ * @param model Editing model.
26
+ * @param stylesProcessor The styles processor instance.
29
27
  */
30
28
  constructor(model, stylesProcessor) {
31
29
  super();
32
- /**
33
- * Editor model.
34
- *
35
- * @readonly
36
- * @member {module:engine/model/model~Model}
37
- */
38
30
  this.model = model;
39
- /**
40
- * Editing view controller.
41
- *
42
- * @readonly
43
- * @member {module:engine/view/view~View}
44
- */
45
31
  this.view = new View(stylesProcessor);
46
- /**
47
- * A mapper that describes the model-view binding.
48
- *
49
- * @readonly
50
- * @member {module:engine/conversion/mapper~Mapper}
51
- */
52
32
  this.mapper = new Mapper();
53
- /**
54
- * Downcast dispatcher that converts changes from the model to the {@link #view editing view}.
55
- *
56
- * @readonly
57
- * @member {module:engine/conversion/downcastdispatcher~DowncastDispatcher} #downcastDispatcher
58
- */
59
33
  this.downcastDispatcher = new DowncastDispatcher({
60
34
  mapper: this.mapper,
61
35
  schema: model.schema
@@ -128,32 +102,34 @@ export default class EditingController extends ObservableMixin() {
128
102
  * Reconverting the marker is useful when you want to change its {@link module:engine/view/element~Element view element}
129
103
  * without changing any marker data. For instance:
130
104
  *
131
- * let isCommentActive = false;
105
+ * ```ts
106
+ * let isCommentActive = false;
132
107
  *
133
- * model.conversion.markerToHighlight( {
134
- * model: 'comment',
135
- * view: data => {
136
- * const classes = [ 'comment-marker' ];
108
+ * model.conversion.markerToHighlight( {
109
+ * model: 'comment',
110
+ * view: data => {
111
+ * const classes = [ 'comment-marker' ];
137
112
  *
138
- * if ( isCommentActive ) {
139
- * classes.push( 'comment-marker--active' );
140
- * }
113
+ * if ( isCommentActive ) {
114
+ * classes.push( 'comment-marker--active' );
115
+ * }
141
116
  *
142
- * return { classes };
143
- * }
144
- * } );
117
+ * return { classes };
118
+ * }
119
+ * } );
145
120
  *
146
- * // ...
121
+ * // ...
147
122
  *
148
- * // Change the property that indicates if marker is displayed as active or not.
149
- * isCommentActive = true;
123
+ * // Change the property that indicates if marker is displayed as active or not.
124
+ * isCommentActive = true;
150
125
  *
151
- * // Reconverting will downcast and synchronize the marker with the new isCommentActive state value.
152
- * editor.editing.reconvertMarker( 'comment' );
126
+ * // Reconverting will downcast and synchronize the marker with the new isCommentActive state value.
127
+ * editor.editing.reconvertMarker( 'comment' );
128
+ * ```
153
129
  *
154
130
  * **Note**: If you want to reconvert a model item, use {@link #reconvertItem} instead.
155
131
  *
156
- * @param {String|module:engine/model/markercollection~Marker} markerOrName Name of a marker to update, or a marker instance.
132
+ * @param markerOrName Name of a marker to update, or a marker instance.
157
133
  */
158
134
  reconvertMarker(markerOrName) {
159
135
  const markerName = typeof markerOrName == 'string' ? markerOrName : markerOrName.name;
@@ -179,7 +155,7 @@ export default class EditingController extends ObservableMixin() {
179
155
  *
180
156
  * **Note**: If you want to reconvert a model marker, use {@link #reconvertMarker} instead.
181
157
  *
182
- * @param {module:engine/model/item~Item} item Item to refresh.
158
+ * @param item Item to refresh.
183
159
  */
184
160
  reconvertItem(item) {
185
161
  this.model.change(() => {