@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,47 @@
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/fakeselectionobserver
7
+ */
8
+ import Observer from './observer.js';
9
+ import type View from '../view.js';
10
+ /**
11
+ * Fake selection observer class. If view selection is fake it is placed in dummy DOM container. This observer listens
12
+ * on {@link module:engine/view/document~Document#event:keydown keydown} events and handles moving fake view selection to the correct place
13
+ * if arrow keys are pressed.
14
+ * Fires {@link module:engine/view/document~Document#event:selectionChange selectionChange event} simulating natural behaviour of
15
+ * {@link module:engine/view/observer/selectionobserver~SelectionObserver SelectionObserver}.
16
+ */
17
+ export default class FakeSelectionObserver extends Observer {
18
+ /**
19
+ * Fires debounced event `selectionChangeDone`. It uses `lodash#debounce` method to delay function call.
20
+ */
21
+ private readonly _fireSelectionChangeDoneDebounced;
22
+ /**
23
+ * Creates new FakeSelectionObserver instance.
24
+ */
25
+ constructor(view: View);
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ observe(): void;
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ stopObserving(): void;
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ destroy(): void;
38
+ /**
39
+ * Handles collapsing view selection according to given key code. If left or up key is provided - new selection will be
40
+ * collapsed to left. If right or down key is pressed - new selection will be collapsed to right.
41
+ *
42
+ * This method fires {@link module:engine/view/document~Document#event:selectionChange} and
43
+ * {@link module:engine/view/document~Document#event:selectionChangeDone} events imitating behaviour of
44
+ * {@link module:engine/view/observer/selectionobserver~SelectionObserver}.
45
+ */
46
+ private _handleSelectionMove;
47
+ }
@@ -0,0 +1,82 @@
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/focusobserver
7
+ */
8
+ import DomEventObserver from './domeventobserver.js';
9
+ import type DomEventData from './domeventdata.js';
10
+ import type View from '../view.js';
11
+ /**
12
+ * {@link module:engine/view/document~Document#event:focus Focus}
13
+ * and {@link module:engine/view/document~Document#event:blur blur} events observer.
14
+ * Focus observer handle also {@link module:engine/view/rooteditableelement~RootEditableElement#isFocused isFocused} property of the
15
+ * {@link module:engine/view/rooteditableelement~RootEditableElement root elements}.
16
+ *
17
+ * Note that this observer is attached by the {@link module:engine/view/view~View} and is available by default.
18
+ */
19
+ export default class FocusObserver extends DomEventObserver<'focus' | 'blur'> {
20
+ /**
21
+ * Identifier of the timeout currently used by focus listener to delay rendering execution.
22
+ */
23
+ private _renderTimeoutId;
24
+ /**
25
+ * Set to `true` if the document is in the process of setting the focus.
26
+ *
27
+ * The flag is used to indicate that setting the focus is in progress.
28
+ */
29
+ private _isFocusChanging;
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ readonly domEventType: readonly ["focus", "blur"];
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ constructor(view: View);
38
+ /**
39
+ * Finishes setting the document focus state.
40
+ */
41
+ flush(): void;
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ onDomEvent(domEvent: FocusEvent): void;
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ destroy(): void;
50
+ }
51
+ /**
52
+ * Fired when one of the editables gets focus.
53
+ *
54
+ * Introduced by {@link module:engine/view/observer/focusobserver~FocusObserver}.
55
+ *
56
+ * Note that because {@link module:engine/view/observer/focusobserver~FocusObserver} is attached by the
57
+ * {@link module:engine/view/view~View} this event is available by default.
58
+ *
59
+ * @see module:engine/view/observer/focusobserver~FocusObserver
60
+ * @eventName module:engine/view/document~Document#focus
61
+ * @param data Event data.
62
+ */
63
+ export type ViewDocumentFocusEvent = {
64
+ name: 'focus';
65
+ args: [data: DomEventData<FocusEvent>];
66
+ };
67
+ /**
68
+ * Fired when one of the editables loses focus.
69
+ *
70
+ * Introduced by {@link module:engine/view/observer/focusobserver~FocusObserver}.
71
+ *
72
+ * Note that because {@link module:engine/view/observer/focusobserver~FocusObserver} is attached by the
73
+ * {@link module:engine/view/view~View} this event is available by default.
74
+ *
75
+ * @see module:engine/view/observer/focusobserver~FocusObserver
76
+ * @eventName module:engine/view/document~Document#blur
77
+ * @param data Event data.
78
+ */
79
+ export type ViewDocumentBlurEvent = {
80
+ name: 'blur';
81
+ args: [data: DomEventData<FocusEvent>];
82
+ };
@@ -0,0 +1,86 @@
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/inputobserver
7
+ */
8
+ import DomEventObserver from './domeventobserver.js';
9
+ import type DomEventData from './domeventdata.js';
10
+ import type ViewRange from '../range.js';
11
+ import DataTransfer from '../datatransfer.js';
12
+ /**
13
+ * Observer for events connected with data input.
14
+ *
15
+ * **Note**: This observer is attached by {@link module:engine/view/view~View} and available by default in all
16
+ * editor instances.
17
+ */
18
+ export default class InputObserver extends DomEventObserver<'beforeinput'> {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ readonly domEventType: "beforeinput";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ onDomEvent(domEvent: InputEvent): void;
27
+ }
28
+ /**
29
+ * Fired before the web browser inputs, deletes, or formats some data.
30
+ *
31
+ * This event is introduced by {@link module:engine/view/observer/inputobserver~InputObserver} and available
32
+ * by default in all editor instances (attached by {@link module:engine/view/view~View}).
33
+ *
34
+ * @see module:engine/view/observer/inputobserver~InputObserver
35
+ * @eventName module:engine/view/document~Document#beforeinput
36
+ * @param data Event data containing detailed information about the event.
37
+ */
38
+ export type ViewDocumentInputEvent = {
39
+ name: 'beforeinput';
40
+ args: [data: InputEventData];
41
+ };
42
+ /**
43
+ * The value of the {@link ~ViewDocumentInputEvent} event.
44
+ */
45
+ export interface InputEventData extends DomEventData<InputEvent> {
46
+ /**
47
+ * The type of the input event (e.g. "insertText" or "deleteWordBackward"). Corresponds to native `InputEvent#inputType`.
48
+ */
49
+ readonly inputType: string;
50
+ /**
51
+ * A unified text data passed along with the input event. Depending on:
52
+ *
53
+ * * the web browser and input events implementation (for instance [Level 1](https://www.w3.org/TR/input-events-1/) or
54
+ * [Level 2](https://www.w3.org/TR/input-events-2/)),
55
+ * * {@link module:engine/view/observer/inputobserver~InputEventData#inputType input type}
56
+ *
57
+ * text data is sometimes passed in the `data` and sometimes in the `dataTransfer` property.
58
+ *
59
+ * * If `InputEvent#data` was set, this property reflects its value.
60
+ * * If `InputEvent#data` is unavailable, this property contains the `'text/plain'` data from
61
+ * {@link module:engine/view/observer/inputobserver~InputEventData#dataTransfer}.
62
+ * * If the event ({@link module:engine/view/observer/inputobserver~InputEventData#inputType input type})
63
+ * provides no data whatsoever, this property is `null`.
64
+ */
65
+ readonly data: string | null;
66
+ /**
67
+ * The data transfer instance of the input event. Corresponds to native `InputEvent#dataTransfer`.
68
+ *
69
+ * The value is `null` when no `dataTransfer` was passed along with the input event.
70
+ */
71
+ readonly dataTransfer: DataTransfer;
72
+ /**
73
+ * A flag indicating that the `beforeinput` event was fired during composition.
74
+ *
75
+ * Corresponds to the
76
+ * {@link module:engine/view/document~Document#event:compositionstart},
77
+ * {@link module:engine/view/document~Document#event:compositionupdate},
78
+ * and {@link module:engine/view/document~Document#event:compositionend } trio.
79
+ */
80
+ readonly isComposing: boolean;
81
+ /**
82
+ * Editing {@link module:engine/view/range~Range view ranges} corresponding to DOM ranges provided by the web browser
83
+ * (as returned by `InputEvent#getTargetRanges()`).
84
+ */
85
+ readonly targetRanges: Array<ViewRange>;
86
+ }
@@ -0,0 +1,66 @@
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/keyobserver
7
+ */
8
+ import DomEventObserver from './domeventobserver.js';
9
+ import type DomEventData from './domeventdata.js';
10
+ import { type KeystrokeInfo } from '@ckeditor/ckeditor5-utils';
11
+ /**
12
+ * Observer for events connected with pressing keyboard keys.
13
+ *
14
+ * Note that this observer is attached by the {@link module:engine/view/view~View} and is available by default.
15
+ */
16
+ export default class KeyObserver extends DomEventObserver<'keydown' | 'keyup', KeystrokeInfo & {
17
+ keystroke: number;
18
+ }> {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ readonly domEventType: readonly ["keydown", "keyup"];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ onDomEvent(domEvt: KeyboardEvent): void;
27
+ }
28
+ /**
29
+ * Fired when a key has been pressed.
30
+ *
31
+ * Introduced by {@link module:engine/view/observer/keyobserver~KeyObserver}.
32
+ *
33
+ * Note that because {@link module:engine/view/observer/keyobserver~KeyObserver} is attached by the
34
+ * {@link module:engine/view/view~View} this event is available by default.
35
+ *
36
+ * @see module:engine/view/observer/keyobserver~KeyObserver
37
+ * @eventName module:engine/view/document~Document#keydown
38
+ */
39
+ export type ViewDocumentKeyDownEvent = {
40
+ name: 'keydown';
41
+ args: [data: KeyEventData];
42
+ };
43
+ /**
44
+ * Fired when a key has been released.
45
+ *
46
+ * Introduced by {@link module:engine/view/observer/keyobserver~KeyObserver}.
47
+ *
48
+ * Note that because {@link module:engine/view/observer/keyobserver~KeyObserver} is attached by the
49
+ * {@link module:engine/view/view~View} this event is available by default.
50
+ *
51
+ * @see module:engine/view/observer/keyobserver~KeyObserver
52
+ * @eventName module:engine/view/document~Document#keyup
53
+ */
54
+ export type ViewDocumentKeyUpEvent = {
55
+ name: 'keyup';
56
+ args: [data: KeyEventData];
57
+ };
58
+ /**
59
+ * The value of both events - {@link ~ViewDocumentKeyDownEvent} and {@link ~ViewDocumentKeyUpEvent}.
60
+ */
61
+ export interface KeyEventData extends DomEventData<KeyboardEvent>, KeystrokeInfo {
62
+ /**
63
+ * Code of the whole keystroke. See {@link module:utils/keyboard~getCode}.
64
+ */
65
+ keystroke: number;
66
+ }
@@ -0,0 +1,89 @@
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/mouseobserver
7
+ */
8
+ import DomEventObserver from './domeventobserver.js';
9
+ import type DomEventData from './domeventdata.js';
10
+ /**
11
+ * Mouse events observer.
12
+ *
13
+ * Note that this observer is not available by default. To make it available it needs to be added to
14
+ * {@link module:engine/view/view~View} by {@link module:engine/view/view~View#addObserver} method.
15
+ */
16
+ export default class MouseObserver extends DomEventObserver<'mousedown' | 'mouseup' | 'mouseover' | 'mouseout'> {
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ readonly domEventType: readonly ["mousedown", "mouseup", "mouseover", "mouseout"];
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ onDomEvent(domEvent: MouseEvent): void;
25
+ }
26
+ /**
27
+ * Fired when the mouse button is pressed down on one of the editing roots of the editor.
28
+ *
29
+ * Introduced by {@link module:engine/view/observer/mouseobserver~MouseObserver}.
30
+ *
31
+ * Note that this event is not available by default. To make it available, {@link module:engine/view/observer/mouseobserver~MouseObserver}
32
+ * needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
33
+ *
34
+ * @see module:engine/view/observer/mouseobserver~MouseObserver
35
+ * @eventName module:engine/view/document~Document#mousedown
36
+ * @param data The event data.
37
+ */
38
+ export type ViewDocumentMouseDownEvent = {
39
+ name: 'mousedown';
40
+ args: [data: DomEventData<MouseEvent>];
41
+ };
42
+ /**
43
+ * Fired when the mouse button is released over one of the editing roots of the editor.
44
+ *
45
+ * Introduced by {@link module:engine/view/observer/mouseobserver~MouseObserver}.
46
+ *
47
+ * Note that this event is not available by default. To make it available, {@link module:engine/view/observer/mouseobserver~MouseObserver}
48
+ * needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
49
+ *
50
+ * @see module:engine/view/observer/mouseobserver~MouseObserver
51
+ * @eventName module:engine/view/document~Document#mouseup
52
+ * @param data The event data.
53
+ */
54
+ export type ViewDocumentMouseUpEvent = {
55
+ name: 'mouseup';
56
+ args: [data: DomEventData<MouseEvent>];
57
+ };
58
+ /**
59
+ * Fired when the mouse is over one of the editing roots of the editor.
60
+ *
61
+ * Introduced by {@link module:engine/view/observer/mouseobserver~MouseObserver}.
62
+ *
63
+ * Note that this event is not available by default. To make it available, {@link module:engine/view/observer/mouseobserver~MouseObserver}
64
+ * needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
65
+ *
66
+ * @see module:engine/view/observer/mouseobserver~MouseObserver
67
+ * @eventName module:engine/view/document~Document#mouseover
68
+ * @param data The event data.
69
+ */
70
+ export type ViewDocumentMouseOverEvent = {
71
+ name: 'mouseover';
72
+ args: [data: DomEventData<MouseEvent>];
73
+ };
74
+ /**
75
+ * Fired when the mouse is moved out of the one of the editing roots of the editor.
76
+ *
77
+ * Introduced by {@link module:engine/view/observer/mouseobserver~MouseObserver}.
78
+ *
79
+ * Note that this event is not available by default. To make it available, {@link module:engine/view/observer/mouseobserver~MouseObserver}
80
+ * needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
81
+ *
82
+ * @see module:engine/view/observer/mouseobserver~MouseObserver
83
+ * @eventName module:engine/view/document~Document#mouseout
84
+ * @param data The event data.
85
+ */
86
+ export type ViewDocumentMouseOutEvent = {
87
+ name: 'mouseout';
88
+ args: [data: DomEventData<MouseEvent>];
89
+ };
@@ -0,0 +1,86 @@
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/mutationobserver
7
+ */
8
+ import Observer from './observer.js';
9
+ import type DomConverter from '../domconverter.js';
10
+ import type Renderer from '../renderer.js';
11
+ import type View from '../view.js';
12
+ /**
13
+ * Mutation observer's role is to watch for any DOM changes inside the editor that weren't
14
+ * done by the editor's {@link module:engine/view/renderer~Renderer} itself and reverting these changes.
15
+ *
16
+ * It does this by observing all mutations in the DOM, marking related view elements as changed and calling
17
+ * {@link module:engine/view/renderer~Renderer#render}. Because all mutated nodes are marked as
18
+ * "to be rendered" and the {@link module:engine/view/renderer~Renderer#render `render()`} method is called,
19
+ * all changes are reverted in the DOM (the DOM is synced with the editor's view structure).
20
+ *
21
+ * Note that this observer is attached by the {@link module:engine/view/view~View} and is available by default.
22
+ */
23
+ export default class MutationObserver extends Observer {
24
+ /**
25
+ * Reference to the {@link module:engine/view/view~View#domConverter}.
26
+ */
27
+ readonly domConverter: DomConverter;
28
+ /**
29
+ * Reference to the {@link module:engine/view/view~View#_renderer}.
30
+ */
31
+ readonly renderer: Renderer;
32
+ /**
33
+ * Native mutation observer config.
34
+ */
35
+ private readonly _config;
36
+ /**
37
+ * Observed DOM elements.
38
+ */
39
+ private readonly _domElements;
40
+ /**
41
+ * Native mutation observer.
42
+ */
43
+ private _mutationObserver;
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ constructor(view: View);
48
+ /**
49
+ * Synchronously handles mutations and empties the queue.
50
+ */
51
+ flush(): void;
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ observe(domElement: HTMLElement): void;
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ stopObserving(domElement: HTMLElement): void;
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ enable(): void;
64
+ /**
65
+ * @inheritDoc
66
+ */
67
+ disable(): void;
68
+ /**
69
+ * @inheritDoc
70
+ */
71
+ destroy(): void;
72
+ /**
73
+ * Handles mutations. Mark view elements to sync and call render.
74
+ *
75
+ * @param domMutations Array of native mutations.
76
+ */
77
+ private _onMutations;
78
+ /**
79
+ * Checks if mutation was generated by the browser inserting bogus br on the end of the block element.
80
+ * Such mutations are generated while pressing space or performing native spellchecker correction
81
+ * on the end of the block element in Firefox browser.
82
+ *
83
+ * @param mutation Native mutation object.
84
+ */
85
+ private _isBogusBrMutation;
86
+ }
@@ -0,0 +1,89 @@
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
+ import type Document from '../document.js';
6
+ import type View from '../view.js';
7
+ declare const Observer_base: {
8
+ new (): import("@ckeditor/ckeditor5-utils").DomEmitter;
9
+ prototype: import("@ckeditor/ckeditor5-utils").DomEmitter;
10
+ };
11
+ /**
12
+ * Abstract base observer class. Observers are classes which listen to DOM events, do the preliminary
13
+ * processing and fire events on the {@link module:engine/view/document~Document} objects.
14
+ * Observers can also add features to the view, for instance by updating its status or marking elements
15
+ * which need a refresh on DOM events.
16
+ */
17
+ export default abstract class Observer extends Observer_base {
18
+ /**
19
+ * An instance of the view controller.
20
+ */
21
+ readonly view: View;
22
+ /**
23
+ * A reference to the {@link module:engine/view/document~Document} object.
24
+ */
25
+ readonly document: Document;
26
+ /**
27
+ * The state of the observer. If it is disabled, no events will be fired.
28
+ */
29
+ private _isEnabled;
30
+ /**
31
+ * Creates an instance of the observer.
32
+ */
33
+ constructor(view: View);
34
+ /**
35
+ * The state of the observer. If it is disabled, no events will be fired.
36
+ */
37
+ get isEnabled(): boolean;
38
+ /**
39
+ * Enables the observer. This method is called when the observer is registered to the
40
+ * {@link module:engine/view/view~View} and after {@link module:engine/view/view~View#forceRender rendering}
41
+ * (all observers are {@link #disable disabled} before rendering).
42
+ *
43
+ * A typical use case for disabling observers is that mutation observers need to be disabled for the rendering.
44
+ * However, a child class may not need to be disabled, so it can implement an empty method.
45
+ *
46
+ * @see module:engine/view/observer/observer~Observer#disable
47
+ */
48
+ enable(): void;
49
+ /**
50
+ * Disables the observer. This method is called before
51
+ * {@link module:engine/view/view~View#forceRender rendering} to prevent firing events during rendering.
52
+ *
53
+ * @see module:engine/view/observer/observer~Observer#enable
54
+ */
55
+ disable(): void;
56
+ /**
57
+ * Disables and destroys the observer, among others removes event listeners created by the observer.
58
+ */
59
+ destroy(): void;
60
+ /**
61
+ * Checks whether a given DOM event should be ignored (should not be turned into a synthetic view document event).
62
+ *
63
+ * Currently, an event will be ignored only if its target or any of its ancestors has the `data-cke-ignore-events` attribute.
64
+ * This attribute can be used inside the structures generated by
65
+ * {@link module:engine/view/downcastwriter~DowncastWriter#createUIElement `DowncastWriter#createUIElement()`} to ignore events
66
+ * fired within a UI that should be excluded from CKEditor 5's realms.
67
+ *
68
+ * @param domTarget The DOM event target to check (usually an element, sometimes a text node and
69
+ * potentially sometimes a document, too).
70
+ * @returns Whether this event should be ignored by the observer.
71
+ */
72
+ checkShouldIgnoreEventFromTarget(domTarget: Node | null): boolean;
73
+ /**
74
+ * Starts observing given DOM element.
75
+ *
76
+ * @param domElement DOM element to observe.
77
+ * @param name The name of the related root element.
78
+ */
79
+ abstract observe(domElement: HTMLElement, name: string): void;
80
+ /**
81
+ * Stops observing given DOM element.
82
+ */
83
+ abstract stopObserving(domElement: HTMLElement): void;
84
+ }
85
+ /**
86
+ * The constructor of {@link ~Observer} subclass.
87
+ */
88
+ export type ObserverConstructor = new (view: View) => Observer;
89
+ export {};