UNPKG

4.89 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/legacylist/legacyutils
7 */
8import { type DowncastConversionApi, type DowncastWriter, type Element, type Item, type Model, type Position, type ViewContainerElement, type ViewElement, type ViewItem, type ViewPosition } from 'ckeditor5/src/engine.js';
9/**
10 * Creates a list item {@link module:engine/view/containerelement~ContainerElement}.
11 *
12 * @param writer The writer instance.
13 */
14export declare function createViewListItemElement(writer: DowncastWriter): ViewContainerElement;
15/**
16 * Helper function that creates a `<ul><li></li></ul>` or (`<ol>`) structure out of the given `modelItem` model `listItem` element.
17 * Then, it binds the created view list item (`<li>`) with the model `listItem` element.
18 * The function then returns the created view list item (`<li>`).
19 *
20 * @param modelItem Model list item.
21 * @param conversionApi Conversion interface.
22 * @returns View list element.
23 */
24export declare function generateLiInUl(modelItem: Item, conversionApi: DowncastConversionApi): ViewContainerElement;
25/**
26 * Helper function that inserts a view list at a correct place and merges it with its siblings.
27 * It takes a model list item element (`modelItem`) and a corresponding view list item element (`injectedItem`). The view list item
28 * should be in a view list element (`<ul>` or `<ol>`) and should be its only child.
29 * See comments below to better understand the algorithm.
30 *
31 * @param modelItem Model list item.
32 * @param injectedItem
33 * @param conversionApi Conversion interface.
34 * @param model The model instance.
35 */
36export declare function injectViewList(modelItem: Element, injectedItem: ViewContainerElement, conversionApi: DowncastConversionApi, model: Model): void;
37/**
38 * Helper function that takes two parameters that are expected to be view list elements, and merges them.
39 * The merge happens only if both parameters are list elements of the same type (the same element name and the same class attributes).
40 *
41 * @param viewWriter The writer instance.
42 * @param firstList The first element to compare.
43 * @param secondList The second element to compare.
44 * @returns The position after merge or `null` when there was no merge.
45 */
46export declare function mergeViewLists(viewWriter: DowncastWriter, firstList: ViewItem, secondList: ViewItem): ViewPosition | null;
47/**
48 * Helper function that for a given `view.Position`, returns a `view.Position` that is after all `view.UIElement`s that
49 * are after the given position.
50 *
51 * For example:
52 * `<container:p>foo^<ui:span></ui:span><ui:span></ui:span>bar</container:p>`
53 * For position ^, the position before "bar" will be returned.
54 *
55 */
56export declare function positionAfterUiElements(viewPosition: ViewPosition): ViewPosition;
57/**
58 * Helper function that searches for a previous list item sibling of a given model item that meets the given criteria
59 * passed by the options object.
60 *
61 * @param options Search criteria.
62 * @param options.sameIndent Whether the sought sibling should have the same indentation.
63 * @param options.smallerIndent Whether the sought sibling should have a smaller indentation.
64 * @param options.listIndent The reference indentation.
65 * @param options.direction Walking direction.
66 */
67export declare function getSiblingListItem(modelItem: Item | null, options: {
68 sameIndent?: boolean;
69 smallerIndent?: boolean;
70 listIndent?: number;
71 direction?: 'forward' | 'backward';
72}): Element | null;
73/**
74 * Returns a first list view element that is direct child of the given view element.
75 */
76export declare function findNestedList(viewElement: ViewElement): ViewElement | null;
77/**
78 * Returns an array with all `listItem` elements that represent the same list.
79 *
80 * It means that values of `listIndent`, `listType`, `listStyle`, `listReversed` and `listStart` for all items are equal.
81 *
82 * Additionally, if the `position` is inside a list item, that list item will be returned as well.
83 *
84 * @param position Starting position.
85 * @param direction Walking direction.
86 */
87export declare function getSiblingNodes(position: Position, direction: 'forward' | 'backward'): Array<Element>;
88/**
89 * Returns an array with all `listItem` elements in the model selection.
90 *
91 * It returns all the items even if only a part of the list is selected, including items that belong to nested lists.
92 * If no list is selected, it returns an empty array.
93 * The order of the elements is not specified.
94 *
95 * @internal
96 */
97export declare function getSelectedListItems(model: Model): Array<Element>;
98/**
99 * Checks whether the given list-style-type is supported by numbered or bulleted list.
100 */
101export declare function getListTypeFromListStyleType(listStyleType: string): 'bulleted' | 'numbered' | null;