@ckeditor/ckeditor5-list 40.2.0 → 41.1.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 +25 -25
- package/LICENSE.md +1 -1
- package/build/list.js +2 -2
- package/build/translations/ug.js +1 -1
- package/ckeditor5-metadata.json +34 -34
- package/lang/translations/ar.po +1 -1
- package/lang/translations/ast.po +1 -1
- package/lang/translations/az.po +1 -1
- package/lang/translations/bg.po +1 -1
- package/lang/translations/bn.po +1 -1
- package/lang/translations/ca.po +1 -1
- package/lang/translations/cs.po +1 -1
- package/lang/translations/da.po +1 -1
- package/lang/translations/de-ch.po +1 -1
- package/lang/translations/de.po +1 -1
- package/lang/translations/el.po +1 -1
- package/lang/translations/en-au.po +1 -1
- package/lang/translations/en-gb.po +1 -1
- package/lang/translations/en.po +1 -1
- package/lang/translations/eo.po +1 -1
- package/lang/translations/es.po +1 -1
- package/lang/translations/et.po +1 -1
- package/lang/translations/eu.po +1 -1
- package/lang/translations/fa.po +1 -1
- package/lang/translations/fi.po +1 -1
- package/lang/translations/fr.po +1 -1
- package/lang/translations/gl.po +1 -1
- package/lang/translations/he.po +1 -1
- package/lang/translations/hi.po +1 -1
- package/lang/translations/hr.po +1 -1
- package/lang/translations/hu.po +1 -1
- package/lang/translations/id.po +1 -1
- package/lang/translations/it.po +1 -1
- package/lang/translations/ja.po +1 -1
- package/lang/translations/jv.po +1 -1
- package/lang/translations/km.po +1 -1
- package/lang/translations/kn.po +1 -1
- package/lang/translations/ko.po +1 -1
- package/lang/translations/ku.po +1 -1
- package/lang/translations/lt.po +1 -1
- package/lang/translations/lv.po +1 -1
- package/lang/translations/ms.po +1 -1
- package/lang/translations/nb.po +1 -1
- package/lang/translations/ne.po +1 -1
- package/lang/translations/nl.po +1 -1
- package/lang/translations/no.po +1 -1
- package/lang/translations/pl.po +1 -1
- package/lang/translations/pt-br.po +1 -1
- package/lang/translations/pt.po +1 -1
- package/lang/translations/ro.po +1 -1
- package/lang/translations/ru.po +1 -1
- package/lang/translations/si.po +1 -1
- package/lang/translations/sk.po +1 -1
- package/lang/translations/sq.po +1 -1
- package/lang/translations/sr-latn.po +1 -1
- package/lang/translations/sr.po +1 -1
- package/lang/translations/sv.po +1 -1
- package/lang/translations/th.po +1 -1
- package/lang/translations/tk.po +1 -1
- package/lang/translations/tr.po +1 -1
- package/lang/translations/tt.po +1 -1
- package/lang/translations/ug.po +20 -20
- package/lang/translations/uk.po +1 -1
- package/lang/translations/ur.po +1 -1
- package/lang/translations/uz.po +1 -1
- package/lang/translations/vi.po +1 -1
- package/lang/translations/zh-cn.po +1 -1
- package/lang/translations/zh.po +1 -1
- package/package.json +3 -2
- package/src/augmentation.d.ts +29 -28
- package/src/augmentation.js +1 -1
- package/src/documentlist.d.ts +9 -7
- package/src/documentlist.js +18 -7
- package/src/documentlistproperties.d.ts +9 -8
- package/src/documentlistproperties.js +18 -8
- package/src/index.d.ts +39 -37
- package/src/index.js +32 -23
- package/src/legacylist/legacyconverters.d.ts +196 -0
- package/src/legacylist/legacyconverters.js +905 -0
- package/src/{list/indentcommand.d.ts → legacylist/legacyindentcommand.d.ts} +4 -4
- package/src/{list/indentcommand.js → legacylist/legacyindentcommand.js} +5 -5
- package/src/{documentlist/documentlistcommand.d.ts → legacylist/legacylistcommand.d.ts} +5 -30
- package/src/legacylist/legacylistcommand.js +274 -0
- package/src/legacylist/legacylistediting.d.ts +32 -0
- package/src/legacylist/legacylistediting.js +161 -0
- package/src/legacylist/legacylistutils.d.ts +41 -0
- package/src/legacylist/legacylistutils.js +46 -0
- package/src/legacylist/legacyutils.d.ts +101 -0
- package/src/legacylist/legacyutils.js +347 -0
- package/src/legacylist.d.ts +26 -0
- package/src/legacylist.js +30 -0
- package/src/legacylistproperties/legacylistpropertiesediting.d.ts +72 -0
- package/src/legacylistproperties/legacylistpropertiesediting.js +696 -0
- package/src/legacylistproperties/legacylistreversedcommand.d.ts +38 -0
- package/src/legacylistproperties/legacylistreversedcommand.js +52 -0
- package/src/{documentlistproperties/documentliststartcommand.d.ts → legacylistproperties/legacyliststartcommand.d.ts} +6 -7
- package/src/legacylistproperties/legacyliststartcommand.js +51 -0
- package/src/{documentlistproperties/documentliststylecommand.d.ts → legacylistproperties/legacyliststylecommand.d.ts} +14 -19
- package/src/{documentlistproperties/documentliststylecommand.js → legacylistproperties/legacyliststylecommand.js} +22 -36
- package/src/legacylistproperties.d.ts +27 -0
- package/src/legacylistproperties.js +31 -0
- package/src/{tododocumentlist/checktododocumentlistcommand.d.ts → legacytodolist/legacychecktodolistcommand.d.ts} +17 -14
- package/src/{tododocumentlist/checktododocumentlistcommand.js → legacytodolist/legacychecktodolistcommand.js} +34 -40
- package/src/{todolist/todolistconverters.d.ts → legacytodolist/legacytodolistconverters.d.ts} +9 -8
- package/src/{todolist/todolistconverters.js → legacytodolist/legacytodolistconverters.js} +6 -5
- package/src/{tododocumentlist/tododocumentlistediting.d.ts → legacytodolist/legacytodolistediting.d.ts} +9 -8
- package/src/legacytodolist/legacytodolistediting.js +161 -0
- package/src/legacytodolist.d.ts +27 -0
- package/src/legacytodolist.js +31 -0
- package/src/{documentlist → list}/adjacentlistssupport.d.ts +2 -2
- package/src/{documentlist → list}/adjacentlistssupport.js +9 -9
- package/src/list/converters.d.ts +41 -172
- package/src/list/converters.js +357 -821
- package/src/list/listcommand.d.ts +28 -3
- package/src/list/listcommand.js +81 -205
- package/src/list/listediting.d.ts +189 -9
- package/src/list/listediting.js +592 -107
- package/src/{documentlist/documentlistindentcommand.d.ts → list/listindentcommand.d.ts} +10 -10
- package/src/{documentlist/documentlistindentcommand.js → list/listindentcommand.js} +7 -7
- package/src/{documentlist/documentlistmergecommand.d.ts → list/listmergecommand.d.ts} +10 -10
- package/src/{documentlist/documentlistmergecommand.js → list/listmergecommand.js} +7 -7
- package/src/{documentlist/documentlistsplitcommand.d.ts → list/listsplitcommand.d.ts} +10 -10
- package/src/{documentlist/documentlistsplitcommand.js → list/listsplitcommand.js} +5 -5
- package/src/list/listui.d.ts +2 -2
- package/src/list/listui.js +5 -7
- package/src/list/listutils.d.ts +22 -17
- package/src/list/listutils.js +24 -20
- package/src/{documentlist → list}/utils/listwalker.d.ts +5 -5
- package/src/{documentlist → list}/utils/listwalker.js +4 -4
- package/src/{documentlist → list}/utils/model.d.ts +4 -4
- package/src/{documentlist → list}/utils/model.js +3 -3
- package/src/{documentlist → list}/utils/postfixers.d.ts +5 -5
- package/src/{documentlist → list}/utils/postfixers.js +3 -3
- package/src/{documentlist → list}/utils/view.d.ts +3 -3
- package/src/{documentlist → list}/utils/view.js +1 -1
- package/src/list/utils.d.ts +2 -96
- package/src/list/utils.js +2 -342
- package/src/list.d.ts +6 -6
- package/src/list.js +6 -6
- package/src/listconfig.d.ts +10 -10
- package/src/listconfig.js +1 -1
- package/src/{documentlistproperties → listproperties}/converters.d.ts +5 -5
- package/src/{documentlistproperties → listproperties}/converters.js +1 -1
- package/src/listproperties/listpropertiesediting.d.ts +56 -40
- package/src/listproperties/listpropertiesediting.js +145 -575
- package/src/listproperties/listpropertiesui.d.ts +2 -2
- package/src/listproperties/listpropertiesui.js +6 -8
- package/src/{documentlistproperties/documentlistpropertiesutils.d.ts → listproperties/listpropertiesutils.d.ts} +5 -5
- package/src/{documentlistproperties/documentlistpropertiesutils.js → listproperties/listpropertiesutils.js} +6 -6
- package/src/listproperties/listreversedcommand.d.ts +4 -6
- package/src/listproperties/listreversedcommand.js +17 -14
- package/src/listproperties/liststartcommand.d.ts +4 -3
- package/src/listproperties/liststartcommand.js +17 -11
- package/src/listproperties/liststylecommand.d.ts +16 -11
- package/src/listproperties/liststylecommand.js +33 -19
- package/src/listproperties/ui/listpropertiesview.d.ts +5 -5
- package/src/listproperties/ui/listpropertiesview.js +3 -3
- package/src/{documentlistproperties → listproperties}/utils/style.d.ts +1 -1
- package/src/{documentlistproperties → listproperties}/utils/style.js +2 -2
- package/src/listproperties.d.ts +6 -5
- package/src/listproperties.js +6 -5
- package/src/tododocumentlist.d.ts +9 -8
- package/src/tododocumentlist.js +18 -8
- package/src/todolist/checktodolistcommand.d.ts +11 -14
- package/src/todolist/checktodolistcommand.js +37 -31
- package/src/{tododocumentlist → todolist}/todocheckboxchangeobserver.d.ts +6 -6
- package/src/{tododocumentlist → todolist}/todocheckboxchangeobserver.js +3 -3
- package/src/todolist/todolistediting.d.ts +5 -6
- package/src/todolist/todolistediting.js +314 -76
- package/src/todolist/todolistui.d.ts +2 -2
- package/src/todolist/todolistui.js +4 -5
- package/src/todolist.d.ts +6 -6
- package/src/todolist.js +6 -6
- package/theme/documentlist.css +1 -1
- package/theme/list.css +1 -1
- package/theme/listproperties.css +1 -1
- package/theme/liststyles.css +1 -1
- package/theme/todolist.css +1 -1
- package/src/documentlist/converters.d.ts +0 -65
- package/src/documentlist/converters.js +0 -441
- package/src/documentlist/documentlistcommand.js +0 -150
- package/src/documentlist/documentlistediting.d.ts +0 -212
- package/src/documentlist/documentlistediting.js +0 -646
- package/src/documentlist/documentlistutils.d.ts +0 -46
- package/src/documentlist/documentlistutils.js +0 -50
- package/src/documentlistproperties/documentlistpropertiesediting.d.ts +0 -88
- package/src/documentlistproperties/documentlistpropertiesediting.js +0 -266
- package/src/documentlistproperties/documentlistreversedcommand.d.ts +0 -36
- package/src/documentlistproperties/documentlistreversedcommand.js +0 -55
- package/src/documentlistproperties/documentliststartcommand.js +0 -57
- package/src/liststyle.d.ts +0 -28
- package/src/liststyle.js +0 -36
- package/src/tododocumentlist/tododocumentlistediting.js +0 -399
- package/theme/icons/bulletedlist.svg +0 -1
- package/theme/icons/numberedlist.svg +0 -1
- package/theme/icons/todolist.svg +0 -1
|
@@ -1,46 +0,0 @@
|
|
|
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/documentlistutils
|
|
7
|
-
*/
|
|
8
|
-
import type { Element, Node } from 'ckeditor5/src/engine';
|
|
9
|
-
import type { ArrayOrItem } from 'ckeditor5/src/utils';
|
|
10
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
/**
|
|
12
|
-
* A set of helpers related to document lists.
|
|
13
|
-
*/
|
|
14
|
-
export default class DocumentListUtils extends Plugin {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
static get pluginName(): "DocumentListUtils";
|
|
19
|
-
/**
|
|
20
|
-
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
21
|
-
*
|
|
22
|
-
* @param blocks The list of selected blocks.
|
|
23
|
-
*/
|
|
24
|
-
expandListBlocksToCompleteList(blocks: ArrayOrItem<Element>): Array<Element>;
|
|
25
|
-
/**
|
|
26
|
-
* Check if the given block is the first in the list item.
|
|
27
|
-
*
|
|
28
|
-
* @param listBlock The list block element.
|
|
29
|
-
*/
|
|
30
|
-
isFirstBlockOfListItem(listBlock: Element): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Returns true if the given model node is a list item block.
|
|
33
|
-
*
|
|
34
|
-
* @param node A model node.
|
|
35
|
-
*/
|
|
36
|
-
isListItemBlock(node: Node): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
39
|
-
*
|
|
40
|
-
* @param blocks The list of selected blocks.
|
|
41
|
-
* @param options.withNested Whether should include nested list items.
|
|
42
|
-
*/
|
|
43
|
-
expandListBlocksToCompleteItems(blocks: ArrayOrItem<Element>, options?: {
|
|
44
|
-
withNested?: boolean;
|
|
45
|
-
}): Array<Element>;
|
|
46
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
6
|
-
import { expandListBlocksToCompleteItems, expandListBlocksToCompleteList, isFirstBlockOfListItem, isListItemBlock } from './utils/model';
|
|
7
|
-
/**
|
|
8
|
-
* A set of helpers related to document lists.
|
|
9
|
-
*/
|
|
10
|
-
export default class DocumentListUtils extends Plugin {
|
|
11
|
-
/**
|
|
12
|
-
* @inheritDoc
|
|
13
|
-
*/
|
|
14
|
-
static get pluginName() {
|
|
15
|
-
return 'DocumentListUtils';
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
19
|
-
*
|
|
20
|
-
* @param blocks The list of selected blocks.
|
|
21
|
-
*/
|
|
22
|
-
expandListBlocksToCompleteList(blocks) {
|
|
23
|
-
return expandListBlocksToCompleteList(blocks);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Check if the given block is the first in the list item.
|
|
27
|
-
*
|
|
28
|
-
* @param listBlock The list block element.
|
|
29
|
-
*/
|
|
30
|
-
isFirstBlockOfListItem(listBlock) {
|
|
31
|
-
return isFirstBlockOfListItem(listBlock);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns true if the given model node is a list item block.
|
|
35
|
-
*
|
|
36
|
-
* @param node A model node.
|
|
37
|
-
*/
|
|
38
|
-
isListItemBlock(node) {
|
|
39
|
-
return isListItemBlock(node);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
43
|
-
*
|
|
44
|
-
* @param blocks The list of selected blocks.
|
|
45
|
-
* @param options.withNested Whether should include nested list items.
|
|
46
|
-
*/
|
|
47
|
-
expandListBlocksToCompleteItems(blocks, options = {}) {
|
|
48
|
-
return expandListBlocksToCompleteItems(blocks, options);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
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/documentlistproperties/documentlistpropertiesediting
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
9
|
-
import type { Consumables, DowncastWriter, Element, Item, ViewElement } from 'ckeditor5/src/engine';
|
|
10
|
-
import DocumentListEditing, { type ListItemAttributesMap } from '../documentlist/documentlistediting';
|
|
11
|
-
import DocumentListPropertiesUtils from './documentlistpropertiesutils';
|
|
12
|
-
/**
|
|
13
|
-
* The document list properties engine feature.
|
|
14
|
-
*
|
|
15
|
-
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
16
|
-
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
17
|
-
*/
|
|
18
|
-
export default class DocumentListPropertiesEditing extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get requires(): readonly [typeof DocumentListEditing, typeof DocumentListPropertiesUtils];
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName(): "DocumentListPropertiesEditing";
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
constructor(editor: Editor);
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
init(): void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Strategy for dealing with `listItem` attributes supported by this plugin.
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export interface AttributeStrategy {
|
|
42
|
-
/**
|
|
43
|
-
* The model attribute name.
|
|
44
|
-
*/
|
|
45
|
-
attributeName: keyof ListItemAttributesMap;
|
|
46
|
-
/**
|
|
47
|
-
* The model attribute default value.
|
|
48
|
-
*/
|
|
49
|
-
defaultValue: unknown;
|
|
50
|
-
/**
|
|
51
|
-
* The view consumable as expected by {@link module:engine/conversion/viewconsumable~ViewConsumable#consume `ViewConsumable`}.
|
|
52
|
-
*/
|
|
53
|
-
viewConsumables: Consumables;
|
|
54
|
-
/**
|
|
55
|
-
* Registers an editor command.
|
|
56
|
-
*/
|
|
57
|
-
addCommand(editor: Editor): void;
|
|
58
|
-
/**
|
|
59
|
-
* Verifies whether the strategy is applicable for the specified model element.
|
|
60
|
-
*/
|
|
61
|
-
appliesToListItem(element: Item): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Verifies whether the model attribute value is valid.
|
|
64
|
-
*/
|
|
65
|
-
hasValidAttribute(element: Element): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Sets the property on the view element.
|
|
68
|
-
*/
|
|
69
|
-
setAttributeOnDowncast(writer: DowncastWriter, value: unknown, element: ViewElement): void;
|
|
70
|
-
/**
|
|
71
|
-
* Retrieves the property value from the view element.
|
|
72
|
-
*/
|
|
73
|
-
getAttributeOnUpcast(element: ViewElement): unknown;
|
|
74
|
-
}
|
|
75
|
-
declare module '../documentlist/documentlistediting' {
|
|
76
|
-
interface ListItemAttributesMap {
|
|
77
|
-
listStyle?: string;
|
|
78
|
-
listStart?: number;
|
|
79
|
-
listReversed?: boolean;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
declare module '../documentlist/utils/model' {
|
|
83
|
-
interface ListElement {
|
|
84
|
-
getAttribute(key: 'listStyle'): string;
|
|
85
|
-
getAttribute(key: 'listStart'): number;
|
|
86
|
-
getAttribute(key: 'listReversed'): boolean;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,266 +0,0 @@
|
|
|
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/documentlistproperties/documentlistpropertiesediting
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import DocumentListEditing from '../documentlist/documentlistediting';
|
|
10
|
-
import DocumentListStartCommand from './documentliststartcommand';
|
|
11
|
-
import DocumentListStyleCommand from './documentliststylecommand';
|
|
12
|
-
import DocumentListReversedCommand from './documentlistreversedcommand';
|
|
13
|
-
import { listPropertiesUpcastConverter } from './converters';
|
|
14
|
-
import { getAllSupportedStyleTypes, getListTypeFromListStyleType, getListStyleTypeFromTypeAttribute, getTypeAttributeFromListStyleType } from './utils/style';
|
|
15
|
-
import DocumentListPropertiesUtils from './documentlistpropertiesutils';
|
|
16
|
-
const DEFAULT_LIST_TYPE = 'default';
|
|
17
|
-
/**
|
|
18
|
-
* The document list properties engine feature.
|
|
19
|
-
*
|
|
20
|
-
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
21
|
-
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
22
|
-
*/
|
|
23
|
-
export default class DocumentListPropertiesEditing extends Plugin {
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
static get requires() {
|
|
28
|
-
return [DocumentListEditing, DocumentListPropertiesUtils];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
static get pluginName() {
|
|
34
|
-
return 'DocumentListPropertiesEditing';
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
constructor(editor) {
|
|
40
|
-
super(editor);
|
|
41
|
-
editor.config.define('list.properties', {
|
|
42
|
-
styles: true,
|
|
43
|
-
startIndex: false,
|
|
44
|
-
reversed: false
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @inheritDoc
|
|
49
|
-
*/
|
|
50
|
-
init() {
|
|
51
|
-
const editor = this.editor;
|
|
52
|
-
const model = editor.model;
|
|
53
|
-
const documentListEditing = editor.plugins.get(DocumentListEditing);
|
|
54
|
-
const enabledProperties = editor.config.get('list.properties');
|
|
55
|
-
const strategies = createAttributeStrategies(enabledProperties);
|
|
56
|
-
for (const strategy of strategies) {
|
|
57
|
-
strategy.addCommand(editor);
|
|
58
|
-
model.schema.extend('$listItem', { allowAttributes: strategy.attributeName });
|
|
59
|
-
// Register downcast strategy.
|
|
60
|
-
documentListEditing.registerDowncastStrategy({
|
|
61
|
-
scope: 'list',
|
|
62
|
-
attributeName: strategy.attributeName,
|
|
63
|
-
setAttributeOnDowncast(writer, attributeValue, viewElement) {
|
|
64
|
-
strategy.setAttributeOnDowncast(writer, attributeValue, viewElement);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// Set up conversion.
|
|
69
|
-
editor.conversion.for('upcast').add(dispatcher => {
|
|
70
|
-
for (const strategy of strategies) {
|
|
71
|
-
dispatcher.on('element:ol', listPropertiesUpcastConverter(strategy));
|
|
72
|
-
dispatcher.on('element:ul', listPropertiesUpcastConverter(strategy));
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
// Verify if the list view element (ul or ol) requires refreshing.
|
|
76
|
-
documentListEditing.on('checkAttributes:list', (evt, { viewElement, modelAttributes }) => {
|
|
77
|
-
for (const strategy of strategies) {
|
|
78
|
-
if (strategy.getAttributeOnUpcast(viewElement) != modelAttributes[strategy.attributeName]) {
|
|
79
|
-
evt.return = true;
|
|
80
|
-
evt.stop();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
// Reset list properties after indenting list items.
|
|
85
|
-
this.listenTo(editor.commands.get('indentList'), 'afterExecute', (evt, changedBlocks) => {
|
|
86
|
-
model.change(writer => {
|
|
87
|
-
for (const node of changedBlocks) {
|
|
88
|
-
for (const strategy of strategies) {
|
|
89
|
-
if (strategy.appliesToListItem(node)) {
|
|
90
|
-
// Just reset the attribute.
|
|
91
|
-
// If there is a previous indented list that this node should be merged into,
|
|
92
|
-
// the postfixer will unify all the attributes of both sub-lists.
|
|
93
|
-
writer.setAttribute(strategy.attributeName, strategy.defaultValue, node);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
// Add or remove list properties attributes depending on the list type.
|
|
100
|
-
documentListEditing.on('postFixer', (evt, { listNodes, writer }) => {
|
|
101
|
-
for (const { node } of listNodes) {
|
|
102
|
-
for (const strategy of strategies) {
|
|
103
|
-
// Check if attribute is valid.
|
|
104
|
-
if (strategy.hasValidAttribute(node)) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
// Add missing default property attributes...
|
|
108
|
-
if (strategy.appliesToListItem(node)) {
|
|
109
|
-
writer.setAttribute(strategy.attributeName, strategy.defaultValue, node);
|
|
110
|
-
}
|
|
111
|
-
// ...or remove invalid property attributes.
|
|
112
|
-
else {
|
|
113
|
-
writer.removeAttribute(strategy.attributeName, node);
|
|
114
|
-
}
|
|
115
|
-
evt.return = true;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
// Make sure that all items in a single list (items at the same level & listType) have the same properties.
|
|
120
|
-
documentListEditing.on('postFixer', (evt, { listNodes, writer }) => {
|
|
121
|
-
for (const { node, previousNodeInList } of listNodes) {
|
|
122
|
-
// This is a first item of a nested list.
|
|
123
|
-
if (!previousNodeInList) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
// This is a first block of a list of a different type.
|
|
127
|
-
if (previousNodeInList.getAttribute('listType') != node.getAttribute('listType')) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
// Copy properties from the previous one.
|
|
131
|
-
for (const strategy of strategies) {
|
|
132
|
-
const { attributeName } = strategy;
|
|
133
|
-
if (!strategy.appliesToListItem(node)) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
const value = previousNodeInList.getAttribute(attributeName);
|
|
137
|
-
if (node.getAttribute(attributeName) != value) {
|
|
138
|
-
writer.setAttribute(attributeName, value, node);
|
|
139
|
-
evt.return = true;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Creates an array of strategies for dealing with enabled listItem attributes.
|
|
148
|
-
*/
|
|
149
|
-
function createAttributeStrategies(enabledProperties) {
|
|
150
|
-
const strategies = [];
|
|
151
|
-
if (enabledProperties.styles) {
|
|
152
|
-
const useAttribute = typeof enabledProperties.styles == 'object' && enabledProperties.styles.useAttribute;
|
|
153
|
-
strategies.push({
|
|
154
|
-
attributeName: 'listStyle',
|
|
155
|
-
defaultValue: DEFAULT_LIST_TYPE,
|
|
156
|
-
viewConsumables: { styles: 'list-style-type' },
|
|
157
|
-
addCommand(editor) {
|
|
158
|
-
let supportedTypes = getAllSupportedStyleTypes();
|
|
159
|
-
if (useAttribute) {
|
|
160
|
-
supportedTypes = supportedTypes.filter(styleType => !!getTypeAttributeFromListStyleType(styleType));
|
|
161
|
-
}
|
|
162
|
-
editor.commands.add('listStyle', new DocumentListStyleCommand(editor, DEFAULT_LIST_TYPE, supportedTypes));
|
|
163
|
-
},
|
|
164
|
-
appliesToListItem(item) {
|
|
165
|
-
return item.getAttribute('listType') == 'numbered' || item.getAttribute('listType') == 'bulleted';
|
|
166
|
-
},
|
|
167
|
-
hasValidAttribute(item) {
|
|
168
|
-
if (!this.appliesToListItem(item)) {
|
|
169
|
-
return !item.hasAttribute('listStyle');
|
|
170
|
-
}
|
|
171
|
-
if (!item.hasAttribute('listStyle')) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
const value = item.getAttribute('listStyle');
|
|
175
|
-
if (value == DEFAULT_LIST_TYPE) {
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
return getListTypeFromListStyleType(value) == item.getAttribute('listType');
|
|
179
|
-
},
|
|
180
|
-
setAttributeOnDowncast(writer, listStyle, element) {
|
|
181
|
-
if (listStyle && listStyle !== DEFAULT_LIST_TYPE) {
|
|
182
|
-
if (useAttribute) {
|
|
183
|
-
const value = getTypeAttributeFromListStyleType(listStyle);
|
|
184
|
-
if (value) {
|
|
185
|
-
writer.setAttribute('type', value, element);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
writer.setStyle('list-style-type', listStyle, element);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
writer.removeStyle('list-style-type', element);
|
|
195
|
-
writer.removeAttribute('type', element);
|
|
196
|
-
},
|
|
197
|
-
getAttributeOnUpcast(listParent) {
|
|
198
|
-
const style = listParent.getStyle('list-style-type');
|
|
199
|
-
if (style) {
|
|
200
|
-
return style;
|
|
201
|
-
}
|
|
202
|
-
const attribute = listParent.getAttribute('type');
|
|
203
|
-
if (attribute) {
|
|
204
|
-
return getListStyleTypeFromTypeAttribute(attribute);
|
|
205
|
-
}
|
|
206
|
-
return DEFAULT_LIST_TYPE;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
if (enabledProperties.reversed) {
|
|
211
|
-
strategies.push({
|
|
212
|
-
attributeName: 'listReversed',
|
|
213
|
-
defaultValue: false,
|
|
214
|
-
viewConsumables: { attributes: 'reversed' },
|
|
215
|
-
addCommand(editor) {
|
|
216
|
-
editor.commands.add('listReversed', new DocumentListReversedCommand(editor));
|
|
217
|
-
},
|
|
218
|
-
appliesToListItem(item) {
|
|
219
|
-
return item.getAttribute('listType') == 'numbered';
|
|
220
|
-
},
|
|
221
|
-
hasValidAttribute(item) {
|
|
222
|
-
return this.appliesToListItem(item) == item.hasAttribute('listReversed');
|
|
223
|
-
},
|
|
224
|
-
setAttributeOnDowncast(writer, listReversed, element) {
|
|
225
|
-
if (listReversed) {
|
|
226
|
-
writer.setAttribute('reversed', 'reversed', element);
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
writer.removeAttribute('reversed', element);
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
getAttributeOnUpcast(listParent) {
|
|
233
|
-
return listParent.hasAttribute('reversed');
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
if (enabledProperties.startIndex) {
|
|
238
|
-
strategies.push({
|
|
239
|
-
attributeName: 'listStart',
|
|
240
|
-
defaultValue: 1,
|
|
241
|
-
viewConsumables: { attributes: 'start' },
|
|
242
|
-
addCommand(editor) {
|
|
243
|
-
editor.commands.add('listStart', new DocumentListStartCommand(editor));
|
|
244
|
-
},
|
|
245
|
-
appliesToListItem(item) {
|
|
246
|
-
return item.getAttribute('listType') == 'numbered';
|
|
247
|
-
},
|
|
248
|
-
hasValidAttribute(item) {
|
|
249
|
-
return this.appliesToListItem(item) == item.hasAttribute('listStart');
|
|
250
|
-
},
|
|
251
|
-
setAttributeOnDowncast(writer, listStart, element) {
|
|
252
|
-
if (listStart == 0 || listStart > 1) {
|
|
253
|
-
writer.setAttribute('start', listStart, element);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
writer.removeAttribute('start', element);
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
getAttributeOnUpcast(listParent) {
|
|
260
|
-
const startAttributeValue = listParent.getAttribute('start');
|
|
261
|
-
return startAttributeValue >= 0 ? startAttributeValue : 1;
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
return strategies;
|
|
266
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
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/documentlistproperties/documentlistreversedcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
/**
|
|
10
|
-
* The list reversed command. It changes the `listReversed` attribute of the selected list items,
|
|
11
|
-
* letting the user to choose the order of an ordered list.
|
|
12
|
-
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
13
|
-
*/
|
|
14
|
-
export default class DocumentListReversedCommand extends Command {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
value: boolean | null;
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
refresh(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Executes the command.
|
|
25
|
-
*
|
|
26
|
-
* @fires execute
|
|
27
|
-
* @param options.reversed Whether the list should be reversed.
|
|
28
|
-
*/
|
|
29
|
-
execute(options?: {
|
|
30
|
-
reversed?: boolean;
|
|
31
|
-
}): void;
|
|
32
|
-
/**
|
|
33
|
-
* Checks the command's {@link #value}.
|
|
34
|
-
*/
|
|
35
|
-
private _getValue;
|
|
36
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
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/documentlistproperties/documentlistreversedcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
import { first } from 'ckeditor5/src/utils';
|
|
10
|
-
import { expandListBlocksToCompleteList, isListItemBlock } from '../documentlist/utils/model';
|
|
11
|
-
/**
|
|
12
|
-
* The list reversed command. It changes the `listReversed` attribute of the selected list items,
|
|
13
|
-
* letting the user to choose the order of an ordered list.
|
|
14
|
-
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
15
|
-
*/
|
|
16
|
-
export default class DocumentListReversedCommand extends Command {
|
|
17
|
-
/**
|
|
18
|
-
* @inheritDoc
|
|
19
|
-
*/
|
|
20
|
-
refresh() {
|
|
21
|
-
const value = this._getValue();
|
|
22
|
-
this.value = value;
|
|
23
|
-
this.isEnabled = value != null;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Executes the command.
|
|
27
|
-
*
|
|
28
|
-
* @fires execute
|
|
29
|
-
* @param options.reversed Whether the list should be reversed.
|
|
30
|
-
*/
|
|
31
|
-
execute(options = {}) {
|
|
32
|
-
const model = this.editor.model;
|
|
33
|
-
const document = model.document;
|
|
34
|
-
let blocks = Array.from(document.selection.getSelectedBlocks())
|
|
35
|
-
.filter(block => isListItemBlock(block) && block.getAttribute('listType') == 'numbered');
|
|
36
|
-
blocks = expandListBlocksToCompleteList(blocks);
|
|
37
|
-
model.change(writer => {
|
|
38
|
-
for (const block of blocks) {
|
|
39
|
-
writer.setAttribute('listReversed', !!options.reversed, block);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks the command's {@link #value}.
|
|
45
|
-
*/
|
|
46
|
-
_getValue() {
|
|
47
|
-
const model = this.editor.model;
|
|
48
|
-
const document = model.document;
|
|
49
|
-
const block = first(document.selection.getSelectedBlocks());
|
|
50
|
-
if (isListItemBlock(block) && block.getAttribute('listType') == 'numbered') {
|
|
51
|
-
return block.getAttribute('listReversed');
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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/documentlistproperties/documentliststartcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
import { first } from 'ckeditor5/src/utils';
|
|
10
|
-
import { expandListBlocksToCompleteList, isListItemBlock } from '../documentlist/utils/model';
|
|
11
|
-
/**
|
|
12
|
-
* The list start index command. It changes the `listStart` attribute of the selected list items,
|
|
13
|
-
* letting the user to choose the starting point of an ordered list.
|
|
14
|
-
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
15
|
-
*/
|
|
16
|
-
export default class DocumentListStartCommand extends Command {
|
|
17
|
-
/**
|
|
18
|
-
* @inheritDoc
|
|
19
|
-
*/
|
|
20
|
-
refresh() {
|
|
21
|
-
const value = this._getValue();
|
|
22
|
-
this.value = value;
|
|
23
|
-
this.isEnabled = value != null;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Executes the command.
|
|
27
|
-
*
|
|
28
|
-
* @fires execute
|
|
29
|
-
* @param options.startIndex The list start index.
|
|
30
|
-
*/
|
|
31
|
-
execute({ startIndex = 1 } = {}) {
|
|
32
|
-
const model = this.editor.model;
|
|
33
|
-
const document = model.document;
|
|
34
|
-
let blocks = Array.from(document.selection.getSelectedBlocks())
|
|
35
|
-
.filter(block => isListItemBlock(block) && block.getAttribute('listType') == 'numbered');
|
|
36
|
-
blocks = expandListBlocksToCompleteList(blocks);
|
|
37
|
-
model.change(writer => {
|
|
38
|
-
for (const block of blocks) {
|
|
39
|
-
writer.setAttribute('listStart', startIndex >= 0 ? startIndex : 1, block);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks the command's {@link #value}.
|
|
45
|
-
*
|
|
46
|
-
* @returns The current value.
|
|
47
|
-
*/
|
|
48
|
-
_getValue() {
|
|
49
|
-
const model = this.editor.model;
|
|
50
|
-
const document = model.document;
|
|
51
|
-
const block = first(document.selection.getSelectedBlocks());
|
|
52
|
-
if (block && isListItemBlock(block) && block.getAttribute('listType') == 'numbered') {
|
|
53
|
-
return block.getAttribute('listStart');
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/liststyle.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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/liststyle
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
9
|
-
import ListProperties from './listproperties';
|
|
10
|
-
/**
|
|
11
|
-
* The list style feature.
|
|
12
|
-
*
|
|
13
|
-
* This is an obsolete plugin that exists for backward compatibility only.
|
|
14
|
-
* Use the {@link module:list/listproperties~ListProperties list properties plugin} instead.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated
|
|
17
|
-
*/
|
|
18
|
-
export default class ListStyle extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get requires(): readonly [typeof ListProperties];
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName(): "ListStyle";
|
|
27
|
-
constructor(editor: Editor);
|
|
28
|
-
}
|
package/src/liststyle.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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/liststyle
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import ListProperties from './listproperties';
|
|
10
|
-
import { logWarning } from 'ckeditor5/src/utils';
|
|
11
|
-
/**
|
|
12
|
-
* The list style feature.
|
|
13
|
-
*
|
|
14
|
-
* This is an obsolete plugin that exists for backward compatibility only.
|
|
15
|
-
* Use the {@link module:list/listproperties~ListProperties list properties plugin} instead.
|
|
16
|
-
*
|
|
17
|
-
* @deprecated
|
|
18
|
-
*/
|
|
19
|
-
export default class ListStyle extends Plugin {
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
static get requires() {
|
|
24
|
-
return [ListProperties];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
static get pluginName() {
|
|
30
|
-
return 'ListStyle';
|
|
31
|
-
}
|
|
32
|
-
constructor(editor) {
|
|
33
|
-
super(editor);
|
|
34
|
-
logWarning('The `ListStyle` plugin is obsolete. Use `ListProperties` instead.');
|
|
35
|
-
}
|
|
36
|
-
}
|