@ckeditor/ckeditor5-engine 48.8.1-alpha.3 → 49.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 (135) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/controller/datacontroller.d.ts +329 -314
  3. package/dist/controller/editingcontroller.d.ts +95 -94
  4. package/dist/conversion/comparemarkers.d.ts +45 -45
  5. package/dist/conversion/conversion.d.ts +474 -474
  6. package/dist/conversion/conversionhelpers.d.ts +21 -21
  7. package/dist/conversion/downcastdispatcher.d.ts +539 -538
  8. package/dist/conversion/downcasthelpers.d.ts +1129 -1129
  9. package/dist/conversion/mapper.d.ts +692 -697
  10. package/dist/conversion/modelconsumable.d.ts +196 -196
  11. package/dist/conversion/upcastdispatcher.d.ts +483 -475
  12. package/dist/conversion/upcasthelpers.d.ts +491 -491
  13. package/dist/conversion/viewconsumable.d.ts +330 -330
  14. package/dist/dataprocessor/basichtmlwriter.d.ts +15 -15
  15. package/dist/dataprocessor/dataprocessor.d.ts +57 -57
  16. package/dist/dataprocessor/htmldataprocessor.d.ts +72 -72
  17. package/dist/dataprocessor/htmlwriter.d.ts +11 -11
  18. package/dist/dataprocessor/xmldataprocessor.d.ts +86 -86
  19. package/dist/dev-utils/model.d.ts +128 -116
  20. package/dist/dev-utils/operationreplayer.d.ts +49 -49
  21. package/dist/dev-utils/utils.d.ts +33 -33
  22. package/dist/dev-utils/view.d.ts +314 -309
  23. package/dist/engineconfig.d.ts +39 -39
  24. package/dist/index-content.css +3 -0
  25. package/dist/index-content.css.map +1 -0
  26. package/dist/index-editor.css +33 -29
  27. package/dist/index-editor.css.map +1 -0
  28. package/dist/index.css +26 -24
  29. package/dist/index.css.map +1 -1
  30. package/dist/index.d.ts +152 -150
  31. package/dist/index.js +34246 -40050
  32. package/dist/index.js.map +1 -1
  33. package/dist/legacyerrors.d.ts +0 -4
  34. package/dist/model/batch.d.ts +86 -86
  35. package/dist/model/differ.d.ts +504 -504
  36. package/dist/model/document.d.ts +265 -262
  37. package/dist/model/documentfragment.d.ts +214 -214
  38. package/dist/model/documentselection.d.ts +412 -410
  39. package/dist/model/element.d.ts +182 -182
  40. package/dist/model/history.d.ts +109 -109
  41. package/dist/model/item.d.ts +9 -9
  42. package/dist/model/liveposition.d.ts +81 -69
  43. package/dist/model/liverange.d.ts +118 -92
  44. package/dist/model/markercollection.d.ts +317 -324
  45. package/dist/model/model.d.ts +889 -909
  46. package/dist/model/node.d.ts +254 -254
  47. package/dist/model/nodelist.d.ts +110 -110
  48. package/dist/model/operation/attributeoperation.d.ts +98 -98
  49. package/dist/model/operation/detachoperation.d.ts +57 -57
  50. package/dist/model/operation/insertoperation.d.ts +85 -85
  51. package/dist/model/operation/markeroperation.d.ts +87 -87
  52. package/dist/model/operation/mergeoperation.d.ts +95 -95
  53. package/dist/model/operation/moveoperation.d.ts +97 -91
  54. package/dist/model/operation/nooperation.d.ts +33 -33
  55. package/dist/model/operation/operation.d.ts +94 -94
  56. package/dist/model/operation/operationfactory.d.ts +14 -14
  57. package/dist/model/operation/renameoperation.d.ts +78 -78
  58. package/dist/model/operation/rootattributeoperation.d.ts +93 -93
  59. package/dist/model/operation/rootoperation.d.ts +71 -71
  60. package/dist/model/operation/splitoperation.d.ts +104 -104
  61. package/dist/model/operation/transform.d.ts +91 -91
  62. package/dist/model/operation/utils.d.ts +58 -58
  63. package/dist/model/position.d.ts +542 -535
  64. package/dist/model/range.d.ts +467 -453
  65. package/dist/model/rootelement.d.ts +55 -55
  66. package/dist/model/schema.d.ts +1325 -1327
  67. package/dist/model/selection.d.ts +452 -471
  68. package/dist/model/text.d.ts +62 -62
  69. package/dist/model/textproxy.d.ts +140 -140
  70. package/dist/model/treewalker.d.ts +190 -190
  71. package/dist/model/typecheckable.d.ts +281 -281
  72. package/dist/model/utils/autoparagraphing.d.ts +29 -29
  73. package/dist/model/utils/deletecontent.d.ts +68 -68
  74. package/dist/model/utils/getselectedcontent.d.ts +27 -27
  75. package/dist/model/utils/insertcontent.d.ts +42 -42
  76. package/dist/model/utils/insertobject.d.ts +41 -41
  77. package/dist/model/utils/modifyselection.d.ts +44 -44
  78. package/dist/model/utils/selection-post-fixer.d.ts +71 -71
  79. package/dist/model/writer.d.ts +857 -848
  80. package/dist/view/attributeelement.d.ts +123 -123
  81. package/dist/view/containerelement.d.ts +49 -49
  82. package/dist/view/datatransfer.d.ts +70 -70
  83. package/dist/view/document.d.ts +175 -177
  84. package/dist/view/documentfragment.d.ts +158 -157
  85. package/dist/view/documentselection.d.ts +308 -307
  86. package/dist/view/domconverter.d.ts +614 -658
  87. package/dist/view/downcastwriter.d.ts +1012 -1006
  88. package/dist/view/editableelement.d.ts +64 -63
  89. package/dist/view/element.d.ts +754 -754
  90. package/dist/view/elementdefinition.d.ts +79 -79
  91. package/dist/view/emptyelement.d.ts +42 -42
  92. package/dist/view/filler.d.ts +75 -75
  93. package/dist/view/item.d.ts +9 -9
  94. package/dist/view/matcher.d.ts +412 -487
  95. package/dist/view/node.d.ts +164 -163
  96. package/dist/view/observer/arrowkeysobserver.d.ts +37 -37
  97. package/dist/view/observer/bubblingemittermixin.d.ts +163 -153
  98. package/dist/view/observer/bubblingeventinfo.d.ts +45 -42
  99. package/dist/view/observer/clickobserver.d.ts +36 -36
  100. package/dist/view/observer/compositionobserver.d.ts +67 -67
  101. package/dist/view/observer/domeventdata.d.ts +46 -46
  102. package/dist/view/observer/domeventobserver.d.ts +77 -74
  103. package/dist/view/observer/fakeselectionobserver.d.ts +42 -42
  104. package/dist/view/observer/focusobserver.d.ts +84 -84
  105. package/dist/view/observer/inputobserver.d.ts +76 -76
  106. package/dist/view/observer/keyobserver.d.ts +53 -53
  107. package/dist/view/observer/mouseobserver.d.ts +73 -73
  108. package/dist/view/observer/mutationobserver.d.ts +101 -101
  109. package/dist/view/observer/observer.d.ts +84 -83
  110. package/dist/view/observer/pointerobserver.d.ts +63 -63
  111. package/dist/view/observer/selectionobserver.d.ts +141 -137
  112. package/dist/view/observer/tabobserver.d.ts +38 -38
  113. package/dist/view/observer/touchobserver.d.ts +60 -60
  114. package/dist/view/placeholder.d.ts +77 -81
  115. package/dist/view/position.d.ts +187 -187
  116. package/dist/view/range.d.ts +282 -282
  117. package/dist/view/rawelement.d.ts +72 -72
  118. package/dist/view/renderer.d.ts +282 -273
  119. package/dist/view/rooteditableelement.d.ts +43 -43
  120. package/dist/view/selection.d.ts +356 -369
  121. package/dist/view/styles/background.d.ts +15 -15
  122. package/dist/view/styles/border.d.ts +27 -27
  123. package/dist/view/styles/margin.d.ts +12 -12
  124. package/dist/view/styles/padding.d.ts +12 -12
  125. package/dist/view/styles/utils.d.ts +72 -72
  126. package/dist/view/stylesmap.d.ts +715 -715
  127. package/dist/view/text.d.ts +75 -75
  128. package/dist/view/textproxy.d.ts +92 -92
  129. package/dist/view/tokenlist.d.ts +104 -104
  130. package/dist/view/treewalker.d.ts +201 -201
  131. package/dist/view/typecheckable.d.ts +445 -445
  132. package/dist/view/uielement.d.ts +93 -93
  133. package/dist/view/upcastwriter.d.ts +412 -412
  134. package/dist/view/view.d.ts +466 -468
  135. package/package.json +3 -3
@@ -1,272 +1,275 @@
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
- */
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
5
  /**
6
- * @module engine/model/document
7
- */
8
- import { Differ } from './differ.js';
9
- import { ModelDocumentSelection } from './documentselection.js';
10
- import { History } from './history.js';
11
- import { ModelRootElement } from './rootelement.js';
12
- import type { Model } from './model.js';
13
- import { type Batch } from './batch.js';
14
- import { type ModelRange } from './range.js';
15
- import { type ModelWriter } from './writer.js';
16
- import { Collection } from '@ckeditor/ckeditor5-utils';
17
- declare const ModelDocument_base: {
18
- new (): import("@ckeditor/ckeditor5-utils").Emitter;
19
- prototype: import("@ckeditor/ckeditor5-utils").Emitter;
20
- };
6
+ * @module engine/model/document
7
+ */
8
+ import { Differ } from "./differ.js";
9
+ import { ModelDocumentSelection } from "./documentselection.js";
10
+ import { History } from "./history.js";
11
+ import { ModelRootElement } from "./rootelement.js";
12
+ import type { Model } from "./model.js";
13
+ import { type Batch } from "./batch.js";
14
+ import { type ModelRange } from "./range.js";
15
+ import { type ModelWriter } from "./writer.js";
16
+ import { Collection, type EmitterMixinConstructor } from "@ckeditor/ckeditor5-utils";
17
+ declare const ModelDocumentBase: EmitterMixinConstructor;
21
18
  /**
22
- * Data model's document. It contains the model's structure, its selection and the history of changes.
23
- *
24
- * Read more about working with the model in
25
- * {@glink framework/architecture/editing-engine#model introduction to the the editing engine's architecture}.
26
- *
27
- * Usually, the document contains just one {@link module:engine/model/document~ModelDocument#roots root element}, so
28
- * you can retrieve it by just calling {@link module:engine/model/document~ModelDocument#getRoot} without specifying its name:
29
- *
30
- * ```ts
31
- * model.document.getRoot(); // -> returns the main root
32
- * ```
33
- *
34
- * However, the document may contain multiple roots – e.g. when the editor has multiple editable areas
35
- * (e.g. a title and a body of a message).
36
- */
37
- export declare class ModelDocument extends /* #__PURE__ */ ModelDocument_base {
38
- /**
39
- * The {@link module:engine/model/model~Model model} that the document is a part of.
40
- */
41
- readonly model: Model;
42
- /**
43
- * The document's history.
44
- */
45
- readonly history: History;
46
- /**
47
- * The selection in this document.
48
- */
49
- readonly selection: ModelDocumentSelection;
50
- /**
51
- * A list of roots that are owned and managed by this document. Use {@link #createRoot}, {@link #getRoot} and
52
- * {@link #getRootNames} to manipulate it.
53
- */
54
- readonly roots: Collection<ModelRootElement>;
55
- /**
56
- * The model differ object. Its role is to buffer changes done on the model document and then calculate a diff of those changes.
57
- */
58
- readonly differ: Differ;
59
- /**
60
- * Defines whether the document is in a read-only mode.
61
- *
62
- * The user should not be able to change the data of a document that is read-only.
63
- *
64
- * @readonly
65
- */
66
- isReadOnly: boolean;
67
- /**
68
- * Post-fixer callbacks registered to the model document.
69
- */
70
- private readonly _postFixers;
71
- /**
72
- * A flag that indicates whether the selection has changed since last change block.
73
- */
74
- private _hasSelectionChangedFromTheLastChangeBlock;
75
- /**
76
- * Creates an empty document instance with no {@link #roots} (other than
77
- * the {@link #graveyard graveyard root}).
78
- */
79
- constructor(model: Model);
80
- /**
81
- * The document version. Every applied operation increases the version number. It is used to
82
- * ensure that operations are applied on a proper document version.
83
- *
84
- * This property is equal to {@link module:engine/model/history~History#version `model.Document#history#version`}.
85
- *
86
- * If the {@link module:engine/model/operation/operation~Operation#baseVersion base version} does not match the document version,
87
- * a {@link module:utils/ckeditorerror~CKEditorError model-document-applyoperation-wrong-version} error is thrown.
88
- */
89
- get version(): number;
90
- set version(version: number);
91
- /**
92
- * The graveyard tree root. A document always has a graveyard root that stores removed nodes.
93
- */
94
- get graveyard(): ModelRootElement;
95
- /**
96
- * Creates a new root.
97
- *
98
- * **Note:** do not use this method after the editor has been initialized! If you want to dynamically add a root, use
99
- * {@link module:engine/model/writer~ModelWriter#addRoot `model.Writer#addRoot`} instead.
100
- *
101
- * @param elementName The element name. Defaults to `'$root'` which also has some basic schema defined
102
- * (e.g. `$block` elements are allowed inside the `$root`). Make sure to define a proper schema if you use a different name.
103
- * @param rootName A unique root name.
104
- * @returns The created root.
105
- */
106
- createRoot(elementName?: string, rootName?: string): ModelRootElement;
107
- /**
108
- * Removes all event listeners set by the document instance.
109
- */
110
- destroy(): void;
111
- /**
112
- * Returns a root by its name.
113
- *
114
- * Detached roots are returned by this method. This is to be able to operate on the detached root (for example, to be able to create
115
- * a position inside such a root for undo feature purposes).
116
- *
117
- * @param name The root name of the root to return.
118
- * @returns The root registered under a given name or `null` when there is no root with the given name.
119
- */
120
- getRoot(name?: string): ModelRootElement | null;
121
- /**
122
- * Returns an array with names of all roots added to the document (except the {@link #graveyard graveyard root}).
123
- *
124
- * Detached roots **are not** returned by this method by default. This is to make sure that all features or algorithms that operate
125
- * on the document data know which roots are still a part of the document and should be processed.
126
- *
127
- * @param includeDetached Specified whether detached roots should be returned as well.
128
- */
129
- getRootNames(includeDetached?: boolean): Array<string>;
130
- /**
131
- * Returns an array with all roots added to the document (except the {@link #graveyard graveyard root}).
132
- *
133
- * Detached roots **are not** returned by this method by default. This is to make sure that all features or algorithms that operate
134
- * on the document data know which roots are still a part of the document and should be processed.
135
- *
136
- * @param includeDetached Specified whether detached roots should be returned as well.
137
- */
138
- getRoots(includeDetached?: boolean): Array<ModelRootElement>;
139
- /**
140
- * Used to register a post-fixer callback. A post-fixer mechanism guarantees that the features
141
- * will operate on a correct model state.
142
- *
143
- * An execution of a feature may lead to an incorrect document tree state. The callbacks are used to fix the document tree after
144
- * it has changed. Post-fixers are fired just after all changes from the outermost change block were applied but
145
- * before the {@link module:engine/model/document~ModelDocument#event:change change event} is fired. If a post-fixer callback made
146
- * a change, it should return `true`. When this happens, all post-fixers are fired again to check if something else should
147
- * not be fixed in the new document tree state.
148
- *
149
- * As a parameter, a post-fixer callback receives a {@link module:engine/model/writer~ModelWriter writer} instance connected with the
150
- * executed changes block. Thanks to that, all changes done by the callback will be added to the same
151
- * {@link module:engine/model/batch~Batch batch} (and undo step) as the original changes. This makes post-fixer changes transparent
152
- * for the user.
153
- *
154
- * An example of a post-fixer is a callback that checks if all the data were removed from the editor. If so, the
155
- * callback should add an empty paragraph so that the editor is never empty:
156
- *
157
- * ```ts
158
- * document.registerPostFixer( writer => {
159
- * const changes = document.differ.getChanges();
160
- *
161
- * // Check if the changes lead to an empty root in the editor.
162
- * for ( const entry of changes ) {
163
- * if ( entry.type == 'remove' && entry.position.root.isEmpty ) {
164
- * writer.insertElement( 'paragraph', entry.position.root, 0 );
165
- *
166
- * // It is fine to return early, even if multiple roots would need to be fixed.
167
- * // All post-fixers will be fired again, so if there are more empty roots, those will be fixed, too.
168
- * return true;
169
- * }
170
- * }
171
- *
172
- * return false;
173
- * } );
174
- * ```
175
- */
176
- registerPostFixer(postFixer: ModelPostFixer): void;
177
- /**
178
- * A custom `toJSON()` method to solve child-parent circular dependencies.
179
- *
180
- * @returns A clone of this object with the document property changed to a string.
181
- */
182
- toJSON(): unknown;
183
- /**
184
- * Check if there were any changes done on document, and if so, call post-fixers,
185
- * fire `change` event for features and conversion and then reset the differ.
186
- * Fire `change:data` event when at least one operation or buffered marker changes the data.
187
- *
188
- * @internal
189
- * @fires change
190
- * @fires change:data
191
- * @param writer The writer on which post-fixers will be called.
192
- */
193
- _handleChangeBlock(writer: ModelWriter): void;
194
- /**
195
- * Returns whether there is a buffered change or if the selection has changed from the last
196
- * {@link module:engine/model/model~Model#enqueueChange `enqueueChange()` block}
197
- * or {@link module:engine/model/model~Model#change `change()` block}.
198
- *
199
- * @returns Returns `true` if document has changed from the last `change()` or `enqueueChange()` block.
200
- */
201
- protected _hasDocumentChangedFromTheLastChangeBlock(): boolean;
202
- /**
203
- * Returns the default root for this document which is either the first root that was added to the document using
204
- * {@link #createRoot} or the {@link #graveyard graveyard root} if no other roots were created.
205
- *
206
- * @returns The default root for this document.
207
- */
208
- protected _getDefaultRoot(): ModelRootElement;
209
- /**
210
- * Returns the default range for this selection. The default range is a collapsed range that starts and ends
211
- * at the beginning of this selection's document {@link #_getDefaultRoot default root}.
212
- *
213
- * @internal
214
- */
215
- _getDefaultRange(): ModelRange;
216
- /**
217
- * Checks whether a given {@link module:engine/model/range~ModelRange range} is a valid range for
218
- * the {@link #selection document's selection}.
219
- *
220
- * @internal
221
- * @param range A range to check.
222
- * @returns `true` if `range` is valid, `false` otherwise.
223
- */
224
- _validateSelectionRange(range: ModelRange): boolean;
225
- /**
226
- * Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
227
- *
228
- * @param writer The writer on which post-fixer callbacks will be called.
229
- */
230
- private _callPostFixers;
19
+ * Data model's document. It contains the model's structure, its selection and the history of changes.
20
+ *
21
+ * Read more about working with the model in
22
+ * {@glink framework/architecture/editing-engine#model introduction to the the editing engine's architecture}.
23
+ *
24
+ * Usually, the document contains just one {@link module:engine/model/document~ModelDocument#roots root element}, so
25
+ * you can retrieve it by just calling {@link module:engine/model/document~ModelDocument#getRoot} without specifying its name:
26
+ *
27
+ * ```ts
28
+ * model.document.getRoot(); // -> returns the main root
29
+ * ```
30
+ *
31
+ * However, the document may contain multiple roots – e.g. when the editor has multiple editable areas
32
+ * (e.g. a title and a body of a message).
33
+ */
34
+ export declare class ModelDocument extends ModelDocumentBase {
35
+ /**
36
+ * The {@link module:engine/model/model~Model model} that the document is a part of.
37
+ */
38
+ readonly model: Model;
39
+ /**
40
+ * The document's history.
41
+ */
42
+ readonly history: History;
43
+ /**
44
+ * The selection in this document.
45
+ */
46
+ readonly selection: ModelDocumentSelection;
47
+ /**
48
+ * A list of roots that are owned and managed by this document. Use {@link #createRoot}, {@link #getRoot} and
49
+ * {@link #getRootNames} to manipulate it.
50
+ */
51
+ readonly roots: Collection<ModelRootElement>;
52
+ /**
53
+ * The model differ object. Its role is to buffer changes done on the model document and then calculate a diff of those changes.
54
+ */
55
+ readonly differ: Differ;
56
+ /**
57
+ * Defines whether the document is in a read-only mode.
58
+ *
59
+ * The user should not be able to change the data of a document that is read-only.
60
+ *
61
+ * @readonly
62
+ */
63
+ isReadOnly: boolean;
64
+ /**
65
+ * Post-fixer callbacks registered to the model document.
66
+ */
67
+ private readonly _postFixers;
68
+ /**
69
+ * A flag that indicates whether the selection has changed since last change block.
70
+ */
71
+ private _hasSelectionChangedFromTheLastChangeBlock;
72
+ /**
73
+ * Creates an empty document instance with no {@link #roots} (other than
74
+ * the {@link #graveyard graveyard root}).
75
+ */
76
+ constructor(model: Model);
77
+ /**
78
+ * The document version. Every applied operation increases the version number. It is used to
79
+ * ensure that operations are applied on a proper document version.
80
+ *
81
+ * This property is equal to {@link module:engine/model/history~History#version `model.Document#history#version`}.
82
+ *
83
+ * If the {@link module:engine/model/operation/operation~Operation#baseVersion base version} does not match the document version,
84
+ * a {@link module:utils/ckeditorerror~CKEditorError model-document-applyoperation-wrong-version} error is thrown.
85
+ */
86
+ get version(): number;
87
+ set version(version: number);
88
+ /**
89
+ * The graveyard tree root. A document always has a graveyard root that stores removed nodes.
90
+ */
91
+ get graveyard(): ModelRootElement;
92
+ /**
93
+ * Creates a new root.
94
+ *
95
+ * **Note:** do not use this method after the editor has been initialized! If you want to dynamically add a root, use
96
+ * {@link module:engine/model/writer~ModelWriter#addRoot `model.Writer#addRoot`} instead.
97
+ *
98
+ * **Note:** The default `elementName` value is `'$root'`. When the editor uses a custom root
99
+ * {@link module:core/editor/editorconfig~RootConfig#modelElement `modelElement`}, pass the configured model element
100
+ * name explicitly so the created root matches the schema the features expect.
101
+ * See the {@glink framework/deep-dive/schema#custom-root-elements Custom root elements} section of the
102
+ * {@glink framework/deep-dive/schema Schema deep-dive} guide for more details.
103
+ *
104
+ * @param elementName The element name. Defaults to `'$root'` which also has some basic schema defined
105
+ * (e.g. `$block` elements are allowed inside the `$root`). Make sure to define a proper schema if you use a different name.
106
+ * @param rootName A unique root name.
107
+ * @returns The created root.
108
+ */
109
+ createRoot(elementName?: string, rootName?: string): ModelRootElement;
110
+ /**
111
+ * Removes all event listeners set by the document instance.
112
+ */
113
+ destroy(): void;
114
+ /**
115
+ * Returns a root by its name.
116
+ *
117
+ * Detached roots are returned by this method. This is to be able to operate on the detached root (for example, to be able to create
118
+ * a position inside such a root for undo feature purposes).
119
+ *
120
+ * @param name The root name of the root to return.
121
+ * @returns The root registered under a given name or `null` when there is no root with the given name.
122
+ */
123
+ getRoot(name?: string): ModelRootElement | null;
124
+ /**
125
+ * Returns an array with names of all roots added to the document (except the {@link #graveyard graveyard root}).
126
+ *
127
+ * Detached roots **are not** returned by this method by default. This is to make sure that all features or algorithms that operate
128
+ * on the document data know which roots are still a part of the document and should be processed.
129
+ *
130
+ * @param includeDetached Specified whether detached roots should be returned as well.
131
+ */
132
+ getRootNames(includeDetached?: boolean): Array<string>;
133
+ /**
134
+ * Returns an array with all roots added to the document (except the {@link #graveyard graveyard root}).
135
+ *
136
+ * Detached roots **are not** returned by this method by default. This is to make sure that all features or algorithms that operate
137
+ * on the document data know which roots are still a part of the document and should be processed.
138
+ *
139
+ * @param includeDetached Specified whether detached roots should be returned as well.
140
+ */
141
+ getRoots(includeDetached?: boolean): Array<ModelRootElement>;
142
+ /**
143
+ * Used to register a post-fixer callback. A post-fixer mechanism guarantees that the features
144
+ * will operate on a correct model state.
145
+ *
146
+ * An execution of a feature may lead to an incorrect document tree state. The callbacks are used to fix the document tree after
147
+ * it has changed. Post-fixers are fired just after all changes from the outermost change block were applied but
148
+ * before the {@link module:engine/model/document~ModelDocument#event:change change event} is fired. If a post-fixer callback made
149
+ * a change, it should return `true`. When this happens, all post-fixers are fired again to check if something else should
150
+ * not be fixed in the new document tree state.
151
+ *
152
+ * As a parameter, a post-fixer callback receives a {@link module:engine/model/writer~ModelWriter writer} instance connected with the
153
+ * executed changes block. Thanks to that, all changes done by the callback will be added to the same
154
+ * {@link module:engine/model/batch~Batch batch} (and undo step) as the original changes. This makes post-fixer changes transparent
155
+ * for the user.
156
+ *
157
+ * An example of a post-fixer is a callback that checks if all the data were removed from the editor. If so, the
158
+ * callback should add an empty paragraph so that the editor is never empty:
159
+ *
160
+ * ```ts
161
+ * document.registerPostFixer( writer => {
162
+ * const changes = document.differ.getChanges();
163
+ *
164
+ * // Check if the changes lead to an empty root in the editor.
165
+ * for ( const entry of changes ) {
166
+ * if ( entry.type == 'remove' && entry.position.root.isEmpty ) {
167
+ * writer.insertElement( 'paragraph', entry.position.root, 0 );
168
+ *
169
+ * // It is fine to return early, even if multiple roots would need to be fixed.
170
+ * // All post-fixers will be fired again, so if there are more empty roots, those will be fixed, too.
171
+ * return true;
172
+ * }
173
+ * }
174
+ *
175
+ * return false;
176
+ * } );
177
+ * ```
178
+ */
179
+ registerPostFixer(postFixer: ModelPostFixer): void;
180
+ /**
181
+ * A custom `toJSON()` method to solve child-parent circular dependencies.
182
+ *
183
+ * @returns A clone of this object with the document property changed to a string.
184
+ */
185
+ toJSON(): unknown;
186
+ /**
187
+ * Check if there were any changes done on document, and if so, call post-fixers,
188
+ * fire `change` event for features and conversion and then reset the differ.
189
+ * Fire `change:data` event when at least one operation or buffered marker changes the data.
190
+ *
191
+ * @internal
192
+ * @fires change
193
+ * @fires change:data
194
+ * @param writer The writer on which post-fixers will be called.
195
+ */
196
+ _handleChangeBlock(writer: ModelWriter): void;
197
+ /**
198
+ * Returns whether there is a buffered change or if the selection has changed from the last
199
+ * {@link module:engine/model/model~Model#enqueueChange `enqueueChange()` block}
200
+ * or {@link module:engine/model/model~Model#change `change()` block}.
201
+ *
202
+ * @returns Returns `true` if document has changed from the last `change()` or `enqueueChange()` block.
203
+ */
204
+ protected _hasDocumentChangedFromTheLastChangeBlock(): boolean;
205
+ /**
206
+ * Returns the default root for this document which is either the first root that was added to the document using
207
+ * {@link #createRoot} or the {@link #graveyard graveyard root} if no other roots were created.
208
+ *
209
+ * @returns The default root for this document.
210
+ */
211
+ protected _getDefaultRoot(): ModelRootElement;
212
+ /**
213
+ * Returns the default range for this selection. The default range is a collapsed range that starts and ends
214
+ * at the beginning of this selection's document {@link #_getDefaultRoot default root}.
215
+ *
216
+ * @internal
217
+ */
218
+ _getDefaultRange(): ModelRange;
219
+ /**
220
+ * Checks whether a given {@link module:engine/model/range~ModelRange range} is a valid range for
221
+ * the {@link #selection document's selection}.
222
+ *
223
+ * @internal
224
+ * @param range A range to check.
225
+ * @returns `true` if `range` is valid, `false` otherwise.
226
+ */
227
+ _validateSelectionRange(range: ModelRange): boolean;
228
+ /**
229
+ * Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
230
+ *
231
+ * @param writer The writer on which post-fixer callbacks will be called.
232
+ */
233
+ private _callPostFixers;
231
234
  }
232
235
  /**
233
- * Fired after each {@link module:engine/model/model~Model#enqueueChange `enqueueChange()` block} or the outermost
234
- * {@link module:engine/model/model~Model#change `change()` block} was executed and the document was changed
235
- * during that block's execution.
236
- *
237
- * The changes which this event will cover include:
238
- *
239
- * * document structure changes,
240
- * * selection changes,
241
- * * marker changes.
242
- *
243
- * If you want to be notified about all these changes, then simply listen to this event like this:
244
- *
245
- * ```ts
246
- * model.document.on( 'change', () => {
247
- * console.log( 'The document has changed!' );
248
- * } );
249
- * ```
250
- *
251
- * If, however, you only want to be notified about the data changes, then use `change:data` event,
252
- * which is fired for document structure changes and marker changes (which affects the data).
253
- *
254
- * ```ts
255
- * model.document.on( 'change:data', () => {
256
- * console.log( 'The data has changed!' );
257
- * } );
258
- * ```
259
- *
260
- * @eventName ~ModelDocument#change
261
- * @eventName ~ModelDocument#change:data
262
- * @param batch The batch that was used in the executed changes block.
263
- */
236
+ * Fired after each {@link module:engine/model/model~Model#enqueueChange `enqueueChange()` block} or the outermost
237
+ * {@link module:engine/model/model~Model#change `change()` block} was executed and the document was changed
238
+ * during that block's execution.
239
+ *
240
+ * The changes which this event will cover include:
241
+ *
242
+ * * document structure changes,
243
+ * * selection changes,
244
+ * * marker changes.
245
+ *
246
+ * If you want to be notified about all these changes, then simply listen to this event like this:
247
+ *
248
+ * ```ts
249
+ * model.document.on( 'change', () => {
250
+ * console.log( 'The document has changed!' );
251
+ * } );
252
+ * ```
253
+ *
254
+ * If, however, you only want to be notified about the data changes, then use `change:data` event,
255
+ * which is fired for document structure changes and marker changes (which affects the data).
256
+ *
257
+ * ```ts
258
+ * model.document.on( 'change:data', () => {
259
+ * console.log( 'The data has changed!' );
260
+ * } );
261
+ * ```
262
+ *
263
+ * @eventName ~ModelDocument#change
264
+ * @eventName ~ModelDocument#change:data
265
+ * @param batch The batch that was used in the executed changes block.
266
+ */
264
267
  export type ModelDocumentChangeEvent = {
265
- name: 'change' | 'change:data';
266
- args: [batch: Batch];
268
+ name: "change" | "change:data";
269
+ args: [batch: Batch];
267
270
  };
268
271
  /**
269
- * Callback passed as an argument to the {@link module:engine/model/document~ModelDocument#registerPostFixer} method.
270
- */
272
+ * Callback passed as an argument to the {@link module:engine/model/document~ModelDocument#registerPostFixer} method.
273
+ */
271
274
  export type ModelPostFixer = (writer: ModelWriter) => boolean;
272
275
  export {};