UNPKG

1.85 kBTypeScriptView Raw
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/list/listutils
7 */
8import type { Element, Node } from 'ckeditor5/src/engine.js';
9import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
10import { Plugin } from 'ckeditor5/src/core.js';
11import { type ListElement } from './utils/model.js';
12import type { ListType } from './listediting.js';
13/**
14 * A set of helpers related to document lists.
15 */
16export default class ListUtils extends Plugin {
17 /**
18 * @inheritDoc
19 */
20 static get pluginName(): "ListUtils";
21 /**
22 * Expands the given list of selected blocks to include all the items of the lists they're in.
23 *
24 * @param blocks The list of selected blocks.
25 */
26 expandListBlocksToCompleteList(blocks: ArrayOrItem<Element>): Array<Element>;
27 /**
28 * Check if the given block is the first in the list item.
29 *
30 * @param listBlock The list block element.
31 */
32 isFirstBlockOfListItem(listBlock: Element): boolean;
33 /**
34 * Returns true if the given model node is a list item block.
35 *
36 * @param node A model node.
37 */
38 isListItemBlock(node: Node | null): node is ListElement;
39 /**
40 * Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
41 *
42 * @param blocks The list of selected blocks.
43 * @param options.withNested Whether should include nested list items.
44 */
45 expandListBlocksToCompleteItems(blocks: ArrayOrItem<Element>, options?: {
46 withNested?: boolean;
47 }): Array<Element>;
48 /**
49 * Returns true if listType is of type `numbered` or `customNumbered`.
50 */
51 isNumberedListType(listType: ListType): boolean;
52}