@ckeditor/ckeditor5-list 47.6.1-alpha.1 → 48.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/LICENSE.md +1 -1
- package/ckeditor5-metadata.json +21 -18
- package/dist/index-content.css +135 -111
- package/dist/index-editor.css +152 -73
- package/dist/index.css +204 -238
- package/dist/index.css.map +1 -1
- package/dist/index.js.map +1 -1
- package/{src → dist}/legacylist/legacyconverters.d.ts +2 -2
- package/{src → dist}/legacylist/legacyindentcommand.d.ts +1 -1
- package/{src → dist}/legacylist/legacylistcommand.d.ts +1 -1
- package/{src → dist}/legacylist/legacylistediting.d.ts +3 -3
- package/{src → dist}/legacylist/legacylistutils.d.ts +2 -2
- package/{src → dist}/legacylist/legacyutils.d.ts +1 -1
- package/{src → dist}/legacylist.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacylistpropertiesediting.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacylistreversedcommand.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacyliststartcommand.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacyliststylecommand.d.ts +1 -1
- package/{src → dist}/legacylistproperties.d.ts +1 -1
- package/{src → dist}/legacytodolist/legacychecktodolistcommand.d.ts +2 -2
- package/{src → dist}/legacytodolist/legacytodolistconverters.d.ts +2 -2
- package/{src → dist}/legacytodolist/legacytodolistediting.d.ts +1 -1
- package/{src → dist}/legacytodolist.d.ts +1 -1
- package/{src → dist}/list/adjacentlistssupport.d.ts +1 -1
- package/{src → dist}/list/converters.d.ts +2 -2
- package/{src → dist}/list/listcommand.d.ts +2 -2
- package/{src → dist}/list/listediting.d.ts +5 -5
- package/{src → dist}/list/listindentcommand.d.ts +2 -2
- package/{src → dist}/list/listmergecommand.d.ts +2 -2
- package/{src → dist}/list/listsplitcommand.d.ts +2 -2
- package/{src → dist}/list/listui.d.ts +1 -1
- package/{src → dist}/list/listutils.d.ts +3 -3
- package/{src → dist}/list/utils/listwalker.d.ts +2 -2
- package/{src → dist}/list/utils/model.d.ts +2 -2
- package/{src → dist}/list/utils/postfixers.d.ts +1 -1
- package/{src → dist}/list/utils/view.d.ts +1 -1
- package/{src → dist}/list/utils.d.ts +1 -1
- package/{src → dist}/list.d.ts +1 -1
- package/{src → dist}/listconfig.d.ts +1 -1
- package/{src → dist}/listformatting/listitemboldintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemfontcolorintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemfontfamilyintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemfontsizeintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemitalicintegration.d.ts +1 -1
- package/{src → dist}/listformatting.d.ts +1 -1
- package/{src → dist}/listproperties/converters.d.ts +2 -2
- package/{src → dist}/listproperties/listpropertiesediting.d.ts +2 -2
- package/{src → dist}/listproperties/listpropertiesui.d.ts +1 -1
- package/{src → dist}/listproperties/listpropertiesutils.d.ts +1 -1
- package/{src → dist}/listproperties/listreversedcommand.d.ts +1 -1
- package/{src → dist}/listproperties/liststartcommand.d.ts +1 -1
- package/{src → dist}/listproperties/liststylecommand.d.ts +1 -1
- package/{src → dist}/listproperties/ui/listpropertiesview.d.ts +2 -2
- package/{src → dist}/listproperties.d.ts +1 -1
- package/{src → dist}/todolist/checktodolistcommand.d.ts +1 -1
- package/{src → dist}/todolist/todocheckboxchangeobserver.d.ts +1 -1
- package/{src → dist}/todolist/todolistediting.d.ts +1 -1
- package/{src → dist}/todolist/todolistui.d.ts +1 -1
- package/{src → dist}/todolist.d.ts +1 -1
- package/package.json +28 -52
- package/build/list.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/lang/contexts.json +0 -37
- package/lang/translations/af.po +0 -152
- package/lang/translations/ar.po +0 -152
- package/lang/translations/ast.po +0 -152
- package/lang/translations/az.po +0 -152
- package/lang/translations/be.po +0 -152
- package/lang/translations/bg.po +0 -152
- package/lang/translations/bn.po +0 -152
- package/lang/translations/bs.po +0 -152
- package/lang/translations/ca.po +0 -152
- package/lang/translations/cs.po +0 -152
- package/lang/translations/da.po +0 -152
- package/lang/translations/de-ch.po +0 -152
- package/lang/translations/de.po +0 -152
- package/lang/translations/el.po +0 -152
- package/lang/translations/en-au.po +0 -152
- package/lang/translations/en-gb.po +0 -152
- package/lang/translations/en.po +0 -152
- package/lang/translations/eo.po +0 -152
- package/lang/translations/es-co.po +0 -152
- package/lang/translations/es.po +0 -152
- package/lang/translations/et.po +0 -152
- package/lang/translations/eu.po +0 -152
- package/lang/translations/fa.po +0 -152
- package/lang/translations/fi.po +0 -152
- package/lang/translations/fr.po +0 -152
- package/lang/translations/gl.po +0 -152
- package/lang/translations/gu.po +0 -152
- package/lang/translations/he.po +0 -152
- package/lang/translations/hi.po +0 -152
- package/lang/translations/hr.po +0 -152
- package/lang/translations/hu.po +0 -152
- package/lang/translations/hy.po +0 -152
- package/lang/translations/id.po +0 -152
- package/lang/translations/it.po +0 -152
- package/lang/translations/ja.po +0 -152
- package/lang/translations/jv.po +0 -152
- package/lang/translations/kk.po +0 -152
- package/lang/translations/km.po +0 -152
- package/lang/translations/kn.po +0 -152
- package/lang/translations/ko.po +0 -152
- package/lang/translations/ku.po +0 -152
- package/lang/translations/lt.po +0 -152
- package/lang/translations/lv.po +0 -152
- package/lang/translations/ms.po +0 -152
- package/lang/translations/nb.po +0 -152
- package/lang/translations/ne.po +0 -152
- package/lang/translations/nl.po +0 -152
- package/lang/translations/no.po +0 -152
- package/lang/translations/oc.po +0 -152
- package/lang/translations/pl.po +0 -152
- package/lang/translations/pt-br.po +0 -152
- package/lang/translations/pt.po +0 -152
- package/lang/translations/ro.po +0 -152
- package/lang/translations/ru.po +0 -152
- package/lang/translations/si.po +0 -152
- package/lang/translations/sk.po +0 -152
- package/lang/translations/sl.po +0 -152
- package/lang/translations/sq.po +0 -152
- package/lang/translations/sr-latn.po +0 -152
- package/lang/translations/sr.po +0 -152
- package/lang/translations/sv.po +0 -152
- package/lang/translations/th.po +0 -152
- package/lang/translations/ti.po +0 -152
- package/lang/translations/tk.po +0 -152
- package/lang/translations/tr.po +0 -152
- package/lang/translations/tt.po +0 -152
- package/lang/translations/ug.po +0 -152
- package/lang/translations/uk.po +0 -152
- package/lang/translations/ur.po +0 -152
- package/lang/translations/uz.po +0 -152
- package/lang/translations/vi.po +0 -152
- package/lang/translations/zh-cn.po +0 -152
- package/lang/translations/zh.po +0 -152
- package/src/augmentation.js +0 -5
- package/src/index.js +0 -67
- package/src/legacyerrors.js +0 -28
- package/src/legacylist/legacyconverters.js +0 -921
- package/src/legacylist/legacyindentcommand.js +0 -111
- package/src/legacylist/legacylistcommand.js +0 -278
- package/src/legacylist/legacylistediting.js +0 -167
- package/src/legacylist/legacylistutils.js +0 -52
- package/src/legacylist/legacyutils.js +0 -357
- package/src/legacylist.js +0 -36
- package/src/legacylistproperties/legacylistpropertiesediting.js +0 -703
- package/src/legacylistproperties/legacylistreversedcommand.js +0 -52
- package/src/legacylistproperties/legacyliststartcommand.js +0 -52
- package/src/legacylistproperties/legacyliststylecommand.js +0 -105
- package/src/legacylistproperties.js +0 -37
- package/src/legacytodolist/legacychecktodolistcommand.js +0 -82
- package/src/legacytodolist/legacytodolistconverters.js +0 -268
- package/src/legacytodolist/legacytodolistediting.js +0 -199
- package/src/legacytodolist.js +0 -37
- package/src/list/adjacentlistssupport.js +0 -87
- package/src/list/converters.js +0 -533
- package/src/list/listcommand.js +0 -176
- package/src/list/listediting.js +0 -696
- package/src/list/listindentcommand.js +0 -136
- package/src/list/listmergecommand.js +0 -182
- package/src/list/listsplitcommand.js +0 -74
- package/src/list/listui.js +0 -42
- package/src/list/listutils.js +0 -68
- package/src/list/utils/listwalker.js +0 -236
- package/src/list/utils/model.js +0 -487
- package/src/list/utils/postfixers.js +0 -131
- package/src/list/utils/view.js +0 -117
- package/src/list/utils.js +0 -51
- package/src/list.js +0 -36
- package/src/listconfig.js +0 -5
- package/src/listformatting/listitemboldintegration.js +0 -88
- package/src/listformatting/listitemfontcolorintegration.js +0 -92
- package/src/listformatting/listitemfontfamilyintegration.js +0 -93
- package/src/listformatting/listitemfontsizeintegration.js +0 -124
- package/src/listformatting/listitemitalicintegration.js +0 -88
- package/src/listformatting.js +0 -248
- package/src/listproperties/converters.js +0 -43
- package/src/listproperties/listpropertiesediting.js +0 -291
- package/src/listproperties/listpropertiesui.js +0 -385
- package/src/listproperties/listpropertiesutils.js +0 -50
- package/src/listproperties/listreversedcommand.js +0 -55
- package/src/listproperties/liststartcommand.js +0 -61
- package/src/listproperties/liststylecommand.js +0 -121
- package/src/listproperties/ui/listpropertiesview.js +0 -318
- package/src/listproperties/utils/config.js +0 -84
- package/src/listproperties/utils/style.js +0 -85
- package/src/listproperties.js +0 -37
- package/src/todolist/checktodolistcommand.js +0 -82
- package/src/todolist/todocheckboxchangeobserver.js +0 -36
- package/src/todolist/todolistediting.js +0 -470
- package/src/todolist/todolistui.js +0 -35
- package/src/todolist.js +0 -37
- package/theme/documentlist.css +0 -8
- package/theme/list.css +0 -40
- package/theme/listformatting.css +0 -66
- package/theme/listproperties.css +0 -10
- package/theme/liststyles.css +0 -8
- package/theme/todolist.css +0 -140
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/legacyerrors.d.ts +0 -0
- /package/{src → dist}/listproperties/utils/config.d.ts +0 -0
- /package/{src → dist}/listproperties/utils/style.d.ts +0 -0
package/src/list/listcommand.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
6
|
-
import { splitListItemBefore, expandListBlocksToCompleteItems, getListItemBlocks, getListItems, removeListAttributes, outdentFollowingItems, ListItemUid, sortBlocks, getSelectedBlockObject, isListItemBlock, canBecomeSimpleListItem } from './utils/model.js';
|
|
7
|
-
/**
|
|
8
|
-
* The list command. It is used by the {@link module:list/list~List list feature}.
|
|
9
|
-
*/
|
|
10
|
-
export class ListCommand extends Command {
|
|
11
|
-
/**
|
|
12
|
-
* The type of the list created by the command.
|
|
13
|
-
*/
|
|
14
|
-
type;
|
|
15
|
-
/**
|
|
16
|
-
* List Walker options that change the range of the list items to be changed when the selection is collapsed within a list item.
|
|
17
|
-
*
|
|
18
|
-
* In a multi-level list, when the selection is collapsed within a list item, instead of changing only the list items of the same list
|
|
19
|
-
* type and current indent level, the entire list structure is changed (all list items at all indent levels of any list type).
|
|
20
|
-
*/
|
|
21
|
-
_listWalkerOptions;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an instance of the command.
|
|
24
|
-
*
|
|
25
|
-
* @param editor The editor instance.
|
|
26
|
-
* @param type List type that will be handled by this command.
|
|
27
|
-
*/
|
|
28
|
-
constructor(editor, type, options = {}) {
|
|
29
|
-
super(editor);
|
|
30
|
-
this.type = type;
|
|
31
|
-
this._listWalkerOptions = options.multiLevel ? {
|
|
32
|
-
higherIndent: true,
|
|
33
|
-
lowerIndent: true,
|
|
34
|
-
sameAttributes: []
|
|
35
|
-
} : undefined;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @inheritDoc
|
|
39
|
-
*/
|
|
40
|
-
refresh() {
|
|
41
|
-
this.value = this._getValue();
|
|
42
|
-
this.isEnabled = this._checkEnabled();
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Executes the list command.
|
|
46
|
-
*
|
|
47
|
-
* @fires execute
|
|
48
|
-
* @fires afterExecute
|
|
49
|
-
* @param options Command options.
|
|
50
|
-
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will try to convert the
|
|
51
|
-
* selected items and potentially the neighbor elements to the proper list items. If set to `false` it will convert selected elements
|
|
52
|
-
* to paragraphs. If not set, the command will toggle selected elements to list items or paragraphs, depending on the selection.
|
|
53
|
-
* @param options.additionalAttributes Additional attributes that are set for list items when the command is executed.
|
|
54
|
-
*/
|
|
55
|
-
execute(options = {}) {
|
|
56
|
-
const model = this.editor.model;
|
|
57
|
-
const document = model.document;
|
|
58
|
-
const selectedBlockObject = getSelectedBlockObject(model);
|
|
59
|
-
const blocks = Array.from(document.selection.getSelectedBlocks())
|
|
60
|
-
.filter(block => model.schema.checkAttribute(block, 'listType') || canBecomeSimpleListItem(block, model.schema));
|
|
61
|
-
// Whether we are turning off some items.
|
|
62
|
-
const turnOff = options.forceValue !== undefined ? !options.forceValue : this.value;
|
|
63
|
-
model.change(writer => {
|
|
64
|
-
if (turnOff) {
|
|
65
|
-
const lastBlock = blocks[blocks.length - 1];
|
|
66
|
-
const listEditing = this.editor.plugins.get('ListEditing');
|
|
67
|
-
const attributeNames = listEditing.getListAttributeNames();
|
|
68
|
-
// Split the first block from the list item.
|
|
69
|
-
const itemBlocks = getListItemBlocks(lastBlock, { direction: 'forward' });
|
|
70
|
-
const changedBlocks = [];
|
|
71
|
-
if (itemBlocks.length > 1) {
|
|
72
|
-
changedBlocks.push(...splitListItemBefore(itemBlocks[1], writer));
|
|
73
|
-
}
|
|
74
|
-
// Strip list attributes.
|
|
75
|
-
changedBlocks.push(...removeListAttributes(blocks, writer, attributeNames));
|
|
76
|
-
// Outdent items following the selected list item.
|
|
77
|
-
changedBlocks.push(...outdentFollowingItems(lastBlock, writer));
|
|
78
|
-
this._fireAfterExecute(changedBlocks);
|
|
79
|
-
}
|
|
80
|
-
// Changing type of list items for a collapsed selection inside a list item.
|
|
81
|
-
else if ((selectedBlockObject || document.selection.isCollapsed) && isListItemBlock(blocks[0])) {
|
|
82
|
-
const changedBlocks = getListItems(selectedBlockObject || blocks[0], this._listWalkerOptions);
|
|
83
|
-
for (const block of changedBlocks) {
|
|
84
|
-
writer.setAttributes({
|
|
85
|
-
...options.additionalAttributes,
|
|
86
|
-
listType: this.type
|
|
87
|
-
}, block);
|
|
88
|
-
}
|
|
89
|
-
this._fireAfterExecute(changedBlocks);
|
|
90
|
-
}
|
|
91
|
-
// Turning on the list items for a non-collapsed selection.
|
|
92
|
-
else {
|
|
93
|
-
const changedBlocks = [];
|
|
94
|
-
for (const block of blocks) {
|
|
95
|
-
// Promote the given block to the list item.
|
|
96
|
-
if (!block.hasAttribute('listType')) {
|
|
97
|
-
// Rename block to a simple list item if this option is enabled.
|
|
98
|
-
if (!block.is('element', 'listItem') && canBecomeSimpleListItem(block, model.schema)) {
|
|
99
|
-
writer.rename(block, 'listItem');
|
|
100
|
-
}
|
|
101
|
-
writer.setAttributes({
|
|
102
|
-
...options.additionalAttributes,
|
|
103
|
-
listIndent: 0,
|
|
104
|
-
listItemId: ListItemUid.next(),
|
|
105
|
-
listType: this.type
|
|
106
|
-
}, block);
|
|
107
|
-
changedBlocks.push(block);
|
|
108
|
-
}
|
|
109
|
-
// Change the type of list item.
|
|
110
|
-
else {
|
|
111
|
-
for (const node of expandListBlocksToCompleteItems(block, { withNested: false })) {
|
|
112
|
-
if (node.getAttribute('listType') != this.type) {
|
|
113
|
-
writer.setAttributes({
|
|
114
|
-
...options.additionalAttributes,
|
|
115
|
-
listType: this.type
|
|
116
|
-
}, node);
|
|
117
|
-
changedBlocks.push(node);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
this._fireAfterExecute(changedBlocks);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Fires the `afterExecute` event.
|
|
128
|
-
*
|
|
129
|
-
* @param changedBlocks The changed list elements.
|
|
130
|
-
*/
|
|
131
|
-
_fireAfterExecute(changedBlocks) {
|
|
132
|
-
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Checks the command's {@link #value}.
|
|
136
|
-
*
|
|
137
|
-
* @returns The current value.
|
|
138
|
-
*/
|
|
139
|
-
_getValue() {
|
|
140
|
-
const selection = this.editor.model.document.selection;
|
|
141
|
-
const blocks = Array.from(selection.getSelectedBlocks());
|
|
142
|
-
if (!blocks.length) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
for (const block of blocks) {
|
|
146
|
-
if (block.getAttribute('listType') != this.type) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Checks whether the command can be enabled in the current context.
|
|
154
|
-
*
|
|
155
|
-
* @returns Whether the command should be enabled.
|
|
156
|
-
*/
|
|
157
|
-
_checkEnabled() {
|
|
158
|
-
const model = this.editor.model;
|
|
159
|
-
const schema = model.schema;
|
|
160
|
-
const selection = model.document.selection;
|
|
161
|
-
const blocks = Array.from(selection.getSelectedBlocks());
|
|
162
|
-
if (!blocks.length) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
// If command value is true it means that we are in list item, so the command should be enabled.
|
|
166
|
-
if (this.value) {
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
for (const block of blocks) {
|
|
170
|
-
if (schema.checkAttribute(block, 'listType') || canBecomeSimpleListItem(block, schema)) {
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
}
|