@ckeditor/ckeditor5-undo 47.6.1 → 48.0.0-alpha.1

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 (94) hide show
  1. package/ckeditor5-metadata.json +3 -3
  2. package/dist/index.css +3 -0
  3. package/dist/index.css.map +1 -0
  4. package/package.json +23 -43
  5. package/lang/contexts.json +0 -4
  6. package/lang/translations/af.po +0 -20
  7. package/lang/translations/ar.po +0 -20
  8. package/lang/translations/ast.po +0 -20
  9. package/lang/translations/az.po +0 -20
  10. package/lang/translations/be.po +0 -20
  11. package/lang/translations/bg.po +0 -20
  12. package/lang/translations/bn.po +0 -20
  13. package/lang/translations/bs.po +0 -20
  14. package/lang/translations/ca.po +0 -20
  15. package/lang/translations/cs.po +0 -20
  16. package/lang/translations/da.po +0 -20
  17. package/lang/translations/de-ch.po +0 -20
  18. package/lang/translations/de.po +0 -20
  19. package/lang/translations/el.po +0 -20
  20. package/lang/translations/en-au.po +0 -20
  21. package/lang/translations/en-gb.po +0 -20
  22. package/lang/translations/en.po +0 -20
  23. package/lang/translations/eo.po +0 -20
  24. package/lang/translations/es-co.po +0 -20
  25. package/lang/translations/es.po +0 -20
  26. package/lang/translations/et.po +0 -20
  27. package/lang/translations/eu.po +0 -20
  28. package/lang/translations/fa.po +0 -20
  29. package/lang/translations/fi.po +0 -20
  30. package/lang/translations/fr.po +0 -20
  31. package/lang/translations/gl.po +0 -20
  32. package/lang/translations/gu.po +0 -20
  33. package/lang/translations/he.po +0 -20
  34. package/lang/translations/hi.po +0 -20
  35. package/lang/translations/hr.po +0 -20
  36. package/lang/translations/hu.po +0 -20
  37. package/lang/translations/hy.po +0 -20
  38. package/lang/translations/id.po +0 -20
  39. package/lang/translations/it.po +0 -20
  40. package/lang/translations/ja.po +0 -20
  41. package/lang/translations/jv.po +0 -20
  42. package/lang/translations/kk.po +0 -20
  43. package/lang/translations/km.po +0 -20
  44. package/lang/translations/kn.po +0 -20
  45. package/lang/translations/ko.po +0 -20
  46. package/lang/translations/ku.po +0 -20
  47. package/lang/translations/lt.po +0 -20
  48. package/lang/translations/lv.po +0 -20
  49. package/lang/translations/ms.po +0 -20
  50. package/lang/translations/nb.po +0 -20
  51. package/lang/translations/ne.po +0 -20
  52. package/lang/translations/nl.po +0 -20
  53. package/lang/translations/no.po +0 -20
  54. package/lang/translations/oc.po +0 -20
  55. package/lang/translations/pl.po +0 -20
  56. package/lang/translations/pt-br.po +0 -20
  57. package/lang/translations/pt.po +0 -20
  58. package/lang/translations/ro.po +0 -20
  59. package/lang/translations/ru.po +0 -20
  60. package/lang/translations/si.po +0 -20
  61. package/lang/translations/sk.po +0 -20
  62. package/lang/translations/sl.po +0 -20
  63. package/lang/translations/sq.po +0 -20
  64. package/lang/translations/sr-latn.po +0 -20
  65. package/lang/translations/sr.po +0 -20
  66. package/lang/translations/sv.po +0 -20
  67. package/lang/translations/th.po +0 -20
  68. package/lang/translations/ti.po +0 -20
  69. package/lang/translations/tk.po +0 -20
  70. package/lang/translations/tr.po +0 -20
  71. package/lang/translations/tt.po +0 -20
  72. package/lang/translations/ug.po +0 -20
  73. package/lang/translations/uk.po +0 -20
  74. package/lang/translations/ur.po +0 -20
  75. package/lang/translations/uz.po +0 -20
  76. package/lang/translations/vi.po +0 -20
  77. package/lang/translations/zh-cn.po +0 -20
  78. package/lang/translations/zh.po +0 -20
  79. package/src/augmentation.js +0 -5
  80. package/src/basecommand.js +0 -192
  81. package/src/index.js +0 -14
  82. package/src/redocommand.js +0 -44
  83. package/src/undo.js +0 -127
  84. package/src/undocommand.js +0 -44
  85. package/src/undoediting.js +0 -109
  86. package/src/undoui.js +0 -80
  87. /package/{src → dist}/augmentation.d.ts +0 -0
  88. /package/{src → dist}/basecommand.d.ts +0 -0
  89. /package/{src → dist}/index.d.ts +0 -0
  90. /package/{src → dist}/redocommand.d.ts +0 -0
  91. /package/{src → dist}/undo.d.ts +0 -0
  92. /package/{src → dist}/undocommand.d.ts +0 -0
  93. /package/{src → dist}/undoediting.d.ts +0 -0
  94. /package/{src → dist}/undoui.d.ts +0 -0
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: si_LK\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "අහෝසි කරන්න"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "නැවත කරන්න"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sk\n"
11
- "Plural-Forms: nplurals=3; plural=(n == 1 ? 0 : (n >= 2 && n <= 4) ? 1 : 2);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Späť"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Znova"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sl\n"
11
- "Plural-Forms: nplurals=4; plural=(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr ""
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr ""
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sq\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Rikthe"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Ribëj"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sr@latin\n"
11
- "Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Povlačenje"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Ponovo"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sr\n"
11
- "Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Повлачење"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Поново"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: sv\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Ångra"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Gör om"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: th\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "ย้อนกลับ"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "ทำซ้ำ"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: ti\n"
11
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "ዝተኸወነ ምለስ"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "ደጊምካ ከውን"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: tk\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Yza gaýtar"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Öňe gaýtar"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: tr\n"
11
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Geri al"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Tekrar yap"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: tt\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr ""
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Кабатла"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: ug\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "يېنىۋېلىش"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "تەكرارلاش"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: uk\n"
11
- "Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Відміна"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Повтор"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: ur\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "رد ترمیم"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "پھر سے کریں"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: uz\n"
11
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Bekor qilish"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Takrorlash"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: vi\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "Hoàn tác"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "Tiếp tục"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: zh_CN\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "撤销"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "重做"
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: zh_TW\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "Toolbar button tooltip for the Undo feature."
15
- msgid "Undo"
16
- msgstr "取消"
17
-
18
- msgctxt "Toolbar button tooltip for the Redo feature."
19
- msgid "Redo"
20
- msgstr "重做"
@@ -1,5 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- export {};
@@ -1,192 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module undo/basecommand
7
- */
8
- import { Command } from '@ckeditor/ckeditor5-core';
9
- import { transformOperationSets, NoOperation } from '@ckeditor/ckeditor5-engine';
10
- /**
11
- * Base class for the undo feature commands: {@link module:undo/undocommand~UndoCommand} and {@link module:undo/redocommand~RedoCommand}.
12
- */
13
- export class UndoRedoBaseCommand extends Command {
14
- /**
15
- * Stack of items stored by the command. These are pairs of:
16
- *
17
- * * {@link module:engine/model/batch~Batch batch} saved by the command,
18
- * * {@link module:engine/model/selection~ModelSelection selection} state at the moment of saving the batch.
19
- */
20
- _stack = [];
21
- /**
22
- * Stores all batches that were created by this command.
23
- *
24
- * @internal
25
- */
26
- _createdBatches = new WeakSet();
27
- /**
28
- * @inheritDoc
29
- */
30
- constructor(editor) {
31
- super(editor);
32
- // Refresh state, so the command is inactive right after initialization.
33
- this.refresh();
34
- // This command should not depend on selection change.
35
- this._isEnabledBasedOnSelection = false;
36
- // Set the transparent batch for the `editor.data.set()` call if the
37
- // batch type is not set already.
38
- this.listenTo(editor.data, 'set', (evt, data) => {
39
- // Create a shallow copy of the options to not change the original args.
40
- // And make sure that an object is assigned to data[ 1 ].
41
- data[1] = { ...data[1] };
42
- const options = data[1];
43
- // If batch type is not set, default to non-undoable batch.
44
- if (!options.batchType) {
45
- options.batchType = { isUndoable: false };
46
- }
47
- }, { priority: 'high' });
48
- // Clear the stack for the `transparent` batches.
49
- this.listenTo(editor.data, 'set', (evt, data) => {
50
- // We can assume that the object exists and it has a `batchType` property.
51
- // It was ensured with a higher priority listener before.
52
- const options = data[1];
53
- if (!options.batchType.isUndoable) {
54
- this.clearStack();
55
- }
56
- });
57
- }
58
- /**
59
- * @inheritDoc
60
- */
61
- refresh() {
62
- this.isEnabled = this._stack.length > 0;
63
- }
64
- /**
65
- * Returns all batches created by this command.
66
- */
67
- get createdBatches() {
68
- return this._createdBatches;
69
- }
70
- /**
71
- * Stores a batch in the command, together with the selection state of the {@link module:engine/model/document~ModelDocument document}
72
- * created by the editor which this command is registered to.
73
- *
74
- * @param batch The batch to add.
75
- */
76
- addBatch(batch) {
77
- const docSelection = this.editor.model.document.selection;
78
- const selection = {
79
- ranges: docSelection.hasOwnRange ? Array.from(docSelection.getRanges()) : [],
80
- isBackward: docSelection.isBackward
81
- };
82
- this._stack.push({ batch, selection });
83
- this.refresh();
84
- }
85
- /**
86
- * Removes all items from the stack.
87
- */
88
- clearStack() {
89
- this._stack = [];
90
- this.refresh();
91
- }
92
- /**
93
- * Restores the {@link module:engine/model/document~ModelDocument#selection document selection} state after a batch was undone.
94
- *
95
- * @param ranges Ranges to be restored.
96
- * @param isBackward A flag describing whether the restored range was selected forward or backward.
97
- * @param operations Operations which has been applied since selection has been stored.
98
- */
99
- _restoreSelection(ranges, isBackward, operations) {
100
- const model = this.editor.model;
101
- const document = model.document;
102
- // This will keep the transformed selection ranges.
103
- const selectionRanges = [];
104
- // Transform all ranges from the restored selection.
105
- const transformedRangeGroups = ranges.map(range => range.getTransformedByOperations(operations));
106
- const allRanges = transformedRangeGroups.flat();
107
- for (const rangeGroup of transformedRangeGroups) {
108
- // While transforming there could appear ranges that are contained by other ranges, we shall ignore them.
109
- const transformed = rangeGroup
110
- .filter(range => range.root != document.graveyard)
111
- .filter(range => !isRangeContainedByAnyOtherRange(range, allRanges));
112
- // All the transformed ranges ended up in graveyard.
113
- if (!transformed.length) {
114
- continue;
115
- }
116
- // After the range got transformed, we have an array of ranges. Some of those
117
- // ranges may be "touching" -- they can be next to each other and could be merged.
118
- normalizeRanges(transformed);
119
- // For each `range` from `ranges`, we take only one transformed range.
120
- // This is because we want to prevent situation where single-range selection
121
- // got transformed to multi-range selection.
122
- selectionRanges.push(transformed[0]);
123
- }
124
- // @if CK_DEBUG_ENGINE // console.log( `Restored selection by undo: ${ selectionRanges.join( ', ' ) }` );
125
- // `selectionRanges` may be empty if all ranges ended up in graveyard. If that is the case, do not restore selection.
126
- if (selectionRanges.length) {
127
- model.change(writer => {
128
- writer.setSelection(selectionRanges, { backward: isBackward });
129
- });
130
- }
131
- }
132
- /**
133
- * Undoes a batch by reversing that batch, transforming reversed batch and finally applying it.
134
- * This is a helper method for {@link #execute}.
135
- *
136
- * @param batchToUndo The batch to be undone.
137
- * @param undoingBatch The batch that will contain undoing changes.
138
- */
139
- _undo(batchToUndo, undoingBatch) {
140
- const model = this.editor.model;
141
- const document = model.document;
142
- // All changes done by the command execution will be saved as one batch.
143
- this._createdBatches.add(undoingBatch);
144
- const operationsToUndo = batchToUndo.operations.slice().filter(operation => operation.isDocumentOperation);
145
- operationsToUndo.reverse();
146
- // We will process each operation from `batchToUndo`, in reverse order. If there were operations A, B and C in undone batch,
147
- // we need to revert them in reverse order, so first C' (reversed C), then B', then A'.
148
- for (const operationToUndo of operationsToUndo) {
149
- const nextBaseVersion = operationToUndo.baseVersion + 1;
150
- const historyOperations = Array.from(document.history.getOperations(nextBaseVersion));
151
- const transformedSets = transformOperationSets([operationToUndo.getReversed()], historyOperations, {
152
- useRelations: true,
153
- document: this.editor.model.document,
154
- padWithNoOps: false,
155
- forceWeakRemove: true
156
- });
157
- const reversedOperations = transformedSets.operationsA;
158
- // After reversed operation has been transformed by all history operations, apply it.
159
- for (let operation of reversedOperations) {
160
- // Do not apply any operation on non-editable space.
161
- const affectedSelectable = operation.affectedSelectable;
162
- if (affectedSelectable && !model.canEditAt(affectedSelectable)) {
163
- operation = new NoOperation(operation.baseVersion);
164
- }
165
- // Before applying, add the operation to the `undoingBatch`.
166
- undoingBatch.addOperation(operation);
167
- model.applyOperation(operation);
168
- document.history.setOperationAsUndone(operationToUndo, operation);
169
- }
170
- }
171
- }
172
- }
173
- /**
174
- * Normalizes list of ranges by joining intersecting or "touching" ranges.
175
- *
176
- * @param ranges Ranges to be normalized.
177
- */
178
- function normalizeRanges(ranges) {
179
- ranges.sort((a, b) => a.start.isBefore(b.start) ? -1 : 1);
180
- for (let i = 1; i < ranges.length; i++) {
181
- const previousRange = ranges[i - 1];
182
- const joinedRange = previousRange.getJoined(ranges[i], true);
183
- if (joinedRange) {
184
- // Replace the ranges on the list with the new joined range.
185
- i--;
186
- ranges.splice(i, 2, joinedRange);
187
- }
188
- }
189
- }
190
- function isRangeContainedByAnyOtherRange(range, ranges) {
191
- return ranges.some(otherRange => otherRange !== range && otherRange.containsRange(range, true));
192
- }
package/src/index.js DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module undo
7
- */
8
- export { Undo } from './undo.js';
9
- export { UndoEditing } from './undoediting.js';
10
- export { UndoUI } from './undoui.js';
11
- export { UndoCommand } from './undocommand.js';
12
- export { RedoCommand } from './redocommand.js';
13
- export { UndoRedoBaseCommand } from './basecommand.js';
14
- import './augmentation.js';
@@ -1,44 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module undo/redocommand
7
- */
8
- import { UndoRedoBaseCommand } from './basecommand.js';
9
- /**
10
- * The redo command stores {@link module:engine/model/batch~Batch batches} that were used to undo a batch by
11
- * {@link module:undo/undocommand~UndoCommand}. It is able to redo a previously undone batch by reversing the undoing
12
- * batches created by `UndoCommand`. The reversed batch is transformed by all the batches from
13
- * {@link module:engine/model/document~ModelDocument#history history} that happened after the reversed undo batch.
14
- *
15
- * The redo command also takes care of restoring the {@link module:engine/model/document~ModelDocument#selection document selection}.
16
- */
17
- export class RedoCommand extends UndoRedoBaseCommand {
18
- /**
19
- * Executes the command. This method reverts the last {@link module:engine/model/batch~Batch batch} added to
20
- * the command's stack, applies the reverted and transformed version on the
21
- * {@link module:engine/model/document~ModelDocument document} and removes the batch from the stack.
22
- * Then, it restores the {@link module:engine/model/document~ModelDocument#selection document selection}.
23
- *
24
- * @fires execute
25
- */
26
- execute() {
27
- const item = this._stack.pop();
28
- const redoingBatch = this.editor.model.createBatch({ isUndo: true });
29
- // All changes have to be done in one `enqueueChange` callback so other listeners will not step between consecutive
30
- // operations, or won't do changes to the document before selection is properly restored.
31
- this.editor.model.enqueueChange(redoingBatch, () => {
32
- const lastOperation = item.batch.operations[item.batch.operations.length - 1];
33
- const nextBaseVersion = lastOperation.baseVersion + 1;
34
- const operations = this.editor.model.document.history.getOperations(nextBaseVersion);
35
- this._restoreSelection(item.selection.ranges, item.selection.isBackward, operations);
36
- this._undo(item.batch, redoingBatch);
37
- });
38
- // Firing `revert` event after the change block to make sure that it includes all changes from post-fixers
39
- // and make sure that the selection is "stabilized" (the selection range is saved after undo is executed and then
40
- // restored on redo, so it is important that the selection range is saved after post-fixers are done).
41
- this.fire('revert', item.batch, redoingBatch);
42
- this.refresh();
43
- }
44
- }