@ckeditor/ckeditor5-engine 41.2.0 → 41.3.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 (134) hide show
  1. package/dist/content-index.css +4 -0
  2. package/dist/editor-index.css +23 -0
  3. package/dist/index.css +49 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.js +36728 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/types/controller/datacontroller.d.ts +335 -0
  8. package/dist/types/controller/editingcontroller.d.ts +98 -0
  9. package/dist/types/conversion/conversion.d.ts +478 -0
  10. package/dist/types/conversion/conversionhelpers.d.ts +26 -0
  11. package/dist/types/conversion/downcastdispatcher.d.ts +562 -0
  12. package/dist/types/conversion/downcasthelpers.d.ts +1190 -0
  13. package/dist/types/conversion/mapper.d.ts +503 -0
  14. package/dist/types/conversion/modelconsumable.d.ts +201 -0
  15. package/dist/types/conversion/upcastdispatcher.d.ts +492 -0
  16. package/dist/types/conversion/upcasthelpers.d.ts +499 -0
  17. package/dist/types/conversion/viewconsumable.d.ts +369 -0
  18. package/dist/types/dataprocessor/basichtmlwriter.d.ts +18 -0
  19. package/dist/types/dataprocessor/dataprocessor.d.ts +61 -0
  20. package/dist/types/dataprocessor/htmldataprocessor.d.ts +76 -0
  21. package/dist/types/dataprocessor/htmlwriter.d.ts +16 -0
  22. package/dist/types/dataprocessor/xmldataprocessor.d.ts +90 -0
  23. package/dist/types/dev-utils/model.d.ts +124 -0
  24. package/dist/types/dev-utils/operationreplayer.d.ts +51 -0
  25. package/dist/types/dev-utils/utils.d.ts +37 -0
  26. package/dist/types/dev-utils/view.d.ts +319 -0
  27. package/dist/types/index.d.ts +113 -0
  28. package/dist/types/model/batch.d.ts +106 -0
  29. package/dist/types/model/differ.d.ts +415 -0
  30. package/dist/types/model/document.d.ts +274 -0
  31. package/dist/types/model/documentfragment.d.ts +200 -0
  32. package/dist/types/model/documentselection.d.ts +420 -0
  33. package/dist/types/model/element.d.ts +165 -0
  34. package/dist/types/model/history.d.ts +114 -0
  35. package/dist/types/model/item.d.ts +14 -0
  36. package/dist/types/model/liveposition.d.ts +77 -0
  37. package/dist/types/model/liverange.d.ts +102 -0
  38. package/dist/types/model/markercollection.d.ts +335 -0
  39. package/dist/types/model/model.d.ts +919 -0
  40. package/dist/types/model/node.d.ts +255 -0
  41. package/dist/types/model/nodelist.d.ts +91 -0
  42. package/dist/types/model/operation/attributeoperation.d.ts +103 -0
  43. package/dist/types/model/operation/detachoperation.d.ts +60 -0
  44. package/dist/types/model/operation/insertoperation.d.ts +90 -0
  45. package/dist/types/model/operation/markeroperation.d.ts +91 -0
  46. package/dist/types/model/operation/mergeoperation.d.ts +100 -0
  47. package/dist/types/model/operation/moveoperation.d.ts +96 -0
  48. package/dist/types/model/operation/nooperation.d.ts +38 -0
  49. package/dist/types/model/operation/operation.d.ts +96 -0
  50. package/dist/types/model/operation/operationfactory.d.ts +18 -0
  51. package/dist/types/model/operation/renameoperation.d.ts +83 -0
  52. package/dist/types/model/operation/rootattributeoperation.d.ts +98 -0
  53. package/dist/types/model/operation/rootoperation.d.ts +76 -0
  54. package/dist/types/model/operation/splitoperation.d.ts +109 -0
  55. package/dist/types/model/operation/transform.d.ts +100 -0
  56. package/dist/types/model/operation/utils.d.ts +71 -0
  57. package/dist/types/model/position.d.ts +538 -0
  58. package/dist/types/model/range.d.ts +458 -0
  59. package/dist/types/model/rootelement.d.ts +60 -0
  60. package/dist/types/model/schema.d.ts +1206 -0
  61. package/dist/types/model/selection.d.ts +482 -0
  62. package/dist/types/model/text.d.ts +66 -0
  63. package/dist/types/model/textproxy.d.ts +144 -0
  64. package/dist/types/model/treewalker.d.ts +186 -0
  65. package/dist/types/model/typecheckable.d.ts +285 -0
  66. package/dist/types/model/utils/autoparagraphing.d.ts +37 -0
  67. package/dist/types/model/utils/deletecontent.d.ts +58 -0
  68. package/dist/types/model/utils/getselectedcontent.d.ts +30 -0
  69. package/dist/types/model/utils/insertcontent.d.ts +46 -0
  70. package/dist/types/model/utils/insertobject.d.ts +47 -0
  71. package/dist/types/model/utils/modifyselection.d.ts +48 -0
  72. package/dist/types/model/utils/selection-post-fixer.d.ts +74 -0
  73. package/dist/types/model/writer.d.ts +851 -0
  74. package/dist/types/view/attributeelement.d.ts +108 -0
  75. package/dist/types/view/containerelement.d.ts +49 -0
  76. package/dist/types/view/datatransfer.d.ts +79 -0
  77. package/dist/types/view/document.d.ts +184 -0
  78. package/dist/types/view/documentfragment.d.ts +153 -0
  79. package/dist/types/view/documentselection.d.ts +306 -0
  80. package/dist/types/view/domconverter.d.ts +652 -0
  81. package/dist/types/view/downcastwriter.d.ts +996 -0
  82. package/dist/types/view/editableelement.d.ts +62 -0
  83. package/dist/types/view/element.d.ts +468 -0
  84. package/dist/types/view/elementdefinition.d.ts +87 -0
  85. package/dist/types/view/emptyelement.d.ts +41 -0
  86. package/dist/types/view/filler.d.ts +111 -0
  87. package/dist/types/view/item.d.ts +14 -0
  88. package/dist/types/view/matcher.d.ts +486 -0
  89. package/dist/types/view/node.d.ts +162 -0
  90. package/dist/types/view/observer/arrowkeysobserver.d.ts +45 -0
  91. package/dist/types/view/observer/bubblingemittermixin.d.ts +166 -0
  92. package/dist/types/view/observer/bubblingeventinfo.d.ts +47 -0
  93. package/dist/types/view/observer/clickobserver.d.ts +43 -0
  94. package/dist/types/view/observer/compositionobserver.d.ts +82 -0
  95. package/dist/types/view/observer/domeventdata.d.ts +50 -0
  96. package/dist/types/view/observer/domeventobserver.d.ts +73 -0
  97. package/dist/types/view/observer/fakeselectionobserver.d.ts +47 -0
  98. package/dist/types/view/observer/focusobserver.d.ts +82 -0
  99. package/dist/types/view/observer/inputobserver.d.ts +86 -0
  100. package/dist/types/view/observer/keyobserver.d.ts +66 -0
  101. package/dist/types/view/observer/mouseobserver.d.ts +89 -0
  102. package/dist/types/view/observer/mutationobserver.d.ts +86 -0
  103. package/dist/types/view/observer/observer.d.ts +89 -0
  104. package/dist/types/view/observer/selectionobserver.d.ts +148 -0
  105. package/dist/types/view/observer/tabobserver.d.ts +46 -0
  106. package/dist/types/view/placeholder.d.ts +96 -0
  107. package/dist/types/view/position.d.ts +188 -0
  108. package/dist/types/view/range.d.ts +279 -0
  109. package/dist/types/view/rawelement.d.ts +73 -0
  110. package/dist/types/view/renderer.d.ts +265 -0
  111. package/dist/types/view/rooteditableelement.d.ts +41 -0
  112. package/dist/types/view/selection.d.ts +375 -0
  113. package/dist/types/view/styles/background.d.ts +33 -0
  114. package/dist/types/view/styles/border.d.ts +43 -0
  115. package/dist/types/view/styles/margin.d.ts +29 -0
  116. package/dist/types/view/styles/padding.d.ts +29 -0
  117. package/dist/types/view/styles/utils.d.ts +93 -0
  118. package/dist/types/view/stylesmap.d.ts +673 -0
  119. package/dist/types/view/text.d.ts +74 -0
  120. package/dist/types/view/textproxy.d.ts +97 -0
  121. package/dist/types/view/treewalker.d.ts +195 -0
  122. package/dist/types/view/typecheckable.d.ts +448 -0
  123. package/dist/types/view/uielement.d.ts +96 -0
  124. package/dist/types/view/upcastwriter.d.ts +417 -0
  125. package/dist/types/view/view.d.ts +487 -0
  126. package/package.json +3 -2
  127. package/src/model/node.d.ts +0 -1
  128. package/src/model/node.js +0 -2
  129. package/src/model/position.d.ts +0 -1
  130. package/src/model/position.js +0 -2
  131. package/src/view/node.d.ts +0 -1
  132. package/src/view/node.js +0 -2
  133. package/src/view/position.d.ts +0 -1
  134. package/src/view/position.js +0 -2
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/observer/selectionobserver
7
+ */
8
+ import Observer from './observer.js';
9
+ import MutationObserver from './mutationobserver.js';
10
+ import type View from '../view.js';
11
+ import type DocumentSelection from '../documentselection.js';
12
+ import type DomConverter from '../domconverter.js';
13
+ import type Selection from '../selection.js';
14
+ import FocusObserver from './focusobserver.js';
15
+ type DomSelection = globalThis.Selection;
16
+ /**
17
+ * Selection observer class observes selection changes in the document. If a selection changes on the document this
18
+ * observer checks if the DOM selection is different from the {@link module:engine/view/document~Document#selection view selection}.
19
+ * The selection observer fires {@link module:engine/view/document~Document#event:selectionChange} event only if
20
+ * a selection change was the only change in the document and the DOM selection is different from the view selection.
21
+ *
22
+ * This observer also manages the {@link module:engine/view/document~Document#isSelecting} property of the view document.
23
+ *
24
+ * Note that this observer is attached by the {@link module:engine/view/view~View} and is available by default.
25
+ */
26
+ export default class SelectionObserver extends Observer {
27
+ /**
28
+ * Instance of the mutation observer. Selection observer calls
29
+ * {@link module:engine/view/observer/mutationobserver~MutationObserver#flush} to ensure that the mutations will be handled
30
+ * before the {@link module:engine/view/document~Document#event:selectionChange} event is fired.
31
+ */
32
+ readonly mutationObserver: MutationObserver;
33
+ /**
34
+ * Instance of the focus observer. Focus observer calls
35
+ * {@link module:engine/view/observer/focusobserver~FocusObserver#flush} to mark the latest focus change as complete.
36
+ */
37
+ readonly focusObserver: FocusObserver;
38
+ /**
39
+ * Reference to the view {@link module:engine/view/documentselection~DocumentSelection} object used to compare
40
+ * new selection with it.
41
+ */
42
+ readonly selection: DocumentSelection;
43
+ /**
44
+ * Reference to the {@link module:engine/view/view~View#domConverter}.
45
+ */
46
+ readonly domConverter: DomConverter;
47
+ /**
48
+ * A set of documents which have added `selectionchange` listener to avoid adding a listener twice to the same
49
+ * document.
50
+ */
51
+ private readonly _documents;
52
+ /**
53
+ * Fires debounced event `selectionChangeDone`. It uses `lodash#debounce` method to delay function call.
54
+ */
55
+ private readonly _fireSelectionChangeDoneDebounced;
56
+ /**
57
+ * When called, starts clearing the {@link #_loopbackCounter} counter in time intervals. When the number of selection
58
+ * changes exceeds a certain limit within the interval of time, the observer will not fire `selectionChange` but warn about
59
+ * possible infinite selection loop.
60
+ */
61
+ private readonly _clearInfiniteLoopInterval;
62
+ /**
63
+ * Unlocks the `isSelecting` state of the view document in case the selection observer did not record this fact
64
+ * correctly (for whatever reason). It is a safeguard (paranoid check), that returns document to the normal state
65
+ * after a certain period of time (debounced, postponed by each selectionchange event).
66
+ */
67
+ private readonly _documentIsSelectingInactivityTimeoutDebounced;
68
+ /**
69
+ * Private property to check if the code does not enter infinite loop.
70
+ */
71
+ private _loopbackCounter;
72
+ constructor(view: View);
73
+ /**
74
+ * @inheritDoc
75
+ */
76
+ observe(domElement: HTMLElement): void;
77
+ /**
78
+ * @inheritDoc
79
+ */
80
+ stopObserving(domElement: HTMLElement): void;
81
+ /**
82
+ * @inheritDoc
83
+ */
84
+ destroy(): void;
85
+ private _reportInfiniteLoop;
86
+ /**
87
+ * Selection change listener. {@link module:engine/view/observer/mutationobserver~MutationObserver#flush Flush} mutations, check if
88
+ * a selection changes and fires {@link module:engine/view/document~Document#event:selectionChange} event on every change
89
+ * and {@link module:engine/view/document~Document#event:selectionChangeDone} when a selection stop changing.
90
+ *
91
+ * @param domEvent DOM event.
92
+ * @param domDocument DOM document.
93
+ */
94
+ private _handleSelectionChange;
95
+ /**
96
+ * Clears `SelectionObserver` internal properties connected with preventing infinite loop.
97
+ */
98
+ private _clearInfiniteLoop;
99
+ }
100
+ /**
101
+ * The value of {@link ~ViewDocumentSelectionChangeEvent} and {@link ~ViewDocumentSelectionChangeDoneEvent} events.
102
+ */
103
+ export type ViewDocumentSelectionEventData = {
104
+ /**
105
+ * Old View selection which is {@link module:engine/view/document~Document#selection}.
106
+ */
107
+ oldSelection: DocumentSelection;
108
+ /**
109
+ * New View selection which is converted DOM selection.
110
+ */
111
+ newSelection: Selection;
112
+ /**
113
+ * Native DOM selection.
114
+ */
115
+ domSelection: DomSelection | null;
116
+ };
117
+ /**
118
+ * Fired when a selection has changed. This event is fired only when the selection change was the only change that happened
119
+ * in the document, and the old selection is different then the new selection.
120
+ *
121
+ * Introduced by {@link module:engine/view/observer/selectionobserver~SelectionObserver}.
122
+ *
123
+ * Note that because {@link module:engine/view/observer/selectionobserver~SelectionObserver} is attached by the
124
+ * {@link module:engine/view/view~View} this event is available by default.
125
+ *
126
+ * @see module:engine/view/observer/selectionobserver~SelectionObserver
127
+ * @eventName module:engine/view/document~Document#selectionChange
128
+ */
129
+ export type ViewDocumentSelectionChangeEvent = {
130
+ name: 'selectionChange';
131
+ args: [ViewDocumentSelectionEventData];
132
+ };
133
+ /**
134
+ * Fired when selection stops changing.
135
+ *
136
+ * Introduced by {@link module:engine/view/observer/selectionobserver~SelectionObserver}.
137
+ *
138
+ * Note that because {@link module:engine/view/observer/selectionobserver~SelectionObserver} is attached by the
139
+ * {@link module:engine/view/view~View} this event is available by default.
140
+ *
141
+ * @see module:engine/view/observer/selectionobserver~SelectionObserver
142
+ * @eventName module:engine/view/document~Document#selectionChangeDone
143
+ */
144
+ export type ViewDocumentSelectionChangeDoneEvent = {
145
+ name: 'selectionChangeDone';
146
+ args: [ViewDocumentSelectionEventData];
147
+ };
148
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/observer/tabobserver
7
+ */
8
+ import type View from '../view.js';
9
+ import Observer from './observer.js';
10
+ import type { KeyEventData } from './keyobserver.js';
11
+ import type { BubblingEvent } from './bubblingemittermixin.js';
12
+ /**
13
+ * Tab observer introduces the {@link module:engine/view/document~Document#event:tab `Document#tab`} event.
14
+ *
15
+ * Note that because {@link module:engine/view/observer/tabobserver~TabObserver} is attached by the
16
+ * {@link module:engine/view/view~View}, this event is available by default.
17
+ */
18
+ export default class TabObserver extends Observer {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ constructor(view: View);
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ observe(): void;
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ stopObserving(): void;
31
+ }
32
+ /**
33
+ * Event fired when the user presses a tab key.
34
+ *
35
+ * Introduced by {@link module:engine/view/observer/tabobserver~TabObserver}.
36
+ *
37
+ * Note that because {@link module:engine/view/observer/tabobserver~TabObserver} is attached by the
38
+ * {@link module:engine/view/view~View}, this event is available by default.
39
+ *
40
+ * @eventName module:engine/view/document~Document#tab
41
+ * @param data
42
+ */
43
+ export type ViewDocumentTabEvent = BubblingEvent<{
44
+ name: 'tab';
45
+ args: [data: KeyEventData];
46
+ }>;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/placeholder
7
+ */
8
+ import '../../theme/placeholder.css';
9
+ import type DowncastWriter from './downcastwriter.js';
10
+ import type EditableElement from './editableelement.js';
11
+ import type Element from './element.js';
12
+ import type View from './view.js';
13
+ /**
14
+ * A helper that enables a placeholder on the provided view element (also updates its visibility).
15
+ * The placeholder is a CSS pseudo–element (with a text content) attached to the element.
16
+ *
17
+ * To change the placeholder text, change value of the `placeholder` property in the provided `element`.
18
+ *
19
+ * To disable the placeholder, use {@link module:engine/view/placeholder~disablePlaceholder `disablePlaceholder()`} helper.
20
+ *
21
+ * @param options Configuration options of the placeholder.
22
+ * @param options.view Editing view instance.
23
+ * @param options.element Element that will gain a placeholder. See `options.isDirectHost` to learn more.
24
+ * @param options.isDirectHost If set `false`, the placeholder will not be enabled directly
25
+ * in the passed `element` but in one of its children (selected automatically, i.e. a first empty child element).
26
+ * Useful when attaching placeholders to elements that can host other elements (not just text), for instance,
27
+ * editable root elements.
28
+ * @param options.text Placeholder text. It's **deprecated** and will be removed soon. Use
29
+ * {@link module:engine/view/placeholder~PlaceholderableElement#placeholder `options.element.placeholder`} instead.
30
+ * @param options.keepOnFocus If set `true`, the placeholder stay visible when the host element is focused.
31
+ */
32
+ export declare function enablePlaceholder({ view, element, text, isDirectHost, keepOnFocus }: {
33
+ view: View;
34
+ element: PlaceholderableElement | EditableElement;
35
+ isDirectHost?: boolean;
36
+ text?: string;
37
+ keepOnFocus?: boolean;
38
+ }): void;
39
+ /**
40
+ * Disables the placeholder functionality from a given element.
41
+ *
42
+ * See {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`} to learn more.
43
+ */
44
+ export declare function disablePlaceholder(view: View, element: Element): void;
45
+ /**
46
+ * Shows a placeholder in the provided element by changing related attributes and CSS classes.
47
+ *
48
+ * **Note**: This helper will not update the placeholder visibility nor manage the
49
+ * it in any way in the future. What it does is a one–time state change of an element. Use
50
+ * {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`} and
51
+ * {@link module:engine/view/placeholder~disablePlaceholder `disablePlaceholder()`} for full
52
+ * placeholder functionality.
53
+ *
54
+ * **Note**: This helper will blindly show the placeholder directly in the root editable element if
55
+ * one is passed, which could result in a visual clash if the editable element has some children
56
+ * (for instance, an empty paragraph). Use {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`}
57
+ * in that case or make sure the correct element is passed to the helper.
58
+ *
59
+ * @returns `true`, if any changes were made to the `element`.
60
+ */
61
+ export declare function showPlaceholder(writer: DowncastWriter, element: Element): boolean;
62
+ /**
63
+ * Hides a placeholder in the element by changing related attributes and CSS classes.
64
+ *
65
+ * **Note**: This helper will not update the placeholder visibility nor manage the
66
+ * it in any way in the future. What it does is a one–time state change of an element. Use
67
+ * {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`} and
68
+ * {@link module:engine/view/placeholder~disablePlaceholder `disablePlaceholder()`} for full
69
+ * placeholder functionality.
70
+ *
71
+ * @returns `true`, if any changes were made to the `element`.
72
+ */
73
+ export declare function hidePlaceholder(writer: DowncastWriter, element: Element): boolean;
74
+ /**
75
+ * Checks if a placeholder should be displayed in the element.
76
+ *
77
+ * **Note**: This helper will blindly check the possibility of showing a placeholder directly in the
78
+ * root editable element if one is passed, which may not be the expected result. If an element can
79
+ * host other elements (not just text), most likely one of its children should be checked instead
80
+ * because it will be the final host for the placeholder. Use
81
+ * {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`} in that case or make
82
+ * sure the correct element is passed to the helper.
83
+ *
84
+ * @param element Element that holds the placeholder.
85
+ * @param keepOnFocus Focusing the element will keep the placeholder visible.
86
+ */
87
+ export declare function needsPlaceholder(element: Element, keepOnFocus: boolean): boolean;
88
+ /**
89
+ * Element that could have a placeholder.
90
+ */
91
+ export interface PlaceholderableElement extends Element {
92
+ /**
93
+ * The text of element's placeholder.
94
+ */
95
+ placeholder?: string;
96
+ }
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/position
7
+ */
8
+ import TypeCheckable from './typecheckable.js';
9
+ import EditableElement from './editableelement.js';
10
+ import type DocumentFragment from './documentfragment.js';
11
+ import type Item from './item.js';
12
+ import type Node from './node.js';
13
+ import { default as TreeWalker, type TreeWalkerValue, type TreeWalkerOptions } from './treewalker.js';
14
+ /**
15
+ * Position in the view tree. Position is represented by its parent node and an offset in this parent.
16
+ *
17
+ * In order to create a new position instance use the `createPosition*()` factory methods available in:
18
+ *
19
+ * * {@link module:engine/view/view~View}
20
+ * * {@link module:engine/view/downcastwriter~DowncastWriter}
21
+ * * {@link module:engine/view/upcastwriter~UpcastWriter}
22
+ */
23
+ export default class Position extends TypeCheckable {
24
+ /**
25
+ * Position parent.
26
+ */
27
+ readonly parent: Node | DocumentFragment;
28
+ /**
29
+ * Position offset.
30
+ */
31
+ offset: number;
32
+ /**
33
+ * Creates a position.
34
+ *
35
+ * @param parent Position parent.
36
+ * @param offset Position offset.
37
+ */
38
+ constructor(parent: Node | DocumentFragment, offset: number);
39
+ /**
40
+ * Node directly after the position. Equals `null` when there is no node after position or position is located
41
+ * inside text node.
42
+ */
43
+ get nodeAfter(): Node | null;
44
+ /**
45
+ * Node directly before the position. Equals `null` when there is no node before position or position is located
46
+ * inside text node.
47
+ */
48
+ get nodeBefore(): Node | null;
49
+ /**
50
+ * Is `true` if position is at the beginning of its {@link module:engine/view/position~Position#parent parent}, `false` otherwise.
51
+ */
52
+ get isAtStart(): boolean;
53
+ /**
54
+ * Is `true` if position is at the end of its {@link module:engine/view/position~Position#parent parent}, `false` otherwise.
55
+ */
56
+ get isAtEnd(): boolean;
57
+ /**
58
+ * Position's root, that is the root of the position's parent element.
59
+ */
60
+ get root(): Node | DocumentFragment;
61
+ /**
62
+ * {@link module:engine/view/editableelement~EditableElement EditableElement} instance that contains this position, or `null` if
63
+ * position is not inside an editable element.
64
+ */
65
+ get editableElement(): EditableElement | null;
66
+ /**
67
+ * Returns a new instance of Position with offset incremented by `shift` value.
68
+ *
69
+ * @param shift How position offset should get changed. Accepts negative values.
70
+ * @returns Shifted position.
71
+ */
72
+ getShiftedBy(shift: number): Position;
73
+ /**
74
+ * Gets the farthest position which matches the callback using
75
+ * {@link module:engine/view/treewalker~TreeWalker TreeWalker}.
76
+ *
77
+ * For example:
78
+ *
79
+ * ```ts
80
+ * getLastMatchingPosition( value => value.type == 'text' ); // <p>{}foo</p> -> <p>foo[]</p>
81
+ * getLastMatchingPosition( value => value.type == 'text', { direction: 'backward' } ); // <p>foo[]</p> -> <p>{}foo</p>
82
+ * getLastMatchingPosition( value => false ); // Do not move the position.
83
+ * ```
84
+ *
85
+ * @param skip Callback function. Gets {@link module:engine/view/treewalker~TreeWalkerValue} and should
86
+ * return `true` if the value should be skipped or `false` if not.
87
+ * @param options Object with configuration options. See {@link module:engine/view/treewalker~TreeWalker}.
88
+ * @returns The position after the last item which matches the `skip` callback test.
89
+ */
90
+ getLastMatchingPosition(skip: (value: TreeWalkerValue) => boolean, options?: TreeWalkerOptions): Position;
91
+ /**
92
+ * Returns ancestors array of this position, that is this position's parent and it's ancestors.
93
+ *
94
+ * @returns Array with ancestors.
95
+ */
96
+ getAncestors(): Array<Node | DocumentFragment>;
97
+ /**
98
+ * Returns a {@link module:engine/view/node~Node} or {@link module:engine/view/documentfragment~DocumentFragment}
99
+ * which is a common ancestor of both positions.
100
+ */
101
+ getCommonAncestor(position: Position): Node | DocumentFragment | null;
102
+ /**
103
+ * Checks whether this position equals given position.
104
+ *
105
+ * @param otherPosition Position to compare with.
106
+ * @returns True if positions are same.
107
+ */
108
+ isEqual(otherPosition: Position): boolean;
109
+ /**
110
+ * Checks whether this position is located before given position. When method returns `false` it does not mean that
111
+ * this position is after give one. Two positions may be located inside separate roots and in that situation this
112
+ * method will still return `false`.
113
+ *
114
+ * @see module:engine/view/position~Position#isAfter
115
+ * @see module:engine/view/position~Position#compareWith
116
+ * @param otherPosition Position to compare with.
117
+ * @returns Returns `true` if this position is before given position.
118
+ */
119
+ isBefore(otherPosition: Position): boolean;
120
+ /**
121
+ * Checks whether this position is located after given position. When method returns `false` it does not mean that
122
+ * this position is before give one. Two positions may be located inside separate roots and in that situation this
123
+ * method will still return `false`.
124
+ *
125
+ * @see module:engine/view/position~Position#isBefore
126
+ * @see module:engine/view/position~Position#compareWith
127
+ * @param otherPosition Position to compare with.
128
+ * @returns Returns `true` if this position is after given position.
129
+ */
130
+ isAfter(otherPosition: Position): boolean;
131
+ /**
132
+ * Checks whether this position is before, after or in same position that other position. Two positions may be also
133
+ * different when they are located in separate roots.
134
+ *
135
+ * @param otherPosition Position to compare with.
136
+ */
137
+ compareWith(otherPosition: Position): PositionRelation;
138
+ /**
139
+ * Creates a {@link module:engine/view/treewalker~TreeWalker TreeWalker} instance with this positions as a start position.
140
+ *
141
+ * @param options Object with configuration options. See {@link module:engine/view/treewalker~TreeWalker}
142
+ */
143
+ getWalker(options?: TreeWalkerOptions): TreeWalker;
144
+ /**
145
+ * Clones this position.
146
+ */
147
+ clone(): Position;
148
+ /**
149
+ * Creates position at the given location. The location can be specified as:
150
+ *
151
+ * * a {@link module:engine/view/position~Position position},
152
+ * * parent element and offset (offset defaults to `0`),
153
+ * * parent element and `'end'` (sets position at the end of that element),
154
+ * * {@link module:engine/view/item~Item view item} and `'before'` or `'after'` (sets position before or after given view item).
155
+ *
156
+ * This method is a shortcut to other constructors such as:
157
+ *
158
+ * * {@link module:engine/view/position~Position._createBefore},
159
+ * * {@link module:engine/view/position~Position._createAfter}.
160
+ *
161
+ * @internal
162
+ * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/view/item~Item view item}.
163
+ */
164
+ static _createAt(itemOrPosition: Item | Position, offset?: PositionOffset): Position;
165
+ /**
166
+ * Creates a new position after given view item.
167
+ *
168
+ * @internal
169
+ * @param item View item after which the position should be located.
170
+ */
171
+ static _createAfter(item: Item): Position;
172
+ /**
173
+ * Creates a new position before given view item.
174
+ *
175
+ * @internal
176
+ * @param item View item before which the position should be located.
177
+ */
178
+ static _createBefore(item: Item): Position;
179
+ }
180
+ /**
181
+ * A flag indicating whether this position is `'before'` or `'after'` or `'same'` as given position.
182
+ * If positions are in different roots `'different'` flag is returned.
183
+ */
184
+ export type PositionRelation = 'before' | 'after' | 'same' | 'different';
185
+ /**
186
+ * Offset or one of the flags.
187
+ */
188
+ export type PositionOffset = number | 'before' | 'after' | 'end';