@ckeditor/ckeditor5-engine 44.3.0-alpha.7 → 45.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 (93) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/index.js +304 -128
  3. package/dist/index.js.map +1 -1
  4. package/package.json +3 -3
  5. package/src/controller/datacontroller.js +40 -0
  6. package/src/controller/editingcontroller.js +16 -0
  7. package/src/conversion/conversion.js +6 -4
  8. package/src/conversion/conversionhelpers.js +1 -0
  9. package/src/conversion/downcastdispatcher.js +10 -0
  10. package/src/conversion/downcasthelpers.js +1 -1
  11. package/src/conversion/mapper.js +92 -95
  12. package/src/conversion/modelconsumable.js +13 -15
  13. package/src/conversion/upcastdispatcher.js +28 -24
  14. package/src/conversion/upcasthelpers.js +1 -1
  15. package/src/conversion/viewconsumable.js +19 -20
  16. package/src/dataprocessor/htmldataprocessor.js +13 -1
  17. package/src/dataprocessor/xmldataprocessor.js +21 -1
  18. package/src/dev-utils/model.js +1 -1
  19. package/src/dev-utils/operationreplayer.js +3 -0
  20. package/src/dev-utils/utils.js +35 -1
  21. package/src/dev-utils/view.js +13 -0
  22. package/src/model/batch.js +20 -0
  23. package/src/model/differ.js +92 -88
  24. package/src/model/document.d.ts +1 -3
  25. package/src/model/document.js +38 -1
  26. package/src/model/documentfragment.js +10 -10
  27. package/src/model/documentselection.js +44 -32
  28. package/src/model/element.js +8 -4
  29. package/src/model/history.js +31 -33
  30. package/src/model/markercollection.js +25 -7
  31. package/src/model/model.js +21 -0
  32. package/src/model/node.js +22 -18
  33. package/src/model/nodelist.js +12 -12
  34. package/src/model/operation/attributeoperation.js +25 -1
  35. package/src/model/operation/detachoperation.js +8 -0
  36. package/src/model/operation/insertoperation.js +18 -0
  37. package/src/model/operation/markeroperation.js +29 -0
  38. package/src/model/operation/mergeoperation.js +16 -0
  39. package/src/model/operation/moveoperation.js +12 -0
  40. package/src/model/operation/operation.js +19 -0
  41. package/src/model/operation/renameoperation.js +12 -0
  42. package/src/model/operation/rootattributeoperation.js +20 -0
  43. package/src/model/operation/rootoperation.js +16 -0
  44. package/src/model/operation/splitoperation.js +19 -0
  45. package/src/model/operation/transform.js +5 -0
  46. package/src/model/position.js +40 -0
  47. package/src/model/range.js +8 -0
  48. package/src/model/rootelement.js +18 -10
  49. package/src/model/schema.js +25 -23
  50. package/src/model/selection.js +10 -10
  51. package/src/model/text.js +6 -0
  52. package/src/model/textproxy.js +12 -0
  53. package/src/model/treewalker.js +49 -0
  54. package/src/model/utils/insertcontent.js +60 -25
  55. package/src/model/writer.js +8 -0
  56. package/src/view/attributeelement.js +23 -23
  57. package/src/view/datatransfer.js +8 -0
  58. package/src/view/document.js +21 -4
  59. package/src/view/documentfragment.js +13 -9
  60. package/src/view/documentselection.js +4 -0
  61. package/src/view/domconverter.d.ts +6 -1
  62. package/src/view/domconverter.js +109 -48
  63. package/src/view/downcastwriter.js +14 -10
  64. package/src/view/element.js +29 -17
  65. package/src/view/matcher.js +1 -1
  66. package/src/view/node.js +9 -1
  67. package/src/view/observer/bubblingeventinfo.js +12 -0
  68. package/src/view/observer/clickobserver.js +4 -7
  69. package/src/view/observer/compositionobserver.js +14 -12
  70. package/src/view/observer/domeventdata.js +17 -1
  71. package/src/view/observer/domeventobserver.js +10 -13
  72. package/src/view/observer/fakeselectionobserver.d.ts +1 -1
  73. package/src/view/observer/fakeselectionobserver.js +5 -1
  74. package/src/view/observer/focusobserver.js +65 -14
  75. package/src/view/observer/inputobserver.js +33 -26
  76. package/src/view/observer/keyobserver.js +4 -7
  77. package/src/view/observer/mouseobserver.js +4 -7
  78. package/src/view/observer/mutationobserver.js +23 -6
  79. package/src/view/observer/observer.js +12 -4
  80. package/src/view/observer/selectionobserver.d.ts +6 -1
  81. package/src/view/observer/selectionobserver.js +94 -17
  82. package/src/view/observer/touchobserver.js +4 -7
  83. package/src/view/position.js +8 -0
  84. package/src/view/range.js +8 -0
  85. package/src/view/renderer.js +142 -70
  86. package/src/view/selection.js +16 -0
  87. package/src/view/stylesmap.js +26 -11
  88. package/src/view/text.js +6 -0
  89. package/src/view/textproxy.js +12 -0
  90. package/src/view/tokenlist.js +4 -6
  91. package/src/view/treewalker.js +42 -0
  92. package/src/view/upcastwriter.js +5 -1
  93. package/src/view/view.js +51 -33
@@ -10,7 +10,7 @@
10
10
  * @module engine/dev-utils/utils
11
11
  */
12
12
  /* globals console */
13
- // @if CK_DEBUG_TYPING // const { debounce } = require( 'lodash-es' );
13
+ // @if CK_DEBUG_TYPING // const { debounce } = require( 'es-toolkit/compat' );
14
14
  /**
15
15
  * Helper function, converts a map to the 'key1="value1" key2="value1"' format.
16
16
  *
@@ -78,3 +78,37 @@ export function logDocument(document, version) {
78
78
  // @if CK_DEBUG_TYPING // 'font-weight: bold; color: red'
79
79
  // @if CK_DEBUG_TYPING // );
80
80
  // @if CK_DEBUG_TYPING // }, 300 );
81
+ // @if CK_DEBUG_TYPING // export function _buildLogMessage( context, className, message = '', ...rest ) {
82
+ // @if CK_DEBUG_TYPING // const editor = _findAllEditorInstances().find( editor => (
83
+ // @if CK_DEBUG_TYPING // _getLogNodes( editor ).includes( context )
84
+ // @if CK_DEBUG_TYPING // ) );
85
+ // @if CK_DEBUG_TYPING // const editorName = editor && Object.getPrototypeOf( editor ).constructor.name;
86
+ // @if CK_DEBUG_TYPING // const editorPrefix = editor ? `${ editorName }-${ editor.id.slice( -4 ) } ` : 'UNKNOWN ';
87
+ // @if CK_DEBUG_TYPING // return [
88
+ // @if CK_DEBUG_TYPING // `%c${ editorPrefix }%c[${ className }]%c ${ message }`,
89
+ // @if CK_DEBUG_TYPING // 'font-weight: normal;',
90
+ // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green',
91
+ // @if CK_DEBUG_TYPING // '',
92
+ // @if CK_DEBUG_TYPING // ...rest
93
+ // @if CK_DEBUG_TYPING // ];
94
+ // @if CK_DEBUG_TYPING // }
95
+ // @if CK_DEBUG_TYPING // function _findAllEditorInstances() {
96
+ // @if CK_DEBUG_TYPING // const editors = new Set();
97
+ // @if CK_DEBUG_TYPING // for ( const domEditable of document.querySelectorAll( '.ck.ck-content.ck-editor__editable' ) ) {
98
+ // @if CK_DEBUG_TYPING // if ( domEditable.ckeditorInstance ) {
99
+ // @if CK_DEBUG_TYPING // editors.add( domEditable.ckeditorInstance );
100
+ // @if CK_DEBUG_TYPING // }
101
+ // @if CK_DEBUG_TYPING // }
102
+ // @if CK_DEBUG_TYPING // return Array.from( editors );
103
+ // @if CK_DEBUG_TYPING // }
104
+ // @if CK_DEBUG_TYPING // function _getLogNodes( editor ) {
105
+ // @if CK_DEBUG_TYPING // return [
106
+ // @if CK_DEBUG_TYPING // editor.editing.view._renderer,
107
+ // @if CK_DEBUG_TYPING // editor.editing.view.domConverter,
108
+ // @if CK_DEBUG_TYPING // ...editor.editing.view._observers.values(),
109
+ // @if CK_DEBUG_TYPING // editor.plugins.get( 'Input' ),
110
+ // @if CK_DEBUG_TYPING // editor.plugins.get( 'WidgetTypeAround' ),
111
+ // @if CK_DEBUG_TYPING // editor.commands.get( 'delete' ),
112
+ // @if CK_DEBUG_TYPING // editor.commands.get( 'deleteForward' )
113
+ // @if CK_DEBUG_TYPING // ];
114
+ // @if CK_DEBUG_TYPING // }
@@ -404,6 +404,8 @@ export function parse(data, options = {}) {
404
404
  * Private helper class used for converting ranges represented as text inside view {@link module:engine/view/text~Text text nodes}.
405
405
  */
406
406
  class RangeParser {
407
+ sameSelectionCharacters;
408
+ _positions;
407
409
  /**
408
410
  * Creates a range parser instance.
409
411
  *
@@ -578,6 +580,17 @@ class RangeParser {
578
580
  * Private helper class used for converting the view tree to a string.
579
581
  */
580
582
  class ViewStringify {
583
+ root;
584
+ selection;
585
+ ranges;
586
+ showType;
587
+ showPriority;
588
+ showAttributeElementId;
589
+ ignoreRoot;
590
+ sameSelectionCharacters;
591
+ renderUIElements;
592
+ renderRawElements;
593
+ domConverter;
581
594
  /**
582
595
  * Creates a view stringify instance.
583
596
  *
@@ -21,6 +21,26 @@ import { logWarning } from '@ckeditor/ckeditor5-utils';
21
21
  * @see module:engine/model/model~Model#change
22
22
  */
23
23
  export default class Batch {
24
+ /**
25
+ * An array of operations that compose this batch.
26
+ */
27
+ operations;
28
+ /**
29
+ * Whether the batch can be undone through the undo feature.
30
+ */
31
+ isUndoable;
32
+ /**
33
+ * Whether the batch includes operations created locally (`true`) or operations created on other, remote editors (`false`).
34
+ */
35
+ isLocal;
36
+ /**
37
+ * Whether the batch was created by the undo feature and undoes other operations.
38
+ */
39
+ isUndo;
40
+ /**
41
+ * Whether the batch includes operations connected with typing.
42
+ */
43
+ isTyping;
24
44
  /**
25
45
  * Creates a batch instance.
26
46
  *
@@ -16,95 +16,104 @@ import Range from './range.js';
16
16
  * elements and new ones and returns a change set.
17
17
  */
18
18
  class Differ {
19
+ /**
20
+ * Priority of the {@link ~Differ#_elementState element states}. States on higher indexes of the array can overwrite states on the lower
21
+ * indexes.
22
+ */
23
+ static _statesPriority = [undefined, 'refresh', 'rename', 'move'];
24
+ /**
25
+ * Reference to the model's marker collection.
26
+ */
27
+ _markerCollection;
28
+ /**
29
+ * A map that stores changes that happened in a given element.
30
+ *
31
+ * The keys of the map are references to the model elements.
32
+ * The values of the map are arrays with changes that were done on this element.
33
+ */
34
+ _changesInElement = new Map();
35
+ /**
36
+ * Stores a snapshot for these model nodes that might have changed.
37
+ *
38
+ * This complements {@link ~Differ#_elementChildrenSnapshots `_elementChildrenSnapshots`}.
39
+ *
40
+ * See also {@link ~DifferSnapshot}.
41
+ */
42
+ _elementsSnapshots = new Map();
43
+ /**
44
+ * For each element or document fragment inside which there was a change, it stores a snapshot of the child nodes list (an array
45
+ * of children snapshots that represent the state in the element / fragment before any change has happened).
46
+ *
47
+ * This complements {@link ~Differ#_elementsSnapshots `_elementsSnapshots`}.
48
+ *
49
+ * See also {@link ~DifferSnapshot}.
50
+ */
51
+ _elementChildrenSnapshots = new Map();
52
+ /**
53
+ * Keeps the state for a given element, describing how the element was changed so far. It is used to evaluate the `action` property
54
+ * of diff items returned by {@link ~Differ#getChanges}.
55
+ *
56
+ * Possible values, in the order from the lowest priority to the highest priority:
57
+ *
58
+ * * `'refresh'` - element was refreshed,
59
+ * * `'rename'` - element was renamed,
60
+ * * `'move'` - element was moved (or, usually, removed, that is moved to the graveyard).
61
+ *
62
+ * Element that was refreshed, may change its state to `'rename'` if it was later renamed, or to `'move'` if it was removed.
63
+ * But the element cannot change its state from `'move'` to `'rename'`, or from `'rename'` to `'refresh'`.
64
+ *
65
+ * Only already existing elements are registered in `_elementState`. If a new element was inserted as a result of a buffered operation,
66
+ * it is not be registered in `_elementState`.
67
+ */
68
+ _elementState = new Map();
69
+ /**
70
+ * A map that stores all changed markers.
71
+ *
72
+ * The keys of the map are marker names.
73
+ *
74
+ * The values of the map are objects with the following properties:
75
+ *
76
+ * * `oldMarkerData`,
77
+ * * `newMarkerData`.
78
+ */
79
+ _changedMarkers = new Map();
80
+ /**
81
+ * A map that stores all roots that have been changed.
82
+ *
83
+ * The keys are the names of the roots while value represents the changes.
84
+ */
85
+ _changedRoots = new Map();
86
+ /**
87
+ * Stores the number of changes that were processed. Used to order the changes chronologically. It is important
88
+ * when changes are sorted.
89
+ */
90
+ _changeCount = 0;
91
+ /**
92
+ * For efficiency purposes, `Differ` stores the change set returned by the differ after {@link #getChanges} call.
93
+ * Cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
94
+ * return the cached value instead of calculating it again.
95
+ *
96
+ * This property stores those changes that did not take place in graveyard root.
97
+ */
98
+ _cachedChanges = null;
99
+ /**
100
+ * For efficiency purposes, `Differ` stores the change set returned by the differ after the {@link #getChanges} call.
101
+ * The cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
102
+ * return the cached value instead of calculating it again.
103
+ *
104
+ * This property stores all changes evaluated by `Differ`, including those that took place in the graveyard.
105
+ */
106
+ _cachedChangesWithGraveyard = null;
107
+ /**
108
+ * Set of model items that were marked to get refreshed in {@link #_refreshItem}.
109
+ */
110
+ _refreshedItems = new Set();
19
111
  /**
20
112
  * Creates a `Differ` instance.
21
113
  *
22
114
  * @param markerCollection Model's marker collection.
23
115
  */
24
116
  constructor(markerCollection) {
25
- /**
26
- * A map that stores changes that happened in a given element.
27
- *
28
- * The keys of the map are references to the model elements.
29
- * The values of the map are arrays with changes that were done on this element.
30
- */
31
- this._changesInElement = new Map();
32
- /**
33
- * Stores a snapshot for these model nodes that might have changed.
34
- *
35
- * This complements {@link ~Differ#_elementChildrenSnapshots `_elementChildrenSnapshots`}.
36
- *
37
- * See also {@link ~DifferSnapshot}.
38
- */
39
- this._elementsSnapshots = new Map();
40
- /**
41
- * For each element or document fragment inside which there was a change, it stores a snapshot of the child nodes list (an array
42
- * of children snapshots that represent the state in the element / fragment before any change has happened).
43
- *
44
- * This complements {@link ~Differ#_elementsSnapshots `_elementsSnapshots`}.
45
- *
46
- * See also {@link ~DifferSnapshot}.
47
- */
48
- this._elementChildrenSnapshots = new Map();
49
- /**
50
- * Keeps the state for a given element, describing how the element was changed so far. It is used to evaluate the `action` property
51
- * of diff items returned by {@link ~Differ#getChanges}.
52
- *
53
- * Possible values, in the order from the lowest priority to the highest priority:
54
- *
55
- * * `'refresh'` - element was refreshed,
56
- * * `'rename'` - element was renamed,
57
- * * `'move'` - element was moved (or, usually, removed, that is moved to the graveyard).
58
- *
59
- * Element that was refreshed, may change its state to `'rename'` if it was later renamed, or to `'move'` if it was removed.
60
- * But the element cannot change its state from `'move'` to `'rename'`, or from `'rename'` to `'refresh'`.
61
- *
62
- * Only already existing elements are registered in `_elementState`. If a new element was inserted as a result of a buffered operation,
63
- * it is not be registered in `_elementState`.
64
- */
65
- this._elementState = new Map();
66
- /**
67
- * A map that stores all changed markers.
68
- *
69
- * The keys of the map are marker names.
70
- *
71
- * The values of the map are objects with the following properties:
72
- *
73
- * * `oldMarkerData`,
74
- * * `newMarkerData`.
75
- */
76
- this._changedMarkers = new Map();
77
- /**
78
- * A map that stores all roots that have been changed.
79
- *
80
- * The keys are the names of the roots while value represents the changes.
81
- */
82
- this._changedRoots = new Map();
83
- /**
84
- * Stores the number of changes that were processed. Used to order the changes chronologically. It is important
85
- * when changes are sorted.
86
- */
87
- this._changeCount = 0;
88
- /**
89
- * For efficiency purposes, `Differ` stores the change set returned by the differ after {@link #getChanges} call.
90
- * Cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
91
- * return the cached value instead of calculating it again.
92
- *
93
- * This property stores those changes that did not take place in graveyard root.
94
- */
95
- this._cachedChanges = null;
96
- /**
97
- * For efficiency purposes, `Differ` stores the change set returned by the differ after the {@link #getChanges} call.
98
- * The cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
99
- * return the cached value instead of calculating it again.
100
- *
101
- * This property stores all changes evaluated by `Differ`, including those that took place in the graveyard.
102
- */
103
- this._cachedChangesWithGraveyard = null;
104
- /**
105
- * Set of model items that were marked to get refreshed in {@link #_refreshItem}.
106
- */
107
- this._refreshedItems = new Set();
108
117
  this._markerCollection = markerCollection;
109
118
  }
110
119
  /**
@@ -1135,11 +1144,6 @@ class Differ {
1135
1144
  }
1136
1145
  }
1137
1146
  }
1138
- /**
1139
- * Priority of the {@link ~Differ#_elementState element states}. States on higher indexes of the array can overwrite states on the lower
1140
- * indexes.
1141
- */
1142
- Differ._statesPriority = [undefined, 'refresh', 'rename', 'move'];
1143
1147
  export default Differ;
1144
1148
  /**
1145
1149
  * Returns a snapshot for the specified child node. Text node snapshots have the `name` property set to `$text`.
@@ -16,9 +16,7 @@ import type Writer from './writer.js';
16
16
  import { Collection } from '@ckeditor/ckeditor5-utils';
17
17
  declare const Document_base: {
18
18
  new (): import("@ckeditor/ckeditor5-utils").Emitter;
19
- prototype: import("@ckeditor/ckeditor5-utils").Emitter; /**
20
- * The model differ object. Its role is to buffer changes done on the model document and then calculate a diff of those changes.
21
- */
19
+ prototype: import("@ckeditor/ckeditor5-utils").Emitter;
22
20
  };
23
21
  /**
24
22
  * Data model's document. It contains the model's structure, its selection and the history of changes.
@@ -10,7 +10,7 @@ import DocumentSelection from './documentselection.js';
10
10
  import History from './history.js';
11
11
  import RootElement from './rootelement.js';
12
12
  import { CKEditorError, Collection, EmitterMixin, isInsideSurrogatePair, isInsideCombinedSymbol } from '@ckeditor/ckeditor5-utils';
13
- import { clone } from 'lodash-es';
13
+ import { clone } from 'es-toolkit/compat';
14
14
  // @if CK_DEBUG_ENGINE // const { logDocument } = require( '../dev-utils/utils' );
15
15
  const graveyardName = '$graveyard';
16
16
  /**
@@ -30,6 +30,43 @@ const graveyardName = '$graveyard';
30
30
  * (e.g. a title and a body of a message).
31
31
  */
32
32
  export default class Document extends /* #__PURE__ */ EmitterMixin() {
33
+ /**
34
+ * The {@link module:engine/model/model~Model model} that the document is a part of.
35
+ */
36
+ model;
37
+ /**
38
+ * The document's history.
39
+ */
40
+ history;
41
+ /**
42
+ * The selection in this document.
43
+ */
44
+ selection;
45
+ /**
46
+ * A list of roots that are owned and managed by this document. Use {@link #createRoot}, {@link #getRoot} and
47
+ * {@link #getRootNames} to manipulate it.
48
+ */
49
+ roots;
50
+ /**
51
+ * The model differ object. Its role is to buffer changes done on the model document and then calculate a diff of those changes.
52
+ */
53
+ differ;
54
+ /**
55
+ * Defines whether the document is in a read-only mode.
56
+ *
57
+ * The user should not be able to change the data of a document that is read-only.
58
+ *
59
+ * @readonly
60
+ */
61
+ isReadOnly;
62
+ /**
63
+ * Post-fixer callbacks registered to the model document.
64
+ */
65
+ _postFixers;
66
+ /**
67
+ * A flag that indicates whether the selection has changed since last change block.
68
+ */
69
+ _hasSelectionChangedFromTheLastChangeBlock;
33
70
  /**
34
71
  * Creates an empty document instance with no {@link #roots} (other than
35
72
  * the {@link #graveyard graveyard root}).
@@ -21,6 +21,16 @@ import { isIterable } from '@ckeditor/ckeditor5-utils';
21
21
  * {@link module:engine/model/writer~Writer#insert} function.
22
22
  */
23
23
  export default class DocumentFragment extends TypeCheckable {
24
+ /**
25
+ * DocumentFragment static markers map. This is a list of names and {@link module:engine/model/range~Range ranges}
26
+ * which will be set as Markers to {@link module:engine/model/model~Model#markers model markers collection}
27
+ * when DocumentFragment will be inserted to the document.
28
+ */
29
+ markers = new Map();
30
+ /**
31
+ * List of nodes contained inside the document fragment.
32
+ */
33
+ _children = new NodeList();
24
34
  /**
25
35
  * Creates an empty `DocumentFragment`.
26
36
  *
@@ -32,16 +42,6 @@ export default class DocumentFragment extends TypeCheckable {
32
42
  */
33
43
  constructor(children) {
34
44
  super();
35
- /**
36
- * DocumentFragment static markers map. This is a list of names and {@link module:engine/model/range~Range ranges}
37
- * which will be set as Markers to {@link module:engine/model/model~Model#markers model markers collection}
38
- * when DocumentFragment will be inserted to the document.
39
- */
40
- this.markers = new Map();
41
- /**
42
- * List of nodes contained inside the document fragment.
43
- */
44
- this._children = new NodeList();
45
45
  if (children) {
46
46
  this._insertChild(0, children);
47
47
  }
@@ -37,6 +37,10 @@ const storePrefix = 'selection:';
37
37
  * use {@link module:engine/model/selection~Selection Selection class} instead.
38
38
  */
39
39
  export default class DocumentSelection extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
40
+ /**
41
+ * Selection used internally by that class (`DocumentSelection` is a proxy to that selection).
42
+ */
43
+ _selection;
40
44
  /**
41
45
  * Creates an empty live selection for given {@link module:engine/model/document~Document}.
42
46
  *
@@ -437,6 +441,46 @@ DocumentSelection.prototype.is = function (type) {
437
441
  * * attributes of `LiveSelection` are updated automatically according to selection ranges.
438
442
  */
439
443
  class LiveSelection extends Selection {
444
+ /**
445
+ * List of selection markers.
446
+ * Marker is a selection marker when selection range is inside the marker range.
447
+ */
448
+ markers = new Collection({ idProperty: 'name' });
449
+ /**
450
+ * Document which owns this selection.
451
+ */
452
+ _model;
453
+ /**
454
+ * Document which owns this selection.
455
+ */
456
+ _document;
457
+ /**
458
+ * Keeps mapping of attribute name to priority with which the attribute got modified (added/changed/removed)
459
+ * last time. Possible values of priority are: `'low'` and `'normal'`.
460
+ *
461
+ * Priorities are used by internal `LiveSelection` mechanisms. All attributes set using `LiveSelection`
462
+ * attributes API are set with `'normal'` priority.
463
+ */
464
+ _attributePriority = new Map();
465
+ /**
466
+ * Position to which the selection should be set if the last selection range was moved to the graveyard.
467
+ */
468
+ _selectionRestorePosition = null;
469
+ /**
470
+ * Flag that informs whether the selection ranges have changed. It is changed on true when `LiveRange#change:range` event is fired.
471
+ */
472
+ _hasChangedRange = false;
473
+ /**
474
+ * Each overriding gravity adds an UID to the set and each removal removes it.
475
+ * Gravity is overridden when there's at least one UID in the set.
476
+ * Gravity is restored when the set is empty.
477
+ * This is to prevent conflicts when gravity is overridden by more than one feature at the same time.
478
+ */
479
+ _overriddenGravityRegister = new Set();
480
+ /**
481
+ * Prefixes of marker names that should affect `LiveSelection#markers` collection.
482
+ */
483
+ _observedMarkers = new Set();
440
484
  /**
441
485
  * Creates an empty live selection for given {@link module:engine/model/document~Document}.
442
486
  *
@@ -444,38 +488,6 @@ class LiveSelection extends Selection {
444
488
  */
445
489
  constructor(doc) {
446
490
  super();
447
- /**
448
- * List of selection markers.
449
- * Marker is a selection marker when selection range is inside the marker range.
450
- */
451
- this.markers = new Collection({ idProperty: 'name' });
452
- /**
453
- * Keeps mapping of attribute name to priority with which the attribute got modified (added/changed/removed)
454
- * last time. Possible values of priority are: `'low'` and `'normal'`.
455
- *
456
- * Priorities are used by internal `LiveSelection` mechanisms. All attributes set using `LiveSelection`
457
- * attributes API are set with `'normal'` priority.
458
- */
459
- this._attributePriority = new Map();
460
- /**
461
- * Position to which the selection should be set if the last selection range was moved to the graveyard.
462
- */
463
- this._selectionRestorePosition = null;
464
- /**
465
- * Flag that informs whether the selection ranges have changed. It is changed on true when `LiveRange#change:range` event is fired.
466
- */
467
- this._hasChangedRange = false;
468
- /**
469
- * Each overriding gravity adds an UID to the set and each removal removes it.
470
- * Gravity is overridden when there's at least one UID in the set.
471
- * Gravity is restored when the set is empty.
472
- * This is to prevent conflicts when gravity is overridden by more than one feature at the same time.
473
- */
474
- this._overriddenGravityRegister = new Set();
475
- /**
476
- * Prefixes of marker names that should affect `LiveSelection#markers` collection.
477
- */
478
- this._observedMarkers = new Set();
479
491
  this._model = doc.model;
480
492
  this._document = doc;
481
493
  // Ensure selection is correct after each operation.
@@ -18,6 +18,14 @@ import { isIterable } from '@ckeditor/ckeditor5-utils';
18
18
  * **Important**: see {@link module:engine/model/node~Node} to read about restrictions using `Element` and `Node` API.
19
19
  */
20
20
  export default class Element extends Node {
21
+ /**
22
+ * Element name.
23
+ */
24
+ name;
25
+ /**
26
+ * List of children nodes.
27
+ */
28
+ _children = new NodeList();
21
29
  /**
22
30
  * Creates a model element.
23
31
  *
@@ -31,10 +39,6 @@ export default class Element extends Node {
31
39
  */
32
40
  constructor(name, attrs, children) {
33
41
  super(attrs);
34
- /**
35
- * List of children nodes.
36
- */
37
- this._children = new NodeList();
38
42
  this.name = name;
39
43
  if (children) {
40
44
  this._insertChild(0, children);
@@ -10,39 +10,37 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
10
10
  * `History` keeps the track of all the operations applied to the {@link module:engine/model/document~Document document}.
11
11
  */
12
12
  export default class History {
13
- constructor() {
14
- /**
15
- * Operations added to the history.
16
- */
17
- this._operations = [];
18
- /**
19
- * Holds an information which {@link module:engine/model/operation/operation~Operation operation} undoes which
20
- * {@link module:engine/model/operation/operation~Operation operation}.
21
- *
22
- * Keys of the map are "undoing operations", that is operations that undone some other operations. For each key, the
23
- * value is an operation that has been undone by the "undoing operation".
24
- */
25
- this._undoPairs = new Map();
26
- /**
27
- * Holds all undone operations.
28
- */
29
- this._undoneOperations = new Set();
30
- /**
31
- * A map that allows retrieving the operations fast based on the given base version.
32
- */
33
- this._baseVersionToOperationIndex = new Map();
34
- /**
35
- * The history version.
36
- */
37
- this._version = 0;
38
- /**
39
- * The gap pairs kept in the <from,to> format.
40
- *
41
- * Anytime the `history.version` is set to a version larger than `history.version + 1`,
42
- * a new <lastHistoryVersion, newHistoryVersion> entry is added to the map.
43
- */
44
- this._gaps = new Map();
45
- }
13
+ /**
14
+ * Operations added to the history.
15
+ */
16
+ _operations = [];
17
+ /**
18
+ * Holds an information which {@link module:engine/model/operation/operation~Operation operation} undoes which
19
+ * {@link module:engine/model/operation/operation~Operation operation}.
20
+ *
21
+ * Keys of the map are "undoing operations", that is operations that undone some other operations. For each key, the
22
+ * value is an operation that has been undone by the "undoing operation".
23
+ */
24
+ _undoPairs = new Map();
25
+ /**
26
+ * Holds all undone operations.
27
+ */
28
+ _undoneOperations = new Set();
29
+ /**
30
+ * A map that allows retrieving the operations fast based on the given base version.
31
+ */
32
+ _baseVersionToOperationIndex = new Map();
33
+ /**
34
+ * The history version.
35
+ */
36
+ _version = 0;
37
+ /**
38
+ * The gap pairs kept in the <from,to> format.
39
+ *
40
+ * Anytime the `history.version` is set to a version larger than `history.version + 1`,
41
+ * a new <lastHistoryVersion, newHistoryVersion> entry is added to the map.
42
+ */
43
+ _gaps = new Map();
46
44
  /**
47
45
  * The version of the last operation in the history.
48
46
  *
@@ -23,13 +23,10 @@ import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
23
23
  * @see module:engine/model/markercollection~Marker
24
24
  */
25
25
  export default class MarkerCollection extends /* #__PURE__ */ EmitterMixin() {
26
- constructor() {
27
- super(...arguments);
28
- /**
29
- * Stores {@link ~Marker markers} added to the collection.
30
- */
31
- this._markers = new Map();
32
- }
26
+ /**
27
+ * Stores {@link ~Marker markers} added to the collection.
28
+ */
29
+ _markers = new Map();
33
30
  /**
34
31
  * Iterable interface.
35
32
  *
@@ -283,6 +280,27 @@ export default class MarkerCollection extends /* #__PURE__ */ EmitterMixin() {
283
280
  * `Marker` instances are created and destroyed only by {@link ~MarkerCollection MarkerCollection}.
284
281
  */
285
282
  class Marker extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
283
+ /**
284
+ * Marker's name.
285
+ */
286
+ name;
287
+ /**
288
+ * Flag indicates if the marker is managed using operations or not.
289
+ *
290
+ * @internal
291
+ */
292
+ _managedUsingOperations;
293
+ /**
294
+ * Specifies whether the marker affects the data produced by the data pipeline
295
+ * (is persisted in the editor's data).
296
+ *
297
+ * @internal
298
+ */
299
+ _affectsData;
300
+ /**
301
+ * Range marked by the marker.
302
+ */
303
+ _liveRange;
286
304
  /**
287
305
  * Creates a marker instance.
288
306
  *
@@ -31,6 +31,27 @@ import { CKEditorError, ObservableMixin } from '@ckeditor/ckeditor5-utils';
31
31
  * {@glink framework/architecture/editing-engine engine architecture} guide.
32
32
  */
33
33
  export default class Model extends /* #__PURE__ */ ObservableMixin() {
34
+ /**
35
+ * Model's marker collection.
36
+ */
37
+ markers;
38
+ /**
39
+ * Model's document.
40
+ */
41
+ document;
42
+ /**
43
+ * Model's schema.
44
+ */
45
+ schema;
46
+ /**
47
+ * All callbacks added by {@link module:engine/model/model~Model#change} or
48
+ * {@link module:engine/model/model~Model#enqueueChange} methods waiting to be executed.
49
+ */
50
+ _pendingChanges;
51
+ /**
52
+ * The last created and currently used writer instance.
53
+ */
54
+ _currentWriter;
34
55
  // @if CK_DEBUG_ENGINE // private _operationLogs: Array<string>;
35
56
  // @if CK_DEBUG_ENGINE // private _appliedOperations: Array<Operation>;
36
57
  constructor() {