@ckeditor/ckeditor5-list 42.0.2 → 43.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -269
- package/build/list.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/dist/index.js +101 -60
- package/dist/index.js.map +1 -1
- package/dist/list/converters.d.ts +0 -8
- package/dist/listconfig.d.ts +29 -1
- package/dist/listproperties/ui/listpropertiesview.d.ts +2 -2
- package/dist/listproperties/utils/config.d.ts +39 -0
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +1 -1
- package/lang/translations/sr-latn.po +6 -6
- package/package.json +9 -9
- package/src/list/converters.d.ts +0 -8
- package/src/list/converters.js +0 -24
- package/src/list/listediting.js +1 -3
- package/src/list/utils.js +8 -1
- package/src/listconfig.d.ts +29 -1
- package/src/listproperties/listpropertiesediting.js +3 -1
- package/src/listproperties/listpropertiesui.js +26 -23
- package/src/listproperties/ui/listpropertiesview.d.ts +2 -2
- package/src/listproperties/ui/listpropertiesview.js +2 -2
- package/src/listproperties/utils/config.d.ts +35 -0
- package/src/listproperties/utils/config.js +70 -0
- package/src/todolist/todolistediting.js +3 -5
|
@@ -19,14 +19,6 @@ import type { default as ListEditing, DowncastStrategy } from './listediting.js'
|
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
export declare function listItemUpcastConverter(): GetCallback<UpcastElementEvent>;
|
|
22
|
-
/**
|
|
23
|
-
* Returns the upcast converter for the `<ul>` and `<ol>` view elements that cleans the input view of garbage.
|
|
24
|
-
* This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element. However,
|
|
25
|
-
* incorrect data can also be cleared if the view was incorrect.
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export declare function listUpcastCleanList(): GetCallback<UpcastElementEvent>;
|
|
30
22
|
/**
|
|
31
23
|
* Returns a model document change:data event listener that triggers conversion of related items if needed.
|
|
32
24
|
*
|
package/dist/listconfig.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* @module list/listconfig
|
|
11
11
|
*/
|
|
12
|
+
import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
12
13
|
/**
|
|
13
14
|
* The configuration of the {@link module:list/list~List list} feature
|
|
14
15
|
* and the {@link module:list/legacylist~LegacyList legacy list} feature.
|
|
@@ -84,7 +85,7 @@ export interface ListPropertiesConfig {
|
|
|
84
85
|
*
|
|
85
86
|
* @default true
|
|
86
87
|
*/
|
|
87
|
-
styles?: boolean | ListPropertiesStyleConfig
|
|
88
|
+
styles?: boolean | ListPropertiesStyleConfig | ArrayOrItem<ListPropertiesStyleListType>;
|
|
88
89
|
/**
|
|
89
90
|
* When set, the list start index feature will be enabled. It allows changing the `start` HTML attribute of the numbered lists. As a
|
|
90
91
|
* result, it will be possible to specify the start value of the first item in an ordered list.
|
|
@@ -105,6 +106,32 @@ export interface ListPropertiesConfig {
|
|
|
105
106
|
reversed?: boolean;
|
|
106
107
|
}
|
|
107
108
|
export interface ListPropertiesStyleConfig {
|
|
109
|
+
/**
|
|
110
|
+
* Enable style feature for the given list type only.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* {
|
|
114
|
+
* list: {
|
|
115
|
+
* properties: {
|
|
116
|
+
* styles: {
|
|
117
|
+
* listTypes: 'numbered'
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* // ...
|
|
121
|
+
* }
|
|
122
|
+
* },
|
|
123
|
+
*
|
|
124
|
+
* // ...
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
*
|
|
129
|
+
* **Note**: This configuration works only with
|
|
130
|
+
* {@link module:list/listproperties~ListProperties list properties}.
|
|
131
|
+
*
|
|
132
|
+
* @default ['bulleted','numbered']
|
|
133
|
+
*/
|
|
134
|
+
listTypes?: ArrayOrItem<ListPropertiesStyleListType>;
|
|
108
135
|
/**
|
|
109
136
|
* When set `true`, the list style feature will use the `type` attribute of `<ul>` and `<ol>` elements instead of the `list-style-type`
|
|
110
137
|
* style.
|
|
@@ -134,3 +161,4 @@ export interface ListPropertiesStyleConfig {
|
|
|
134
161
|
*/
|
|
135
162
|
useAttribute?: boolean;
|
|
136
163
|
}
|
|
164
|
+
export type ListPropertiesStyleListType = 'numbered' | 'bulleted';
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { View, ViewCollection, FocusCycler, SwitchButtonView, LabeledFieldView, CollapsibleView, type ButtonView, type InputNumberView, type FocusableView } from 'ckeditor5/src/ui.js';
|
|
13
13
|
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { NormalizedListPropertiesConfig } from '../utils/config.js';
|
|
15
15
|
import '../../../theme/listproperties.css';
|
|
16
16
|
/**
|
|
17
17
|
* The list properties view to be displayed in the list dropdown.
|
|
@@ -89,7 +89,7 @@ export default class ListPropertiesView extends View {
|
|
|
89
89
|
* @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).
|
|
90
90
|
*/
|
|
91
91
|
constructor(locale: Locale, { enabledProperties, styleButtonViews, styleGridAriaLabel }: {
|
|
92
|
-
enabledProperties:
|
|
92
|
+
enabledProperties: NormalizedListPropertiesConfig;
|
|
93
93
|
styleButtonViews: Array<ButtonView> | null;
|
|
94
94
|
styleGridAriaLabel: string;
|
|
95
95
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
import type { ListPropertiesConfig, ListPropertiesStyleListType } from '../../listconfig.js';
|
|
10
|
+
/**
|
|
11
|
+
* Normalizes {@link module:list/listconfig~ListPropertiesConfig} in the configuration of the list properties feature.
|
|
12
|
+
* The structure of normalized list properties options looks as follows:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* {
|
|
16
|
+
* styles: {
|
|
17
|
+
* listTypes: [ 'bulleted', 'numbered' ],
|
|
18
|
+
* useAttribute: false
|
|
19
|
+
* },
|
|
20
|
+
* startIndex: true,
|
|
21
|
+
* reversed: true
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param config The list properties {@link module:list/listconfig~ListPropertiesConfig config}.
|
|
26
|
+
* @returns An object with normalized list properties options.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getNormalizedConfig(config: ListPropertiesConfig): NormalizedListPropertiesConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Normalized list properties config.
|
|
31
|
+
*/
|
|
32
|
+
export type NormalizedListPropertiesConfig = {
|
|
33
|
+
styles: {
|
|
34
|
+
listTypes: Array<ListPropertiesStyleListType>;
|
|
35
|
+
useAttribute: boolean;
|
|
36
|
+
};
|
|
37
|
+
startIndex: boolean;
|
|
38
|
+
reversed: boolean;
|
|
39
|
+
};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
export default {"sr-latn":{"dictionary":{"Numbered List":"Lista sa brojevima","Bulleted List":"Nabrajane liste","To-do List":"Lista obaveza","Bulleted list styles toolbar":"Traka sa alatkama za nabrajane liste","Numbered list styles toolbar":"Traka sa altakama za liste sa brojevima","Toggle the disc list style":"Uključite / isključite stil liste diskova","Toggle the circle list style":"Uključite / isključite stil liste krugova","Toggle the square list style":"Uključite / isključite stil liste kvadrata","Toggle the decimal list style":"Uključi / isključi stil dekadne liste","Toggle the decimal with leading zero list style":"Prebaci decimalni znak sa vodećim stilom liste nula","Toggle the lower–roman list style":"Uključite / isključite stil donje rimske liste","Toggle the upper–roman list style":"Uključite / isključite stil gornje rimske liste","Toggle the lower–latin list style":"Uključite / isključite stil donje liste latinice","Toggle the upper–latin list style":"Uključite / isključite stil gornje liste latinice","Disc":"Disk","Circle":"Krug","Square":"Kvadrat","Decimal":"Decimala","Decimal with leading zero":"Decimalni broj sa nulom na početku","Lower–roman":"Donji - rimski","Upper-roman":"Gornji - rimski","Lower-latin":"Donji - latinski","Upper-latin":"Gornji - latinski","List properties":"Navedite svojstva","Start at":"Početi u","Invalid start index value.":"","Start index must be greater than 0.":"Početni indeks mora biti veći od 0.","Reversed order":"Obrnuti redosled","Keystrokes that can be used in a list":"","Increase list item indent":"","Decrease list item indent":"","Entering a to-do list":"","Leaving a to-do list":""},getPluralForm(n){return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}}}
|
|
5
|
+
export default {"sr-latn":{"dictionary":{"Numbered List":"Lista sa brojevima","Bulleted List":"Nabrajane liste","To-do List":"Lista obaveza","Bulleted list styles toolbar":"Traka sa alatkama za nabrajane liste","Numbered list styles toolbar":"Traka sa altakama za liste sa brojevima","Toggle the disc list style":"Uključite / isključite stil liste diskova","Toggle the circle list style":"Uključite / isključite stil liste krugova","Toggle the square list style":"Uključite / isključite stil liste kvadrata","Toggle the decimal list style":"Uključi / isključi stil dekadne liste","Toggle the decimal with leading zero list style":"Prebaci decimalni znak sa vodećim stilom liste nula","Toggle the lower–roman list style":"Uključite / isključite stil donje rimske liste","Toggle the upper–roman list style":"Uključite / isključite stil gornje rimske liste","Toggle the lower–latin list style":"Uključite / isključite stil donje liste latinice","Toggle the upper–latin list style":"Uključite / isključite stil gornje liste latinice","Disc":"Disk","Circle":"Krug","Square":"Kvadrat","Decimal":"Decimala","Decimal with leading zero":"Decimalni broj sa nulom na početku","Lower–roman":"Donji - rimski","Upper-roman":"Gornji - rimski","Lower-latin":"Donji - latinski","Upper-latin":"Gornji - latinski","List properties":"Navedite svojstva","Start at":"Početi u","Invalid start index value.":"Nevažeća vrednost početnog indeksa.","Start index must be greater than 0.":"Početni indeks mora biti veći od 0.","Reversed order":"Obrnuti redosled","Keystrokes that can be used in a list":"Pritisci na tastere koji se mogu koristiti na listi","Increase list item indent":"Povećaj uvlačenje stavke liste","Decrease list item indent":"Smanji uvlačenje stavke liste","Entering a to-do list":"Unošenje liste obaveza","Leaving a to-do list":"Ostavljanje liste obaveza"},getPluralForm(n){return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}}}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
( e => {
|
|
7
|
-
const { [ 'sr-latn' ]: { dictionary, getPluralForm } } = {"sr-latn":{"dictionary":{"Numbered List":"Lista sa brojevima","Bulleted List":"Nabrajane liste","To-do List":"Lista obaveza","Bulleted list styles toolbar":"Traka sa alatkama za nabrajane liste","Numbered list styles toolbar":"Traka sa altakama za liste sa brojevima","Toggle the disc list style":"Uključite / isključite stil liste diskova","Toggle the circle list style":"Uključite / isključite stil liste krugova","Toggle the square list style":"Uključite / isključite stil liste kvadrata","Toggle the decimal list style":"Uključi / isključi stil dekadne liste","Toggle the decimal with leading zero list style":"Prebaci decimalni znak sa vodećim stilom liste nula","Toggle the lower–roman list style":"Uključite / isključite stil donje rimske liste","Toggle the upper–roman list style":"Uključite / isključite stil gornje rimske liste","Toggle the lower–latin list style":"Uključite / isključite stil donje liste latinice","Toggle the upper–latin list style":"Uključite / isključite stil gornje liste latinice","Disc":"Disk","Circle":"Krug","Square":"Kvadrat","Decimal":"Decimala","Decimal with leading zero":"Decimalni broj sa nulom na početku","Lower–roman":"Donji - rimski","Upper-roman":"Gornji - rimski","Lower-latin":"Donji - latinski","Upper-latin":"Gornji - latinski","List properties":"Navedite svojstva","Start at":"Početi u","Invalid start index value.":"","Start index must be greater than 0.":"Početni indeks mora biti veći od 0.","Reversed order":"Obrnuti redosled","Keystrokes that can be used in a list":"","Increase list item indent":"","Decrease list item indent":"","Entering a to-do list":"","Leaving a to-do list":""},getPluralForm(n){return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}}};
|
|
7
|
+
const { [ 'sr-latn' ]: { dictionary, getPluralForm } } = {"sr-latn":{"dictionary":{"Numbered List":"Lista sa brojevima","Bulleted List":"Nabrajane liste","To-do List":"Lista obaveza","Bulleted list styles toolbar":"Traka sa alatkama za nabrajane liste","Numbered list styles toolbar":"Traka sa altakama za liste sa brojevima","Toggle the disc list style":"Uključite / isključite stil liste diskova","Toggle the circle list style":"Uključite / isključite stil liste krugova","Toggle the square list style":"Uključite / isključite stil liste kvadrata","Toggle the decimal list style":"Uključi / isključi stil dekadne liste","Toggle the decimal with leading zero list style":"Prebaci decimalni znak sa vodećim stilom liste nula","Toggle the lower–roman list style":"Uključite / isključite stil donje rimske liste","Toggle the upper–roman list style":"Uključite / isključite stil gornje rimske liste","Toggle the lower–latin list style":"Uključite / isključite stil donje liste latinice","Toggle the upper–latin list style":"Uključite / isključite stil gornje liste latinice","Disc":"Disk","Circle":"Krug","Square":"Kvadrat","Decimal":"Decimala","Decimal with leading zero":"Decimalni broj sa nulom na početku","Lower–roman":"Donji - rimski","Upper-roman":"Gornji - rimski","Lower-latin":"Donji - latinski","Upper-latin":"Gornji - latinski","List properties":"Navedite svojstva","Start at":"Početi u","Invalid start index value.":"Nevažeća vrednost početnog indeksa.","Start index must be greater than 0.":"Početni indeks mora biti veći od 0.","Reversed order":"Obrnuti redosled","Keystrokes that can be used in a list":"Pritisci na tastere koji se mogu koristiti na listi","Increase list item indent":"Povećaj uvlačenje stavke liste","Decrease list item indent":"Smanji uvlačenje stavke liste","Entering a to-do list":"Unošenje liste obaveza","Leaving a to-do list":"Ostavljanje liste obaveza"},getPluralForm(n){return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}}};
|
|
8
8
|
e[ 'sr-latn' ] ||= { dictionary: {}, getPluralForm: null };
|
|
9
9
|
e[ 'sr-latn' ].dictionary = Object.assign( e[ 'sr-latn' ].dictionary, dictionary );
|
|
10
10
|
e[ 'sr-latn' ].getPluralForm = getPluralForm;
|
|
@@ -119,7 +119,7 @@ msgstr "Početi u"
|
|
|
119
119
|
|
|
120
120
|
msgctxt "The error message displayed when the numbered list start index input value is not a valid number."
|
|
121
121
|
msgid "Invalid start index value."
|
|
122
|
-
msgstr ""
|
|
122
|
+
msgstr "Nevažeća vrednost početnog indeksa."
|
|
123
123
|
|
|
124
124
|
msgctxt "The error message displayed when the numbered list start index input value is invalid."
|
|
125
125
|
msgid "Start index must be greater than 0."
|
|
@@ -131,20 +131,20 @@ msgstr "Obrnuti redosled"
|
|
|
131
131
|
|
|
132
132
|
msgctxt "Accessibility help dialog header text displayed before the list of keystrokes that can be used in a list."
|
|
133
133
|
msgid "Keystrokes that can be used in a list"
|
|
134
|
-
msgstr ""
|
|
134
|
+
msgstr "Pritisci na tastere koji se mogu koristiti na listi"
|
|
135
135
|
|
|
136
136
|
msgctxt "Keystroke description for assistive technologies: keystroke for increasing list item indentation."
|
|
137
137
|
msgid "Increase list item indent"
|
|
138
|
-
msgstr ""
|
|
138
|
+
msgstr "Povećaj uvlačenje stavke liste"
|
|
139
139
|
|
|
140
140
|
msgctxt "Keystroke description for assistive technologies: keystroke for decreasing list item indentation."
|
|
141
141
|
msgid "Decrease list item indent"
|
|
142
|
-
msgstr ""
|
|
142
|
+
msgstr "Smanji uvlačenje stavke liste"
|
|
143
143
|
|
|
144
144
|
msgctxt "Assistive technologies label for entering the to-do list."
|
|
145
145
|
msgid "Entering a to-do list"
|
|
146
|
-
msgstr ""
|
|
146
|
+
msgstr "Unošenje liste obaveza"
|
|
147
147
|
|
|
148
148
|
msgctxt "Assistive technologies label for leaving the to-do list."
|
|
149
149
|
msgid "Leaving a to-do list"
|
|
150
|
-
msgstr ""
|
|
150
|
+
msgstr "Ostavljanje liste obaveza"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-list",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "43.0.0-alpha.0",
|
|
4
4
|
"description": "Ordered and unordered lists feature to CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-clipboard": "
|
|
17
|
-
"@ckeditor/ckeditor5-core": "
|
|
18
|
-
"@ckeditor/ckeditor5-engine": "
|
|
19
|
-
"@ckeditor/ckeditor5-enter": "
|
|
20
|
-
"@ckeditor/ckeditor5-typing": "
|
|
21
|
-
"@ckeditor/ckeditor5-ui": "
|
|
22
|
-
"@ckeditor/ckeditor5-utils": "
|
|
23
|
-
"ckeditor5": "
|
|
16
|
+
"@ckeditor/ckeditor5-clipboard": "43.0.0-alpha.0",
|
|
17
|
+
"@ckeditor/ckeditor5-core": "43.0.0-alpha.0",
|
|
18
|
+
"@ckeditor/ckeditor5-engine": "43.0.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-enter": "43.0.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-typing": "43.0.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-ui": "43.0.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-utils": "43.0.0-alpha.0",
|
|
23
|
+
"ckeditor5": "43.0.0-alpha.0"
|
|
24
24
|
},
|
|
25
25
|
"author": "CKSource (http://cksource.com/)",
|
|
26
26
|
"license": "GPL-2.0-or-later",
|
package/src/list/converters.d.ts
CHANGED
|
@@ -15,14 +15,6 @@ import type { default as ListEditing, DowncastStrategy } from './listediting.js'
|
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
17
|
export declare function listItemUpcastConverter(): GetCallback<UpcastElementEvent>;
|
|
18
|
-
/**
|
|
19
|
-
* Returns the upcast converter for the `<ul>` and `<ol>` view elements that cleans the input view of garbage.
|
|
20
|
-
* This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element. However,
|
|
21
|
-
* incorrect data can also be cleared if the view was incorrect.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export declare function listUpcastCleanList(): GetCallback<UpcastElementEvent>;
|
|
26
18
|
/**
|
|
27
19
|
* Returns a model document change:data event listener that triggers conversion of related items if needed.
|
|
28
20
|
*
|
package/src/list/converters.js
CHANGED
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module list/list/converters
|
|
7
|
-
*/
|
|
8
|
-
import { UpcastWriter } from 'ckeditor5/src/engine.js';
|
|
9
5
|
import { getAllListItemBlocks, getListItemBlocks, isListItemBlock, isFirstBlockOfListItem, ListItemUid } from './utils/model.js';
|
|
10
6
|
import { createListElement, createListItemElement, getIndent, isListView, isListItemView } from './utils/view.js';
|
|
11
7
|
import ListWalker, { iterateSiblingListBlocks } from './utils/listwalker.js';
|
|
@@ -61,26 +57,6 @@ export function listItemUpcastConverter() {
|
|
|
61
57
|
}
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Returns the upcast converter for the `<ul>` and `<ol>` view elements that cleans the input view of garbage.
|
|
66
|
-
* This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element. However,
|
|
67
|
-
* incorrect data can also be cleared if the view was incorrect.
|
|
68
|
-
*
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
export function listUpcastCleanList() {
|
|
72
|
-
return (evt, data, conversionApi) => {
|
|
73
|
-
if (!conversionApi.consumable.test(data.viewItem, { name: true })) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const viewWriter = new UpcastWriter(data.viewItem.document);
|
|
77
|
-
for (const child of Array.from(data.viewItem.getChildren())) {
|
|
78
|
-
if (!isListItemView(child) && !isListView(child)) {
|
|
79
|
-
viewWriter.remove(child);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
60
|
/**
|
|
85
61
|
* Returns a model document change:data event listener that triggers conversion of related items if needed.
|
|
86
62
|
*
|
package/src/list/listediting.js
CHANGED
|
@@ -14,7 +14,7 @@ import ListCommand from './listcommand.js';
|
|
|
14
14
|
import ListMergeCommand from './listmergecommand.js';
|
|
15
15
|
import ListSplitCommand from './listsplitcommand.js';
|
|
16
16
|
import ListUtils from './listutils.js';
|
|
17
|
-
import { bogusParagraphCreator, createModelToViewPositionMapper, listItemDowncastConverter, listItemDowncastRemoveConverter, listItemUpcastConverter,
|
|
17
|
+
import { bogusParagraphCreator, createModelToViewPositionMapper, listItemDowncastConverter, listItemDowncastRemoveConverter, listItemUpcastConverter, reconvertItemsOnDataChange } from './converters.js';
|
|
18
18
|
import { findAndAddListHeadToMap, fixListIndents, fixListItemIds } from './utils/postfixers.js';
|
|
19
19
|
import { getAllListItemBlocks, isFirstBlockOfListItem, isLastBlockOfListItem, isSingleListItem, getSelectedBlockObject, isListItemBlock, removeListAttributes, ListItemUid } from './utils/model.js';
|
|
20
20
|
import { getViewElementIdForListType, getViewElementNameForListType } from './utils/view.js';
|
|
@@ -331,8 +331,6 @@ export default class ListEditing extends Plugin {
|
|
|
331
331
|
})
|
|
332
332
|
.add(dispatcher => {
|
|
333
333
|
dispatcher.on('element:li', listItemUpcastConverter());
|
|
334
|
-
dispatcher.on('element:ul', listUpcastCleanList(), { priority: 'high' });
|
|
335
|
-
dispatcher.on('element:ol', listUpcastCleanList(), { priority: 'high' });
|
|
336
334
|
});
|
|
337
335
|
if (!multiBlock) {
|
|
338
336
|
editor.conversion.for('downcast')
|
package/src/list/utils.js
CHANGED
|
@@ -21,7 +21,14 @@ export function createUIComponents(editor, commandName, label, icon) {
|
|
|
21
21
|
});
|
|
22
22
|
return buttonView;
|
|
23
23
|
});
|
|
24
|
-
editor.ui.componentFactory.add(`menuBar:${commandName}`, () =>
|
|
24
|
+
editor.ui.componentFactory.add(`menuBar:${commandName}`, () => {
|
|
25
|
+
const buttonView = _createButton(MenuBarMenuListItemButtonView, editor, commandName, label, icon);
|
|
26
|
+
buttonView.set({
|
|
27
|
+
role: 'menuitemcheckbox',
|
|
28
|
+
isToggleable: true
|
|
29
|
+
});
|
|
30
|
+
return buttonView;
|
|
31
|
+
});
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Creates a button to use either in toolbar or in menu bar.
|
package/src/listconfig.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/listconfig
|
|
7
7
|
*/
|
|
8
|
+
import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
8
9
|
/**
|
|
9
10
|
* The configuration of the {@link module:list/list~List list} feature
|
|
10
11
|
* and the {@link module:list/legacylist~LegacyList legacy list} feature.
|
|
@@ -80,7 +81,7 @@ export interface ListPropertiesConfig {
|
|
|
80
81
|
*
|
|
81
82
|
* @default true
|
|
82
83
|
*/
|
|
83
|
-
styles?: boolean | ListPropertiesStyleConfig
|
|
84
|
+
styles?: boolean | ListPropertiesStyleConfig | ArrayOrItem<ListPropertiesStyleListType>;
|
|
84
85
|
/**
|
|
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
|
|
86
87
|
* result, it will be possible to specify the start value of the first item in an ordered list.
|
|
@@ -101,6 +102,32 @@ export interface ListPropertiesConfig {
|
|
|
101
102
|
reversed?: boolean;
|
|
102
103
|
}
|
|
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>;
|
|
104
131
|
/**
|
|
105
132
|
* When set `true`, the list style feature will use the `type` attribute of `<ul>` and `<ol>` elements instead of the `list-style-type`
|
|
106
133
|
* style.
|
|
@@ -130,3 +157,4 @@ export interface ListPropertiesStyleConfig {
|
|
|
130
157
|
*/
|
|
131
158
|
useAttribute?: boolean;
|
|
132
159
|
}
|
|
160
|
+
export type ListPropertiesStyleListType = 'numbered' | 'bulleted';
|
|
@@ -14,6 +14,7 @@ import { listPropertiesUpcastConverter } from './converters.js';
|
|
|
14
14
|
import { getAllSupportedStyleTypes, getListTypeFromListStyleType, getListStyleTypeFromTypeAttribute, getTypeAttributeFromListStyleType } from './utils/style.js';
|
|
15
15
|
import ListPropertiesUtils from './listpropertiesutils.js';
|
|
16
16
|
import { isNumberedListType } from '../list/utils/model.js';
|
|
17
|
+
import { getNormalizedConfig } from './utils/config.js';
|
|
17
18
|
const DEFAULT_LIST_TYPE = 'default';
|
|
18
19
|
/**
|
|
19
20
|
* The document list properties engine feature.
|
|
@@ -149,8 +150,9 @@ export default class ListPropertiesEditing extends Plugin {
|
|
|
149
150
|
*/
|
|
150
151
|
function createAttributeStrategies(enabledProperties) {
|
|
151
152
|
const strategies = [];
|
|
153
|
+
const normalizedConfig = getNormalizedConfig(enabledProperties);
|
|
152
154
|
if (enabledProperties.styles) {
|
|
153
|
-
const useAttribute =
|
|
155
|
+
const useAttribute = normalizedConfig.styles.useAttribute;
|
|
154
156
|
strategies.push({
|
|
155
157
|
attributeName: 'listStyle',
|
|
156
158
|
defaultValue: DEFAULT_LIST_TYPE,
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { icons, Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { ButtonView, SplitButtonView, createDropdown, focusChildOnDropdownOpen, MenuBarMenuView } from 'ckeditor5/src/ui.js';
|
|
10
10
|
import ListPropertiesView from './ui/listpropertiesview.js';
|
|
11
|
+
import { getNormalizedConfig } from './utils/config.js';
|
|
11
12
|
import listStyleDiscIcon from '../../theme/icons/liststyledisc.svg';
|
|
12
13
|
import listStyleCircleIcon from '../../theme/icons/liststylecircle.svg';
|
|
13
14
|
import listStyleSquareIcon from '../../theme/icons/liststylesquare.svg';
|
|
@@ -36,10 +37,12 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
36
37
|
const editor = this.editor;
|
|
37
38
|
const t = editor.locale.t;
|
|
38
39
|
const propertiesConfig = editor.config.get('list.properties');
|
|
40
|
+
const normalizedConfig = getNormalizedConfig(propertiesConfig);
|
|
41
|
+
const stylesListTypes = normalizedConfig.styles.listTypes;
|
|
39
42
|
// Note: When this plugin does not register the "bulletedList" dropdown due to properties configuration,
|
|
40
43
|
// a simple button will be still registered under the same name by ListUI as a fallback. This should happen
|
|
41
44
|
// in most editor configuration because the List plugin automatically requires ListUI.
|
|
42
|
-
if (
|
|
45
|
+
if (stylesListTypes.includes('bulleted')) {
|
|
43
46
|
const styleDefinitions = [
|
|
44
47
|
{
|
|
45
48
|
label: t('Toggle the disc list style'),
|
|
@@ -65,7 +68,7 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
65
68
|
const commandName = 'bulletedList';
|
|
66
69
|
editor.ui.componentFactory.add(commandName, getDropdownViewCreator({
|
|
67
70
|
editor,
|
|
68
|
-
|
|
71
|
+
normalizedConfig,
|
|
69
72
|
parentCommandName: commandName,
|
|
70
73
|
buttonLabel,
|
|
71
74
|
buttonIcon: icons.bulletedList,
|
|
@@ -75,7 +78,7 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
75
78
|
// Add the menu bar item for bulleted list.
|
|
76
79
|
editor.ui.componentFactory.add(`menuBar:${commandName}`, getMenuBarStylesMenuCreator({
|
|
77
80
|
editor,
|
|
78
|
-
|
|
81
|
+
normalizedConfig,
|
|
79
82
|
parentCommandName: commandName,
|
|
80
83
|
buttonLabel,
|
|
81
84
|
styleGridAriaLabel,
|
|
@@ -85,7 +88,7 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
85
88
|
// Note: When this plugin does not register the "numberedList" dropdown due to properties configuration,
|
|
86
89
|
// a simple button will be still registered under the same name by ListUI as a fallback. This should happen
|
|
87
90
|
// in most editor configuration because the List plugin automatically requires ListUI.
|
|
88
|
-
if (
|
|
91
|
+
if (stylesListTypes.includes('numbered') || propertiesConfig.startIndex || propertiesConfig.reversed) {
|
|
89
92
|
const styleDefinitions = [
|
|
90
93
|
{
|
|
91
94
|
label: t('Toggle the decimal list style'),
|
|
@@ -129,7 +132,7 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
129
132
|
const commandName = 'numberedList';
|
|
130
133
|
editor.ui.componentFactory.add(commandName, getDropdownViewCreator({
|
|
131
134
|
editor,
|
|
132
|
-
|
|
135
|
+
normalizedConfig,
|
|
133
136
|
parentCommandName: commandName,
|
|
134
137
|
buttonLabel,
|
|
135
138
|
buttonIcon: icons.numberedList,
|
|
@@ -138,10 +141,10 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
138
141
|
}));
|
|
139
142
|
// Menu bar menu does not display list start index or reverse UI. If there are no styles enabled,
|
|
140
143
|
// the menu makes no sense and should be omitted.
|
|
141
|
-
if (
|
|
144
|
+
if (stylesListTypes.includes('numbered')) {
|
|
142
145
|
editor.ui.componentFactory.add(`menuBar:${commandName}`, getMenuBarStylesMenuCreator({
|
|
143
146
|
editor,
|
|
144
|
-
|
|
147
|
+
normalizedConfig,
|
|
145
148
|
parentCommandName: commandName,
|
|
146
149
|
buttonLabel,
|
|
147
150
|
styleGridAriaLabel,
|
|
@@ -156,7 +159,7 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
156
159
|
* which in turn contains buttons allowing users to change list styles in the context of the current selection.
|
|
157
160
|
*
|
|
158
161
|
* @param options.editor
|
|
159
|
-
* @param options.
|
|
162
|
+
* @param options.normalizedConfig List properties configuration.
|
|
160
163
|
* @param options.parentCommandName The name of the higher-order editor command associated with
|
|
161
164
|
* the set of particular list styles (e.g. "bulletedList" for "disc", "circle", and "square" styles).
|
|
162
165
|
* @param options.buttonLabel Label of the main part of the split button.
|
|
@@ -165,7 +168,7 @@ export default class ListPropertiesUI extends Plugin {
|
|
|
165
168
|
* @param options.styleDefinitions Definitions of the style buttons.
|
|
166
169
|
* @returns A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.
|
|
167
170
|
*/
|
|
168
|
-
function getDropdownViewCreator({ editor,
|
|
171
|
+
function getDropdownViewCreator({ editor, normalizedConfig, parentCommandName, buttonLabel, buttonIcon, styleGridAriaLabel, styleDefinitions }) {
|
|
169
172
|
const parentCommand = editor.commands.get(parentCommandName);
|
|
170
173
|
return (locale) => {
|
|
171
174
|
const dropdownView = createDropdown(locale, SplitButtonView);
|
|
@@ -187,7 +190,7 @@ function getDropdownViewCreator({ editor, propertiesConfig, parentCommandName, b
|
|
|
187
190
|
dropdownView.once('change:isOpen', () => {
|
|
188
191
|
const listPropertiesView = createListPropertiesView({
|
|
189
192
|
editor,
|
|
190
|
-
|
|
193
|
+
normalizedConfig,
|
|
191
194
|
dropdownView,
|
|
192
195
|
parentCommandName,
|
|
193
196
|
styleGridAriaLabel,
|
|
@@ -249,24 +252,25 @@ function getStyleButtonCreator({ editor, listStyleCommand, parentCommandName })
|
|
|
249
252
|
* A helper that creates the properties view for the individual style dropdown.
|
|
250
253
|
*
|
|
251
254
|
* @param options.editor Editor instance.
|
|
252
|
-
* @param options.
|
|
255
|
+
* @param options.normalizedConfig List properties configuration.
|
|
253
256
|
* @param options.dropdownView Styles dropdown view that hosts the properties view.
|
|
254
257
|
* @param options.parentCommandName The name of the higher-order editor command associated with
|
|
255
258
|
* the set of particular list styles (e.g. "bulletedList" for "disc", "circle", and "square" styles).
|
|
256
259
|
* @param options.styleDefinitions Definitions of the style buttons.
|
|
257
260
|
* @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).
|
|
258
261
|
*/
|
|
259
|
-
function createListPropertiesView({ editor,
|
|
262
|
+
function createListPropertiesView({ editor, normalizedConfig, dropdownView, parentCommandName, styleDefinitions, styleGridAriaLabel }) {
|
|
260
263
|
const locale = editor.locale;
|
|
261
264
|
const enabledProperties = {
|
|
262
|
-
...
|
|
265
|
+
...normalizedConfig,
|
|
266
|
+
...(parentCommandName != 'numberedList' ? {
|
|
267
|
+
startIndex: false,
|
|
268
|
+
reversed: false
|
|
269
|
+
} : null)
|
|
263
270
|
};
|
|
264
|
-
|
|
265
|
-
enabledProperties.startIndex = false;
|
|
266
|
-
enabledProperties.reversed = false;
|
|
267
|
-
}
|
|
271
|
+
const listType = parentCommandName.replace('List', '');
|
|
268
272
|
let styleButtonViews = null;
|
|
269
|
-
if (
|
|
273
|
+
if (normalizedConfig.styles.listTypes.includes(listType)) {
|
|
270
274
|
const listStyleCommand = editor.commands.get('listStyle');
|
|
271
275
|
const styleButtonCreator = getStyleButtonCreator({
|
|
272
276
|
editor,
|
|
@@ -282,7 +286,7 @@ function createListPropertiesView({ editor, propertiesConfig, dropdownView, pare
|
|
|
282
286
|
enabledProperties,
|
|
283
287
|
styleButtonViews
|
|
284
288
|
});
|
|
285
|
-
if (
|
|
289
|
+
if (normalizedConfig.styles.listTypes.includes(listType)) {
|
|
286
290
|
// Accessibility: focus the first active style when opening the dropdown.
|
|
287
291
|
focusChildOnDropdownOpen(dropdownView, () => {
|
|
288
292
|
return listPropertiesView.stylesView.children.find((child) => child.isOn);
|
|
@@ -311,13 +315,12 @@ function createListPropertiesView({ editor, propertiesConfig, dropdownView, pare
|
|
|
311
315
|
* A helper that creates the list style submenu for menu bar.
|
|
312
316
|
*
|
|
313
317
|
* @param editor Editor instance.
|
|
314
|
-
* @param
|
|
318
|
+
* @param normalizedConfig List properties configuration.
|
|
315
319
|
* @param parentCommandName Name of the list command.
|
|
316
320
|
* @param buttonLabel Label of the menu button.
|
|
317
321
|
* @param styleGridAriaLabel ARIA label of the styles grid.
|
|
318
|
-
* @param styleDefinitions Array of available styles for processed list type.
|
|
319
322
|
*/
|
|
320
|
-
function getMenuBarStylesMenuCreator({ editor,
|
|
323
|
+
function getMenuBarStylesMenuCreator({ editor, normalizedConfig, parentCommandName, buttonLabel, styleGridAriaLabel, styleDefinitions }) {
|
|
321
324
|
return (locale) => {
|
|
322
325
|
const menuView = new MenuBarMenuView(locale);
|
|
323
326
|
const listCommand = editor.commands.get(parentCommandName);
|
|
@@ -332,7 +335,7 @@ function getMenuBarStylesMenuCreator({ editor, propertiesConfig, parentCommandNa
|
|
|
332
335
|
const listPropertiesView = new ListPropertiesView(locale, {
|
|
333
336
|
styleGridAriaLabel,
|
|
334
337
|
enabledProperties: {
|
|
335
|
-
...
|
|
338
|
+
...normalizedConfig,
|
|
336
339
|
// Disable list start index and reversed in the menu bar.
|
|
337
340
|
startIndex: false,
|
|
338
341
|
reversed: false
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { View, ViewCollection, FocusCycler, SwitchButtonView, LabeledFieldView, CollapsibleView, type ButtonView, type InputNumberView, type FocusableView } from 'ckeditor5/src/ui.js';
|
|
9
9
|
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import type {
|
|
10
|
+
import type { NormalizedListPropertiesConfig } from '../utils/config.js';
|
|
11
11
|
import '../../../theme/listproperties.css';
|
|
12
12
|
/**
|
|
13
13
|
* The list properties view to be displayed in the list dropdown.
|
|
@@ -85,7 +85,7 @@ export default class ListPropertiesView extends View {
|
|
|
85
85
|
* @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).
|
|
86
86
|
*/
|
|
87
87
|
constructor(locale: Locale, { enabledProperties, styleButtonViews, styleGridAriaLabel }: {
|
|
88
|
-
enabledProperties:
|
|
88
|
+
enabledProperties: NormalizedListPropertiesConfig;
|
|
89
89
|
styleButtonViews: Array<ButtonView> | null;
|
|
90
90
|
styleGridAriaLabel: string;
|
|
91
91
|
});
|
|
@@ -91,7 +91,7 @@ export default class ListPropertiesView extends View {
|
|
|
91
91
|
});
|
|
92
92
|
// The rendering of the styles grid is conditional. When there is no styles grid, the view will render without collapsible
|
|
93
93
|
// for numbered list properties, hence simplifying the layout.
|
|
94
|
-
if (
|
|
94
|
+
if (styleButtonViews && styleButtonViews.length) {
|
|
95
95
|
this.stylesView = this._createStylesView(styleButtonViews, styleGridAriaLabel);
|
|
96
96
|
this.children.add(this.stylesView);
|
|
97
97
|
}
|
|
@@ -230,7 +230,7 @@ export default class ListPropertiesView extends View {
|
|
|
230
230
|
numberedPropertyViews.push(this.reversedSwitchButtonView);
|
|
231
231
|
}
|
|
232
232
|
// When there are some style buttons, pack the numbered list properties into a collapsible to separate them.
|
|
233
|
-
if (
|
|
233
|
+
if (this.stylesView) {
|
|
234
234
|
this.additionalPropertiesCollapsibleView = new CollapsibleView(this.locale, numberedPropertyViews);
|
|
235
235
|
this.additionalPropertiesCollapsibleView.set({
|
|
236
236
|
label: t('List properties'),
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import type { ListPropertiesConfig, ListPropertiesStyleListType } from '../../listconfig.js';
|
|
6
|
+
/**
|
|
7
|
+
* Normalizes {@link module:list/listconfig~ListPropertiesConfig} in the configuration of the list properties feature.
|
|
8
|
+
* The structure of normalized list properties options looks as follows:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* {
|
|
12
|
+
* styles: {
|
|
13
|
+
* listTypes: [ 'bulleted', 'numbered' ],
|
|
14
|
+
* useAttribute: false
|
|
15
|
+
* },
|
|
16
|
+
* startIndex: true,
|
|
17
|
+
* reversed: true
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param config The list properties {@link module:list/listconfig~ListPropertiesConfig config}.
|
|
22
|
+
* @returns An object with normalized list properties options.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getNormalizedConfig(config: ListPropertiesConfig): NormalizedListPropertiesConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Normalized list properties config.
|
|
27
|
+
*/
|
|
28
|
+
export type NormalizedListPropertiesConfig = {
|
|
29
|
+
styles: {
|
|
30
|
+
listTypes: Array<ListPropertiesStyleListType>;
|
|
31
|
+
useAttribute: boolean;
|
|
32
|
+
};
|
|
33
|
+
startIndex: boolean;
|
|
34
|
+
reversed: boolean;
|
|
35
|
+
};
|