UNPKG

3 kBTypeScriptView 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 */
5/**
6 * @module list/documentlist/utils/view
7 */
8import type { DowncastWriter, ViewAttributeElement, ViewDocumentFragment, ViewElement, ViewNode } from 'ckeditor5/src/engine';
9/**
10 * Checks if view element is a list type (ul or ol).
11 *
12 * @internal
13 */
14export declare function isListView(viewElement: ViewNode | ViewDocumentFragment): viewElement is ViewElement & {
15 name: 'ul' | 'ol';
16};
17/**
18 * Checks if view element is a list item (li).
19 *
20 * @internal
21 */
22export declare function isListItemView(viewElement: ViewNode | ViewDocumentFragment): viewElement is ViewElement & {
23 name: 'li';
24};
25/**
26 * Calculates the indent value for a list item. Handles HTML compliant and non-compliant lists.
27 *
28 * Also, fixes non HTML compliant lists indents:
29 *
30 * ```
31 * before: fixed list:
32 * OL OL
33 * |-> LI (parent LIs: 0) |-> LI (indent: 0)
34 * |-> OL |-> OL
35 * |-> OL |
36 * | |-> OL |
37 * | |-> OL |
38 * | |-> LI (parent LIs: 1) |-> LI (indent: 1)
39 * |-> LI (parent LIs: 1) |-> LI (indent: 1)
40 *
41 * before: fixed list:
42 * OL OL
43 * |-> OL |
44 * |-> OL |
45 * |-> OL |
46 * |-> LI (parent LIs: 0) |-> LI (indent: 0)
47 *
48 * before: fixed list:
49 * OL OL
50 * |-> LI (parent LIs: 0) |-> LI (indent: 0)
51 * |-> OL |-> OL
52 * |-> LI (parent LIs: 0) |-> LI (indent: 1)
53 * ```
54 *
55 * @internal
56 */
57export declare function getIndent(listItem: ViewElement): number;
58/**
59 * Creates a list attribute element (ol or ul).
60 *
61 * @internal
62 */
63export declare function createListElement(writer: DowncastWriter, indent: number, type: 'bulleted' | 'numbered', id?: string): ViewAttributeElement;
64/**
65 * Creates a list item attribute element (li).
66 *
67 * @internal
68 */
69export declare function createListItemElement(writer: DowncastWriter, indent: number, id: string): ViewAttributeElement;
70/**
71 * Returns a view element name for the given list type.
72 *
73 * @internal
74 */
75export declare function getViewElementNameForListType(type?: 'bulleted' | 'numbered'): 'ol' | 'ul';
76/**
77 * Returns a view element ID for the given list type and indent.
78 *
79 * @internal
80 */
81export declare function getViewElementIdForListType(type?: 'bulleted' | 'numbered', indent?: number): string;