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/listconfig
|
7 | */
|
8 | import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
9 | /**
|
10 | * The configuration of the {@link module:list/list~List list} feature
|
11 | * and the {@link module:list/legacylist~LegacyList legacy list} feature.
|
12 | *
|
13 | * ```ts
|
14 | * ClassicEditor
|
15 | * .create( editorElement, {
|
16 | * list: ... // The list feature configuration.
|
17 | * } )
|
18 | * .then( ... )
|
19 | * .catch( ... );
|
20 | * ```
|
21 | *
|
22 | * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
23 | *
|
24 | * @interface ListConfig
|
25 | */
|
26 | export interface ListConfig {
|
27 | /**
|
28 | * The configuration of the {@link module:list/listproperties~ListProperties} feature and the
|
29 | * {@link module:list/legacylistproperties~LegacyListProperties legacy list properties} feature.
|
30 | *
|
31 | * Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
32 | */
|
33 | properties?: ListPropertiesConfig;
|
34 | /**
|
35 | * Allows multiple blocks in single list item.
|
36 | *
|
37 | * With this option enabled you can have block widgets, for example images or even tables, within a list item.
|
38 | *
|
39 | * **Note:** This is enabled by default.
|
40 | *
|
41 | * @default true
|
42 | */
|
43 | multiBlock?: boolean;
|
44 | }
|
45 | /**
|
46 | * The configuration of the {@link module:list/listproperties~ListProperties list properties} feature and the
|
47 | * {@link module:list/legacylistproperties~LegacyListProperties legacy list properties} feature.
|
48 | *
|
49 | * This configuration controls the individual list properties. For instance, it enables or disables specific editor commands
|
50 | * operating on lists ({@link module:list/listproperties/liststylecommand~ListStyleCommand `'listStyle'`},
|
51 | * {@link module:list/listproperties/liststartcommand~ListStartCommand `'listStart'`},
|
52 | * {@link module:list/listproperties/listreversedcommand~ListReversedCommand `'listReversed'`}, or on the legacy lists
|
53 | * {@link module:list/legacylistproperties/legacyliststylecommand~LegacyListStyleCommand `'listStyle'`},
|
54 | * {@link module:list/legacylistproperties/legacyliststartcommand~LegacyListStartCommand `'listStart'`},
|
55 | * {@link module:list/legacylistproperties/legacylistreversedcommand~LegacyListReversedCommand `'listReversed'`}), the look of the UI
|
56 | * (`'numberedList'` and `'bulletedList'` dropdowns), and the editor data pipeline (allowed HTML attributes).
|
57 | *
|
58 | * ```ts
|
59 | * ClassicEditor
|
60 | * .create( editorElement, {
|
61 | * list: {
|
62 | * properties: {
|
63 | * styles: true,
|
64 | * startIndex: true,
|
65 | * reversed: true
|
66 | * }
|
67 | * }
|
68 | * } )
|
69 | * .then( ... )
|
70 | * .catch( ... );
|
71 | * ```
|
72 | */
|
73 | export interface ListPropertiesConfig {
|
74 | /**
|
75 | * When set, the list style feature will be enabled.
|
76 | * It allows changing the `list-style-type` style or the `type` HTML attribute of a list.
|
77 | *
|
78 | * **Note**: Styling using the `type` HTML attribute is only available in
|
79 | * {@link module:list/listproperties~ListProperties list properties}
|
80 | * ({@link module:list/listconfig~ListPropertiesStyleConfig learn more}).
|
81 | *
|
82 | * @default true
|
83 | */
|
84 | styles?: boolean | ListPropertiesStyleConfig | ArrayOrItem<ListPropertiesStyleListType>;
|
85 | /**
|
86 | * When set, the list start index feature will be enabled. It allows changing the `start` HTML attribute of the numbered lists. As a
|
87 | * result, it will be possible to specify the start value of the first item in an ordered list.
|
88 | *
|
89 | * **Note**: This configuration does not affect bulleted and to-do lists.
|
90 | *
|
91 | * @default false
|
92 | */
|
93 | startIndex?: boolean;
|
94 | /**
|
95 | * When set, the reversed list feature will be enabled. It allows changing the `reversed` HTML attribute of the numbered lists. As a
|
96 | * result, it will be possible to make the list order descending instead of ascending.
|
97 | *
|
98 | * **Note**: This configuration does not affect bulleted and to-do lists.
|
99 | *
|
100 | * @default false
|
101 | */
|
102 | reversed?: boolean;
|
103 | }
|
104 | export interface ListPropertiesStyleConfig {
|
105 | /**
|
106 | * Enable style feature for the given list type only.
|
107 | *
|
108 | * ```ts
|
109 | * {
|
110 | * list: {
|
111 | * properties: {
|
112 | * styles: {
|
113 | * listTypes: 'numbered'
|
114 | * }
|
115 | *
|
116 | * // ...
|
117 | * }
|
118 | * },
|
119 | *
|
120 | * // ...
|
121 | * }
|
122 | * ```
|
123 | *
|
124 | *
|
125 | * **Note**: This configuration works only with
|
126 | * {@link module:list/listproperties~ListProperties list properties}.
|
127 | *
|
128 | * @default ['bulleted','numbered']
|
129 | */
|
130 | listTypes?: ArrayOrItem<ListPropertiesStyleListType>;
|
131 | /**
|
132 | * When set `true`, the list style feature will use the `type` attribute of `<ul>` and `<ol>` elements instead of the `list-style-type`
|
133 | * style.
|
134 | *
|
135 | * ```ts
|
136 | * {
|
137 | * list: {
|
138 | * properties: {
|
139 | * styles: {
|
140 | * useAttribute: true
|
141 | * },
|
142 | *
|
143 | * // ...
|
144 | * }
|
145 | * },
|
146 | *
|
147 | * // ...
|
148 | * }
|
149 | * ```
|
150 | *
|
151 | * **Note**: Due to limitations of HTML, the "Decimal with leading zero" style is impossible to set using the `type` attribute.
|
152 | *
|
153 | * **Note**: This configuration works only with
|
154 | * {@link module:list/listproperties~ListProperties list properties}.
|
155 | *
|
156 | * @default false
|
157 | */
|
158 | useAttribute?: boolean;
|
159 | }
|
160 | export type ListPropertiesStyleListType = 'numbered' | 'bulleted';
|