@ckeditor/ckeditor5-undo 41.3.0 → 41.4.0-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/dist/index-content.css +4 -0
  2. package/dist/index-editor.css +4 -0
  3. package/dist/index.css +4 -0
  4. package/dist/index.js +410 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/translations/ar.d.ts +8 -0
  7. package/dist/translations/ar.js +5 -0
  8. package/dist/translations/ast.d.ts +8 -0
  9. package/dist/translations/ast.js +5 -0
  10. package/dist/translations/az.d.ts +8 -0
  11. package/dist/translations/az.js +5 -0
  12. package/dist/translations/bg.d.ts +8 -0
  13. package/dist/translations/bg.js +5 -0
  14. package/dist/translations/bn.d.ts +8 -0
  15. package/dist/translations/bn.js +5 -0
  16. package/dist/translations/ca.d.ts +8 -0
  17. package/dist/translations/ca.js +5 -0
  18. package/dist/translations/cs.d.ts +8 -0
  19. package/dist/translations/cs.js +5 -0
  20. package/dist/translations/da.d.ts +8 -0
  21. package/dist/translations/da.js +5 -0
  22. package/dist/translations/de-ch.d.ts +8 -0
  23. package/dist/translations/de-ch.js +5 -0
  24. package/dist/translations/de.d.ts +8 -0
  25. package/dist/translations/de.js +5 -0
  26. package/dist/translations/el.d.ts +8 -0
  27. package/dist/translations/el.js +5 -0
  28. package/dist/translations/en-au.d.ts +8 -0
  29. package/dist/translations/en-au.js +5 -0
  30. package/dist/translations/en-gb.d.ts +8 -0
  31. package/dist/translations/en-gb.js +5 -0
  32. package/dist/translations/en.d.ts +8 -0
  33. package/dist/translations/en.js +5 -0
  34. package/dist/translations/eo.d.ts +8 -0
  35. package/dist/translations/eo.js +5 -0
  36. package/dist/translations/es.d.ts +8 -0
  37. package/dist/translations/es.js +5 -0
  38. package/dist/translations/et.d.ts +8 -0
  39. package/dist/translations/et.js +5 -0
  40. package/dist/translations/eu.d.ts +8 -0
  41. package/dist/translations/eu.js +5 -0
  42. package/dist/translations/fa.d.ts +8 -0
  43. package/dist/translations/fa.js +5 -0
  44. package/dist/translations/fi.d.ts +8 -0
  45. package/dist/translations/fi.js +5 -0
  46. package/dist/translations/fr.d.ts +8 -0
  47. package/dist/translations/fr.js +5 -0
  48. package/dist/translations/gl.d.ts +8 -0
  49. package/dist/translations/gl.js +5 -0
  50. package/dist/translations/he.d.ts +8 -0
  51. package/dist/translations/he.js +5 -0
  52. package/dist/translations/hi.d.ts +8 -0
  53. package/dist/translations/hi.js +5 -0
  54. package/dist/translations/hr.d.ts +8 -0
  55. package/dist/translations/hr.js +5 -0
  56. package/dist/translations/hu.d.ts +8 -0
  57. package/dist/translations/hu.js +5 -0
  58. package/dist/translations/id.d.ts +8 -0
  59. package/dist/translations/id.js +5 -0
  60. package/dist/translations/it.d.ts +8 -0
  61. package/dist/translations/it.js +5 -0
  62. package/dist/translations/ja.d.ts +8 -0
  63. package/dist/translations/ja.js +5 -0
  64. package/dist/translations/km.d.ts +8 -0
  65. package/dist/translations/km.js +5 -0
  66. package/dist/translations/kn.d.ts +8 -0
  67. package/dist/translations/kn.js +5 -0
  68. package/dist/translations/ko.d.ts +8 -0
  69. package/dist/translations/ko.js +5 -0
  70. package/dist/translations/ku.d.ts +8 -0
  71. package/dist/translations/ku.js +5 -0
  72. package/dist/translations/lt.d.ts +8 -0
  73. package/dist/translations/lt.js +5 -0
  74. package/dist/translations/lv.d.ts +8 -0
  75. package/dist/translations/lv.js +5 -0
  76. package/dist/translations/ms.d.ts +8 -0
  77. package/dist/translations/ms.js +5 -0
  78. package/dist/translations/nb.d.ts +8 -0
  79. package/dist/translations/nb.js +5 -0
  80. package/dist/translations/ne.d.ts +8 -0
  81. package/dist/translations/ne.js +5 -0
  82. package/dist/translations/nl.d.ts +8 -0
  83. package/dist/translations/nl.js +5 -0
  84. package/dist/translations/no.d.ts +8 -0
  85. package/dist/translations/no.js +5 -0
  86. package/dist/translations/pl.d.ts +8 -0
  87. package/dist/translations/pl.js +5 -0
  88. package/dist/translations/pt-br.d.ts +8 -0
  89. package/dist/translations/pt-br.js +5 -0
  90. package/dist/translations/pt.d.ts +8 -0
  91. package/dist/translations/pt.js +5 -0
  92. package/dist/translations/ro.d.ts +8 -0
  93. package/dist/translations/ro.js +5 -0
  94. package/dist/translations/ru.d.ts +8 -0
  95. package/dist/translations/ru.js +5 -0
  96. package/dist/translations/si.d.ts +8 -0
  97. package/dist/translations/si.js +5 -0
  98. package/dist/translations/sk.d.ts +8 -0
  99. package/dist/translations/sk.js +5 -0
  100. package/dist/translations/sq.d.ts +8 -0
  101. package/dist/translations/sq.js +5 -0
  102. package/dist/translations/sr-latn.d.ts +8 -0
  103. package/dist/translations/sr-latn.js +5 -0
  104. package/dist/translations/sr.d.ts +8 -0
  105. package/dist/translations/sr.js +5 -0
  106. package/dist/translations/sv.d.ts +8 -0
  107. package/dist/translations/sv.js +5 -0
  108. package/dist/translations/th.d.ts +8 -0
  109. package/dist/translations/th.js +5 -0
  110. package/dist/translations/tk.d.ts +8 -0
  111. package/dist/translations/tk.js +5 -0
  112. package/dist/translations/tr.d.ts +8 -0
  113. package/dist/translations/tr.js +5 -0
  114. package/dist/translations/tt.d.ts +8 -0
  115. package/dist/translations/tt.js +5 -0
  116. package/dist/translations/ug.d.ts +8 -0
  117. package/dist/translations/ug.js +5 -0
  118. package/dist/translations/uk.d.ts +8 -0
  119. package/dist/translations/uk.js +5 -0
  120. package/dist/translations/ur.d.ts +8 -0
  121. package/dist/translations/ur.js +5 -0
  122. package/dist/translations/uz.d.ts +8 -0
  123. package/dist/translations/uz.js +5 -0
  124. package/dist/translations/vi.d.ts +8 -0
  125. package/dist/translations/vi.js +5 -0
  126. package/dist/translations/zh-cn.d.ts +8 -0
  127. package/dist/translations/zh-cn.js +5 -0
  128. package/dist/translations/zh.d.ts +8 -0
  129. package/dist/translations/zh.js +5 -0
  130. package/dist/types/augmentation.d.ts +20 -0
  131. package/dist/types/basecommand.d.ts +76 -0
  132. package/dist/types/index.d.ts +17 -0
  133. package/dist/types/redocommand.d.ts +31 -0
  134. package/dist/types/undo.d.ts +121 -0
  135. package/dist/types/undocommand.d.ts +41 -0
  136. package/dist/types/undoediting.d.ts +41 -0
  137. package/dist/types/undoui.d.ts +38 -0
  138. package/package.json +5 -4
@@ -0,0 +1,5 @@
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
+ export default {"ur":{"dictionary":{"Undo":"رد ترمیم","Redo":"پھر سے کریں"},getPluralForm(n){return (n != 1);}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"uz":{"dictionary":{"Undo":"Bekor qilish","Redo":"Takrorlash"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"vi":{"dictionary":{"Undo":"Hoàn tác","Redo":"Tiếp tục"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"zh-cn":{"dictionary":{"Undo":"撤销","Redo":"重做"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"zh":{"dictionary":{"Undo":"取消","Redo":"重做"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,20 @@
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
+ import type { Undo, UndoEditing, UndoUI, UndoCommand, RedoCommand } from './index.js';
10
+ declare module '@ckeditor/ckeditor5-core' {
11
+ interface CommandsMap {
12
+ undo: UndoCommand;
13
+ redo: RedoCommand;
14
+ }
15
+ interface PluginsMap {
16
+ [Undo.pluginName]: Undo;
17
+ [UndoEditing.pluginName]: UndoEditing;
18
+ [UndoUI.pluginName]: UndoUI;
19
+ }
20
+ }
@@ -0,0 +1,76 @@
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
+ }
@@ -0,0 +1,17 @@
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';
@@ -0,0 +1,31 @@
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
+ }
@@ -0,0 +1,121 @@
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
+ }
@@ -0,0 +1,41 @@
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
+ };
@@ -0,0 +1,41 @@
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
+ }
@@ -0,0 +1,38 @@
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 _addButtonsToFactory;
34
+ /**
35
+ * TODO
36
+ */
37
+ private _createButton;
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-undo",
3
- "version": "41.3.0",
3
+ "version": "41.4.0-alpha.0",
4
4
  "description": "Undo feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,9 +13,9 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "41.3.0",
17
- "@ckeditor/ckeditor5-engine": "41.3.0",
18
- "@ckeditor/ckeditor5-ui": "41.3.0"
16
+ "@ckeditor/ckeditor5-core": "41.4.0-alpha.0",
17
+ "@ckeditor/ckeditor5-engine": "41.4.0-alpha.0",
18
+ "@ckeditor/ckeditor5-ui": "41.4.0-alpha.0"
19
19
  },
20
20
  "author": "CKSource (http://cksource.com/)",
21
21
  "license": "GPL-2.0-or-later",
@@ -27,6 +27,7 @@
27
27
  "directory": "packages/ckeditor5-undo"
28
28
  },
29
29
  "files": [
30
+ "dist",
30
31
  "lang",
31
32
  "src/**/*.js",
32
33
  "src/**/*.d.ts",