@ckeditor/ckeditor5-undo 41.3.0-alpha.4 → 41.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/package.json +4 -5
  2. package/src/undoui.d.ts +5 -1
  3. package/src/undoui.js +31 -17
  4. package/dist/content-index.css +0 -4
  5. package/dist/editor-index.css +0 -4
  6. package/dist/index.css +0 -4
  7. package/dist/translations/ar.d.ts +0 -8
  8. package/dist/translations/ar.js +0 -5
  9. package/dist/translations/ast.d.ts +0 -8
  10. package/dist/translations/ast.js +0 -5
  11. package/dist/translations/az.d.ts +0 -8
  12. package/dist/translations/az.js +0 -5
  13. package/dist/translations/bg.d.ts +0 -8
  14. package/dist/translations/bg.js +0 -5
  15. package/dist/translations/bn.d.ts +0 -8
  16. package/dist/translations/bn.js +0 -5
  17. package/dist/translations/ca.d.ts +0 -8
  18. package/dist/translations/ca.js +0 -5
  19. package/dist/translations/cs.d.ts +0 -8
  20. package/dist/translations/cs.js +0 -5
  21. package/dist/translations/da.d.ts +0 -8
  22. package/dist/translations/da.js +0 -5
  23. package/dist/translations/de-ch.d.ts +0 -8
  24. package/dist/translations/de-ch.js +0 -5
  25. package/dist/translations/de.d.ts +0 -8
  26. package/dist/translations/de.js +0 -5
  27. package/dist/translations/el.d.ts +0 -8
  28. package/dist/translations/el.js +0 -5
  29. package/dist/translations/en-au.d.ts +0 -8
  30. package/dist/translations/en-au.js +0 -5
  31. package/dist/translations/en-gb.d.ts +0 -8
  32. package/dist/translations/en-gb.js +0 -5
  33. package/dist/translations/en.d.ts +0 -8
  34. package/dist/translations/en.js +0 -5
  35. package/dist/translations/eo.d.ts +0 -8
  36. package/dist/translations/eo.js +0 -5
  37. package/dist/translations/es.d.ts +0 -8
  38. package/dist/translations/es.js +0 -5
  39. package/dist/translations/et.d.ts +0 -8
  40. package/dist/translations/et.js +0 -5
  41. package/dist/translations/eu.d.ts +0 -8
  42. package/dist/translations/eu.js +0 -5
  43. package/dist/translations/fa.d.ts +0 -8
  44. package/dist/translations/fa.js +0 -5
  45. package/dist/translations/fi.d.ts +0 -8
  46. package/dist/translations/fi.js +0 -5
  47. package/dist/translations/fr.d.ts +0 -8
  48. package/dist/translations/fr.js +0 -5
  49. package/dist/translations/gl.d.ts +0 -8
  50. package/dist/translations/gl.js +0 -5
  51. package/dist/translations/he.d.ts +0 -8
  52. package/dist/translations/he.js +0 -5
  53. package/dist/translations/hi.d.ts +0 -8
  54. package/dist/translations/hi.js +0 -5
  55. package/dist/translations/hr.d.ts +0 -8
  56. package/dist/translations/hr.js +0 -5
  57. package/dist/translations/hu.d.ts +0 -8
  58. package/dist/translations/hu.js +0 -5
  59. package/dist/translations/id.d.ts +0 -8
  60. package/dist/translations/id.js +0 -5
  61. package/dist/translations/it.d.ts +0 -8
  62. package/dist/translations/it.js +0 -5
  63. package/dist/translations/ja.d.ts +0 -8
  64. package/dist/translations/ja.js +0 -5
  65. package/dist/translations/km.d.ts +0 -8
  66. package/dist/translations/km.js +0 -5
  67. package/dist/translations/kn.d.ts +0 -8
  68. package/dist/translations/kn.js +0 -5
  69. package/dist/translations/ko.d.ts +0 -8
  70. package/dist/translations/ko.js +0 -5
  71. package/dist/translations/ku.d.ts +0 -8
  72. package/dist/translations/ku.js +0 -5
  73. package/dist/translations/lt.d.ts +0 -8
  74. package/dist/translations/lt.js +0 -5
  75. package/dist/translations/lv.d.ts +0 -8
  76. package/dist/translations/lv.js +0 -5
  77. package/dist/translations/ms.d.ts +0 -8
  78. package/dist/translations/ms.js +0 -5
  79. package/dist/translations/nb.d.ts +0 -8
  80. package/dist/translations/nb.js +0 -5
  81. package/dist/translations/ne.d.ts +0 -8
  82. package/dist/translations/ne.js +0 -5
  83. package/dist/translations/nl.d.ts +0 -8
  84. package/dist/translations/nl.js +0 -5
  85. package/dist/translations/no.d.ts +0 -8
  86. package/dist/translations/no.js +0 -5
  87. package/dist/translations/pl.d.ts +0 -8
  88. package/dist/translations/pl.js +0 -5
  89. package/dist/translations/pt-br.d.ts +0 -8
  90. package/dist/translations/pt-br.js +0 -5
  91. package/dist/translations/pt.d.ts +0 -8
  92. package/dist/translations/pt.js +0 -5
  93. package/dist/translations/ro.d.ts +0 -8
  94. package/dist/translations/ro.js +0 -5
  95. package/dist/translations/ru.d.ts +0 -8
  96. package/dist/translations/ru.js +0 -5
  97. package/dist/translations/si.d.ts +0 -8
  98. package/dist/translations/si.js +0 -5
  99. package/dist/translations/sk.d.ts +0 -8
  100. package/dist/translations/sk.js +0 -5
  101. package/dist/translations/sq.d.ts +0 -8
  102. package/dist/translations/sq.js +0 -5
  103. package/dist/translations/sr-latn.d.ts +0 -8
  104. package/dist/translations/sr-latn.js +0 -5
  105. package/dist/translations/sr.d.ts +0 -8
  106. package/dist/translations/sr.js +0 -5
  107. package/dist/translations/sv.d.ts +0 -8
  108. package/dist/translations/sv.js +0 -5
  109. package/dist/translations/th.d.ts +0 -8
  110. package/dist/translations/th.js +0 -5
  111. package/dist/translations/tk.d.ts +0 -8
  112. package/dist/translations/tk.js +0 -5
  113. package/dist/translations/tr.d.ts +0 -8
  114. package/dist/translations/tr.js +0 -5
  115. package/dist/translations/tt.d.ts +0 -8
  116. package/dist/translations/tt.js +0 -5
  117. package/dist/translations/ug.d.ts +0 -8
  118. package/dist/translations/ug.js +0 -5
  119. package/dist/translations/uk.d.ts +0 -8
  120. package/dist/translations/uk.js +0 -5
  121. package/dist/translations/ur.d.ts +0 -8
  122. package/dist/translations/ur.js +0 -5
  123. package/dist/translations/uz.d.ts +0 -8
  124. package/dist/translations/uz.js +0 -5
  125. package/dist/translations/vi.d.ts +0 -8
  126. package/dist/translations/vi.js +0 -5
  127. package/dist/translations/zh-cn.d.ts +0 -8
  128. package/dist/translations/zh-cn.js +0 -5
  129. package/dist/translations/zh.d.ts +0 -8
  130. package/dist/translations/zh.js +0 -5
  131. package/dist/types/augmentation.d.ts +0 -20
  132. package/dist/types/basecommand.d.ts +0 -76
  133. package/dist/types/index.d.ts +0 -17
  134. package/dist/types/redocommand.d.ts +0 -31
  135. package/dist/types/undo.d.ts +0 -121
  136. package/dist/types/undocommand.d.ts +0 -41
  137. package/dist/types/undoediting.d.ts +0 -41
  138. package/dist/types/undoui.d.ts +0 -34
@@ -1,76 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module undo/basecommand
11
- */
12
- import { Command, type Editor } from '@ckeditor/ckeditor5-core';
13
- import { type Batch, type Operation, type Range } from '@ckeditor/ckeditor5-engine';
14
- /**
15
- * Base class for the undo feature commands: {@link module:undo/undocommand~UndoCommand} and {@link module:undo/redocommand~RedoCommand}.
16
- */
17
- export default abstract class BaseCommand extends Command {
18
- /**
19
- * Stack of items stored by the command. These are pairs of:
20
- *
21
- * * {@link module:engine/model/batch~Batch batch} saved by the command,
22
- * * {@link module:engine/model/selection~Selection selection} state at the moment of saving the batch.
23
- */
24
- protected _stack: Array<{
25
- batch: Batch;
26
- selection: {
27
- ranges: Array<Range>;
28
- isBackward: boolean;
29
- };
30
- }>;
31
- /**
32
- * Stores all batches that were created by this command.
33
- *
34
- * @internal
35
- */
36
- _createdBatches: WeakSet<Batch>;
37
- /**
38
- * @inheritDoc
39
- */
40
- constructor(editor: Editor);
41
- /**
42
- * @inheritDoc
43
- */
44
- refresh(): void;
45
- /**
46
- * Returns all batches created by this command.
47
- */
48
- get createdBatches(): WeakSet<Batch>;
49
- /**
50
- * Stores a batch in the command, together with the selection state of the {@link module:engine/model/document~Document document}
51
- * created by the editor which this command is registered to.
52
- *
53
- * @param batch The batch to add.
54
- */
55
- addBatch(batch: Batch): void;
56
- /**
57
- * Removes all items from the stack.
58
- */
59
- clearStack(): void;
60
- /**
61
- * Restores the {@link module:engine/model/document~Document#selection document selection} state after a batch was undone.
62
- *
63
- * @param ranges Ranges to be restored.
64
- * @param isBackward A flag describing whether the restored range was selected forward or backward.
65
- * @param operations Operations which has been applied since selection has been stored.
66
- */
67
- protected _restoreSelection(ranges: Array<Range>, isBackward: boolean, operations: Array<Operation>): void;
68
- /**
69
- * Undoes a batch by reversing that batch, transforming reversed batch and finally applying it.
70
- * This is a helper method for {@link #execute}.
71
- *
72
- * @param batchToUndo The batch to be undone.
73
- * @param undoingBatch The batch that will contain undoing changes.
74
- */
75
- protected _undo(batchToUndo: Batch, undoingBatch: Batch): void;
76
- }
@@ -1,17 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module undo
11
- */
12
- export { default as Undo } from './undo.js';
13
- export { default as UndoEditing } from './undoediting.js';
14
- export { default as UndoUI } from './undoui.js';
15
- export type { default as UndoCommand } from './undocommand.js';
16
- export type { default as RedoCommand } from './redocommand.js';
17
- import './augmentation.js';
@@ -1,31 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module undo/redocommand
11
- */
12
- import BaseCommand from './basecommand.js';
13
- /**
14
- * The redo command stores {@link module:engine/model/batch~Batch batches} that were used to undo a batch by
15
- * {@link module:undo/undocommand~UndoCommand}. It is able to redo a previously undone batch by reversing the undoing
16
- * batches created by `UndoCommand`. The reversed batch is transformed by all the batches from
17
- * {@link module:engine/model/document~Document#history history} that happened after the reversed undo batch.
18
- *
19
- * The redo command also takes care of restoring the {@link module:engine/model/document~Document#selection document selection}.
20
- */
21
- export default class RedoCommand extends BaseCommand {
22
- /**
23
- * Executes the command. This method reverts the last {@link module:engine/model/batch~Batch batch} added to
24
- * the command's stack, applies the reverted and transformed version on the
25
- * {@link module:engine/model/document~Document document} and removes the batch from the stack.
26
- * Then, it restores the {@link module:engine/model/document~Document#selection document selection}.
27
- *
28
- * @fires execute
29
- */
30
- execute(): void;
31
- }
@@ -1,121 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module undo/undo
11
- */
12
- import { Plugin } from '@ckeditor/ckeditor5-core';
13
- import UndoEditing from './undoediting.js';
14
- import UndoUI from './undoui.js';
15
- /**
16
- * The undo feature.
17
- *
18
- * This is a "glue" plugin which loads the {@link module:undo/undoediting~UndoEditing undo editing feature}
19
- * and the {@link module:undo/undoui~UndoUI undo UI feature}.
20
- *
21
- * Below is an explanation of the undo mechanism working together with {@link module:engine/model/history~History History}:
22
- *
23
- * Whenever an {@link module:engine/model/operation/operation~Operation operation} is applied to the
24
- * {@link module:engine/model/document~Document document}, it is saved to `History` as is.
25
- * The {@link module:engine/model/batch~Batch batch} that owns that operation is also saved, in
26
- * {@link module:undo/undocommand~UndoCommand}, together with the selection that was present in the document before the
27
- * operation was applied. A batch is saved instead of the operation because changes are undone batch-by-batch, not operation-by-operation
28
- * and a batch is seen as one undo step.
29
- *
30
- * After changes happen to the document, the `History` and `UndoCommand` stack can be represented as follows:
31
- *
32
- * ```
33
- * History Undo stack
34
- * ============== ==================================
35
- * [operation A1] [ batch A ]
36
- * [operation B1] [ batch B ]
37
- * [operation B2] [ batch C ]
38
- * [operation C1]
39
- * [operation C2]
40
- * [operation B3]
41
- * [operation C3]
42
- * ```
43
- *
44
- * Where operations starting with the same letter are from same batch.
45
- *
46
- * Undoing a batch means that a set of operations which will reverse the effects of that batch needs to be generated.
47
- * For example, if a batch added several letters, undoing the batch should remove them. It is important to apply undoing
48
- * operations in the reversed order, so if a batch has operation `X`, `Y`, `Z`, reversed operations `Zr`, `Yr` and `Xr`
49
- * need to be applied. Otherwise reversed operation `Xr` would operate on a wrong document state, because operation `X`
50
- * does not know that operations `Y` and `Z` happened.
51
- *
52
- * After operations from an undone batch got {@link module:engine/model/operation/operation~Operation#getReversed reversed},
53
- * one needs to make sure if they are ready to be applied. In the scenario above, operation `C3` is the last operation and `C3r`
54
- * bases on up-to-date document state, so it can be applied to the document.
55
- *
56
- * ```
57
- * History Undo stack
58
- * ================= ==================================
59
- * [ operation A1 ] [ batch A ]
60
- * [ operation B1 ] [ batch B ]
61
- * [ operation B2 ] [ processing undoing batch C ]
62
- * [ operation C1 ]
63
- * [ operation C2 ]
64
- * [ operation B3 ]
65
- * [ operation C3 ]
66
- * [ operation C3r ]
67
- * ```
68
- *
69
- * Next is operation `C2`, reversed to `C2r`. `C2r` bases on `C2`, so it bases on the wrong document state. It needs to be
70
- * transformed by operations from history that happened after it, so it "knows" about them. Let us assume that `C2' = C2r * B3 * C3 * C3r`,
71
- * where `*` means "transformed by". Rest of operations from that batch are processed in the same fashion.
72
- *
73
- * ```
74
- * History Undo stack Redo stack
75
- * ================= ================================== ==================================
76
- * [ operation A1 ] [ batch A ] [ batch Cr ]
77
- * [ operation B1 ] [ batch B ]
78
- * [ operation B2 ]
79
- * [ operation C1 ]
80
- * [ operation C2 ]
81
- * [ operation B3 ]
82
- * [ operation C3 ]
83
- * [ operation C3r ]
84
- * [ operation C2' ]
85
- * [ operation C1' ]
86
- * ```
87
- *
88
- * Selective undo works on the same basis, however, instead of undoing the last batch in the undo stack, any batch can be undone.
89
- * The same algorithm applies: operations from a batch (i.e. `A1`) are reversed and then transformed by operations stored in history.
90
- *
91
- * Redo also is very similar to undo. It has its own stack that is filled with undoing (reversed batches). Operations from
92
- * the batch that is re-done are reversed-back, transformed in proper order and applied to the document.
93
- *
94
- * ```
95
- * History Undo stack Redo stack
96
- * ================= ================================== ==================================
97
- * [ operation A1 ] [ batch A ]
98
- * [ operation B1 ] [ batch B ]
99
- * [ operation B2 ] [ batch Crr ]
100
- * [ operation C1 ]
101
- * [ operation C2 ]
102
- * [ operation B3 ]
103
- * [ operation C3 ]
104
- * [ operation C3r ]
105
- * [ operation C2' ]
106
- * [ operation C1' ]
107
- * [ operation C1'r]
108
- * [ operation C2'r]
109
- * [ operation C3rr]
110
- * ```
111
- */
112
- export default class Undo extends Plugin {
113
- /**
114
- * @inheritDoc
115
- */
116
- static get requires(): readonly [typeof UndoEditing, typeof UndoUI];
117
- /**
118
- * @inheritDoc
119
- */
120
- static get pluginName(): "Undo";
121
- }
@@ -1,41 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module undo/undocommand
11
- */
12
- import BaseCommand from './basecommand.js';
13
- import type { Batch } from '@ckeditor/ckeditor5-engine';
14
- /**
15
- * The undo command stores {@link module:engine/model/batch~Batch batches} applied to the
16
- * {@link module:engine/model/document~Document document} and is able to undo a batch by reversing it and transforming by
17
- * batches from {@link module:engine/model/document~Document#history history} that happened after the reversed batch.
18
- *
19
- * The undo command also takes care of restoring the {@link module:engine/model/document~Document#selection document selection}.
20
- */
21
- export default class UndoCommand extends BaseCommand {
22
- /**
23
- * Executes the command. This method reverts a {@link module:engine/model/batch~Batch batch} added to the command's stack, transforms
24
- * and applies the reverted version on the {@link module:engine/model/document~Document document} and removes the batch from the stack.
25
- * Then, it restores the {@link module:engine/model/document~Document#selection document selection}.
26
- *
27
- * @fires execute
28
- * @fires revert
29
- * @param batch A batch that should be undone. If not set, the last added batch will be undone.
30
- */
31
- execute(batch?: Batch | null): void;
32
- }
33
- /**
34
- * Fired when execution of the command reverts some batch.
35
- *
36
- * @eventName ~UndoCommand#revert
37
- */
38
- export type UndoCommandRevertEvent = {
39
- name: 'revert';
40
- args: [batch: Batch, undoingBatch: Batch];
41
- };
@@ -1,41 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module undo/undoediting
11
- */
12
- import { Plugin } from '@ckeditor/ckeditor5-core';
13
- /**
14
- * The undo engine feature.
15
- *
16
- * It introduces the `'undo'` and `'redo'` commands to the editor.
17
- */
18
- export default class UndoEditing extends Plugin {
19
- /**
20
- * The command that manages the undo {@link module:engine/model/batch~Batch batches} stack (history).
21
- * Created and registered during the {@link #init feature initialization}.
22
- */
23
- private _undoCommand;
24
- /**
25
- * The command that manages the redo {@link module:engine/model/batch~Batch batches} stack (history).
26
- * Created and registered during the {@link #init feature initialization}.
27
- */
28
- private _redoCommand;
29
- /**
30
- * Keeps track of which batches were registered in undo.
31
- */
32
- private _batchRegistry;
33
- /**
34
- * @inheritDoc
35
- */
36
- static get pluginName(): "UndoEditing";
37
- /**
38
- * @inheritDoc
39
- */
40
- init(): void;
41
- }
@@ -1,34 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module undo/undoui
11
- */
12
- import { Plugin } from '@ckeditor/ckeditor5-core';
13
- /**
14
- * The undo UI feature. It introduces the `'undo'` and `'redo'` buttons to the editor.
15
- */
16
- export default class UndoUI extends Plugin {
17
- /**
18
- * @inheritDoc
19
- */
20
- static get pluginName(): "UndoUI";
21
- /**
22
- * @inheritDoc
23
- */
24
- init(): void;
25
- /**
26
- * Creates a button for the specified command.
27
- *
28
- * @param name Command name.
29
- * @param label Button label.
30
- * @param keystroke Command keystroke.
31
- * @param Icon Source of the icon.
32
- */
33
- private _addButton;
34
- }