@ckeditor/ckeditor5-list 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 (275) hide show
  1. package/LICENSE.md +1 -1
  2. package/ckeditor5-metadata.json +21 -18
  3. package/dist/index-content.css +135 -111
  4. package/dist/index-editor.css +152 -73
  5. package/dist/index.css +204 -238
  6. package/dist/index.css.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/{src → dist}/legacylist/legacyconverters.d.ts +2 -2
  9. package/{src → dist}/legacylist/legacyindentcommand.d.ts +1 -1
  10. package/{src → dist}/legacylist/legacylistcommand.d.ts +1 -1
  11. package/{src → dist}/legacylist/legacylistediting.d.ts +3 -3
  12. package/{src → dist}/legacylist/legacylistutils.d.ts +2 -2
  13. package/{src → dist}/legacylist/legacyutils.d.ts +1 -1
  14. package/{src → dist}/legacylist.d.ts +1 -1
  15. package/{src → dist}/legacylistproperties/legacylistpropertiesediting.d.ts +1 -1
  16. package/{src → dist}/legacylistproperties/legacylistreversedcommand.d.ts +1 -1
  17. package/{src → dist}/legacylistproperties/legacyliststartcommand.d.ts +1 -1
  18. package/{src → dist}/legacylistproperties/legacyliststylecommand.d.ts +1 -1
  19. package/{src → dist}/legacylistproperties.d.ts +1 -1
  20. package/{src → dist}/legacytodolist/legacychecktodolistcommand.d.ts +2 -2
  21. package/{src → dist}/legacytodolist/legacytodolistconverters.d.ts +2 -2
  22. package/{src → dist}/legacytodolist/legacytodolistediting.d.ts +1 -1
  23. package/{src → dist}/legacytodolist.d.ts +1 -1
  24. package/{src → dist}/list/adjacentlistssupport.d.ts +1 -1
  25. package/{src → dist}/list/converters.d.ts +2 -2
  26. package/{src → dist}/list/listcommand.d.ts +2 -2
  27. package/{src → dist}/list/listediting.d.ts +5 -5
  28. package/{src → dist}/list/listindentcommand.d.ts +2 -2
  29. package/{src → dist}/list/listmergecommand.d.ts +2 -2
  30. package/{src → dist}/list/listsplitcommand.d.ts +2 -2
  31. package/{src → dist}/list/listui.d.ts +1 -1
  32. package/{src → dist}/list/listutils.d.ts +3 -3
  33. package/{src → dist}/list/utils/listwalker.d.ts +2 -2
  34. package/{src → dist}/list/utils/model.d.ts +2 -2
  35. package/{src → dist}/list/utils/postfixers.d.ts +1 -1
  36. package/{src → dist}/list/utils/view.d.ts +1 -1
  37. package/{src → dist}/list/utils.d.ts +1 -1
  38. package/{src → dist}/list.d.ts +1 -1
  39. package/{src → dist}/listconfig.d.ts +1 -1
  40. package/{src → dist}/listformatting/listitemboldintegration.d.ts +1 -1
  41. package/{src → dist}/listformatting/listitemfontcolorintegration.d.ts +1 -1
  42. package/{src → dist}/listformatting/listitemfontfamilyintegration.d.ts +1 -1
  43. package/{src → dist}/listformatting/listitemfontsizeintegration.d.ts +1 -1
  44. package/{src → dist}/listformatting/listitemitalicintegration.d.ts +1 -1
  45. package/{src → dist}/listformatting.d.ts +1 -1
  46. package/{src → dist}/listproperties/converters.d.ts +2 -2
  47. package/{src → dist}/listproperties/listpropertiesediting.d.ts +2 -2
  48. package/{src → dist}/listproperties/listpropertiesui.d.ts +1 -1
  49. package/{src → dist}/listproperties/listpropertiesutils.d.ts +1 -1
  50. package/{src → dist}/listproperties/listreversedcommand.d.ts +1 -1
  51. package/{src → dist}/listproperties/liststartcommand.d.ts +1 -1
  52. package/{src → dist}/listproperties/liststylecommand.d.ts +1 -1
  53. package/{src → dist}/listproperties/ui/listpropertiesview.d.ts +2 -2
  54. package/{src → dist}/listproperties.d.ts +1 -1
  55. package/{src → dist}/todolist/checktodolistcommand.d.ts +1 -1
  56. package/{src → dist}/todolist/todocheckboxchangeobserver.d.ts +1 -1
  57. package/{src → dist}/todolist/todolistediting.d.ts +1 -1
  58. package/{src → dist}/todolist/todolistui.d.ts +1 -1
  59. package/{src → dist}/todolist.d.ts +1 -1
  60. package/package.json +28 -52
  61. package/build/list.js +0 -5
  62. package/build/translations/af.js +0 -1
  63. package/build/translations/ar.js +0 -1
  64. package/build/translations/ast.js +0 -1
  65. package/build/translations/az.js +0 -1
  66. package/build/translations/be.js +0 -1
  67. package/build/translations/bg.js +0 -1
  68. package/build/translations/bn.js +0 -1
  69. package/build/translations/bs.js +0 -1
  70. package/build/translations/ca.js +0 -1
  71. package/build/translations/cs.js +0 -1
  72. package/build/translations/da.js +0 -1
  73. package/build/translations/de-ch.js +0 -1
  74. package/build/translations/de.js +0 -1
  75. package/build/translations/el.js +0 -1
  76. package/build/translations/en-au.js +0 -1
  77. package/build/translations/en-gb.js +0 -1
  78. package/build/translations/eo.js +0 -1
  79. package/build/translations/es-co.js +0 -1
  80. package/build/translations/es.js +0 -1
  81. package/build/translations/et.js +0 -1
  82. package/build/translations/eu.js +0 -1
  83. package/build/translations/fa.js +0 -1
  84. package/build/translations/fi.js +0 -1
  85. package/build/translations/fr.js +0 -1
  86. package/build/translations/gl.js +0 -1
  87. package/build/translations/gu.js +0 -1
  88. package/build/translations/he.js +0 -1
  89. package/build/translations/hi.js +0 -1
  90. package/build/translations/hr.js +0 -1
  91. package/build/translations/hu.js +0 -1
  92. package/build/translations/hy.js +0 -1
  93. package/build/translations/id.js +0 -1
  94. package/build/translations/it.js +0 -1
  95. package/build/translations/ja.js +0 -1
  96. package/build/translations/jv.js +0 -1
  97. package/build/translations/kk.js +0 -1
  98. package/build/translations/km.js +0 -1
  99. package/build/translations/kn.js +0 -1
  100. package/build/translations/ko.js +0 -1
  101. package/build/translations/ku.js +0 -1
  102. package/build/translations/lt.js +0 -1
  103. package/build/translations/lv.js +0 -1
  104. package/build/translations/ms.js +0 -1
  105. package/build/translations/nb.js +0 -1
  106. package/build/translations/ne.js +0 -1
  107. package/build/translations/nl.js +0 -1
  108. package/build/translations/no.js +0 -1
  109. package/build/translations/oc.js +0 -1
  110. package/build/translations/pl.js +0 -1
  111. package/build/translations/pt-br.js +0 -1
  112. package/build/translations/pt.js +0 -1
  113. package/build/translations/ro.js +0 -1
  114. package/build/translations/ru.js +0 -1
  115. package/build/translations/si.js +0 -1
  116. package/build/translations/sk.js +0 -1
  117. package/build/translations/sl.js +0 -1
  118. package/build/translations/sq.js +0 -1
  119. package/build/translations/sr-latn.js +0 -1
  120. package/build/translations/sr.js +0 -1
  121. package/build/translations/sv.js +0 -1
  122. package/build/translations/th.js +0 -1
  123. package/build/translations/ti.js +0 -1
  124. package/build/translations/tk.js +0 -1
  125. package/build/translations/tr.js +0 -1
  126. package/build/translations/tt.js +0 -1
  127. package/build/translations/ug.js +0 -1
  128. package/build/translations/uk.js +0 -1
  129. package/build/translations/ur.js +0 -1
  130. package/build/translations/uz.js +0 -1
  131. package/build/translations/vi.js +0 -1
  132. package/build/translations/zh-cn.js +0 -1
  133. package/build/translations/zh.js +0 -1
  134. package/lang/contexts.json +0 -37
  135. package/lang/translations/af.po +0 -152
  136. package/lang/translations/ar.po +0 -152
  137. package/lang/translations/ast.po +0 -152
  138. package/lang/translations/az.po +0 -152
  139. package/lang/translations/be.po +0 -152
  140. package/lang/translations/bg.po +0 -152
  141. package/lang/translations/bn.po +0 -152
  142. package/lang/translations/bs.po +0 -152
  143. package/lang/translations/ca.po +0 -152
  144. package/lang/translations/cs.po +0 -152
  145. package/lang/translations/da.po +0 -152
  146. package/lang/translations/de-ch.po +0 -152
  147. package/lang/translations/de.po +0 -152
  148. package/lang/translations/el.po +0 -152
  149. package/lang/translations/en-au.po +0 -152
  150. package/lang/translations/en-gb.po +0 -152
  151. package/lang/translations/en.po +0 -152
  152. package/lang/translations/eo.po +0 -152
  153. package/lang/translations/es-co.po +0 -152
  154. package/lang/translations/es.po +0 -152
  155. package/lang/translations/et.po +0 -152
  156. package/lang/translations/eu.po +0 -152
  157. package/lang/translations/fa.po +0 -152
  158. package/lang/translations/fi.po +0 -152
  159. package/lang/translations/fr.po +0 -152
  160. package/lang/translations/gl.po +0 -152
  161. package/lang/translations/gu.po +0 -152
  162. package/lang/translations/he.po +0 -152
  163. package/lang/translations/hi.po +0 -152
  164. package/lang/translations/hr.po +0 -152
  165. package/lang/translations/hu.po +0 -152
  166. package/lang/translations/hy.po +0 -152
  167. package/lang/translations/id.po +0 -152
  168. package/lang/translations/it.po +0 -152
  169. package/lang/translations/ja.po +0 -152
  170. package/lang/translations/jv.po +0 -152
  171. package/lang/translations/kk.po +0 -152
  172. package/lang/translations/km.po +0 -152
  173. package/lang/translations/kn.po +0 -152
  174. package/lang/translations/ko.po +0 -152
  175. package/lang/translations/ku.po +0 -152
  176. package/lang/translations/lt.po +0 -152
  177. package/lang/translations/lv.po +0 -152
  178. package/lang/translations/ms.po +0 -152
  179. package/lang/translations/nb.po +0 -152
  180. package/lang/translations/ne.po +0 -152
  181. package/lang/translations/nl.po +0 -152
  182. package/lang/translations/no.po +0 -152
  183. package/lang/translations/oc.po +0 -152
  184. package/lang/translations/pl.po +0 -152
  185. package/lang/translations/pt-br.po +0 -152
  186. package/lang/translations/pt.po +0 -152
  187. package/lang/translations/ro.po +0 -152
  188. package/lang/translations/ru.po +0 -152
  189. package/lang/translations/si.po +0 -152
  190. package/lang/translations/sk.po +0 -152
  191. package/lang/translations/sl.po +0 -152
  192. package/lang/translations/sq.po +0 -152
  193. package/lang/translations/sr-latn.po +0 -152
  194. package/lang/translations/sr.po +0 -152
  195. package/lang/translations/sv.po +0 -152
  196. package/lang/translations/th.po +0 -152
  197. package/lang/translations/ti.po +0 -152
  198. package/lang/translations/tk.po +0 -152
  199. package/lang/translations/tr.po +0 -152
  200. package/lang/translations/tt.po +0 -152
  201. package/lang/translations/ug.po +0 -152
  202. package/lang/translations/uk.po +0 -152
  203. package/lang/translations/ur.po +0 -152
  204. package/lang/translations/uz.po +0 -152
  205. package/lang/translations/vi.po +0 -152
  206. package/lang/translations/zh-cn.po +0 -152
  207. package/lang/translations/zh.po +0 -152
  208. package/src/augmentation.js +0 -5
  209. package/src/index.js +0 -67
  210. package/src/legacyerrors.js +0 -28
  211. package/src/legacylist/legacyconverters.js +0 -921
  212. package/src/legacylist/legacyindentcommand.js +0 -111
  213. package/src/legacylist/legacylistcommand.js +0 -278
  214. package/src/legacylist/legacylistediting.js +0 -167
  215. package/src/legacylist/legacylistutils.js +0 -52
  216. package/src/legacylist/legacyutils.js +0 -357
  217. package/src/legacylist.js +0 -36
  218. package/src/legacylistproperties/legacylistpropertiesediting.js +0 -703
  219. package/src/legacylistproperties/legacylistreversedcommand.js +0 -52
  220. package/src/legacylistproperties/legacyliststartcommand.js +0 -52
  221. package/src/legacylistproperties/legacyliststylecommand.js +0 -105
  222. package/src/legacylistproperties.js +0 -37
  223. package/src/legacytodolist/legacychecktodolistcommand.js +0 -82
  224. package/src/legacytodolist/legacytodolistconverters.js +0 -268
  225. package/src/legacytodolist/legacytodolistediting.js +0 -199
  226. package/src/legacytodolist.js +0 -37
  227. package/src/list/adjacentlistssupport.js +0 -87
  228. package/src/list/converters.js +0 -533
  229. package/src/list/listcommand.js +0 -176
  230. package/src/list/listediting.js +0 -696
  231. package/src/list/listindentcommand.js +0 -136
  232. package/src/list/listmergecommand.js +0 -182
  233. package/src/list/listsplitcommand.js +0 -74
  234. package/src/list/listui.js +0 -42
  235. package/src/list/listutils.js +0 -68
  236. package/src/list/utils/listwalker.js +0 -236
  237. package/src/list/utils/model.js +0 -487
  238. package/src/list/utils/postfixers.js +0 -131
  239. package/src/list/utils/view.js +0 -117
  240. package/src/list/utils.js +0 -51
  241. package/src/list.js +0 -36
  242. package/src/listconfig.js +0 -5
  243. package/src/listformatting/listitemboldintegration.js +0 -88
  244. package/src/listformatting/listitemfontcolorintegration.js +0 -92
  245. package/src/listformatting/listitemfontfamilyintegration.js +0 -93
  246. package/src/listformatting/listitemfontsizeintegration.js +0 -124
  247. package/src/listformatting/listitemitalicintegration.js +0 -88
  248. package/src/listformatting.js +0 -248
  249. package/src/listproperties/converters.js +0 -43
  250. package/src/listproperties/listpropertiesediting.js +0 -291
  251. package/src/listproperties/listpropertiesui.js +0 -385
  252. package/src/listproperties/listpropertiesutils.js +0 -50
  253. package/src/listproperties/listreversedcommand.js +0 -55
  254. package/src/listproperties/liststartcommand.js +0 -61
  255. package/src/listproperties/liststylecommand.js +0 -121
  256. package/src/listproperties/ui/listpropertiesview.js +0 -318
  257. package/src/listproperties/utils/config.js +0 -84
  258. package/src/listproperties/utils/style.js +0 -85
  259. package/src/listproperties.js +0 -37
  260. package/src/todolist/checktodolistcommand.js +0 -82
  261. package/src/todolist/todocheckboxchangeobserver.js +0 -36
  262. package/src/todolist/todolistediting.js +0 -470
  263. package/src/todolist/todolistui.js +0 -35
  264. package/src/todolist.js +0 -37
  265. package/theme/documentlist.css +0 -8
  266. package/theme/list.css +0 -40
  267. package/theme/listformatting.css +0 -66
  268. package/theme/listproperties.css +0 -10
  269. package/theme/liststyles.css +0 -8
  270. package/theme/todolist.css +0 -140
  271. /package/{src → dist}/augmentation.d.ts +0 -0
  272. /package/{src → dist}/index.d.ts +0 -0
  273. /package/{src → dist}/legacyerrors.d.ts +0 -0
  274. /package/{src → dist}/listproperties/utils/config.d.ts +0 -0
  275. /package/{src → dist}/listproperties/utils/style.d.ts +0 -0
@@ -1,52 +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 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 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,52 +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 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 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 Execute options.
28
- * @param options.startIndex The list start index.
29
- */
30
- execute({ startIndex = 1 } = {}) {
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('listStart', startIndex >= 0 ? startIndex : 1, 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('listStart');
49
- }
50
- return null;
51
- }
52
- }
@@ -1,105 +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 list/legacylistproperties/legacyliststylecommand
7
- */
8
- import { Command } from 'ckeditor5/src/core.js';
9
- import { getListTypeFromListStyleType, getSelectedListItems } from '../legacylist/legacyutils.js';
10
- /**
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
- */
17
- export class LegacyListStyleCommand extends Command {
18
- /**
19
- * The default type of the list style.
20
- */
21
- defaultType;
22
- /**
23
- * Creates an instance of the command.
24
- *
25
- * @param editor The editor instance.
26
- * @param defaultType The list type that will be used by default if the value was not specified during
27
- * the command execution.
28
- */
29
- constructor(editor, defaultType) {
30
- super(editor);
31
- this.defaultType = defaultType;
32
- }
33
- /**
34
- * @inheritDoc
35
- */
36
- refresh() {
37
- this.value = this._getValue();
38
- this.isEnabled = this._checkEnabled();
39
- }
40
- /**
41
- * Executes the command.
42
- *
43
- * @fires execute
44
- * @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
45
- * style will be applied.
46
- */
47
- execute(options = {}) {
48
- this._tryToConvertItemsToList(options);
49
- const model = this.editor.model;
50
- const listItems = getSelectedListItems(model);
51
- if (!listItems.length) {
52
- return;
53
- }
54
- model.change(writer => {
55
- for (const item of listItems) {
56
- writer.setAttribute('listStyle', options.type || this.defaultType, item);
57
- }
58
- });
59
- }
60
- /**
61
- * Checks the command's {@link #value}.
62
- *
63
- * @returns The current value.
64
- */
65
- _getValue() {
66
- const listItem = this.editor.model.document.selection.getFirstPosition().parent;
67
- if (listItem && listItem.is('element', 'listItem')) {
68
- return listItem.getAttribute('listStyle');
69
- }
70
- return null;
71
- }
72
- /**
73
- * Checks whether the command can be enabled in the current context.
74
- *
75
- * @returns Whether the command should be enabled.
76
- */
77
- _checkEnabled() {
78
- const editor = this.editor;
79
- const numberedList = editor.commands.get('numberedList');
80
- const bulletedList = editor.commands.get('bulletedList');
81
- return numberedList.isEnabled || bulletedList.isEnabled;
82
- }
83
- /**
84
- * Checks if the provided list style is valid. Also changes the selection to a list if it's not set yet.
85
- *
86
- * @param options Additional options.
87
- * @param options.type The type of the list style. If `null` is specified, the function does nothing.
88
- */
89
- _tryToConvertItemsToList(options) {
90
- if (!options.type) {
91
- return;
92
- }
93
- const listType = getListTypeFromListStyleType(options.type);
94
- /* istanbul ignore next -- @preserve */
95
- if (!listType) {
96
- return;
97
- }
98
- const editor = this.editor;
99
- const commandName = `${listType}List`;
100
- const command = editor.commands.get(commandName);
101
- if (!command.value) {
102
- editor.execute(commandName);
103
- }
104
- }
105
- }
@@ -1,37 +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 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 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
- /**
32
- * @inheritDoc
33
- */
34
- static get isOfficialPlugin() {
35
- return true;
36
- }
37
- }
@@ -1,82 +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 list/legacytodolist/legacychecktodolistcommand
7
- */
8
- import { Command } from 'ckeditor5/src/core.js';
9
- const attributeKey = 'todoListChecked';
10
- /**
11
- * The check to-do command.
12
- *
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
- */
16
- export class LegacyCheckTodoListCommand extends Command {
17
- /**
18
- * A list of to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
19
- *
20
- * @internal
21
- */
22
- _selectedElements;
23
- /**
24
- * @inheritDoc
25
- */
26
- constructor(editor) {
27
- super(editor);
28
- this._selectedElements = [];
29
- // Refresh command before executing to be sure all values are up to date.
30
- // It is needed when selection has changed before command execution, in the same change block.
31
- this.on('execute', () => {
32
- this.refresh();
33
- }, { priority: 'highest' });
34
- }
35
- /**
36
- * Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
37
- */
38
- refresh() {
39
- this._selectedElements = this._getSelectedItems();
40
- this.value = this._selectedElements.every(element => !!element.getAttribute(attributeKey));
41
- this.isEnabled = !!this._selectedElements.length;
42
- }
43
- /**
44
- * Gets all to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
45
- */
46
- _getSelectedItems() {
47
- const model = this.editor.model;
48
- const schema = model.schema;
49
- const selectionRange = model.document.selection.getFirstRange();
50
- const startElement = selectionRange.start.parent;
51
- const elements = [];
52
- if (schema.checkAttribute(startElement, attributeKey)) {
53
- elements.push(startElement);
54
- }
55
- for (const item of selectionRange.getItems()) {
56
- if (schema.checkAttribute(item, attributeKey) && !elements.includes(item)) {
57
- elements.push(item);
58
- }
59
- }
60
- return elements;
61
- }
62
- /**
63
- * Executes the command.
64
- *
65
- * @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
66
- * the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
67
- * value to decide what it should do.
68
- */
69
- execute(options = {}) {
70
- this.editor.model.change(writer => {
71
- for (const element of this._selectedElements) {
72
- const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
73
- if (value) {
74
- writer.setAttribute(attributeKey, true, element);
75
- }
76
- else {
77
- writer.removeAttribute(attributeKey, element);
78
- }
79
- }
80
- });
81
- }
82
- }
@@ -1,268 +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
- import { createElement } from 'ckeditor5/src/utils.js';
6
- import { generateLiInUl, injectViewList, positionAfterUiElements, findNestedList } from '../legacylist/legacyutils.js';
7
- /**
8
- * A model-to-view converter for the `listItem` model element insertion.
9
- *
10
- * It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~ViewUIElement checkbox element}
11
- * at the beginning of each list item. It also merges the list with surrounding lists (if available).
12
- *
13
- * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
14
- *
15
- * @internal
16
- * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
17
- * @param model Model instance.
18
- * @param onCheckboxChecked Callback function.
19
- * @returns Returns a conversion callback.
20
- */
21
- export function modelViewInsertion(model, onCheckboxChecked) {
22
- return (evt, data, conversionApi) => {
23
- const consumable = conversionApi.consumable;
24
- if (!consumable.test(data.item, 'insert') ||
25
- !consumable.test(data.item, 'attribute:listType') ||
26
- !consumable.test(data.item, 'attribute:listIndent')) {
27
- return;
28
- }
29
- if (data.item.getAttribute('listType') != 'todo') {
30
- return;
31
- }
32
- const modelItem = data.item;
33
- consumable.consume(modelItem, 'insert');
34
- consumable.consume(modelItem, 'attribute:listType');
35
- consumable.consume(modelItem, 'attribute:listIndent');
36
- consumable.consume(modelItem, 'attribute:todoListChecked');
37
- const viewWriter = conversionApi.writer;
38
- const viewItem = generateLiInUl(modelItem, conversionApi);
39
- const isChecked = !!modelItem.getAttribute('todoListChecked');
40
- const checkmarkElement = createCheckmarkElement(modelItem, viewWriter, isChecked, onCheckboxChecked);
41
- const span = viewWriter.createContainerElement('span', {
42
- class: 'todo-list__label__description'
43
- });
44
- viewWriter.addClass('todo-list', viewItem.parent);
45
- viewWriter.insert(viewWriter.createPositionAt(viewItem, 0), checkmarkElement);
46
- viewWriter.insert(viewWriter.createPositionAfter(checkmarkElement), span);
47
- injectViewList(modelItem, viewItem, conversionApi, model);
48
- };
49
- }
50
- /**
51
- * A model-to-view converter for the `listItem` model element insertion.
52
- *
53
- * It is used by {@link module:engine/controller/datacontroller~DataController}.
54
- *
55
- * @internal
56
- * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
57
- * @param model Model instance.
58
- * @returns Returns a conversion callback.
59
- */
60
- export function dataModelViewInsertion(model) {
61
- return (evt, data, conversionApi) => {
62
- const consumable = conversionApi.consumable;
63
- if (!consumable.test(data.item, 'insert') ||
64
- !consumable.test(data.item, 'attribute:listType') ||
65
- !consumable.test(data.item, 'attribute:listIndent')) {
66
- return;
67
- }
68
- if (data.item.getAttribute('listType') != 'todo') {
69
- return;
70
- }
71
- const modelItem = data.item;
72
- consumable.consume(modelItem, 'insert');
73
- consumable.consume(modelItem, 'attribute:listType');
74
- consumable.consume(modelItem, 'attribute:listIndent');
75
- consumable.consume(modelItem, 'attribute:todoListChecked');
76
- const viewWriter = conversionApi.writer;
77
- const viewItem = generateLiInUl(modelItem, conversionApi);
78
- viewWriter.addClass('todo-list', viewItem.parent);
79
- const label = viewWriter.createContainerElement('label', {
80
- class: 'todo-list__label'
81
- });
82
- const checkbox = viewWriter.createEmptyElement('input', {
83
- type: 'checkbox',
84
- disabled: 'disabled'
85
- });
86
- const span = viewWriter.createContainerElement('span', {
87
- class: 'todo-list__label__description'
88
- });
89
- if (modelItem.getAttribute('todoListChecked')) {
90
- viewWriter.setAttribute('checked', 'checked', checkbox);
91
- }
92
- viewWriter.insert(viewWriter.createPositionAt(viewItem, 0), label);
93
- viewWriter.insert(viewWriter.createPositionAt(label, 0), checkbox);
94
- viewWriter.insert(viewWriter.createPositionAfter(checkbox), span);
95
- injectViewList(modelItem, viewItem, conversionApi, model);
96
- };
97
- }
98
- /**
99
- * A view-to-model converter for the checkbox element inside a view list item.
100
- *
101
- * It changes the `listType` of the model `listItem` to a `todo` value.
102
- * When a view checkbox element is marked as checked, an additional `todoListChecked="true"` attribute is added to the model item.
103
- *
104
- * It is used by {@link module:engine/controller/datacontroller~DataController}.
105
- *
106
- * @internal
107
- * @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
108
- */
109
- export const dataViewModelCheckmarkInsertion = (evt, data, conversionApi) => {
110
- const modelCursor = data.modelCursor;
111
- const modelItem = modelCursor.parent;
112
- const viewItem = data.viewItem;
113
- if (viewItem.getAttribute('type') != 'checkbox' || modelItem.name != 'listItem' || !modelCursor.isAtStart) {
114
- return;
115
- }
116
- if (!conversionApi.consumable.consume(viewItem, { name: true })) {
117
- return;
118
- }
119
- const writer = conversionApi.writer;
120
- writer.setAttribute('listType', 'todo', modelItem);
121
- if (data.viewItem.hasAttribute('checked')) {
122
- writer.setAttribute('todoListChecked', true, modelItem);
123
- }
124
- data.modelRange = writer.createRange(modelCursor);
125
- };
126
- /**
127
- * A model-to-view converter for the `listType` attribute change on the `listItem` model element.
128
- *
129
- * This change means that the `<li>` element parent changes to `<ul class="todo-list">` and a
130
- * {@link module:engine/view/uielement~ViewUIElement checkbox UI element} is added at the beginning
131
- * of the list item element (or vice versa).
132
- *
133
- * This converter is preceded by {@link module:list/legacylist/legacyconverters~modelViewChangeType} and followed by
134
- * {@link module:list/legacylist/legacyconverters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists
135
- * of the same type.
136
- *
137
- * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
138
- *
139
- * @internal
140
- * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
141
- * @param onCheckedChange Callback fired after clicking the checkbox UI element.
142
- * @param view Editing view controller.
143
- * @returns Returns a conversion callback.
144
- */
145
- export function modelViewChangeType(onCheckedChange, view) {
146
- return (evt, data, conversionApi) => {
147
- if (!conversionApi.consumable.consume(data.item, evt.name)) {
148
- return;
149
- }
150
- const viewItem = conversionApi.mapper.toViewElement(data.item);
151
- const viewWriter = conversionApi.writer;
152
- const labelElement = findLabel(viewItem, view);
153
- if (data.attributeNewValue == 'todo') {
154
- const isChecked = !!data.item.getAttribute('todoListChecked');
155
- const checkmarkElement = createCheckmarkElement(data.item, viewWriter, isChecked, onCheckedChange);
156
- const span = viewWriter.createContainerElement('span', {
157
- class: 'todo-list__label__description'
158
- });
159
- const itemRange = viewWriter.createRangeIn(viewItem);
160
- const nestedList = findNestedList(viewItem);
161
- const descriptionStart = positionAfterUiElements(itemRange.start);
162
- const descriptionEnd = nestedList ? viewWriter.createPositionBefore(nestedList) : itemRange.end;
163
- const descriptionRange = viewWriter.createRange(descriptionStart, descriptionEnd);
164
- viewWriter.addClass('todo-list', viewItem.parent);
165
- viewWriter.move(descriptionRange, viewWriter.createPositionAt(span, 0));
166
- viewWriter.insert(viewWriter.createPositionAt(viewItem, 0), checkmarkElement);
167
- viewWriter.insert(viewWriter.createPositionAfter(checkmarkElement), span);
168
- }
169
- else if (data.attributeOldValue == 'todo') {
170
- const descriptionSpan = findDescription(viewItem, view);
171
- viewWriter.removeClass('todo-list', viewItem.parent);
172
- viewWriter.remove(labelElement);
173
- viewWriter.move(viewWriter.createRangeIn(descriptionSpan), viewWriter.createPositionBefore(descriptionSpan));
174
- viewWriter.remove(descriptionSpan);
175
- }
176
- };
177
- }
178
- /**
179
- * A model-to-view converter for the `todoListChecked` attribute change on the `listItem` model element.
180
- *
181
- * It marks the {@link module:engine/view/uielement~ViewUIElement checkbox UI element} as checked.
182
- *
183
- * It is used by {@link module:engine/controller/editingcontroller~EditingController}.
184
- *
185
- * @internal
186
- * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
187
- * @param onCheckedChange Callback fired after clicking the checkbox UI element.
188
- * @returns Returns a conversion callback.
189
- */
190
- export function modelViewChangeChecked(onCheckedChange) {
191
- return (evt, data, conversionApi) => {
192
- // Do not convert `todoListChecked` attribute when to-do list item has changed to other list item.
193
- // This attribute will be removed by the model post fixer.
194
- if (data.item.getAttribute('listType') != 'todo') {
195
- return;
196
- }
197
- if (!conversionApi.consumable.consume(data.item, 'attribute:todoListChecked')) {
198
- return;
199
- }
200
- const { mapper, writer: viewWriter } = conversionApi;
201
- const isChecked = !!data.item.getAttribute('todoListChecked');
202
- const viewItem = mapper.toViewElement(data.item);
203
- // Because of m -> v position mapper we can be sure checkbox is always at the beginning.
204
- const oldCheckmarkElement = viewItem.getChild(0);
205
- const newCheckmarkElement = createCheckmarkElement(data.item, viewWriter, isChecked, onCheckedChange);
206
- viewWriter.insert(viewWriter.createPositionAfter(oldCheckmarkElement), newCheckmarkElement);
207
- viewWriter.remove(oldCheckmarkElement);
208
- };
209
- }
210
- /**
211
- * A model-to-view position at zero offset mapper.
212
- *
213
- * This helper ensures that position inside todo-list in the view is mapped after the checkbox.
214
- *
215
- * It only handles the position at the beginning of a list item as other positions are properly mapped be the default mapper.
216
- *
217
- * @internal
218
- */
219
- export function mapModelToViewPosition(view) {
220
- return (evt, data) => {
221
- const modelPosition = data.modelPosition;
222
- const parent = modelPosition.parent;
223
- if (!parent.is('element', 'listItem') || parent.getAttribute('listType') != 'todo') {
224
- return;
225
- }
226
- const viewLi = data.mapper.toViewElement(parent);
227
- const descSpan = findDescription(viewLi, view);
228
- if (descSpan) {
229
- data.viewPosition = data.mapper.findPositionIn(descSpan, modelPosition.offset);
230
- }
231
- };
232
- }
233
- /**
234
- * Creates a checkbox UI element.
235
- */
236
- function createCheckmarkElement(modelItem, viewWriter, isChecked, onChange) {
237
- const uiElement = viewWriter.createUIElement('label', {
238
- class: 'todo-list__label',
239
- contenteditable: false
240
- }, function (domDocument) {
241
- const checkbox = createElement(document, 'input', { type: 'checkbox', tabindex: '-1' });
242
- if (isChecked) {
243
- checkbox.setAttribute('checked', 'checked');
244
- }
245
- checkbox.addEventListener('change', () => onChange(modelItem));
246
- const domElement = this.toDomElement(domDocument);
247
- domElement.appendChild(checkbox);
248
- return domElement;
249
- });
250
- return uiElement;
251
- }
252
- // Helper method to find label element inside li.
253
- function findLabel(viewItem, view) {
254
- const range = view.createRangeIn(viewItem);
255
- for (const value of range) {
256
- if (value.item.is('uiElement', 'label')) {
257
- return value.item;
258
- }
259
- }
260
- }
261
- function findDescription(viewItem, view) {
262
- const range = view.createRangeIn(viewItem);
263
- for (const value of range) {
264
- if (value.item.is('containerElement', 'span') && value.item.hasClass('todo-list__label__description')) {
265
- return value.item;
266
- }
267
- }
268
- }