UNPKG

1.7 kBJavaScriptView Raw
1/**
2 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5import { Plugin } from 'ckeditor5/src/core';
6import { getListTypeFromListStyleType, getSelectedListItems, getSiblingNodes } from './utils';
7/**
8 * A set of helpers related to document lists.
9 */
10export default class ListUtils extends Plugin {
11 /**
12 * @inheritDoc
13 */
14 static get pluginName() {
15 return 'ListUtils';
16 }
17 /**
18 * Checks whether the given list-style-type is supported by numbered or bulleted list.
19 */
20 getListTypeFromListStyleType(listStyleType) {
21 return getListTypeFromListStyleType(listStyleType);
22 }
23 /**
24 * Returns an array with all `listItem` elements in the model selection.
25 *
26 * It returns all the items even if only a part of the list is selected, including items that belong to nested lists.
27 * If no list is selected, it returns an empty array.
28 * The order of the elements is not specified.
29 */
30 getSelectedListItems(model) {
31 return getSelectedListItems(model);
32 }
33 /**
34 * Returns an array with all `listItem` elements that represent the same list.
35 *
36 * It means that values of `listIndent`, `listType`, `listStyle`, `listReversed` and `listStart` for all items are equal.
37 *
38 * Additionally, if the `position` is inside a list item, that list item will be returned as well.
39 *
40 * @param position Starting position.
41 * @param direction Walking direction.
42 */
43 getSiblingNodes(position, direction) {
44 return getSiblingNodes(position, direction);
45 }
46}