@ckeditor/ckeditor5-list 40.2.0 → 41.0.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 (196) hide show
  1. package/CHANGELOG.md +25 -25
  2. package/LICENSE.md +1 -1
  3. package/build/list.js +2 -2
  4. package/build/translations/ug.js +1 -1
  5. package/ckeditor5-metadata.json +34 -34
  6. package/lang/translations/ar.po +1 -1
  7. package/lang/translations/ast.po +1 -1
  8. package/lang/translations/az.po +1 -1
  9. package/lang/translations/bg.po +1 -1
  10. package/lang/translations/bn.po +1 -1
  11. package/lang/translations/ca.po +1 -1
  12. package/lang/translations/cs.po +1 -1
  13. package/lang/translations/da.po +1 -1
  14. package/lang/translations/de-ch.po +1 -1
  15. package/lang/translations/de.po +1 -1
  16. package/lang/translations/el.po +1 -1
  17. package/lang/translations/en-au.po +1 -1
  18. package/lang/translations/en-gb.po +1 -1
  19. package/lang/translations/en.po +1 -1
  20. package/lang/translations/eo.po +1 -1
  21. package/lang/translations/es.po +1 -1
  22. package/lang/translations/et.po +1 -1
  23. package/lang/translations/eu.po +1 -1
  24. package/lang/translations/fa.po +1 -1
  25. package/lang/translations/fi.po +1 -1
  26. package/lang/translations/fr.po +1 -1
  27. package/lang/translations/gl.po +1 -1
  28. package/lang/translations/he.po +1 -1
  29. package/lang/translations/hi.po +1 -1
  30. package/lang/translations/hr.po +1 -1
  31. package/lang/translations/hu.po +1 -1
  32. package/lang/translations/id.po +1 -1
  33. package/lang/translations/it.po +1 -1
  34. package/lang/translations/ja.po +1 -1
  35. package/lang/translations/jv.po +1 -1
  36. package/lang/translations/km.po +1 -1
  37. package/lang/translations/kn.po +1 -1
  38. package/lang/translations/ko.po +1 -1
  39. package/lang/translations/ku.po +1 -1
  40. package/lang/translations/lt.po +1 -1
  41. package/lang/translations/lv.po +1 -1
  42. package/lang/translations/ms.po +1 -1
  43. package/lang/translations/nb.po +1 -1
  44. package/lang/translations/ne.po +1 -1
  45. package/lang/translations/nl.po +1 -1
  46. package/lang/translations/no.po +1 -1
  47. package/lang/translations/pl.po +1 -1
  48. package/lang/translations/pt-br.po +1 -1
  49. package/lang/translations/pt.po +1 -1
  50. package/lang/translations/ro.po +1 -1
  51. package/lang/translations/ru.po +1 -1
  52. package/lang/translations/si.po +1 -1
  53. package/lang/translations/sk.po +1 -1
  54. package/lang/translations/sq.po +1 -1
  55. package/lang/translations/sr-latn.po +1 -1
  56. package/lang/translations/sr.po +1 -1
  57. package/lang/translations/sv.po +1 -1
  58. package/lang/translations/th.po +1 -1
  59. package/lang/translations/tk.po +1 -1
  60. package/lang/translations/tr.po +1 -1
  61. package/lang/translations/tt.po +1 -1
  62. package/lang/translations/ug.po +8 -8
  63. package/lang/translations/uk.po +1 -1
  64. package/lang/translations/ur.po +1 -1
  65. package/lang/translations/uz.po +1 -1
  66. package/lang/translations/vi.po +1 -1
  67. package/lang/translations/zh-cn.po +1 -1
  68. package/lang/translations/zh.po +1 -1
  69. package/package.json +3 -2
  70. package/src/augmentation.d.ts +29 -28
  71. package/src/augmentation.js +1 -1
  72. package/src/documentlist.d.ts +9 -7
  73. package/src/documentlist.js +18 -7
  74. package/src/documentlistproperties.d.ts +9 -8
  75. package/src/documentlistproperties.js +18 -8
  76. package/src/index.d.ts +39 -37
  77. package/src/index.js +32 -23
  78. package/src/legacylist/legacyconverters.d.ts +196 -0
  79. package/src/legacylist/legacyconverters.js +905 -0
  80. package/src/{list/indentcommand.d.ts → legacylist/legacyindentcommand.d.ts} +4 -4
  81. package/src/{list/indentcommand.js → legacylist/legacyindentcommand.js} +5 -5
  82. package/src/{documentlist/documentlistcommand.d.ts → legacylist/legacylistcommand.d.ts} +5 -30
  83. package/src/legacylist/legacylistcommand.js +274 -0
  84. package/src/legacylist/legacylistediting.d.ts +32 -0
  85. package/src/legacylist/legacylistediting.js +161 -0
  86. package/src/legacylist/legacylistutils.d.ts +41 -0
  87. package/src/legacylist/legacylistutils.js +46 -0
  88. package/src/legacylist/legacyutils.d.ts +101 -0
  89. package/src/legacylist/legacyutils.js +347 -0
  90. package/src/legacylist.d.ts +26 -0
  91. package/src/legacylist.js +30 -0
  92. package/src/legacylistproperties/legacylistpropertiesediting.d.ts +72 -0
  93. package/src/legacylistproperties/legacylistpropertiesediting.js +696 -0
  94. package/src/legacylistproperties/legacylistreversedcommand.d.ts +38 -0
  95. package/src/legacylistproperties/legacylistreversedcommand.js +52 -0
  96. package/src/{documentlistproperties/documentliststartcommand.d.ts → legacylistproperties/legacyliststartcommand.d.ts} +6 -7
  97. package/src/legacylistproperties/legacyliststartcommand.js +51 -0
  98. package/src/{documentlistproperties/documentliststylecommand.d.ts → legacylistproperties/legacyliststylecommand.d.ts} +14 -19
  99. package/src/{documentlistproperties/documentliststylecommand.js → legacylistproperties/legacyliststylecommand.js} +22 -36
  100. package/src/legacylistproperties.d.ts +27 -0
  101. package/src/legacylistproperties.js +31 -0
  102. package/src/{tododocumentlist/checktododocumentlistcommand.d.ts → legacytodolist/legacychecktodolistcommand.d.ts} +17 -14
  103. package/src/{tododocumentlist/checktododocumentlistcommand.js → legacytodolist/legacychecktodolistcommand.js} +34 -40
  104. package/src/{todolist/todolistconverters.d.ts → legacytodolist/legacytodolistconverters.d.ts} +9 -8
  105. package/src/{todolist/todolistconverters.js → legacytodolist/legacytodolistconverters.js} +6 -5
  106. package/src/{tododocumentlist/tododocumentlistediting.d.ts → legacytodolist/legacytodolistediting.d.ts} +9 -8
  107. package/src/legacytodolist/legacytodolistediting.js +161 -0
  108. package/src/legacytodolist.d.ts +27 -0
  109. package/src/legacytodolist.js +31 -0
  110. package/src/{documentlist → list}/adjacentlistssupport.d.ts +2 -2
  111. package/src/{documentlist → list}/adjacentlistssupport.js +9 -9
  112. package/src/list/converters.d.ts +41 -172
  113. package/src/list/converters.js +357 -821
  114. package/src/list/listcommand.d.ts +28 -3
  115. package/src/list/listcommand.js +81 -205
  116. package/src/list/listediting.d.ts +189 -9
  117. package/src/list/listediting.js +592 -107
  118. package/src/{documentlist/documentlistindentcommand.d.ts → list/listindentcommand.d.ts} +10 -10
  119. package/src/{documentlist/documentlistindentcommand.js → list/listindentcommand.js} +7 -7
  120. package/src/{documentlist/documentlistmergecommand.d.ts → list/listmergecommand.d.ts} +10 -10
  121. package/src/{documentlist/documentlistmergecommand.js → list/listmergecommand.js} +7 -7
  122. package/src/{documentlist/documentlistsplitcommand.d.ts → list/listsplitcommand.d.ts} +10 -10
  123. package/src/{documentlist/documentlistsplitcommand.js → list/listsplitcommand.js} +5 -5
  124. package/src/list/listui.d.ts +2 -2
  125. package/src/list/listui.js +5 -7
  126. package/src/list/listutils.d.ts +22 -17
  127. package/src/list/listutils.js +24 -20
  128. package/src/{documentlist → list}/utils/listwalker.d.ts +5 -5
  129. package/src/{documentlist → list}/utils/listwalker.js +4 -4
  130. package/src/{documentlist → list}/utils/model.d.ts +4 -4
  131. package/src/{documentlist → list}/utils/model.js +3 -3
  132. package/src/{documentlist → list}/utils/postfixers.d.ts +5 -5
  133. package/src/{documentlist → list}/utils/postfixers.js +3 -3
  134. package/src/{documentlist → list}/utils/view.d.ts +3 -3
  135. package/src/{documentlist → list}/utils/view.js +1 -1
  136. package/src/list/utils.d.ts +2 -96
  137. package/src/list/utils.js +2 -342
  138. package/src/list.d.ts +6 -6
  139. package/src/list.js +6 -6
  140. package/src/listconfig.d.ts +10 -10
  141. package/src/listconfig.js +1 -1
  142. package/src/{documentlistproperties → listproperties}/converters.d.ts +5 -5
  143. package/src/{documentlistproperties → listproperties}/converters.js +1 -1
  144. package/src/listproperties/listpropertiesediting.d.ts +56 -40
  145. package/src/listproperties/listpropertiesediting.js +145 -575
  146. package/src/listproperties/listpropertiesui.d.ts +2 -2
  147. package/src/listproperties/listpropertiesui.js +6 -8
  148. package/src/{documentlistproperties/documentlistpropertiesutils.d.ts → listproperties/listpropertiesutils.d.ts} +5 -5
  149. package/src/{documentlistproperties/documentlistpropertiesutils.js → listproperties/listpropertiesutils.js} +6 -6
  150. package/src/listproperties/listreversedcommand.d.ts +4 -6
  151. package/src/listproperties/listreversedcommand.js +17 -14
  152. package/src/listproperties/liststartcommand.d.ts +4 -3
  153. package/src/listproperties/liststartcommand.js +17 -11
  154. package/src/listproperties/liststylecommand.d.ts +16 -11
  155. package/src/listproperties/liststylecommand.js +33 -19
  156. package/src/listproperties/ui/listpropertiesview.d.ts +5 -5
  157. package/src/listproperties/ui/listpropertiesview.js +3 -3
  158. package/src/{documentlistproperties → listproperties}/utils/style.d.ts +1 -1
  159. package/src/{documentlistproperties → listproperties}/utils/style.js +2 -2
  160. package/src/listproperties.d.ts +6 -5
  161. package/src/listproperties.js +6 -5
  162. package/src/tododocumentlist.d.ts +9 -8
  163. package/src/tododocumentlist.js +18 -8
  164. package/src/todolist/checktodolistcommand.d.ts +11 -14
  165. package/src/todolist/checktodolistcommand.js +37 -31
  166. package/src/{tododocumentlist → todolist}/todocheckboxchangeobserver.d.ts +6 -6
  167. package/src/{tododocumentlist → todolist}/todocheckboxchangeobserver.js +3 -3
  168. package/src/todolist/todolistediting.d.ts +5 -6
  169. package/src/todolist/todolistediting.js +314 -76
  170. package/src/todolist/todolistui.d.ts +2 -2
  171. package/src/todolist/todolistui.js +4 -5
  172. package/src/todolist.d.ts +6 -6
  173. package/src/todolist.js +6 -6
  174. package/theme/documentlist.css +1 -1
  175. package/theme/list.css +1 -1
  176. package/theme/listproperties.css +1 -1
  177. package/theme/liststyles.css +1 -1
  178. package/theme/todolist.css +1 -1
  179. package/src/documentlist/converters.d.ts +0 -65
  180. package/src/documentlist/converters.js +0 -441
  181. package/src/documentlist/documentlistcommand.js +0 -150
  182. package/src/documentlist/documentlistediting.d.ts +0 -212
  183. package/src/documentlist/documentlistediting.js +0 -646
  184. package/src/documentlist/documentlistutils.d.ts +0 -46
  185. package/src/documentlist/documentlistutils.js +0 -50
  186. package/src/documentlistproperties/documentlistpropertiesediting.d.ts +0 -88
  187. package/src/documentlistproperties/documentlistpropertiesediting.js +0 -266
  188. package/src/documentlistproperties/documentlistreversedcommand.d.ts +0 -36
  189. package/src/documentlistproperties/documentlistreversedcommand.js +0 -55
  190. package/src/documentlistproperties/documentliststartcommand.js +0 -57
  191. package/src/liststyle.d.ts +0 -28
  192. package/src/liststyle.js +0 -36
  193. package/src/tododocumentlist/tododocumentlistediting.js +0 -399
  194. package/theme/icons/bulletedlist.svg +0 -1
  195. package/theme/icons/numberedlist.svg +0 -1
  196. package/theme/icons/todolist.svg +0 -1
@@ -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
+ * @module list/legacylistproperties/legacylistreversedcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ /**
10
+ * The reversed list command. It changes the `listReversed` attribute of the selected list items. As a result, the list order will be
11
+ * reversed.
12
+ * It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
13
+ */
14
+ export default class LegacyListReversedCommand extends Command {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ value: boolean | null;
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ refresh(): void;
23
+ /**
24
+ * Executes the command.
25
+ *
26
+ * @fires execute
27
+ * @param options.reversed Whether the list should be reversed.
28
+ */
29
+ execute(options?: {
30
+ reversed?: boolean;
31
+ }): void;
32
+ /**
33
+ * Checks the command's {@link #value}.
34
+ *
35
+ * @returns The current value.
36
+ */
37
+ private _getValue;
38
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/legacylistproperties/legacylistreversedcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ import { getSelectedListItems } from '../legacylist/legacyutils.js';
10
+ /**
11
+ * The reversed list command. It changes the `listReversed` attribute of the selected list items. As a result, the list order will be
12
+ * reversed.
13
+ * It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
14
+ */
15
+ export default class LegacyListReversedCommand extends Command {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ refresh() {
20
+ const value = this._getValue();
21
+ this.value = value;
22
+ this.isEnabled = value != null;
23
+ }
24
+ /**
25
+ * Executes the command.
26
+ *
27
+ * @fires execute
28
+ * @param options.reversed Whether the list should be reversed.
29
+ */
30
+ execute(options = {}) {
31
+ const model = this.editor.model;
32
+ const listItems = getSelectedListItems(model)
33
+ .filter(item => item.getAttribute('listType') == 'numbered');
34
+ model.change(writer => {
35
+ for (const item of listItems) {
36
+ writer.setAttribute('listReversed', !!options.reversed, item);
37
+ }
38
+ });
39
+ }
40
+ /**
41
+ * Checks the command's {@link #value}.
42
+ *
43
+ * @returns The current value.
44
+ */
45
+ _getValue() {
46
+ const listItem = this.editor.model.document.selection.getFirstPosition().parent;
47
+ if (listItem && listItem.is('element', 'listItem') && listItem.getAttribute('listType') == 'numbered') {
48
+ return listItem.getAttribute('listReversed');
49
+ }
50
+ return null;
51
+ }
52
+ }
@@ -1,17 +1,16 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
- * @module list/documentlistproperties/documentliststartcommand
6
+ * @module list/legacylistproperties/legacyliststartcommand
7
7
  */
8
- import { Command } from 'ckeditor5/src/core';
8
+ import { Command } from 'ckeditor5/src/core.js';
9
9
  /**
10
- * The list start index command. It changes the `listStart` attribute of the selected list items,
11
- * letting the user to choose the starting point of an ordered list.
12
- * It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
10
+ * The list start index command. It changes the `listStart` attribute of the selected list items.
11
+ * It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
13
12
  */
14
- export default class DocumentListStartCommand extends Command {
13
+ export default class LegacyListStartCommand extends Command {
15
14
  /**
16
15
  * @inheritDoc
17
16
  */
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/legacylistproperties/legacyliststartcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ import { getSelectedListItems } from '../legacylist/legacyutils.js';
10
+ /**
11
+ * The list start index command. It changes the `listStart` attribute of the selected list items.
12
+ * It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
13
+ */
14
+ export default class LegacyListStartCommand extends Command {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ refresh() {
19
+ const value = this._getValue();
20
+ this.value = value;
21
+ this.isEnabled = value != null;
22
+ }
23
+ /**
24
+ * Executes the command.
25
+ *
26
+ * @fires execute
27
+ * @param options.startIndex The list start index.
28
+ */
29
+ execute({ startIndex = 1 } = {}) {
30
+ const model = this.editor.model;
31
+ const listItems = getSelectedListItems(model)
32
+ .filter(item => item.getAttribute('listType') == 'numbered');
33
+ model.change(writer => {
34
+ for (const item of listItems) {
35
+ writer.setAttribute('listStart', startIndex >= 0 ? startIndex : 1, item);
36
+ }
37
+ });
38
+ }
39
+ /**
40
+ * Checks the command's {@link #value}.
41
+ *
42
+ * @returns The current value.
43
+ */
44
+ _getValue() {
45
+ const listItem = this.editor.model.document.selection.getFirstPosition().parent;
46
+ if (listItem && listItem.is('element', 'listItem') && listItem.getAttribute('listType') == 'numbered') {
47
+ return listItem.getAttribute('listStart');
48
+ }
49
+ return null;
50
+ }
51
+ }
@@ -1,38 +1,37 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
- * @module list/documentlistproperties/documentliststylecommand
6
+ * @module list/legacylistproperties/legacyliststylecommand
7
7
  */
8
- import { Command, type Editor } from 'ckeditor5/src/core';
8
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
9
9
  /**
10
- * The list style command. It changes `listStyle` attribute of the selected list items,
11
- * letting the user choose styles for the list item markers.
12
- * It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
10
+ * The list style command. It changes the `listStyle` attribute of the selected list items.
11
+ *
12
+ * If the list type (numbered or bulleted) can be inferred from the passed style type,
13
+ * the command tries to convert selected items to a list of that type.
14
+ * It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
13
15
  */
14
- export default class DocumentListStyleCommand extends Command {
16
+ export default class LegacyListStyleCommand extends Command {
17
+ isStyleTypeSupported: undefined;
15
18
  /**
16
19
  * @inheritDoc
20
+ * @readonly
17
21
  */
18
22
  value: string | null;
19
23
  /**
20
24
  * The default type of the list style.
21
25
  */
22
26
  readonly defaultType: string;
23
- /**
24
- * The list of supported style types by this command.
25
- */
26
- private _supportedTypes;
27
27
  /**
28
28
  * Creates an instance of the command.
29
29
  *
30
30
  * @param editor The editor instance.
31
31
  * @param defaultType The list type that will be used by default if the value was not specified during
32
32
  * the command execution.
33
- * @param supportedTypes The list of supported style types by this command.
34
33
  */
35
- constructor(editor: Editor, defaultType: string, supportedTypes?: Array<string>);
34
+ constructor(editor: Editor, defaultType: string);
36
35
  /**
37
36
  * @inheritDoc
38
37
  */
@@ -47,10 +46,6 @@ export default class DocumentListStyleCommand extends Command {
47
46
  execute(options?: {
48
47
  type?: string | null;
49
48
  }): void;
50
- /**
51
- * Checks if the given style type is supported by this plugin.
52
- */
53
- isStyleTypeSupported(value: string): boolean;
54
49
  /**
55
50
  * Checks the command's {@link #value}.
56
51
  *
@@ -64,9 +59,9 @@ export default class DocumentListStyleCommand extends Command {
64
59
  */
65
60
  private _checkEnabled;
66
61
  /**
67
- * Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
62
+ * Checks if the provided list style is valid. Also changes the selection to a list if it's not set yet.
68
63
  *
69
- * @param options.type The type of the list style. If `null` is specified, the function does nothing.
64
+ * @param The type of the list style. If `null` is specified, the function does nothing.
70
65
  */
71
66
  private _tryToConvertItemsToList;
72
67
  }
@@ -1,32 +1,30 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
- * @module list/documentlistproperties/documentliststylecommand
6
+ * @module list/legacylistproperties/legacyliststylecommand
7
7
  */
8
- import { Command } from 'ckeditor5/src/core';
9
- import { first } from 'ckeditor5/src/utils';
10
- import { expandListBlocksToCompleteList, isListItemBlock } from '../documentlist/utils/model';
11
- import { getListTypeFromListStyleType } from './utils/style';
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ import { getListTypeFromListStyleType, getSelectedListItems } from '../legacylist/legacyutils.js';
12
10
  /**
13
- * The list style command. It changes `listStyle` attribute of the selected list items,
14
- * letting the user choose styles for the list item markers.
15
- * It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
11
+ * The list style command. It changes the `listStyle` attribute of the selected list items.
12
+ *
13
+ * If the list type (numbered or bulleted) can be inferred from the passed style type,
14
+ * the command tries to convert selected items to a list of that type.
15
+ * It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
16
16
  */
17
- export default class DocumentListStyleCommand extends Command {
17
+ export default class LegacyListStyleCommand extends Command {
18
18
  /**
19
19
  * Creates an instance of the command.
20
20
  *
21
21
  * @param editor The editor instance.
22
22
  * @param defaultType The list type that will be used by default if the value was not specified during
23
23
  * the command execution.
24
- * @param supportedTypes The list of supported style types by this command.
25
24
  */
26
- constructor(editor, defaultType, supportedTypes) {
25
+ constructor(editor, defaultType) {
27
26
  super(editor);
28
27
  this.defaultType = defaultType;
29
- this._supportedTypes = supportedTypes;
30
28
  }
31
29
  /**
32
30
  * @inheritDoc
@@ -43,38 +41,26 @@ export default class DocumentListStyleCommand extends Command {
43
41
  * style will be applied.
44
42
  */
45
43
  execute(options = {}) {
44
+ this._tryToConvertItemsToList(options);
46
45
  const model = this.editor.model;
47
- const document = model.document;
46
+ const listItems = getSelectedListItems(model);
47
+ if (!listItems.length) {
48
+ return;
49
+ }
48
50
  model.change(writer => {
49
- this._tryToConvertItemsToList(options);
50
- let blocks = Array.from(document.selection.getSelectedBlocks())
51
- .filter(block => block.hasAttribute('listType'));
52
- if (!blocks.length) {
53
- return;
54
- }
55
- blocks = expandListBlocksToCompleteList(blocks);
56
- for (const block of blocks) {
57
- writer.setAttribute('listStyle', options.type || this.defaultType, block);
51
+ for (const item of listItems) {
52
+ writer.setAttribute('listStyle', options.type || this.defaultType, item);
58
53
  }
59
54
  });
60
55
  }
61
- /**
62
- * Checks if the given style type is supported by this plugin.
63
- */
64
- isStyleTypeSupported(value) {
65
- if (!this._supportedTypes) {
66
- return true;
67
- }
68
- return this._supportedTypes.includes(value);
69
- }
70
56
  /**
71
57
  * Checks the command's {@link #value}.
72
58
  *
73
59
  * @returns The current value.
74
60
  */
75
61
  _getValue() {
76
- const listItem = first(this.editor.model.document.selection.getSelectedBlocks());
77
- if (isListItemBlock(listItem)) {
62
+ const listItem = this.editor.model.document.selection.getFirstPosition().parent;
63
+ if (listItem && listItem.is('element', 'listItem')) {
78
64
  return listItem.getAttribute('listStyle');
79
65
  }
80
66
  return null;
@@ -91,9 +77,9 @@ export default class DocumentListStyleCommand extends Command {
91
77
  return numberedList.isEnabled || bulletedList.isEnabled;
92
78
  }
93
79
  /**
94
- * Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
80
+ * Checks if the provided list style is valid. Also changes the selection to a list if it's not set yet.
95
81
  *
96
- * @param options.type The type of the list style. If `null` is specified, the function does nothing.
82
+ * @param The type of the list style. If `null` is specified, the function does nothing.
97
83
  */
98
84
  _tryToConvertItemsToList(options) {
99
85
  if (!options.type) {
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/legacylistproperties
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import LegacyListPropertiesEditing from './legacylistproperties/legacylistpropertiesediting.js';
10
+ import ListPropertiesUI from './listproperties/listpropertiesui.js';
11
+ /**
12
+ * The legacy list properties feature.
13
+ *
14
+ * This is a "glue" plugin that loads the {@link module:list/legacylistproperties/legacylistpropertiesediting~LegacyListPropertiesEditing
15
+ * legacy list properties editing feature} and the
16
+ * {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
17
+ */
18
+ export default class LegacyListProperties extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): readonly [typeof LegacyListPropertiesEditing, typeof ListPropertiesUI];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): "LegacyListProperties";
27
+ }
@@ -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
+ * @module list/legacylistproperties
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import LegacyListPropertiesEditing from './legacylistproperties/legacylistpropertiesediting.js';
10
+ import ListPropertiesUI from './listproperties/listpropertiesui.js';
11
+ /**
12
+ * The legacy list properties feature.
13
+ *
14
+ * This is a "glue" plugin that loads the {@link module:list/legacylistproperties/legacylistpropertiesediting~LegacyListPropertiesEditing
15
+ * legacy list properties editing feature} and the
16
+ * {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
17
+ */
18
+ export default class LegacyListProperties extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires() {
23
+ return [LegacyListPropertiesEditing, ListPropertiesUI];
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName() {
29
+ return 'LegacyListProperties';
30
+ }
31
+ }
@@ -1,18 +1,19 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
- * @module list/tododocumentlist/checktododocumentlistcommand
6
+ * @module list/legacytodolist/legacychecktodolistcommand
7
7
  */
8
- import { Command, type Editor } from 'ckeditor5/src/core';
8
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
9
+ import type { Element } from 'ckeditor5/src/engine.js';
9
10
  /**
10
11
  * The check to-do command.
11
12
  *
12
- * The command is registered by the {@link module:list/tododocumentlist/tododocumentlistediting~TodoDocumentListEditing} as
13
- * the `checkTodoList` editor command.
13
+ * The command is registered by the {@link module:list/legacytodolist/legacytodolistediting~LegacyTodoListEditing} as
14
+ * the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
14
15
  */
15
- export default class CheckTodoDocumentListCommand extends Command {
16
+ export default class LegacyCheckTodoListCommand extends Command {
16
17
  /**
17
18
  * A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
18
19
  *
@@ -20,6 +21,12 @@ export default class CheckTodoDocumentListCommand extends Command {
20
21
  * @readonly
21
22
  */
22
23
  value: boolean;
24
+ /**
25
+ * A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
26
+ *
27
+ * @internal
28
+ */
29
+ _selectedElements: Array<Element>;
23
30
  /**
24
31
  * @inheritDoc
25
32
  */
@@ -28,6 +35,10 @@ export default class CheckTodoDocumentListCommand extends Command {
28
35
  * Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
29
36
  */
30
37
  refresh(): void;
38
+ /**
39
+ * Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
40
+ */
41
+ private _getSelectedItems;
31
42
  /**
32
43
  * Executes the command.
33
44
  *
@@ -38,12 +49,4 @@ export default class CheckTodoDocumentListCommand extends Command {
38
49
  execute(options?: {
39
50
  forceValue?: boolean;
40
51
  }): void;
41
- /**
42
- * Returns a value for the command.
43
- */
44
- private _getValue;
45
- /**
46
- * Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
47
- */
48
- private _getSelectedItems;
49
52
  }
@@ -1,24 +1,25 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
- * @module list/tododocumentlist/checktododocumentlistcommand
6
+ * @module list/legacytodolist/legacychecktodolistcommand
7
7
  */
8
- import { Command } from 'ckeditor5/src/core';
9
- import { getAllListItemBlocks } from '../documentlist/utils/model';
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ const attributeKey = 'todoListChecked';
10
10
  /**
11
11
  * The check to-do command.
12
12
  *
13
- * The command is registered by the {@link module:list/tododocumentlist/tododocumentlistediting~TodoDocumentListEditing} as
14
- * the `checkTodoList` editor command.
13
+ * The command is registered by the {@link module:list/legacytodolist/legacytodolistediting~LegacyTodoListEditing} as
14
+ * the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
15
15
  */
16
- export default class CheckTodoDocumentListCommand extends Command {
16
+ export default class LegacyCheckTodoListCommand extends Command {
17
17
  /**
18
18
  * @inheritDoc
19
19
  */
20
20
  constructor(editor) {
21
21
  super(editor);
22
+ this._selectedElements = [];
22
23
  // Refresh command before executing to be sure all values are up to date.
23
24
  // It is needed when selection has changed before command execution, in the same change block.
24
25
  this.on('execute', () => {
@@ -29,9 +30,28 @@ export default class CheckTodoDocumentListCommand extends Command {
29
30
  * Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
30
31
  */
31
32
  refresh() {
32
- const selectedElements = this._getSelectedItems();
33
- this.value = this._getValue(selectedElements);
34
- this.isEnabled = !!selectedElements.length;
33
+ this._selectedElements = this._getSelectedItems();
34
+ this.value = this._selectedElements.every(element => !!element.getAttribute(attributeKey));
35
+ this.isEnabled = !!this._selectedElements.length;
36
+ }
37
+ /**
38
+ * Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
39
+ */
40
+ _getSelectedItems() {
41
+ const model = this.editor.model;
42
+ const schema = model.schema;
43
+ const selectionRange = model.document.selection.getFirstRange();
44
+ const startElement = selectionRange.start.parent;
45
+ const elements = [];
46
+ if (schema.checkAttribute(startElement, attributeKey)) {
47
+ elements.push(startElement);
48
+ }
49
+ for (const item of selectionRange.getItems()) {
50
+ if (schema.checkAttribute(item, attributeKey) && !elements.includes(item)) {
51
+ elements.push(item);
52
+ }
53
+ }
54
+ return elements;
35
55
  }
36
56
  /**
37
57
  * Executes the command.
@@ -42,41 +62,15 @@ export default class CheckTodoDocumentListCommand extends Command {
42
62
  */
43
63
  execute(options = {}) {
44
64
  this.editor.model.change(writer => {
45
- const selectedElements = this._getSelectedItems();
46
- const value = (options.forceValue === undefined) ? !this._getValue(selectedElements) : options.forceValue;
47
- for (const element of selectedElements) {
65
+ for (const element of this._selectedElements) {
66
+ const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
48
67
  if (value) {
49
- writer.setAttribute('todoListChecked', true, element);
68
+ writer.setAttribute(attributeKey, true, element);
50
69
  }
51
70
  else {
52
- writer.removeAttribute('todoListChecked', element);
71
+ writer.removeAttribute(attributeKey, element);
53
72
  }
54
73
  }
55
74
  });
56
75
  }
57
- /**
58
- * Returns a value for the command.
59
- */
60
- _getValue(selectedElements) {
61
- return selectedElements.every(element => element.getAttribute('todoListChecked'));
62
- }
63
- /**
64
- * Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
65
- */
66
- _getSelectedItems() {
67
- const model = this.editor.model;
68
- const schema = model.schema;
69
- const selectionRange = model.document.selection.getFirstRange();
70
- const startElement = selectionRange.start.parent;
71
- const elements = [];
72
- if (schema.checkAttribute(startElement, 'todoListChecked')) {
73
- elements.push(...getAllListItemBlocks(startElement));
74
- }
75
- for (const item of selectionRange.getItems({ shallow: true })) {
76
- if (schema.checkAttribute(item, 'todoListChecked') && !elements.includes(item)) {
77
- elements.push(...getAllListItemBlocks(item));
78
- }
79
- }
80
- return elements;
81
- }
82
76
  }
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
- * @module list/todolist/todolistconverters
6
+ * @module list/legacytodolist/legacytodolistconverters
7
7
  */
8
- import type { DowncastAttributeEvent, DowncastInsertEvent, Element, MapperModelToViewPositionEvent, Model, UpcastElementEvent, View } from 'ckeditor5/src/engine';
9
- import { type GetCallback } from 'ckeditor5/src/utils';
8
+ import type { DowncastAttributeEvent, DowncastInsertEvent, Element, MapperModelToViewPositionEvent, Model, UpcastElementEvent, EditingView } from 'ckeditor5/src/engine.js';
9
+ import { type GetCallback } from 'ckeditor5/src/utils.js';
10
10
  /**
11
11
  * A model-to-view converter for the `listItem` model element insertion.
12
12
  *
@@ -49,8 +49,9 @@ export declare const dataViewModelCheckmarkInsertion: GetCallback<UpcastElementE
49
49
  * {@link module:engine/view/uielement~UIElement checkbox UI element} is added at the beginning
50
50
  * of the list item element (or vice versa).
51
51
  *
52
- * This converter is preceded by {@link module:list/list/converters~modelViewChangeType} and followed by
53
- * {@link module:list/list/converters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists of the same type.
52
+ * This converter is preceded by {@link module:list/legacylist/legacyconverters~modelViewChangeType} and followed by
53
+ * {@link module:list/legacylist/legacyconverters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists
54
+ * of the same type.
54
55
  *
55
56
  * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
56
57
  *
@@ -59,7 +60,7 @@ export declare const dataViewModelCheckmarkInsertion: GetCallback<UpcastElementE
59
60
  * @param view Editing view controller.
60
61
  * @returns Returns a conversion callback.
61
62
  */
62
- export declare function modelViewChangeType(onCheckedChange: (element: Element) => void, view: View): GetCallback<DowncastAttributeEvent<Element>>;
63
+ export declare function modelViewChangeType(onCheckedChange: (element: Element) => void, view: EditingView): GetCallback<DowncastAttributeEvent<Element>>;
63
64
  /**
64
65
  * A model-to-view converter for the `todoListChecked` attribute change on the `listItem` model element.
65
66
  *
@@ -79,4 +80,4 @@ export declare function modelViewChangeChecked(onCheckedChange: (element: Elemen
79
80
  *
80
81
  * It only handles the position at the beginning of a list item as other positions are properly mapped be the default mapper.
81
82
  */
82
- export declare function mapModelToViewPosition(view: View): GetCallback<MapperModelToViewPositionEvent>;
83
+ export declare function mapModelToViewPosition(view: EditingView): GetCallback<MapperModelToViewPositionEvent>;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import { createElement } from 'ckeditor5/src/utils';
6
- import { generateLiInUl, injectViewList, positionAfterUiElements, findNestedList } from '../list/utils';
5
+ import { createElement } from 'ckeditor5/src/utils.js';
6
+ import { generateLiInUl, injectViewList, positionAfterUiElements, findNestedList } from '../legacylist/legacyutils.js';
7
7
  /**
8
8
  * A model-to-view converter for the `listItem` model element insertion.
9
9
  *
@@ -127,8 +127,9 @@ export const dataViewModelCheckmarkInsertion = (evt, data, conversionApi) => {
127
127
  * {@link module:engine/view/uielement~UIElement checkbox UI element} is added at the beginning
128
128
  * of the list item element (or vice versa).
129
129
  *
130
- * This converter is preceded by {@link module:list/list/converters~modelViewChangeType} and followed by
131
- * {@link module:list/list/converters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists of the same type.
130
+ * This converter is preceded by {@link module:list/legacylist/legacyconverters~modelViewChangeType} and followed by
131
+ * {@link module:list/legacylist/legacyconverters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists
132
+ * of the same type.
132
133
  *
133
134
  * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
134
135
  *