@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
|
@@ -1,136 +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
|
-
/**
|
|
6
|
-
* @module list/list/listindentcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { expandListBlocksToCompleteItems, indentBlocks, isFirstBlockOfListItem, isListItemBlock, isSingleListItem, outdentBlocksWithMerge, sortBlocks, splitListItemBefore } from './utils/model.js';
|
|
10
|
-
import { ListWalker } from './utils/listwalker.js';
|
|
11
|
-
/**
|
|
12
|
-
* The document list indent command. It is used by the {@link module:list/list~List list feature}.
|
|
13
|
-
*/
|
|
14
|
-
export class ListIndentCommand extends Command {
|
|
15
|
-
/**
|
|
16
|
-
* Determines by how much the command will change the list item's indent attribute.
|
|
17
|
-
*/
|
|
18
|
-
_direction;
|
|
19
|
-
/**
|
|
20
|
-
* Creates an instance of the command.
|
|
21
|
-
*
|
|
22
|
-
* @param editor The editor instance.
|
|
23
|
-
* @param indentDirection The direction of indent. If it is equal to `backward`, the command
|
|
24
|
-
* will outdent a list item.
|
|
25
|
-
*/
|
|
26
|
-
constructor(editor, indentDirection) {
|
|
27
|
-
super(editor);
|
|
28
|
-
this._direction = indentDirection;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
refresh() {
|
|
34
|
-
this.isEnabled = this._checkEnabled();
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
|
|
38
|
-
*
|
|
39
|
-
* @fires execute
|
|
40
|
-
* @fires afterExecute
|
|
41
|
-
*/
|
|
42
|
-
execute() {
|
|
43
|
-
const editor = this.editor;
|
|
44
|
-
const model = editor.model;
|
|
45
|
-
const blocks = getSelectedListBlocks(model.document.selection);
|
|
46
|
-
const listEditing = editor.plugins.get('ListEditing');
|
|
47
|
-
const attributeNames = listEditing.getListAttributeNames();
|
|
48
|
-
model.change(writer => {
|
|
49
|
-
const changedBlocks = [];
|
|
50
|
-
// Handle selection contained in the single list item and starting in the following blocks.
|
|
51
|
-
if (isSingleListItem(blocks) && !isFirstBlockOfListItem(blocks[0])) {
|
|
52
|
-
// Allow increasing indent of following list item blocks.
|
|
53
|
-
if (this._direction == 'forward') {
|
|
54
|
-
changedBlocks.push(...indentBlocks(blocks, writer, { attributeNames }));
|
|
55
|
-
}
|
|
56
|
-
// For indent make sure that indented blocks have a new ID.
|
|
57
|
-
// For outdent just split blocks from the list item (give them a new IDs).
|
|
58
|
-
changedBlocks.push(...splitListItemBefore(blocks[0], writer));
|
|
59
|
-
}
|
|
60
|
-
// More than a single list item is selected, or the first block of list item is selected.
|
|
61
|
-
else {
|
|
62
|
-
// Now just update the attributes of blocks.
|
|
63
|
-
if (this._direction == 'forward') {
|
|
64
|
-
changedBlocks.push(...indentBlocks(blocks, writer, { expand: true, attributeNames }));
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
changedBlocks.push(...outdentBlocksWithMerge(blocks, writer, { attributeNames }));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Align the list item type to match the previous list item (from the same list).
|
|
71
|
-
for (const block of changedBlocks) {
|
|
72
|
-
// This block become a plain block (for example a paragraph).
|
|
73
|
-
if (!block.hasAttribute('listType')) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const previousItemBlock = ListWalker.first(block, { sameIndent: true });
|
|
77
|
-
if (previousItemBlock) {
|
|
78
|
-
writer.setAttribute('listType', previousItemBlock.getAttribute('listType'), block);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
this._fireAfterExecute(changedBlocks);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Fires the `afterExecute` event.
|
|
86
|
-
*
|
|
87
|
-
* @param changedBlocks The changed list elements.
|
|
88
|
-
*/
|
|
89
|
-
_fireAfterExecute(changedBlocks) {
|
|
90
|
-
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Checks whether the command can be enabled in the current context.
|
|
94
|
-
*
|
|
95
|
-
* @returns Whether the command should be enabled.
|
|
96
|
-
*/
|
|
97
|
-
_checkEnabled() {
|
|
98
|
-
// Check whether any of position's ancestor is a list item.
|
|
99
|
-
let blocks = getSelectedListBlocks(this.editor.model.document.selection);
|
|
100
|
-
let firstBlock = blocks[0];
|
|
101
|
-
// If selection is not in a list item, the command is disabled.
|
|
102
|
-
if (!firstBlock) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
// If we are outdenting it is enough to be in list item. Every list item can always be outdented.
|
|
106
|
-
if (this._direction == 'backward') {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
// A single block of a list item is selected, so it could be indented as a sublist.
|
|
110
|
-
if (isSingleListItem(blocks) && !isFirstBlockOfListItem(blocks[0])) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
blocks = expandListBlocksToCompleteItems(blocks);
|
|
114
|
-
firstBlock = blocks[0];
|
|
115
|
-
// Check if there is any list item before selected items that could become a parent of selected items.
|
|
116
|
-
const siblingItem = ListWalker.first(firstBlock, { sameIndent: true });
|
|
117
|
-
if (!siblingItem) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
if (siblingItem.getAttribute('listType') == firstBlock.getAttribute('listType')) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Returns an array of selected blocks truncated to the first non list block element.
|
|
128
|
-
*/
|
|
129
|
-
function getSelectedListBlocks(selection) {
|
|
130
|
-
const blocks = Array.from(selection.getSelectedBlocks());
|
|
131
|
-
const firstNonListBlockIndex = blocks.findIndex(block => !isListItemBlock(block));
|
|
132
|
-
if (firstNonListBlockIndex != -1) {
|
|
133
|
-
blocks.length = firstNonListBlockIndex;
|
|
134
|
-
}
|
|
135
|
-
return blocks;
|
|
136
|
-
}
|
|
@@ -1,182 +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
|
-
/**
|
|
6
|
-
* @module list/list/listmergecommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { getNestedListBlocks, indentBlocks, sortBlocks, isFirstBlockOfListItem, mergeListItemBefore, isSingleListItem, getSelectedBlockObject, isListItemBlock } from './utils/model.js';
|
|
10
|
-
import { ListWalker } from './utils/listwalker.js';
|
|
11
|
-
/**
|
|
12
|
-
* The document list merge command. It is used by the {@link module:list/list~List list feature}.
|
|
13
|
-
*/
|
|
14
|
-
export class ListMergeCommand extends Command {
|
|
15
|
-
/**
|
|
16
|
-
* Whether list item should be merged before or after the selected block.
|
|
17
|
-
*/
|
|
18
|
-
_direction;
|
|
19
|
-
/**
|
|
20
|
-
* Creates an instance of the command.
|
|
21
|
-
*
|
|
22
|
-
* @param editor The editor instance.
|
|
23
|
-
* @param direction Whether list item should be merged before or after the selected block.
|
|
24
|
-
*/
|
|
25
|
-
constructor(editor, direction) {
|
|
26
|
-
super(editor);
|
|
27
|
-
this._direction = direction;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
refresh() {
|
|
33
|
-
this.isEnabled = this._checkEnabled();
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Merges list blocks together (depending on the {@link #constructor}'s `direction` parameter).
|
|
37
|
-
*
|
|
38
|
-
* @fires execute
|
|
39
|
-
* @fires afterExecute
|
|
40
|
-
* @param options Command options.
|
|
41
|
-
* @param options.shouldMergeOnBlocksContentLevel When set `true`, merging will be performed together
|
|
42
|
-
* with {@link module:engine/model/model~Model#deleteContent} to get rid of the inline content in the selection or take advantage
|
|
43
|
-
* of the heuristics in `deleteContent()` that helps convert lists into paragraphs in certain cases.
|
|
44
|
-
*/
|
|
45
|
-
execute({ shouldMergeOnBlocksContentLevel = false } = {}) {
|
|
46
|
-
const editor = this.editor;
|
|
47
|
-
const model = editor.model;
|
|
48
|
-
const selection = model.document.selection;
|
|
49
|
-
const changedBlocks = [];
|
|
50
|
-
const listEditing = editor.plugins.get('ListEditing');
|
|
51
|
-
const attributeNames = listEditing.getListAttributeNames();
|
|
52
|
-
model.change(writer => {
|
|
53
|
-
const { firstElement, lastElement } = this._getMergeSubjectElements(selection, shouldMergeOnBlocksContentLevel);
|
|
54
|
-
const firstIndent = firstElement.getAttribute('listIndent') || 0;
|
|
55
|
-
const lastIndent = lastElement.getAttribute('listIndent');
|
|
56
|
-
const lastElementId = lastElement.getAttribute('listItemId');
|
|
57
|
-
if (firstIndent != lastIndent) {
|
|
58
|
-
const nestedLastElementBlocks = getNestedListBlocks(lastElement);
|
|
59
|
-
changedBlocks.push(...indentBlocks([lastElement, ...nestedLastElementBlocks], writer, {
|
|
60
|
-
indentBy: firstIndent - lastIndent,
|
|
61
|
-
// If outdenting, the entire sub-tree that follows must be included.
|
|
62
|
-
expand: firstIndent < lastIndent,
|
|
63
|
-
attributeNames
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
if (shouldMergeOnBlocksContentLevel) {
|
|
67
|
-
let sel = selection;
|
|
68
|
-
if (selection.isCollapsed) {
|
|
69
|
-
sel = writer.createSelection(writer.createRange(writer.createPositionAt(firstElement, 'end'), writer.createPositionAt(lastElement, 0)));
|
|
70
|
-
}
|
|
71
|
-
// Delete selected content. Replace entire content only for non-collapsed selection.
|
|
72
|
-
model.deleteContent(sel, { doNotResetEntireContent: selection.isCollapsed });
|
|
73
|
-
// Get the last "touched" element after deleteContent call (can't use the lastElement because
|
|
74
|
-
// it could get merged into the firstElement while deleting content).
|
|
75
|
-
const lastElementAfterDelete = sel.getLastPosition().parent;
|
|
76
|
-
// Check if the element after it was in the same list item and adjust it if needed.
|
|
77
|
-
const nextSibling = lastElementAfterDelete.nextSibling;
|
|
78
|
-
changedBlocks.push(lastElementAfterDelete);
|
|
79
|
-
if (nextSibling && nextSibling !== lastElement && nextSibling.getAttribute('listItemId') == lastElementId) {
|
|
80
|
-
changedBlocks.push(...mergeListItemBefore(nextSibling, lastElementAfterDelete, writer));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
changedBlocks.push(...mergeListItemBefore(lastElement, firstElement, writer));
|
|
85
|
-
}
|
|
86
|
-
this._fireAfterExecute(changedBlocks);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Fires the `afterExecute` event.
|
|
91
|
-
*
|
|
92
|
-
* @param changedBlocks The changed list elements.
|
|
93
|
-
*/
|
|
94
|
-
_fireAfterExecute(changedBlocks) {
|
|
95
|
-
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Checks whether the command can be enabled in the current context.
|
|
99
|
-
*
|
|
100
|
-
* @returns Whether the command should be enabled.
|
|
101
|
-
*/
|
|
102
|
-
_checkEnabled() {
|
|
103
|
-
const model = this.editor.model;
|
|
104
|
-
const selection = model.document.selection;
|
|
105
|
-
const selectedBlockObject = getSelectedBlockObject(model);
|
|
106
|
-
if (selection.isCollapsed || selectedBlockObject) {
|
|
107
|
-
const positionParent = selectedBlockObject || selection.getFirstPosition().parent;
|
|
108
|
-
if (!isListItemBlock(positionParent)) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
const siblingNode = this._direction == 'backward' ?
|
|
112
|
-
positionParent.previousSibling :
|
|
113
|
-
positionParent.nextSibling;
|
|
114
|
-
if (!siblingNode) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
if (isSingleListItem([positionParent, siblingNode])) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const lastPosition = selection.getLastPosition();
|
|
123
|
-
const firstPosition = selection.getFirstPosition();
|
|
124
|
-
// If deleting within a single block of a list item, there's no need to merge anything.
|
|
125
|
-
// The default delete should be executed instead.
|
|
126
|
-
if (lastPosition.parent === firstPosition.parent) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
if (!isListItemBlock(lastPosition.parent)) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Returns the boundary elements the merge should be executed for. These are not necessarily selection's first
|
|
137
|
-
* and last position parents but sometimes sibling or even further blocks depending on the context.
|
|
138
|
-
*
|
|
139
|
-
* @param selection The selection the merge is executed for.
|
|
140
|
-
* @param shouldMergeOnBlocksContentLevel When `true`, merge is performed together with
|
|
141
|
-
* {@link module:engine/model/model~Model#deleteContent} to remove the inline content within the selection.
|
|
142
|
-
*/
|
|
143
|
-
_getMergeSubjectElements(selection, shouldMergeOnBlocksContentLevel) {
|
|
144
|
-
const model = this.editor.model;
|
|
145
|
-
const selectedBlockObject = getSelectedBlockObject(model);
|
|
146
|
-
let firstElement, lastElement;
|
|
147
|
-
if (selection.isCollapsed || selectedBlockObject) {
|
|
148
|
-
const positionParent = selectedBlockObject || selection.getFirstPosition().parent;
|
|
149
|
-
const isFirstBlock = isFirstBlockOfListItem(positionParent);
|
|
150
|
-
if (this._direction == 'backward') {
|
|
151
|
-
lastElement = positionParent;
|
|
152
|
-
if (isFirstBlock && !shouldMergeOnBlocksContentLevel) {
|
|
153
|
-
// For the "c" as an anchorElement:
|
|
154
|
-
// * a
|
|
155
|
-
// * b
|
|
156
|
-
// * [c] <-- this block should be merged with "a"
|
|
157
|
-
// It should find "a" element to merge with:
|
|
158
|
-
// * a
|
|
159
|
-
// * b
|
|
160
|
-
// c
|
|
161
|
-
firstElement = ListWalker.first(positionParent, { sameIndent: true, lowerIndent: true });
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
firstElement = positionParent.previousSibling;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
// In case of the forward merge there is no case as above, just merge with next sibling.
|
|
169
|
-
firstElement = positionParent;
|
|
170
|
-
lastElement = positionParent.nextSibling;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
firstElement = selection.getFirstPosition().parent;
|
|
175
|
-
lastElement = selection.getLastPosition().parent;
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
firstElement: firstElement,
|
|
179
|
-
lastElement: lastElement
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
}
|
|
@@ -1,74 +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 { isFirstBlockOfListItem, isListItemBlock, sortBlocks, splitListItemBefore } from './utils/model.js';
|
|
7
|
-
/**
|
|
8
|
-
* The document list split command that splits the list item at the selection.
|
|
9
|
-
*
|
|
10
|
-
* It is used by the {@link module:list/list~List list feature}.
|
|
11
|
-
*/
|
|
12
|
-
export class ListSplitCommand extends Command {
|
|
13
|
-
/**
|
|
14
|
-
* Whether list item should be split before or after the selected block.
|
|
15
|
-
*/
|
|
16
|
-
_direction;
|
|
17
|
-
/**
|
|
18
|
-
* Creates an instance of the command.
|
|
19
|
-
*
|
|
20
|
-
* @param editor The editor instance.
|
|
21
|
-
* @param direction Whether list item should be split before or after the selected block.
|
|
22
|
-
*/
|
|
23
|
-
constructor(editor, direction) {
|
|
24
|
-
super(editor);
|
|
25
|
-
this._direction = direction;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
refresh() {
|
|
31
|
-
this.isEnabled = this._checkEnabled();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Splits the list item at the selection.
|
|
35
|
-
*
|
|
36
|
-
* @fires execute
|
|
37
|
-
* @fires afterExecute
|
|
38
|
-
*/
|
|
39
|
-
execute() {
|
|
40
|
-
const editor = this.editor;
|
|
41
|
-
editor.model.change(writer => {
|
|
42
|
-
const changedBlocks = splitListItemBefore(this._getStartBlock(), writer);
|
|
43
|
-
this._fireAfterExecute(changedBlocks);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Fires the `afterExecute` event.
|
|
48
|
-
*
|
|
49
|
-
* @param changedBlocks The changed list elements.
|
|
50
|
-
*/
|
|
51
|
-
_fireAfterExecute(changedBlocks) {
|
|
52
|
-
this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Checks whether the command can be enabled in the current context.
|
|
56
|
-
*
|
|
57
|
-
* @returns Whether the command should be enabled.
|
|
58
|
-
*/
|
|
59
|
-
_checkEnabled() {
|
|
60
|
-
const selection = this.editor.model.document.selection;
|
|
61
|
-
const block = this._getStartBlock();
|
|
62
|
-
return selection.isCollapsed &&
|
|
63
|
-
isListItemBlock(block) &&
|
|
64
|
-
!isFirstBlockOfListItem(block);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Returns the model element that is the main focus of the command (according to the current selection and command direction).
|
|
68
|
-
*/
|
|
69
|
-
_getStartBlock() {
|
|
70
|
-
const doc = this.editor.model.document;
|
|
71
|
-
const positionParent = doc.selection.getFirstPosition().parent;
|
|
72
|
-
return (this._direction == 'before' ? positionParent : positionParent.nextSibling);
|
|
73
|
-
}
|
|
74
|
-
}
|
package/src/list/listui.js
DELETED
|
@@ -1,42 +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
|
-
/**
|
|
6
|
-
* @module list/list/listui
|
|
7
|
-
*/
|
|
8
|
-
import { createUIComponents } from './utils.js';
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
-
import { IconBulletedList, IconNumberedList } from 'ckeditor5/src/icons.js';
|
|
11
|
-
/**
|
|
12
|
-
* The list UI feature. It introduces the `'numberedList'` and `'bulletedList'` buttons that
|
|
13
|
-
* allow to convert paragraphs to and from list items and indent or outdent them.
|
|
14
|
-
*/
|
|
15
|
-
export class ListUI extends Plugin {
|
|
16
|
-
/**
|
|
17
|
-
* @inheritDoc
|
|
18
|
-
*/
|
|
19
|
-
static get pluginName() {
|
|
20
|
-
return 'ListUI';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
static get isOfficialPlugin() {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
init() {
|
|
32
|
-
const t = this.editor.t;
|
|
33
|
-
// Create button numberedList.
|
|
34
|
-
if (!this.editor.ui.componentFactory.has('numberedList')) {
|
|
35
|
-
createUIComponents(this.editor, 'numberedList', t('Numbered List'), IconNumberedList);
|
|
36
|
-
}
|
|
37
|
-
// Create button bulletedList.
|
|
38
|
-
if (!this.editor.ui.componentFactory.has('bulletedList')) {
|
|
39
|
-
createUIComponents(this.editor, 'bulletedList', t('Bulleted List'), IconBulletedList);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
package/src/list/listutils.js
DELETED
|
@@ -1,68 +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 { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import { expandListBlocksToCompleteItems, expandListBlocksToCompleteList, isFirstBlockOfListItem, isFirstListItemInList, isListItemBlock, isNumberedListType } from './utils/model.js';
|
|
7
|
-
/**
|
|
8
|
-
* A set of helpers related to document lists.
|
|
9
|
-
*/
|
|
10
|
-
export class ListUtils extends Plugin {
|
|
11
|
-
/**
|
|
12
|
-
* @inheritDoc
|
|
13
|
-
*/
|
|
14
|
-
static get pluginName() {
|
|
15
|
-
return 'ListUtils';
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @inheritDoc
|
|
19
|
-
*/
|
|
20
|
-
static get isOfficialPlugin() {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
25
|
-
*
|
|
26
|
-
* @param blocks The list of selected blocks.
|
|
27
|
-
*/
|
|
28
|
-
expandListBlocksToCompleteList(blocks) {
|
|
29
|
-
return expandListBlocksToCompleteList(blocks);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Check if the given block is the first in the list item.
|
|
33
|
-
*
|
|
34
|
-
* @param listBlock The list block element.
|
|
35
|
-
*/
|
|
36
|
-
isFirstBlockOfListItem(listBlock) {
|
|
37
|
-
return isFirstBlockOfListItem(listBlock);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Returns true if the given model node is a list item block.
|
|
41
|
-
*
|
|
42
|
-
* @param node A model node.
|
|
43
|
-
*/
|
|
44
|
-
isListItemBlock(node) {
|
|
45
|
-
return isListItemBlock(node);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
49
|
-
*
|
|
50
|
-
* @param blocks The list of selected blocks.
|
|
51
|
-
* @param options.withNested Whether should include nested list items.
|
|
52
|
-
*/
|
|
53
|
-
expandListBlocksToCompleteItems(blocks, options = {}) {
|
|
54
|
-
return expandListBlocksToCompleteItems(blocks, options);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Returns true if listType is of type `numbered` or `customNumbered`.
|
|
58
|
-
*/
|
|
59
|
-
isNumberedListType(listType) {
|
|
60
|
-
return isNumberedListType(listType);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns true if the given list item is the first item in the list.
|
|
64
|
-
*/
|
|
65
|
-
isFirstListItemInList(listItem) {
|
|
66
|
-
return isFirstListItemInList(listItem);
|
|
67
|
-
}
|
|
68
|
-
}
|