@ckeditor/ckeditor5-engine 48.2.0 → 48.3.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 (129) hide show
  1. package/dist/controller/datacontroller.d.ts +329 -328
  2. package/dist/controller/editingcontroller.d.ts +95 -94
  3. package/dist/conversion/comparemarkers.d.ts +45 -45
  4. package/dist/conversion/conversion.d.ts +474 -474
  5. package/dist/conversion/conversionhelpers.d.ts +21 -21
  6. package/dist/conversion/downcastdispatcher.d.ts +539 -538
  7. package/dist/conversion/downcasthelpers.d.ts +1129 -1129
  8. package/dist/conversion/mapper.d.ts +692 -697
  9. package/dist/conversion/modelconsumable.d.ts +196 -196
  10. package/dist/conversion/upcastdispatcher.d.ts +483 -482
  11. package/dist/conversion/upcasthelpers.d.ts +491 -491
  12. package/dist/conversion/viewconsumable.d.ts +330 -330
  13. package/dist/dataprocessor/basichtmlwriter.d.ts +15 -15
  14. package/dist/dataprocessor/dataprocessor.d.ts +57 -57
  15. package/dist/dataprocessor/htmldataprocessor.d.ts +72 -72
  16. package/dist/dataprocessor/htmlwriter.d.ts +11 -11
  17. package/dist/dataprocessor/xmldataprocessor.d.ts +86 -86
  18. package/dist/dev-utils/model.d.ts +128 -123
  19. package/dist/dev-utils/operationreplayer.d.ts +49 -49
  20. package/dist/dev-utils/utils.d.ts +33 -33
  21. package/dist/dev-utils/view.d.ts +314 -309
  22. package/dist/engineconfig.d.ts +39 -39
  23. package/dist/index.css.map +1 -1
  24. package/dist/index.d.ts +150 -150
  25. package/dist/index.js +34026 -40107
  26. package/dist/index.js.map +1 -1
  27. package/dist/legacyerrors.d.ts +0 -4
  28. package/dist/model/batch.d.ts +86 -86
  29. package/dist/model/differ.d.ts +504 -504
  30. package/dist/model/document.d.ts +265 -268
  31. package/dist/model/documentfragment.d.ts +214 -214
  32. package/dist/model/documentselection.d.ts +406 -410
  33. package/dist/model/element.d.ts +182 -182
  34. package/dist/model/history.d.ts +109 -109
  35. package/dist/model/item.d.ts +9 -9
  36. package/dist/model/liveposition.d.ts +70 -69
  37. package/dist/model/liverange.d.ts +93 -92
  38. package/dist/model/markercollection.d.ts +317 -324
  39. package/dist/model/model.d.ts +889 -909
  40. package/dist/model/node.d.ts +254 -254
  41. package/dist/model/nodelist.d.ts +110 -110
  42. package/dist/model/operation/attributeoperation.d.ts +98 -98
  43. package/dist/model/operation/detachoperation.d.ts +57 -57
  44. package/dist/model/operation/insertoperation.d.ts +85 -85
  45. package/dist/model/operation/markeroperation.d.ts +87 -87
  46. package/dist/model/operation/mergeoperation.d.ts +95 -95
  47. package/dist/model/operation/moveoperation.d.ts +97 -97
  48. package/dist/model/operation/nooperation.d.ts +33 -33
  49. package/dist/model/operation/operation.d.ts +94 -94
  50. package/dist/model/operation/operationfactory.d.ts +14 -14
  51. package/dist/model/operation/renameoperation.d.ts +78 -78
  52. package/dist/model/operation/rootattributeoperation.d.ts +93 -93
  53. package/dist/model/operation/rootoperation.d.ts +71 -71
  54. package/dist/model/operation/splitoperation.d.ts +104 -104
  55. package/dist/model/operation/transform.d.ts +91 -91
  56. package/dist/model/operation/utils.d.ts +58 -58
  57. package/dist/model/position.d.ts +535 -535
  58. package/dist/model/range.d.ts +458 -453
  59. package/dist/model/rootelement.d.ts +55 -55
  60. package/dist/model/schema.d.ts +1325 -1327
  61. package/dist/model/selection.d.ts +452 -471
  62. package/dist/model/text.d.ts +62 -62
  63. package/dist/model/textproxy.d.ts +140 -140
  64. package/dist/model/treewalker.d.ts +190 -190
  65. package/dist/model/typecheckable.d.ts +281 -281
  66. package/dist/model/utils/autoparagraphing.d.ts +29 -29
  67. package/dist/model/utils/deletecontent.d.ts +68 -68
  68. package/dist/model/utils/getselectedcontent.d.ts +27 -27
  69. package/dist/model/utils/insertcontent.d.ts +42 -42
  70. package/dist/model/utils/insertobject.d.ts +41 -41
  71. package/dist/model/utils/modifyselection.d.ts +44 -44
  72. package/dist/model/utils/selection-post-fixer.d.ts +71 -71
  73. package/dist/model/writer.d.ts +854 -854
  74. package/dist/view/attributeelement.d.ts +123 -123
  75. package/dist/view/containerelement.d.ts +49 -49
  76. package/dist/view/datatransfer.d.ts +70 -70
  77. package/dist/view/document.d.ts +175 -177
  78. package/dist/view/documentfragment.d.ts +158 -157
  79. package/dist/view/documentselection.d.ts +308 -307
  80. package/dist/view/domconverter.d.ts +612 -657
  81. package/dist/view/downcastwriter.d.ts +1006 -1006
  82. package/dist/view/editableelement.d.ts +64 -63
  83. package/dist/view/element.d.ts +754 -754
  84. package/dist/view/elementdefinition.d.ts +79 -79
  85. package/dist/view/emptyelement.d.ts +42 -42
  86. package/dist/view/filler.d.ts +75 -75
  87. package/dist/view/item.d.ts +9 -9
  88. package/dist/view/matcher.d.ts +412 -487
  89. package/dist/view/node.d.ts +164 -163
  90. package/dist/view/observer/arrowkeysobserver.d.ts +37 -37
  91. package/dist/view/observer/bubblingemittermixin.d.ts +163 -153
  92. package/dist/view/observer/bubblingeventinfo.d.ts +45 -42
  93. package/dist/view/observer/clickobserver.d.ts +36 -36
  94. package/dist/view/observer/compositionobserver.d.ts +67 -67
  95. package/dist/view/observer/domeventdata.d.ts +46 -46
  96. package/dist/view/observer/domeventobserver.d.ts +77 -74
  97. package/dist/view/observer/fakeselectionobserver.d.ts +42 -42
  98. package/dist/view/observer/focusobserver.d.ts +84 -84
  99. package/dist/view/observer/inputobserver.d.ts +76 -76
  100. package/dist/view/observer/keyobserver.d.ts +53 -53
  101. package/dist/view/observer/mouseobserver.d.ts +73 -73
  102. package/dist/view/observer/mutationobserver.d.ts +101 -101
  103. package/dist/view/observer/observer.d.ts +84 -83
  104. package/dist/view/observer/pointerobserver.d.ts +63 -63
  105. package/dist/view/observer/selectionobserver.d.ts +136 -136
  106. package/dist/view/observer/tabobserver.d.ts +38 -38
  107. package/dist/view/observer/touchobserver.d.ts +60 -60
  108. package/dist/view/placeholder.d.ts +80 -80
  109. package/dist/view/position.d.ts +187 -187
  110. package/dist/view/range.d.ts +282 -282
  111. package/dist/view/rawelement.d.ts +72 -72
  112. package/dist/view/renderer.d.ts +270 -272
  113. package/dist/view/rooteditableelement.d.ts +43 -43
  114. package/dist/view/selection.d.ts +356 -369
  115. package/dist/view/styles/background.d.ts +15 -15
  116. package/dist/view/styles/border.d.ts +27 -27
  117. package/dist/view/styles/margin.d.ts +12 -12
  118. package/dist/view/styles/padding.d.ts +12 -12
  119. package/dist/view/styles/utils.d.ts +72 -72
  120. package/dist/view/stylesmap.d.ts +715 -715
  121. package/dist/view/text.d.ts +75 -75
  122. package/dist/view/textproxy.d.ts +92 -92
  123. package/dist/view/tokenlist.d.ts +104 -104
  124. package/dist/view/treewalker.d.ts +201 -201
  125. package/dist/view/typecheckable.d.ts +445 -445
  126. package/dist/view/uielement.d.ts +93 -93
  127. package/dist/view/upcastwriter.d.ts +412 -412
  128. package/dist/view/view.d.ts +466 -469
  129. package/package.json +2 -2
@@ -1,350 +1,351 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- import { Mapper } from '../conversion/mapper.js';
6
- import { DowncastDispatcher } from '../conversion/downcastdispatcher.js';
7
- import { UpcastDispatcher } from '../conversion/upcastdispatcher.js';
8
- import { ViewDocumentFragment } from '../view/documentfragment.js';
9
- import { ViewDocument } from '../view/document.js';
10
- import { type ViewElement } from '../view/element.js';
11
- import type { StylesProcessor } from '../view/stylesmap.js';
12
- import type { MatcherPattern } from '../view/matcher.js';
13
- import { type Model } from '../model/model.js';
14
- import { type ModelElement } from '../model/element.js';
15
- import { type ModelDocumentFragment } from '../model/documentfragment.js';
16
- import type { ModelSchemaContextDefinition } from '../model/schema.js';
17
- import type { BatchType } from '../model/batch.js';
18
- import { HtmlDataProcessor } from '../dataprocessor/htmldataprocessor.js';
19
- import { type DataProcessor } from '../dataprocessor/dataprocessor.js';
20
- declare const DataController_base: {
21
- new (): import("@ckeditor/ckeditor5-utils").Emitter;
22
- prototype: import("@ckeditor/ckeditor5-utils").Emitter;
23
- };
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module engine/controller/datacontroller
7
+ */
8
+ import { type EmitterMixinConstructor } from "@ckeditor/ckeditor5-utils";
9
+ import { Mapper } from "../conversion/mapper.js";
10
+ import { DowncastDispatcher } from "../conversion/downcastdispatcher.js";
11
+ import { UpcastDispatcher } from "../conversion/upcastdispatcher.js";
12
+ import { ViewDocumentFragment } from "../view/documentfragment.js";
13
+ import { ViewDocument } from "../view/document.js";
14
+ import { type ViewElement } from "../view/element.js";
15
+ import type { StylesProcessor } from "../view/stylesmap.js";
16
+ import type { MatcherPattern } from "../view/matcher.js";
17
+ import { type Model } from "../model/model.js";
18
+ import { type ModelElement } from "../model/element.js";
19
+ import { type ModelDocumentFragment } from "../model/documentfragment.js";
20
+ import type { ModelSchemaContextDefinition } from "../model/schema.js";
21
+ import type { BatchType } from "../model/batch.js";
22
+ import { HtmlDataProcessor } from "../dataprocessor/htmldataprocessor.js";
23
+ import { type DataProcessor } from "../dataprocessor/dataprocessor.js";
24
+ declare const DataControllerBase: EmitterMixinConstructor;
24
25
  /**
25
- * Controller for the data pipeline. The data pipeline controls how data is retrieved from the document
26
- * and set inside it. Hence, the controller features two methods which allow to {@link ~DataController#get get}
27
- * and {@link ~DataController#set set} data of the {@link ~DataController#model model}
28
- * using the given:
29
- *
30
- * * {@link module:engine/dataprocessor/dataprocessor~DataProcessor data processor},
31
- * * downcast converters,
32
- * * upcast converters.
33
- *
34
- * An instance of the data controller is always available in the {@link module:core/editor/editor~Editor#data `editor.data`}
35
- * property:
36
- *
37
- * ```ts
38
- * editor.data.get( { rootName: 'customRoot' } ); // -> '<p>Hello!</p>'
39
- * ```
40
- */
41
- export declare class DataController extends /* #__PURE__ */ DataController_base {
42
- /**
43
- * Data model.
44
- */
45
- readonly model: Model;
46
- /**
47
- * Mapper used for the conversion. It has no permanent bindings, because these are created while getting data and
48
- * are cleared directly after the data are converted. However, the mapper is defined as a class property, because
49
- * it needs to be passed to the `DowncastDispatcher` as a conversion API.
50
- */
51
- readonly mapper: Mapper;
52
- /**
53
- * Downcast dispatcher used by the {@link #get get method}. Downcast converters should be attached to it.
54
- */
55
- readonly downcastDispatcher: DowncastDispatcher;
56
- /**
57
- * Upcast dispatcher used by the {@link #set set method}. Upcast converters should be attached to it.
58
- */
59
- readonly upcastDispatcher: UpcastDispatcher;
60
- /**
61
- * The view document used by the data controller.
62
- */
63
- readonly viewDocument: ViewDocument;
64
- /**
65
- * Styles processor used during the conversion.
66
- */
67
- readonly stylesProcessor: StylesProcessor;
68
- /**
69
- * Data processor used specifically for HTML conversion.
70
- */
71
- readonly htmlProcessor: HtmlDataProcessor;
72
- /**
73
- * Data processor used during the conversion.
74
- * Same instance as {@link #htmlProcessor} by default. Can be replaced at run time to handle different format, e.g. XML or Markdown.
75
- */
76
- processor: DataProcessor;
77
- /**
78
- * The view downcast writer just for data conversion purposes, i.e. to modify
79
- * the {@link #viewDocument}.
80
- */
81
- private readonly _viewWriter;
82
- /**
83
- * Creates a data controller instance.
84
- *
85
- * @param model Data model.
86
- * @param stylesProcessor The styles processor instance.
87
- */
88
- constructor(model: Model, stylesProcessor: StylesProcessor);
89
- /**
90
- * Returns the model's data converted by downcast dispatchers attached to {@link #downcastDispatcher} and
91
- * formatted by the {@link #processor data processor}.
92
- *
93
- * A warning is logged when you try to retrieve data for a detached root, as most probably this is a mistake. A detached root should
94
- * be treated like it is removed, and you should not save its data. Note, that the detached root data is always an empty string.
95
- *
96
- * @fires get
97
- * @param options Additional configuration for the retrieved data. `DataController` provides two optional
98
- * properties: `rootName` and `trim`. Other properties of this object are specified by various editor features.
99
- * @param options.rootName Root name. Default 'main'.
100
- * @param options.trim Whether returned data should be trimmed. This option is set to `empty` by default,
101
- * which means whenever editor content is considered empty, an empty string will be returned. To turn off trimming completely
102
- * use `'none'`. In such cases the exact content will be returned (for example a `<p>&nbsp;</p>` for an empty editor).
103
- * @returns Output data.
104
- */
105
- get(options?: {
106
- rootName?: string;
107
- trim?: 'empty' | 'none';
108
- [key: string]: unknown;
109
- }): string;
110
- /**
111
- * Returns the content of the given {@link module:engine/model/element~ModelElement model's element} or
112
- * {@link module:engine/model/documentfragment~ModelDocumentFragment model document fragment} converted by the downcast converters
113
- * attached to the {@link #downcastDispatcher} and formatted by the {@link #processor data processor}.
114
- *
115
- * @param modelElementOrFragment The element whose content will be stringified.
116
- * @param options Additional configuration passed to the conversion process.
117
- * @returns Output data.
118
- */
119
- stringify(modelElementOrFragment: ModelElement | ModelDocumentFragment, options?: Record<string, unknown>): string;
120
- /**
121
- * Returns the content of the given {@link module:engine/model/element~ModelElement model element} or
122
- * {@link module:engine/model/documentfragment~ModelDocumentFragment model document fragment} converted by the downcast
123
- * converters attached to {@link #downcastDispatcher} into a
124
- * {@link module:engine/view/documentfragment~ViewDocumentFragment view document fragment}.
125
- *
126
- * @fires toView
127
- * @param modelElementOrFragment Element or document fragment whose content will be converted.
128
- * @param options Additional configuration that will be available through the
129
- * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi#options} during the conversion process.
130
- * @returns Output view ModelDocumentFragment.
131
- */
132
- toView(modelElementOrFragment: ModelElement | ModelDocumentFragment, options?: Record<string, unknown>): ViewDocumentFragment;
133
- /**
134
- * Sets the initial input data parsed by the {@link #processor data processor} and
135
- * converted by the {@link #upcastDispatcher view-to-model converters}.
136
- * Initial data can be only set to a document whose {@link module:engine/model/document~ModelDocument#version} is equal 0.
137
- *
138
- * **Note** This method is {@link module:utils/observablemixin~Observable#decorate decorated} which is
139
- * used by e.g. collaborative editing plugin that syncs remote data on init.
140
- *
141
- * When data is passed as a string, it is initialized on the default `main` root:
142
- *
143
- * ```ts
144
- * dataController.init( '<p>Foo</p>' ); // Initializes data on the `main` root only, as no other is specified.
145
- * ```
146
- *
147
- * To initialize data on a different root or multiple roots at once, an object containing `rootName` - `data` pairs should be passed:
148
- *
149
- * ```ts
150
- * dataController.init( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Initializes data on both the `main` and `title` roots.
151
- * ```
152
- *
153
- * @fires init
154
- * @param data Input data as a string or an object containing the `rootName` - `data`
155
- * pairs to initialize data on multiple roots at once.
156
- * @returns Promise that is resolved after the data is set on the editor.
157
- */
158
- init(data: string | Record<string, string>): Promise<void>;
159
- /**
160
- * Sets the input data parsed by the {@link #processor data processor} and
161
- * converted by the {@link #upcastDispatcher view-to-model converters}.
162
- * This method can be used any time to replace existing editor data with the new one without clearing the
163
- * {@link module:engine/model/document~ModelDocument#history document history}.
164
- *
165
- * This method also creates a batch with all the changes applied. If all you need is to parse data, use
166
- * the {@link #parse} method.
167
- *
168
- * When data is passed as a string it is set on the default `main` root:
169
- *
170
- * ```ts
171
- * dataController.set( '<p>Foo</p>' ); // Sets data on the `main` root, as no other is specified.
172
- * ```
173
- *
174
- * To set data on a different root or multiple roots at once, an object containing `rootName` - `data` pairs should be passed:
175
- *
176
- * ```ts
177
- * dataController.set( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Sets data on the `main` and `title` roots as specified.
178
- * ```
179
- *
180
- * To set the data with a preserved undo stack and add the change to the undo stack, set `{ isUndoable: true }` as a `batchType` option.
181
- *
182
- * ```ts
183
- * dataController.set( '<p>Foo</p>', { batchType: { isUndoable: true } } );
184
- * ```
185
- *
186
- * @fires set
187
- * @param data Input data as a string or an object containing the `rootName` - `data`
188
- * pairs to set data on multiple roots at once.
189
- * @param options Options for setting data.
190
- * @param options.batchType The batch type that will be used to create a batch for the changes applied by this method.
191
- * By default, the batch will be set as {@link module:engine/model/batch~Batch#isUndoable not undoable} and the undo stack will be
192
- * cleared after the new data is applied (all undo steps will be removed). If the batch type `isUndoable` flag is be set to `true`,
193
- * the undo stack will be preserved instead and not cleared when new data is applied.
194
- */
195
- set(data: string | Record<string, string>, options?: {
196
- batchType?: BatchType;
197
- [key: string]: unknown;
198
- }): void;
199
- /**
200
- * Returns the data parsed by the {@link #processor data processor} and then converted by upcast converters
201
- * attached to the {@link #upcastDispatcher}.
202
- *
203
- * **Note:** The default `context` value is `'$root'`, which only matches the generic root. When the editor uses a
204
- * custom root {@link module:core/editor/editorconfig~RootConfig#modelElement `modelElement`}, pass the target
205
- * {@link module:engine/model/rootelement~ModelRootElement root element} (or its configured model element name)
206
- * explicitly, otherwise the conversion result may be wrong.
207
- * See the {@glink framework/deep-dive/schema#custom-root-elements Custom root elements} section of the
208
- * {@glink framework/deep-dive/schema Schema deep-dive} guide for more details.
209
- *
210
- * @see #set
211
- * @param data Data to parse.
212
- * @param context Base context in which the view will be converted to the model.
213
- * See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
214
- * @returns Parsed data.
215
- */
216
- parse(data: string, context?: ModelSchemaContextDefinition): ModelDocumentFragment;
217
- /**
218
- * Returns the result of the given {@link module:engine/view/element~ViewElement view element} or
219
- * {@link module:engine/view/documentfragment~ViewDocumentFragment view document fragment} converted by the
220
- * {@link #upcastDispatcher view-to-model converters}, wrapped by {@link module:engine/model/documentfragment~ModelDocumentFragment}.
221
- *
222
- * When marker elements were converted during the conversion process, it will be set as a document fragment's
223
- * {@link module:engine/model/documentfragment~ModelDocumentFragment#markers static markers map}.
224
- *
225
- * **Note:** The default `context` value is `'$root'`, which only matches the generic root. When the editor uses a
226
- * custom root {@link module:core/editor/editorconfig~RootConfig#modelElement `modelElement`}, pass the target
227
- * {@link module:engine/model/rootelement~ModelRootElement root element} (or its configured model element name)
228
- * explicitly, otherwise the conversion result may be wrong.
229
- * See the {@glink framework/deep-dive/schema#custom-root-elements Custom root elements} section of the
230
- * {@glink framework/deep-dive/schema Schema deep-dive} guide for more details.
231
- *
232
- * @fires toModel
233
- * @param viewElementOrFragment The element or document fragment whose content will be converted.
234
- * @param context Base context in which the view will be converted to the model.
235
- * See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
236
- * @returns Output document fragment.
237
- */
238
- toModel(viewElementOrFragment: ViewElement | ViewDocumentFragment, context?: ModelSchemaContextDefinition): ModelDocumentFragment;
239
- /**
240
- * Adds the style processor normalization rules.
241
- *
242
- * You can implement your own rules as well as use one of the available processor rules:
243
- *
244
- * * background: {@link module:engine/view/styles/background~addBackgroundStylesRules}
245
- * * border: {@link module:engine/view/styles/border~addBorderStylesRules}
246
- * * margin: {@link module:engine/view/styles/margin~addMarginStylesRules}
247
- * * padding: {@link module:engine/view/styles/padding~addPaddingStylesRules}
248
- */
249
- addStyleProcessorRules(callback: (stylesProcessor: StylesProcessor) => void): void;
250
- /**
251
- * Registers a {@link module:engine/view/matcher~MatcherPattern} on an {@link #htmlProcessor htmlProcessor}
252
- * and a {@link #processor processor} for view elements whose content should be treated as raw data
253
- * and not processed during the conversion from DOM to view elements.
254
- *
255
- * The raw data can be later accessed by the
256
- * {@link module:engine/view/element~ViewElement#getCustomProperty view element custom property}
257
- * `"$rawContent"`.
258
- *
259
- * @param pattern Pattern matching all view elements whose content should be treated as a raw data.
260
- */
261
- registerRawContentMatcher(pattern: MatcherPattern): void;
262
- /**
263
- * Removes all event listeners set by the DataController.
264
- */
265
- destroy(): void;
266
- /**
267
- * Checks whether all provided root names are actually existing editor roots.
268
- *
269
- * @param rootNames Root names to check.
270
- * @returns Whether all provided root names are existing editor roots.
271
- */
272
- private _checkIfRootsExists;
26
+ * Controller for the data pipeline. The data pipeline controls how data is retrieved from the document
27
+ * and set inside it. Hence, the controller features two methods which allow to {@link ~DataController#get get}
28
+ * and {@link ~DataController#set set} data of the {@link ~DataController#model model}
29
+ * using the given:
30
+ *
31
+ * * {@link module:engine/dataprocessor/dataprocessor~DataProcessor data processor},
32
+ * * downcast converters,
33
+ * * upcast converters.
34
+ *
35
+ * An instance of the data controller is always available in the {@link module:core/editor/editor~Editor#data `editor.data`}
36
+ * property:
37
+ *
38
+ * ```ts
39
+ * editor.data.get( { rootName: 'customRoot' } ); // -> '<p>Hello!</p>'
40
+ * ```
41
+ */
42
+ export declare class DataController extends DataControllerBase {
43
+ /**
44
+ * Data model.
45
+ */
46
+ readonly model: Model;
47
+ /**
48
+ * Mapper used for the conversion. It has no permanent bindings, because these are created while getting data and
49
+ * are cleared directly after the data are converted. However, the mapper is defined as a class property, because
50
+ * it needs to be passed to the `DowncastDispatcher` as a conversion API.
51
+ */
52
+ readonly mapper: Mapper;
53
+ /**
54
+ * Downcast dispatcher used by the {@link #get get method}. Downcast converters should be attached to it.
55
+ */
56
+ readonly downcastDispatcher: DowncastDispatcher;
57
+ /**
58
+ * Upcast dispatcher used by the {@link #set set method}. Upcast converters should be attached to it.
59
+ */
60
+ readonly upcastDispatcher: UpcastDispatcher;
61
+ /**
62
+ * The view document used by the data controller.
63
+ */
64
+ readonly viewDocument: ViewDocument;
65
+ /**
66
+ * Styles processor used during the conversion.
67
+ */
68
+ readonly stylesProcessor: StylesProcessor;
69
+ /**
70
+ * Data processor used specifically for HTML conversion.
71
+ */
72
+ readonly htmlProcessor: HtmlDataProcessor;
73
+ /**
74
+ * Data processor used during the conversion.
75
+ * Same instance as {@link #htmlProcessor} by default. Can be replaced at run time to handle different format, e.g. XML or Markdown.
76
+ */
77
+ processor: DataProcessor;
78
+ /**
79
+ * The view downcast writer just for data conversion purposes, i.e. to modify
80
+ * the {@link #viewDocument}.
81
+ */
82
+ private readonly _viewWriter;
83
+ /**
84
+ * Creates a data controller instance.
85
+ *
86
+ * @param model Data model.
87
+ * @param stylesProcessor The styles processor instance.
88
+ */
89
+ constructor(model: Model, stylesProcessor: StylesProcessor);
90
+ /**
91
+ * Returns the model's data converted by downcast dispatchers attached to {@link #downcastDispatcher} and
92
+ * formatted by the {@link #processor data processor}.
93
+ *
94
+ * A warning is logged when you try to retrieve data for a detached root, as most probably this is a mistake. A detached root should
95
+ * be treated like it is removed, and you should not save its data. Note, that the detached root data is always an empty string.
96
+ *
97
+ * @fires get
98
+ * @param options Additional configuration for the retrieved data. `DataController` provides two optional
99
+ * properties: `rootName` and `trim`. Other properties of this object are specified by various editor features.
100
+ * @param options.rootName Root name. Default 'main'.
101
+ * @param options.trim Whether returned data should be trimmed. This option is set to `empty` by default,
102
+ * which means whenever editor content is considered empty, an empty string will be returned. To turn off trimming completely
103
+ * use `'none'`. In such cases the exact content will be returned (for example a `<p>&nbsp;</p>` for an empty editor).
104
+ * @returns Output data.
105
+ */
106
+ get(options?: {
107
+ rootName?: string;
108
+ trim?: "empty" | "none";
109
+ [key: string]: unknown;
110
+ }): string;
111
+ /**
112
+ * Returns the content of the given {@link module:engine/model/element~ModelElement model's element} or
113
+ * {@link module:engine/model/documentfragment~ModelDocumentFragment model document fragment} converted by the downcast converters
114
+ * attached to the {@link #downcastDispatcher} and formatted by the {@link #processor data processor}.
115
+ *
116
+ * @param modelElementOrFragment The element whose content will be stringified.
117
+ * @param options Additional configuration passed to the conversion process.
118
+ * @returns Output data.
119
+ */
120
+ stringify(modelElementOrFragment: ModelElement | ModelDocumentFragment, options?: Record<string, unknown>): string;
121
+ /**
122
+ * Returns the content of the given {@link module:engine/model/element~ModelElement model element} or
123
+ * {@link module:engine/model/documentfragment~ModelDocumentFragment model document fragment} converted by the downcast
124
+ * converters attached to {@link #downcastDispatcher} into a
125
+ * {@link module:engine/view/documentfragment~ViewDocumentFragment view document fragment}.
126
+ *
127
+ * @fires toView
128
+ * @param modelElementOrFragment Element or document fragment whose content will be converted.
129
+ * @param options Additional configuration that will be available through the
130
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi#options} during the conversion process.
131
+ * @returns Output view ModelDocumentFragment.
132
+ */
133
+ toView(modelElementOrFragment: ModelElement | ModelDocumentFragment, options?: Record<string, unknown>): ViewDocumentFragment;
134
+ /**
135
+ * Sets the initial input data parsed by the {@link #processor data processor} and
136
+ * converted by the {@link #upcastDispatcher view-to-model converters}.
137
+ * Initial data can be only set to a document whose {@link module:engine/model/document~ModelDocument#version} is equal 0.
138
+ *
139
+ * **Note** This method is {@link module:utils/observablemixin~Observable#decorate decorated} which is
140
+ * used by e.g. collaborative editing plugin that syncs remote data on init.
141
+ *
142
+ * When data is passed as a string, it is initialized on the default `main` root:
143
+ *
144
+ * ```ts
145
+ * dataController.init( '<p>Foo</p>' ); // Initializes data on the `main` root only, as no other is specified.
146
+ * ```
147
+ *
148
+ * To initialize data on a different root or multiple roots at once, an object containing `rootName` - `data` pairs should be passed:
149
+ *
150
+ * ```ts
151
+ * dataController.init( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Initializes data on both the `main` and `title` roots.
152
+ * ```
153
+ *
154
+ * @fires init
155
+ * @param data Input data as a string or an object containing the `rootName` - `data`
156
+ * pairs to initialize data on multiple roots at once.
157
+ * @returns Promise that is resolved after the data is set on the editor.
158
+ */
159
+ init(data: string | Record<string, string>): Promise<void>;
160
+ /**
161
+ * Sets the input data parsed by the {@link #processor data processor} and
162
+ * converted by the {@link #upcastDispatcher view-to-model converters}.
163
+ * This method can be used any time to replace existing editor data with the new one without clearing the
164
+ * {@link module:engine/model/document~ModelDocument#history document history}.
165
+ *
166
+ * This method also creates a batch with all the changes applied. If all you need is to parse data, use
167
+ * the {@link #parse} method.
168
+ *
169
+ * When data is passed as a string it is set on the default `main` root:
170
+ *
171
+ * ```ts
172
+ * dataController.set( '<p>Foo</p>' ); // Sets data on the `main` root, as no other is specified.
173
+ * ```
174
+ *
175
+ * To set data on a different root or multiple roots at once, an object containing `rootName` - `data` pairs should be passed:
176
+ *
177
+ * ```ts
178
+ * dataController.set( { main: '<p>Foo</p>', title: '<h1>Bar</h1>' } ); // Sets data on the `main` and `title` roots as specified.
179
+ * ```
180
+ *
181
+ * To set the data with a preserved undo stack and add the change to the undo stack, set `{ isUndoable: true }` as a `batchType` option.
182
+ *
183
+ * ```ts
184
+ * dataController.set( '<p>Foo</p>', { batchType: { isUndoable: true } } );
185
+ * ```
186
+ *
187
+ * @fires set
188
+ * @param data Input data as a string or an object containing the `rootName` - `data`
189
+ * pairs to set data on multiple roots at once.
190
+ * @param options Options for setting data.
191
+ * @param options.batchType The batch type that will be used to create a batch for the changes applied by this method.
192
+ * By default, the batch will be set as {@link module:engine/model/batch~Batch#isUndoable not undoable} and the undo stack will be
193
+ * cleared after the new data is applied (all undo steps will be removed). If the batch type `isUndoable` flag is be set to `true`,
194
+ * the undo stack will be preserved instead and not cleared when new data is applied.
195
+ */
196
+ set(data: string | Record<string, string>, options?: {
197
+ batchType?: BatchType;
198
+ [key: string]: unknown;
199
+ }): void;
200
+ /**
201
+ * Returns the data parsed by the {@link #processor data processor} and then converted by upcast converters
202
+ * attached to the {@link #upcastDispatcher}.
203
+ *
204
+ * **Note:** The default `context` value is `'$root'`, which only matches the generic root. When the editor uses a
205
+ * custom root {@link module:core/editor/editorconfig~RootConfig#modelElement `modelElement`}, pass the target
206
+ * {@link module:engine/model/rootelement~ModelRootElement root element} (or its configured model element name)
207
+ * explicitly, otherwise the conversion result may be wrong.
208
+ * See the {@glink framework/deep-dive/schema#custom-root-elements Custom root elements} section of the
209
+ * {@glink framework/deep-dive/schema Schema deep-dive} guide for more details.
210
+ *
211
+ * @see #set
212
+ * @param data Data to parse.
213
+ * @param context Base context in which the view will be converted to the model.
214
+ * See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
215
+ * @returns Parsed data.
216
+ */
217
+ parse(data: string, context?: ModelSchemaContextDefinition): ModelDocumentFragment;
218
+ /**
219
+ * Returns the result of the given {@link module:engine/view/element~ViewElement view element} or
220
+ * {@link module:engine/view/documentfragment~ViewDocumentFragment view document fragment} converted by the
221
+ * {@link #upcastDispatcher view-to-model converters}, wrapped by {@link module:engine/model/documentfragment~ModelDocumentFragment}.
222
+ *
223
+ * When marker elements were converted during the conversion process, it will be set as a document fragment's
224
+ * {@link module:engine/model/documentfragment~ModelDocumentFragment#markers static markers map}.
225
+ *
226
+ * **Note:** The default `context` value is `'$root'`, which only matches the generic root. When the editor uses a
227
+ * custom root {@link module:core/editor/editorconfig~RootConfig#modelElement `modelElement`}, pass the target
228
+ * {@link module:engine/model/rootelement~ModelRootElement root element} (or its configured model element name)
229
+ * explicitly, otherwise the conversion result may be wrong.
230
+ * See the {@glink framework/deep-dive/schema#custom-root-elements Custom root elements} section of the
231
+ * {@glink framework/deep-dive/schema Schema deep-dive} guide for more details.
232
+ *
233
+ * @fires toModel
234
+ * @param viewElementOrFragment The element or document fragment whose content will be converted.
235
+ * @param context Base context in which the view will be converted to the model.
236
+ * See: {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#convert}.
237
+ * @returns Output document fragment.
238
+ */
239
+ toModel(viewElementOrFragment: ViewElement | ViewDocumentFragment, context?: ModelSchemaContextDefinition): ModelDocumentFragment;
240
+ /**
241
+ * Adds the style processor normalization rules.
242
+ *
243
+ * You can implement your own rules as well as use one of the available processor rules:
244
+ *
245
+ * * background: {@link module:engine/view/styles/background~addBackgroundStylesRules}
246
+ * * border: {@link module:engine/view/styles/border~addBorderStylesRules}
247
+ * * margin: {@link module:engine/view/styles/margin~addMarginStylesRules}
248
+ * * padding: {@link module:engine/view/styles/padding~addPaddingStylesRules}
249
+ */
250
+ addStyleProcessorRules(callback: (stylesProcessor: StylesProcessor) => void): void;
251
+ /**
252
+ * Registers a {@link module:engine/view/matcher~MatcherPattern} on an {@link #htmlProcessor htmlProcessor}
253
+ * and a {@link #processor processor} for view elements whose content should be treated as raw data
254
+ * and not processed during the conversion from DOM to view elements.
255
+ *
256
+ * The raw data can be later accessed by the
257
+ * {@link module:engine/view/element~ViewElement#getCustomProperty view element custom property}
258
+ * `"$rawContent"`.
259
+ *
260
+ * @param pattern Pattern matching all view elements whose content should be treated as a raw data.
261
+ */
262
+ registerRawContentMatcher(pattern: MatcherPattern): void;
263
+ /**
264
+ * Removes all event listeners set by the DataController.
265
+ */
266
+ destroy(): void;
267
+ /**
268
+ * Checks whether all provided root names are actually existing editor roots.
269
+ *
270
+ * @param rootNames Root names to check.
271
+ * @returns Whether all provided root names are existing editor roots.
272
+ */
273
+ private _checkIfRootsExists;
273
274
  }
274
275
  /**
275
- * Event fired once the data initialization has finished.
276
- *
277
- * @eventName ~DataController#ready
278
- */
276
+ * Event fired once the data initialization has finished.
277
+ *
278
+ * @eventName ~DataController#ready
279
+ */
279
280
  export type DataControllerReadyEvent = {
280
- name: 'ready';
281
- args: [];
281
+ name: "ready";
282
+ args: [];
282
283
  };
283
284
  /**
284
- * An event fired after the {@link ~DataController#init `init()` method} was run. It can be {@link ~DataController#listenTo listened to} in
285
- * order to adjust or modify the initialization flow. However, if the `init` event is stopped or prevented,
286
- * the {@link ~DataController#event:ready `ready` event} should be fired manually.
287
- *
288
- * The `init` event is fired by the decorated {@link ~DataController#init} method.
289
- * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
290
- *
291
- * @eventName ~DataController#init
292
- */
285
+ * An event fired after the {@link ~DataController#init `init()` method} was run. It can be {@link ~DataController#listenTo listened to} in
286
+ * order to adjust or modify the initialization flow. However, if the `init` event is stopped or prevented,
287
+ * the {@link ~DataController#event:ready `ready` event} should be fired manually.
288
+ *
289
+ * The `init` event is fired by the decorated {@link ~DataController#init} method.
290
+ * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
291
+ *
292
+ * @eventName ~DataController#init
293
+ */
293
294
  export type DataControllerInitEvent = {
294
- name: 'init';
295
- args: [Parameters<DataController['init']>];
296
- return: ReturnType<DataController['init']>;
295
+ name: "init";
296
+ args: [Parameters<DataController["init"]>];
297
+ return: ReturnType<DataController["init"]>;
297
298
  };
298
299
  /**
299
- * An event fired after {@link ~DataController#set set() method} has been run.
300
- *
301
- * The `set` event is fired by the decorated {@link ~DataController#set} method.
302
- * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
303
- *
304
- * @eventName ~DataController#set
305
- */
300
+ * An event fired after {@link ~DataController#set set() method} has been run.
301
+ *
302
+ * The `set` event is fired by the decorated {@link ~DataController#set} method.
303
+ * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
304
+ *
305
+ * @eventName ~DataController#set
306
+ */
306
307
  export type DataControllerSetEvent = {
307
- name: 'set';
308
- args: [Parameters<DataController['set']>];
309
- return: ReturnType<DataController['set']>;
308
+ name: "set";
309
+ args: [Parameters<DataController["set"]>];
310
+ return: ReturnType<DataController["set"]>;
310
311
  };
311
312
  /**
312
- * Event fired after the {@link ~DataController#get get() method} has been run.
313
- *
314
- * The `get` event is fired by the decorated {@link ~DataController#get} method.
315
- * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
316
- *
317
- * @eventName ~DataController#get
318
- */
313
+ * Event fired after the {@link ~DataController#get get() method} has been run.
314
+ *
315
+ * The `get` event is fired by the decorated {@link ~DataController#get} method.
316
+ * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
317
+ *
318
+ * @eventName ~DataController#get
319
+ */
319
320
  export type DataControllerGetEvent = {
320
- name: 'get';
321
- args: [Parameters<DataController['get']>];
322
- return: ReturnType<DataController['get']>;
321
+ name: "get";
322
+ args: [Parameters<DataController["get"]>];
323
+ return: ReturnType<DataController["get"]>;
323
324
  };
324
325
  /**
325
- * Event fired after the {@link ~DataController#toView toView() method} has been run.
326
- *
327
- * The `toView` event is fired by the decorated {@link ~DataController#toView} method.
328
- * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
329
- *
330
- * @eventName ~DataController#toView
331
- */
326
+ * Event fired after the {@link ~DataController#toView toView() method} has been run.
327
+ *
328
+ * The `toView` event is fired by the decorated {@link ~DataController#toView} method.
329
+ * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
330
+ *
331
+ * @eventName ~DataController#toView
332
+ */
332
333
  export type DataControllerToViewEvent = {
333
- name: 'toView';
334
- args: [Parameters<DataController['toView']>];
335
- return: ReturnType<DataController['toView']>;
334
+ name: "toView";
335
+ args: [Parameters<DataController["toView"]>];
336
+ return: ReturnType<DataController["toView"]>;
336
337
  };
337
338
  /**
338
- * Event fired after the {@link ~DataController#toModel toModel() method} has been run.
339
- *
340
- * The `toModel` event is fired by the decorated {@link ~DataController#toModel} method.
341
- * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
342
- *
343
- * @eventName ~DataController#toModel
344
- */
339
+ * Event fired after the {@link ~DataController#toModel toModel() method} has been run.
340
+ *
341
+ * The `toModel` event is fired by the decorated {@link ~DataController#toModel} method.
342
+ * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
343
+ *
344
+ * @eventName ~DataController#toModel
345
+ */
345
346
  export type DataControllerToModelEvent = {
346
- name: 'toModel';
347
- args: [Parameters<DataController['toModel']>];
348
- return: ReturnType<DataController['toModel']>;
347
+ name: "toModel";
348
+ args: [Parameters<DataController["toModel"]>];
349
+ return: ReturnType<DataController["toModel"]>;
349
350
  };
350
351
  export {};