@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
@@ -0,0 +1,417 @@
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
+ /**
6
+ * @module engine/view/view
7
+ */
8
+ import Document from './document';
9
+ import DowncastWriter from './downcastwriter';
10
+ import Renderer from './renderer';
11
+ import DomConverter from './domconverter';
12
+ import Position, { type PositionOffset } from './position';
13
+ import Range from './range';
14
+ import Selection, { type PlaceOrOffset, type Selectable, type SelectionOptions } from './selection';
15
+ import type { default as Observer, ObserverConstructor } from './observer/observer';
16
+ import type { StylesProcessor } from './stylesmap';
17
+ import type Element from './element';
18
+ import type Node from './node';
19
+ import type Item from './item';
20
+ declare const View_base: {
21
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
22
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
23
+ };
24
+ /**
25
+ * Editor's view controller class. Its main responsibility is DOM - View management for editing purposes, to provide
26
+ * abstraction over the DOM structure and events and hide all browsers quirks.
27
+ *
28
+ * View controller renders view document to DOM whenever view structure changes. To determine when view can be rendered,
29
+ * all changes need to be done using the {@link module:engine/view/view~View#change} method, using
30
+ * {@link module:engine/view/downcastwriter~DowncastWriter}:
31
+ *
32
+ * ```ts
33
+ * view.change( writer => {
34
+ * writer.insert( position, writer.createText( 'foo' ) );
35
+ * } );
36
+ * ```
37
+ *
38
+ * View controller also register {@link module:engine/view/observer/observer~Observer observers} which observes changes
39
+ * on DOM and fire events on the {@link module:engine/view/document~Document Document}.
40
+ * Note that the following observers are added by the class constructor and are always available:
41
+ *
42
+ * * {@link module:engine/view/observer/selectionobserver~SelectionObserver},
43
+ * * {@link module:engine/view/observer/focusobserver~FocusObserver},
44
+ * * {@link module:engine/view/observer/keyobserver~KeyObserver},
45
+ * * {@link module:engine/view/observer/fakeselectionobserver~FakeSelectionObserver}.
46
+ * * {@link module:engine/view/observer/compositionobserver~CompositionObserver}.
47
+ * * {@link module:engine/view/observer/inputobserver~InputObserver}.
48
+ * * {@link module:engine/view/observer/arrowkeysobserver~ArrowKeysObserver}.
49
+ * * {@link module:engine/view/observer/tabobserver~TabObserver}.
50
+ *
51
+ * This class also {@link module:engine/view/view~View#attachDomRoot binds the DOM and the view elements}.
52
+ *
53
+ * If you do not need full a DOM - view management, and only want to transform a tree of view elements to a tree of DOM
54
+ * elements you do not need this controller. You can use the {@link module:engine/view/domconverter~DomConverter DomConverter} instead.
55
+ */
56
+ export default class View extends View_base {
57
+ /**
58
+ * Instance of the {@link module:engine/view/document~Document} associated with this view controller.
59
+ */
60
+ readonly document: Document;
61
+ /**
62
+ * Instance of the {@link module:engine/view/domconverter~DomConverter domConverter} used by
63
+ * {@link module:engine/view/view~View#_renderer renderer}
64
+ * and {@link module:engine/view/observer/observer~Observer observers}.
65
+ */
66
+ readonly domConverter: DomConverter;
67
+ /**
68
+ * Roots of the DOM tree. Map on the `HTMLElement`s with roots names as keys.
69
+ */
70
+ readonly domRoots: Map<string, HTMLElement>;
71
+ /**
72
+ * Used to prevent calling {@link #forceRender} and {@link #change} during rendering view to the DOM.
73
+ *
74
+ * @observable
75
+ * @readonly
76
+ */
77
+ isRenderingInProgress: boolean;
78
+ /**
79
+ * Informs whether the DOM selection is inside any of the DOM roots managed by the view.
80
+ *
81
+ * @observable
82
+ * @readonly
83
+ */
84
+ hasDomSelection: boolean;
85
+ /**
86
+ * Instance of the {@link module:engine/view/renderer~Renderer renderer}.
87
+ *
88
+ * @internal
89
+ */
90
+ readonly _renderer: Renderer;
91
+ /**
92
+ * A DOM root attributes cache. It saves the initial values of DOM root attributes before the DOM element
93
+ * is {@link module:engine/view/view~View#attachDomRoot attached} to the view so later on, when
94
+ * the view is destroyed ({@link module:engine/view/view~View#detachDomRoot}), they can be easily restored.
95
+ * This way, the DOM element can go back to the (clean) state as if the editing view never used it.
96
+ */
97
+ private readonly _initialDomRootAttributes;
98
+ /**
99
+ * Map of registered {@link module:engine/view/observer/observer~Observer observers}.
100
+ */
101
+ private readonly _observers;
102
+ /**
103
+ * DowncastWriter instance used in {@link #change change method} callbacks.
104
+ */
105
+ private readonly _writer;
106
+ /**
107
+ * Is set to `true` when {@link #change view changes} are currently in progress.
108
+ */
109
+ private _ongoingChange;
110
+ /**
111
+ * Used to prevent calling {@link #forceRender} and {@link #change} during rendering view to the DOM.
112
+ */
113
+ private _postFixersInProgress;
114
+ /**
115
+ * Internal flag to temporary disable rendering. See the usage in the {@link #_disableRendering}.
116
+ */
117
+ private _renderingDisabled;
118
+ /**
119
+ * Internal flag that disables rendering when there are no changes since the last rendering.
120
+ * It stores information about changed selection and changed elements from attached document roots.
121
+ */
122
+ private _hasChangedSinceTheLastRendering;
123
+ /**
124
+ * @param stylesProcessor The styles processor instance.
125
+ */
126
+ constructor(stylesProcessor: StylesProcessor);
127
+ /**
128
+ * Attaches a DOM root element to the view element and enable all observers on that element.
129
+ * Also {@link module:engine/view/renderer~Renderer#markToSync mark element} to be synchronized
130
+ * with the view what means that all child nodes will be removed and replaced with content of the view root.
131
+ *
132
+ * This method also will change view element name as the same as tag name of given dom root.
133
+ * Name is always transformed to lower case.
134
+ *
135
+ * **Note:** Use {@link #detachDomRoot `detachDomRoot()`} to revert this action.
136
+ *
137
+ * @param domRoot DOM root element.
138
+ * @param name Name of the root.
139
+ */
140
+ attachDomRoot(domRoot: HTMLElement, name?: string): void;
141
+ /**
142
+ * Detaches a DOM root element from the view element and restores its attributes to the state before
143
+ * {@link #attachDomRoot `attachDomRoot()`}.
144
+ *
145
+ * @param name Name of the root to detach.
146
+ */
147
+ detachDomRoot(name: string): void;
148
+ /**
149
+ * Gets DOM root element.
150
+ *
151
+ * @param name Name of the root.
152
+ * @returns DOM root element instance.
153
+ */
154
+ getDomRoot(name?: string): HTMLElement | undefined;
155
+ /**
156
+ * Creates observer of the given type if not yet created, {@link module:engine/view/observer/observer~Observer#enable enables} it
157
+ * and {@link module:engine/view/observer/observer~Observer#observe attaches} to all existing and future
158
+ * {@link #domRoots DOM roots}.
159
+ *
160
+ * Note: Observers are recognized by their constructor (classes). A single observer will be instantiated and used only
161
+ * when registered for the first time. This means that features and other components can register a single observer
162
+ * multiple times without caring whether it has been already added or not.
163
+ *
164
+ * @param ObserverConstructor The constructor of an observer to add.
165
+ * Should create an instance inheriting from {@link module:engine/view/observer/observer~Observer}.
166
+ * @returns Added observer instance.
167
+ */
168
+ addObserver(ObserverConstructor: ObserverConstructor): Observer;
169
+ /**
170
+ * Returns observer of the given type or `undefined` if such observer has not been added yet.
171
+ *
172
+ * @param ObserverConstructor The constructor of an observer to get.
173
+ * @returns Observer instance or undefined.
174
+ */
175
+ getObserver<T extends ObserverConstructor>(ObserverConstructor: T): InstanceType<T> | undefined;
176
+ /**
177
+ * Disables all added observers.
178
+ */
179
+ disableObservers(): void;
180
+ /**
181
+ * Enables all added observers.
182
+ */
183
+ enableObservers(): void;
184
+ /**
185
+ * Scrolls the page viewport and {@link #domRoots} with their ancestors to reveal the
186
+ * caret, if not already visible to the user.
187
+ */
188
+ scrollToTheSelection(): void;
189
+ /**
190
+ * It will focus DOM element representing {@link module:engine/view/editableelement~EditableElement EditableElement}
191
+ * that is currently having selection inside.
192
+ */
193
+ focus(): void;
194
+ /**
195
+ * The `change()` method is the primary way of changing the view. You should use it to modify any node in the view tree.
196
+ * It makes sure that after all changes are made the view is rendered to the DOM (assuming that the view will be changed
197
+ * inside the callback). It prevents situations when the DOM is updated when the view state is not yet correct. It allows
198
+ * to nest calls one inside another and still performs a single rendering after all those changes are made.
199
+ * It also returns the return value of its callback.
200
+ *
201
+ * ```ts
202
+ * const text = view.change( writer => {
203
+ * const newText = writer.createText( 'foo' );
204
+ * writer.insert( position1, newText );
205
+ *
206
+ * view.change( writer => {
207
+ * writer.insert( position2, writer.createText( 'bar' ) );
208
+ * } );
209
+ *
210
+ * writer.remove( range );
211
+ *
212
+ * return newText;
213
+ * } );
214
+ * ```
215
+ *
216
+ * When the outermost change block is done and rendering to the DOM is over the
217
+ * {@link module:engine/view/view~View#event:render `View#render`} event is fired.
218
+ *
219
+ * This method throws a `applying-view-changes-on-rendering` error when
220
+ * the change block is used after rendering to the DOM has started.
221
+ *
222
+ * @param callback Callback function which may modify the view.
223
+ * @returns Value returned by the callback.
224
+ */
225
+ change<TReturn>(callback: (writer: DowncastWriter) => TReturn): TReturn;
226
+ /**
227
+ * Forces rendering {@link module:engine/view/document~Document view document} to DOM. If any view changes are
228
+ * currently in progress, rendering will start after all {@link #change change blocks} are processed.
229
+ *
230
+ * Note that this method is dedicated for special cases. All view changes should be wrapped in the {@link #change}
231
+ * block and the view will automatically check whether it needs to render DOM or not.
232
+ *
233
+ * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `applying-view-changes-on-rendering` when
234
+ * trying to re-render when rendering to DOM has already started.
235
+ */
236
+ forceRender(): void;
237
+ /**
238
+ * Destroys this instance. Makes sure that all observers are destroyed and listeners removed.
239
+ */
240
+ destroy(): void;
241
+ /**
242
+ * Creates position at the given location. The location can be specified as:
243
+ *
244
+ * * a {@link module:engine/view/position~Position position},
245
+ * * parent element and offset (offset defaults to `0`),
246
+ * * parent element and `'end'` (sets position at the end of that element),
247
+ * * {@link module:engine/view/item~Item view item} and `'before'` or `'after'` (sets position before or after given view item).
248
+ *
249
+ * This method is a shortcut to other constructors such as:
250
+ *
251
+ * * {@link #createPositionBefore},
252
+ * * {@link #createPositionAfter},
253
+ *
254
+ * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/view/item~Item view item}.
255
+ */
256
+ createPositionAt(itemOrPosition: Item | Position, offset?: PositionOffset): Position;
257
+ /**
258
+ * Creates a new position after given view item.
259
+ *
260
+ * @param item View item after which the position should be located.
261
+ */
262
+ createPositionAfter(item: Item): Position;
263
+ /**
264
+ * Creates a new position before given view item.
265
+ *
266
+ * @param item View item before which the position should be located.
267
+ */
268
+ createPositionBefore(item: Item): Position;
269
+ /**
270
+ * Creates a range spanning from `start` position to `end` position.
271
+ *
272
+ * **Note:** This factory method creates it's own {@link module:engine/view/position~Position} instances basing on passed values.
273
+ *
274
+ * @param start Start position.
275
+ * @param end End position. If not set, range will be collapsed at `start` position.
276
+ */
277
+ createRange(start: Position, end?: Position | null): Range;
278
+ /**
279
+ * Creates a range that starts before given {@link module:engine/view/item~Item view item} and ends after it.
280
+ */
281
+ createRangeOn(item: Item): Range;
282
+ /**
283
+ * Creates a range inside an {@link module:engine/view/element~Element element} which starts before the first child of
284
+ * that element and ends after the last child of that element.
285
+ *
286
+ * @param element Element which is a parent for the range.
287
+ */
288
+ createRangeIn(element: Element): Range;
289
+ /**
290
+ * Creates new {@link module:engine/view/selection~Selection} instance.
291
+ *
292
+ * ```ts
293
+ * // Creates collapsed selection at the position of given item and offset.
294
+ * const paragraph = view.createContainerElement( 'paragraph' );
295
+ * const selection = view.createSelection( paragraph, offset );
296
+ *
297
+ * // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
298
+ * // first child of that element and ends after the last child of that element.
299
+ * const selection = view.createSelection( paragraph, 'in' );
300
+ *
301
+ * // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
302
+ * // just after the item.
303
+ * const selection = view.createSelection( paragraph, 'on' );
304
+ * ```
305
+ *
306
+ * `Selection`'s factory method allow passing additional options (`backward`, `fake` and `label`) as the last argument.
307
+ *
308
+ * ```ts
309
+ * // Creates backward selection.
310
+ * const selection = view.createSelection( paragraph, 'in', { backward: true } );
311
+ * ```
312
+ *
313
+ * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
314
+ * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
315
+ * represented in other way, for example by applying proper CSS class.
316
+ *
317
+ * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
318
+ * (and be properly handled by screen readers).
319
+ *
320
+ * ```ts
321
+ * // Creates fake selection with label.
322
+ * const selection = view.createSelection( element, 'in', { fake: true, label: 'foo' } );
323
+ * ```
324
+ *
325
+ * See also: {@link #createSelection:SELECTABLE `createSelection( selectable, options )`}.
326
+ *
327
+ * @label NODE_OFFSET
328
+ */
329
+ createSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: SelectionOptions): Selection;
330
+ /**
331
+ * Creates new {@link module:engine/view/selection~Selection} instance.
332
+ *
333
+ * ```ts
334
+ * // Creates empty selection without ranges.
335
+ * const selection = view.createSelection();
336
+ *
337
+ * // Creates selection at the given range.
338
+ * const range = view.createRange( start, end );
339
+ * const selection = view.createSelection( range );
340
+ *
341
+ * // Creates selection at the given ranges
342
+ * const ranges = [ view.createRange( start1, end2 ), view.createRange( star2, end2 ) ];
343
+ * const selection = view.createSelection( ranges );
344
+ *
345
+ * // Creates selection from the other selection.
346
+ * const otherSelection = view.createSelection();
347
+ * const selection = view.createSelection( otherSelection );
348
+ *
349
+ * // Creates selection from the document selection.
350
+ * const selection = view.createSelection( editor.editing.view.document.selection );
351
+ *
352
+ * // Creates selection at the given position.
353
+ * const position = view.createPositionFromPath( root, path );
354
+ * const selection = view.createSelection( position );
355
+ * ```
356
+ *
357
+ * `Selection`'s factory method allow passing additional options (`backward`, `fake` and `label`) as the last argument.
358
+ *
359
+ * ```ts
360
+ * // Creates backward selection.
361
+ * const selection = view.createSelection( range, { backward: true } );
362
+ * ```
363
+ *
364
+ * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
365
+ * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
366
+ * represented in other way, for example by applying proper CSS class.
367
+ *
368
+ * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
369
+ * (and be properly handled by screen readers).
370
+ *
371
+ * ```ts
372
+ * // Creates fake selection with label.
373
+ * const selection = view.createSelection( range, { fake: true, label: 'foo' } );
374
+ * ```
375
+ *
376
+ * See also: {@link #createSelection:NODE_OFFSET `createSelection( node, placeOrOffset, options )`}.
377
+ *
378
+ * @label SELECTABLE
379
+ */
380
+ createSelection(selectable?: Exclude<Selectable, Node>, options?: SelectionOptions): Selection;
381
+ /**
382
+ * Disables or enables rendering. If the flag is set to `true` then the rendering will be disabled.
383
+ * If the flag is set to `false` and if there was some change in the meantime, then the rendering action will be performed.
384
+ *
385
+ * @internal
386
+ * @param flag A flag indicates whether the rendering should be disabled.
387
+ */
388
+ _disableRendering(flag: boolean): void;
389
+ /**
390
+ * Renders all changes. In order to avoid triggering the observers (e.g. selection) all observers are disabled
391
+ * before rendering and re-enabled after that.
392
+ */
393
+ private _render;
394
+ }
395
+ /**
396
+ * Fired after a topmost {@link module:engine/view/view~View#change change block} and all
397
+ * {@link module:engine/view/document~Document#registerPostFixer post-fixers} are executed.
398
+ *
399
+ * Actual rendering is performed as a first listener on 'normal' priority.
400
+ *
401
+ * ```ts
402
+ * view.on( 'render', () => {
403
+ * // Rendering to the DOM is complete.
404
+ * } );
405
+ * ```
406
+ *
407
+ * This event is useful when you want to update interface elements after the rendering, e.g. position of the
408
+ * balloon panel. If you wants to change view structure use
409
+ * {@link module:engine/view/document~Document#registerPostFixer post-fixers}.
410
+ *
411
+ * @eventName ~View#render
412
+ */
413
+ export type ViewRenderEvent = {
414
+ name: 'render';
415
+ args: [];
416
+ };
417
+ export {};