@ckeditor/ckeditor5-list 47.6.1-alpha.1 → 48.0.0-alpha.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 (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,357 +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/legacylist/legacyutils
7
- */
8
- import { ModelTreeWalker, getViewFillerOffset } from 'ckeditor5/src/engine.js';
9
- /**
10
- * Creates a list item {@link module:engine/view/containerelement~ViewContainerElement}.
11
- *
12
- * @internal
13
- * @param writer The writer instance.
14
- */
15
- export function createViewListItemElement(writer) {
16
- const viewItem = writer.createContainerElement('li');
17
- viewItem.getFillerOffset = getListItemFillerOffset;
18
- return viewItem;
19
- }
20
- /**
21
- * Helper function that creates a `<ul><li></li></ul>` or (`<ol>`) structure out of the given `modelItem` model `listItem` element.
22
- * Then, it binds the created view list item (`<li>`) with the model `listItem` element.
23
- * The function then returns the created view list item (`<li>`).
24
- *
25
- * @internal
26
- * @param modelItem Model list item.
27
- * @param conversionApi Conversion interface.
28
- * @returns View list element.
29
- */
30
- export function generateLiInUl(modelItem, conversionApi) {
31
- const mapper = conversionApi.mapper;
32
- const viewWriter = conversionApi.writer;
33
- const listType = modelItem.getAttribute('listType') == 'numbered' ? 'ol' : 'ul';
34
- const viewItem = createViewListItemElement(viewWriter);
35
- const viewList = viewWriter.createContainerElement(listType, null);
36
- viewWriter.insert(viewWriter.createPositionAt(viewList, 0), viewItem);
37
- mapper.bindElements(modelItem, viewItem);
38
- return viewItem;
39
- }
40
- /**
41
- * Helper function that inserts a view list at a correct place and merges it with its siblings.
42
- * It takes a model list item element (`modelItem`) and a corresponding view list item element (`injectedItem`). The view list item
43
- * should be in a view list element (`<ul>` or `<ol>`) and should be its only child.
44
- * See comments below to better understand the algorithm.
45
- *
46
- * @internal
47
- * @param modelItem Model list item.
48
- * @param injectedItem
49
- * @param conversionApi Conversion interface.
50
- * @param model The model instance.
51
- */
52
- export function injectViewList(modelItem, injectedItem, conversionApi, model) {
53
- const injectedList = injectedItem.parent;
54
- const mapper = conversionApi.mapper;
55
- const viewWriter = conversionApi.writer;
56
- // The position where the view list will be inserted.
57
- let insertPosition = mapper.toViewPosition(model.createPositionBefore(modelItem));
58
- // 1. Find the previous list item that has the same or smaller indent. Basically we are looking for the first model item
59
- // that is a "parent" or "sibling" of the injected model item.
60
- // If there is no such list item, it means that the injected list item is the first item in "its list".
61
- const refItem = getSiblingListItem(modelItem.previousSibling, {
62
- sameIndent: true,
63
- smallerIndent: true,
64
- listIndent: modelItem.getAttribute('listIndent')
65
- });
66
- const prevItem = modelItem.previousSibling;
67
- if (refItem && refItem.getAttribute('listIndent') == modelItem.getAttribute('listIndent')) {
68
- // There is a list item with the same indent - we found the same-level sibling.
69
- // Break the list after it. The inserted view item will be added in the broken space.
70
- const viewItem = mapper.toViewElement(refItem);
71
- insertPosition = viewWriter.breakContainer(viewWriter.createPositionAfter(viewItem));
72
- }
73
- else {
74
- // There is no list item with the same indent. Check the previous model item.
75
- if (prevItem && prevItem.name == 'listItem') {
76
- // If it is a list item, it has to have a lower indent.
77
- // It means that the inserted item should be added to it as its nested item.
78
- insertPosition = mapper.toViewPosition(model.createPositionAt(prevItem, 'end'));
79
- // There could be some not mapped elements (eg. span in to-do list) but we need to insert
80
- // a nested list directly inside the li element.
81
- const mappedViewAncestor = mapper.findMappedViewAncestor(insertPosition);
82
- const nestedList = findNestedList(mappedViewAncestor);
83
- // If there already is some nested list, then use it's position.
84
- if (nestedList) {
85
- insertPosition = viewWriter.createPositionBefore(nestedList);
86
- }
87
- else {
88
- // Else just put new list on the end of list item content.
89
- insertPosition = viewWriter.createPositionAt(mappedViewAncestor, 'end');
90
- }
91
- }
92
- else {
93
- // The previous item is not a list item (or does not exist at all).
94
- // Just map the position and insert the view item at the mapped position.
95
- insertPosition = mapper.toViewPosition(model.createPositionBefore(modelItem));
96
- }
97
- }
98
- insertPosition = positionAfterUiElements(insertPosition);
99
- // Insert the view item.
100
- viewWriter.insert(insertPosition, injectedList);
101
- // 2. Handle possible children of the injected model item.
102
- if (prevItem && prevItem.name == 'listItem') {
103
- const prevView = mapper.toViewElement(prevItem);
104
- const walkerBoundaries = viewWriter.createRange(viewWriter.createPositionAt(prevView, 0), insertPosition);
105
- const walker = walkerBoundaries.getWalker({ ignoreElementEnd: true });
106
- for (const value of walker) {
107
- if (value.item.is('element', 'li')) {
108
- const breakPosition = viewWriter.breakContainer(viewWriter.createPositionBefore(value.item));
109
- const viewList = value.item.parent;
110
- const targetPosition = viewWriter.createPositionAt(injectedItem, 'end');
111
- mergeViewLists(viewWriter, targetPosition.nodeBefore, targetPosition.nodeAfter);
112
- viewWriter.move(viewWriter.createRangeOn(viewList), targetPosition);
113
- // This is bad, but those lists will be removed soon anyway.
114
- walker._position = breakPosition;
115
- }
116
- }
117
- }
118
- else {
119
- const nextViewList = injectedList.nextSibling;
120
- if (nextViewList && (nextViewList.is('element', 'ul') || nextViewList.is('element', 'ol'))) {
121
- let lastSubChild = null;
122
- for (const child of nextViewList.getChildren()) {
123
- const modelChild = mapper.toModelElement(child);
124
- if (modelChild &&
125
- modelChild.getAttribute('listIndent') > modelItem.getAttribute('listIndent')) {
126
- lastSubChild = child;
127
- }
128
- else {
129
- break;
130
- }
131
- }
132
- if (lastSubChild) {
133
- viewWriter.breakContainer(viewWriter.createPositionAfter(lastSubChild));
134
- viewWriter.move(viewWriter.createRangeOn(lastSubChild.parent), viewWriter.createPositionAt(injectedItem, 'end'));
135
- }
136
- }
137
- }
138
- // Merge the inserted view list with its possible neighbor lists.
139
- mergeViewLists(viewWriter, injectedList, injectedList.nextSibling);
140
- mergeViewLists(viewWriter, injectedList.previousSibling, injectedList);
141
- }
142
- export function mergeViewLists(viewWriter, firstList, secondList) {
143
- // Check if two lists are going to be merged.
144
- if (!firstList || !secondList || (firstList.name != 'ul' && firstList.name != 'ol')) {
145
- return null;
146
- }
147
- // Both parameters are list elements, so compare types now.
148
- if (firstList.name != secondList.name || firstList.getAttribute('class') !== secondList.getAttribute('class')) {
149
- return null;
150
- }
151
- return viewWriter.mergeContainers(viewWriter.createPositionAfter(firstList));
152
- }
153
- /**
154
- * Helper function that for a given `view.Position`, returns a `view.Position` that is after all `view.UIElement`s that
155
- * are after the given position.
156
- *
157
- * For example:
158
- * `<container:p>foo^<ui:span></ui:span><ui:span></ui:span>bar</container:p>`
159
- * For position ^, the position before "bar" will be returned.
160
- *
161
- * @internal
162
- */
163
- export function positionAfterUiElements(viewPosition) {
164
- return viewPosition.getLastMatchingPosition(value => value.item.is('uiElement'));
165
- }
166
- /**
167
- * Helper function that searches for a previous list item sibling of a given model item that meets the given criteria
168
- * passed by the options object.
169
- *
170
- * @internal
171
- * @param options Search criteria.
172
- * @param options.sameIndent Whether the sought sibling should have the same indentation.
173
- * @param options.smallerIndent Whether the sought sibling should have a smaller indentation.
174
- * @param options.listIndent The reference indentation.
175
- * @param options.direction Walking direction.
176
- */
177
- export function getSiblingListItem(modelItem, options) {
178
- const sameIndent = !!options.sameIndent;
179
- const smallerIndent = !!options.smallerIndent;
180
- const indent = options.listIndent;
181
- let item = modelItem;
182
- while (item && item.name == 'listItem') {
183
- const itemIndent = item.getAttribute('listIndent');
184
- if ((sameIndent && indent == itemIndent) || (smallerIndent && indent > itemIndent)) {
185
- return item;
186
- }
187
- if (options.direction === 'forward') {
188
- item = item.nextSibling;
189
- }
190
- else {
191
- item = item.previousSibling;
192
- }
193
- }
194
- return null;
195
- }
196
- /**
197
- * Returns a first list view element that is direct child of the given view element.
198
- *
199
- * @internal
200
- */
201
- export function findNestedList(viewElement) {
202
- for (const node of viewElement.getChildren()) {
203
- if (node.name == 'ul' || node.name == 'ol') {
204
- return node;
205
- }
206
- }
207
- return null;
208
- }
209
- /**
210
- * Returns an array with all `listItem` elements that represent the same list.
211
- *
212
- * It means that values of `listIndent`, `listType`, `listStyle`, `listReversed` and `listStart` for all items are equal.
213
- *
214
- * Additionally, if the `position` is inside a list item, that list item will be returned as well.
215
- *
216
- * @internal
217
- * @param position Starting position.
218
- * @param direction Walking direction.
219
- */
220
- export function getSiblingNodes(position, direction) {
221
- const items = [];
222
- const listItem = position.parent;
223
- const walkerOptions = {
224
- ignoreElementEnd: false,
225
- startPosition: position,
226
- shallow: true,
227
- direction
228
- };
229
- const limitIndent = listItem.getAttribute('listIndent');
230
- const nodes = [...new ModelTreeWalker(walkerOptions)]
231
- .filter(value => value.item.is('element'))
232
- .map(value => value.item);
233
- for (const element of nodes) {
234
- // If found something else than `listItem`, we're out of the list scope.
235
- if (!element.is('element', 'listItem')) {
236
- break;
237
- }
238
- // If current parsed item has lower indent that element that the element that was a starting point,
239
- // it means we left a nested list. Abort searching items.
240
- //
241
- // ■ List item 1. [listIndent=0]
242
- // ○ List item 2.[] [listIndent=1], limitIndent = 1,
243
- // ○ List item 3. [listIndent=1]
244
- // ■ List item 4. [listIndent=0]
245
- //
246
- // Abort searching when leave nested list.
247
- if (element.getAttribute('listIndent') < limitIndent) {
248
- break;
249
- }
250
- // ■ List item 1.[] [listIndent=0] limitIndent = 0,
251
- // ○ List item 2. [listIndent=1]
252
- // ○ List item 3. [listIndent=1]
253
- // ■ List item 4. [listIndent=0]
254
- //
255
- // Ignore nested lists.
256
- if (element.getAttribute('listIndent') > limitIndent) {
257
- continue;
258
- }
259
- // ■ List item 1.[] [listType=bulleted]
260
- // 1. List item 2. [listType=numbered]
261
- // 2.List item 3. [listType=numbered]
262
- //
263
- // Abort searching when found a different kind of a list.
264
- if (element.getAttribute('listType') !== listItem.getAttribute('listType')) {
265
- break;
266
- }
267
- // ■ List item 1.[] [listType=bulleted]
268
- // ■ List item 2. [listType=bulleted]
269
- // ○ List item 3. [listType=bulleted]
270
- // ○ List item 4. [listType=bulleted]
271
- //
272
- // Abort searching when found a different list style,
273
- if (element.getAttribute('listStyle') !== listItem.getAttribute('listStyle')) {
274
- break;
275
- }
276
- // ... different direction
277
- if (element.getAttribute('listReversed') !== listItem.getAttribute('listReversed')) {
278
- break;
279
- }
280
- // ... and different start index
281
- if (element.getAttribute('listStart') !== listItem.getAttribute('listStart')) {
282
- break;
283
- }
284
- if (direction === 'backward') {
285
- items.unshift(element);
286
- }
287
- else {
288
- items.push(element);
289
- }
290
- }
291
- return items;
292
- }
293
- /**
294
- * Returns an array with all `listItem` elements in the model selection.
295
- *
296
- * It returns all the items even if only a part of the list is selected, including items that belong to nested lists.
297
- * If no list is selected, it returns an empty array.
298
- * The order of the elements is not specified.
299
- *
300
- * @internal
301
- */
302
- export function getSelectedListItems(model) {
303
- const document = model.document;
304
- // For all selected blocks find all list items that are being selected
305
- // and update the `listStyle` attribute in those lists.
306
- let listItems = [...document.selection.getSelectedBlocks()]
307
- .filter(element => element.is('element', 'listItem'))
308
- .map(element => {
309
- const position = model.change(writer => writer.createPositionAt(element, 0));
310
- return [
311
- ...getSiblingNodes(position, 'backward'),
312
- ...getSiblingNodes(position, 'forward')
313
- ];
314
- })
315
- .flat();
316
- // Since `getSelectedBlocks()` can return items that belong to the same list, and
317
- // `getSiblingNodes()` returns the entire list, we need to remove duplicated items.
318
- listItems = [...new Set(listItems)];
319
- return listItems;
320
- }
321
- const BULLETED_LIST_STYLE_TYPES = ['disc', 'circle', 'square'];
322
- // There's a lot of them (https://www.w3.org/TR/css-counter-styles-3/#typedef-counter-style).
323
- // Let's support only those that can be selected by ListPropertiesUI.
324
- const NUMBERED_LIST_STYLE_TYPES = [
325
- 'decimal',
326
- 'decimal-leading-zero',
327
- 'lower-roman',
328
- 'upper-roman',
329
- 'lower-latin',
330
- 'upper-latin'
331
- ];
332
- /**
333
- * Checks whether the given list-style-type is supported by numbered or bulleted list.
334
- *
335
- * @internal
336
- */
337
- export function getListTypeFromListStyleType(listStyleType) {
338
- if (BULLETED_LIST_STYLE_TYPES.includes(listStyleType)) {
339
- return 'bulleted';
340
- }
341
- if (NUMBERED_LIST_STYLE_TYPES.includes(listStyleType)) {
342
- return 'numbered';
343
- }
344
- return null;
345
- }
346
- /**
347
- * Implementation of getFillerOffset for view list item element.
348
- *
349
- * @returns Block filler offset or `null` if block filler is not needed.
350
- */
351
- function getListItemFillerOffset() {
352
- const hasOnlyLists = !this.isEmpty && (this.getChild(0).name == 'ul' || this.getChild(0).name == 'ol');
353
- if (this.isEmpty || hasOnlyLists) {
354
- return 0;
355
- }
356
- return getViewFillerOffset.call(this);
357
- }
package/src/legacylist.js DELETED
@@ -1,36 +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/legacylist
7
- */
8
- import { LegacyListEditing } from './legacylist/legacylistediting.js';
9
- import { ListUI } from './list/listui.js';
10
- import { Plugin } from 'ckeditor5/src/core.js';
11
- /**
12
- * The legacy list feature.
13
- *
14
- * This is a "glue" plugin that loads the {@link module:list/legacylist/legacylistediting~LegacyListEditing legacy list editing feature}
15
- * and {@link module:list/list/listui~ListUI list UI feature}.
16
- */
17
- export class LegacyList extends Plugin {
18
- /**
19
- * @inheritDoc
20
- */
21
- static get requires() {
22
- return [LegacyListEditing, ListUI];
23
- }
24
- /**
25
- * @inheritDoc
26
- */
27
- static get pluginName() {
28
- return 'LegacyList';
29
- }
30
- /**
31
- * @inheritDoc
32
- */
33
- static get isOfficialPlugin() {
34
- return true;
35
- }
36
- }