@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
|
@@ -0,0 +1,70 @@
|
|
|
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/listproperties/utils/config
|
|
7
|
+
*/
|
|
8
|
+
import { toArray } from 'ckeditor5/src/utils.js';
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes {@link module:list/listconfig~ListPropertiesConfig} in the configuration of the list properties feature.
|
|
11
|
+
* The structure of normalized list properties options looks as follows:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* {
|
|
15
|
+
* styles: {
|
|
16
|
+
* listTypes: [ 'bulleted', 'numbered' ],
|
|
17
|
+
* useAttribute: false
|
|
18
|
+
* },
|
|
19
|
+
* startIndex: true,
|
|
20
|
+
* reversed: true
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param config The list properties {@link module:list/listconfig~ListPropertiesConfig config}.
|
|
25
|
+
* @returns An object with normalized list properties options.
|
|
26
|
+
*/
|
|
27
|
+
export function getNormalizedConfig(config) {
|
|
28
|
+
const { startIndex, reversed, styles } = config;
|
|
29
|
+
return {
|
|
30
|
+
styles: getNormalizedStylesConfig(styles),
|
|
31
|
+
startIndex: startIndex || false,
|
|
32
|
+
reversed: reversed || false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Normalizes styles in the configuration of the list properties feature.
|
|
37
|
+
* The structure of normalized list properties options looks as follows:
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* {
|
|
41
|
+
* listTypes: [ 'bulleted', 'numbered' ],
|
|
42
|
+
* useAttribute: false
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param styles The list properties styles.
|
|
47
|
+
* @returns An object with normalized list properties styles.
|
|
48
|
+
*/
|
|
49
|
+
function getNormalizedStylesConfig(styles) {
|
|
50
|
+
const normalizedConfig = {
|
|
51
|
+
listTypes: ['bulleted', 'numbered'],
|
|
52
|
+
useAttribute: false
|
|
53
|
+
};
|
|
54
|
+
if (styles === true) {
|
|
55
|
+
return normalizedConfig;
|
|
56
|
+
}
|
|
57
|
+
if (!styles) {
|
|
58
|
+
normalizedConfig.listTypes = [];
|
|
59
|
+
}
|
|
60
|
+
else if (Array.isArray(styles) || typeof styles == 'string') {
|
|
61
|
+
normalizedConfig.listTypes = toArray(styles);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
normalizedConfig.listTypes = styles.listTypes ?
|
|
65
|
+
toArray(styles.listTypes) :
|
|
66
|
+
normalizedConfig.listTypes;
|
|
67
|
+
normalizedConfig.useAttribute = !!styles.useAttribute;
|
|
68
|
+
}
|
|
69
|
+
return normalizedConfig;
|
|
70
|
+
}
|
|
@@ -50,15 +50,13 @@ export default class TodoListEditing extends Plugin {
|
|
|
50
50
|
editor.commands.add('checkTodoList', new CheckTodoListCommand(editor));
|
|
51
51
|
editing.view.addObserver(TodoCheckboxChangeObserver);
|
|
52
52
|
model.schema.extend('$listItem', { allowAttributes: 'todoListChecked' });
|
|
53
|
-
model.schema.addAttributeCheck(
|
|
53
|
+
model.schema.addAttributeCheck(context => {
|
|
54
54
|
const item = context.last;
|
|
55
|
-
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
55
|
+
// Don't allow `todoListChecked` attribute on elements which are not todo list items.
|
|
58
56
|
if (!item.getAttribute('listItemId') || item.getAttribute('listType') != 'todo') {
|
|
59
57
|
return false;
|
|
60
58
|
}
|
|
61
|
-
});
|
|
59
|
+
}, 'todoListChecked');
|
|
62
60
|
editor.conversion.for('upcast').add(dispatcher => {
|
|
63
61
|
// Upcast of to-do list item is based on a checkbox at the beginning of a <li> to keep compatibility with markdown input.
|
|
64
62
|
dispatcher.on('element:input', todoItemInputConverter());
|