@ckeditor/ckeditor5-list 39.0.2 → 40.0.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.
Files changed (109) hide show
  1. package/build/list.js +1 -1
  2. package/build/list.js.map +1 -0
  3. package/build/translations/fi.js +1 -1
  4. package/build/translations/pt-br.js +1 -1
  5. package/ckeditor5-metadata.json +44 -0
  6. package/lang/translations/fi.po +1 -1
  7. package/lang/translations/pt-br.po +10 -10
  8. package/package.json +3 -3
  9. package/src/augmentation.d.ts +52 -50
  10. package/src/augmentation.js +5 -5
  11. package/src/documentlist/adjacentlistssupport.d.ts +15 -15
  12. package/src/documentlist/adjacentlistssupport.js +81 -81
  13. package/src/documentlist/converters.d.ts +65 -63
  14. package/src/documentlist/converters.js +441 -354
  15. package/src/documentlist/documentlistcommand.d.ts +80 -80
  16. package/src/documentlist/documentlistcommand.js +150 -145
  17. package/src/documentlist/documentlistediting.d.ts +212 -154
  18. package/src/documentlist/documentlistediting.js +645 -565
  19. package/src/documentlist/documentlistindentcommand.d.ts +62 -62
  20. package/src/documentlist/documentlistindentcommand.js +129 -129
  21. package/src/documentlist/documentlistmergecommand.d.ts +76 -76
  22. package/src/documentlist/documentlistmergecommand.js +174 -174
  23. package/src/documentlist/documentlistsplitcommand.d.ts +67 -67
  24. package/src/documentlist/documentlistsplitcommand.js +70 -70
  25. package/src/documentlist/documentlistutils.d.ts +46 -46
  26. package/src/documentlist/documentlistutils.js +50 -50
  27. package/src/documentlist/utils/listwalker.d.ts +145 -141
  28. package/src/documentlist/utils/listwalker.js +182 -162
  29. package/src/documentlist/utils/model.d.ts +202 -193
  30. package/src/documentlist/utils/model.js +455 -435
  31. package/src/documentlist/utils/postfixers.d.ts +37 -37
  32. package/src/documentlist/utils/postfixers.js +126 -118
  33. package/src/documentlist/utils/view.d.ts +81 -81
  34. package/src/documentlist/utils/view.js +117 -117
  35. package/src/documentlist.d.ts +26 -26
  36. package/src/documentlist.js +30 -30
  37. package/src/documentlistproperties/converters.d.ts +19 -19
  38. package/src/documentlistproperties/converters.js +43 -43
  39. package/src/documentlistproperties/documentlistpropertiesediting.d.ts +88 -88
  40. package/src/documentlistproperties/documentlistpropertiesediting.js +266 -289
  41. package/src/documentlistproperties/documentlistpropertiesutils.d.ts +33 -33
  42. package/src/documentlistproperties/documentlistpropertiesutils.js +44 -44
  43. package/src/documentlistproperties/documentlistreversedcommand.d.ts +36 -36
  44. package/src/documentlistproperties/documentlistreversedcommand.js +55 -55
  45. package/src/documentlistproperties/documentliststartcommand.d.ts +38 -38
  46. package/src/documentlistproperties/documentliststartcommand.js +57 -57
  47. package/src/documentlistproperties/documentliststylecommand.d.ts +72 -72
  48. package/src/documentlistproperties/documentliststylecommand.js +113 -113
  49. package/src/documentlistproperties/utils/style.d.ts +20 -20
  50. package/src/documentlistproperties/utils/style.js +54 -54
  51. package/src/documentlistproperties.d.ts +27 -27
  52. package/src/documentlistproperties.js +31 -31
  53. package/src/index.d.ts +43 -40
  54. package/src/index.js +29 -27
  55. package/src/list/converters.d.ts +196 -196
  56. package/src/list/converters.js +905 -905
  57. package/src/list/indentcommand.d.ts +37 -37
  58. package/src/list/indentcommand.js +107 -107
  59. package/src/list/listcommand.d.ts +55 -55
  60. package/src/list/listcommand.js +274 -274
  61. package/src/list/listediting.d.ts +32 -32
  62. package/src/list/listediting.js +161 -161
  63. package/src/list/listui.d.ts +19 -19
  64. package/src/list/listui.js +32 -32
  65. package/src/list/listutils.d.ts +41 -41
  66. package/src/list/listutils.js +46 -46
  67. package/src/list/utils.d.ts +112 -112
  68. package/src/list/utils.js +374 -374
  69. package/src/list.d.ts +26 -26
  70. package/src/list.js +30 -30
  71. package/src/listconfig.d.ts +132 -122
  72. package/src/listconfig.js +5 -5
  73. package/src/listproperties/listpropertiesediting.d.ts +72 -72
  74. package/src/listproperties/listpropertiesediting.js +696 -696
  75. package/src/listproperties/listpropertiesui.d.ts +23 -23
  76. package/src/listproperties/listpropertiesui.js +277 -277
  77. package/src/listproperties/listreversedcommand.d.ts +38 -38
  78. package/src/listproperties/listreversedcommand.js +52 -52
  79. package/src/listproperties/liststartcommand.d.ts +37 -37
  80. package/src/listproperties/liststartcommand.js +51 -51
  81. package/src/listproperties/liststylecommand.d.ts +67 -67
  82. package/src/listproperties/liststylecommand.js +99 -99
  83. package/src/listproperties/ui/collapsibleview.d.ts +63 -63
  84. package/src/listproperties/ui/collapsibleview.js +89 -89
  85. package/src/listproperties/ui/listpropertiesview.d.ts +157 -157
  86. package/src/listproperties/ui/listpropertiesview.js +299 -299
  87. package/src/listproperties.d.ts +26 -26
  88. package/src/listproperties.js +30 -30
  89. package/src/liststyle.d.ts +28 -28
  90. package/src/liststyle.js +36 -36
  91. package/src/tododocumentlist/checktododocumentlistcommand.d.ts +49 -0
  92. package/src/tododocumentlist/checktododocumentlistcommand.js +82 -0
  93. package/src/tododocumentlist/todocheckboxchangeobserver.d.ts +41 -0
  94. package/src/tododocumentlist/todocheckboxchangeobserver.js +37 -0
  95. package/src/tododocumentlist/tododocumentlistediting.d.ts +38 -0
  96. package/src/tododocumentlist/tododocumentlistediting.js +399 -0
  97. package/src/tododocumentlist.d.ts +27 -0
  98. package/src/tododocumentlist.js +31 -0
  99. package/src/todolist/checktodolistcommand.d.ts +52 -52
  100. package/src/todolist/checktodolistcommand.js +76 -76
  101. package/src/todolist/todolistconverters.d.ts +82 -82
  102. package/src/todolist/todolistconverters.js +260 -260
  103. package/src/todolist/todolistediting.d.ts +39 -39
  104. package/src/todolist/todolistediting.js +161 -161
  105. package/src/todolist/todolistui.d.ts +19 -19
  106. package/src/todolist/todolistui.js +29 -29
  107. package/src/todolist.d.ts +27 -27
  108. package/src/todolist.js +31 -31
  109. package/theme/todolist.css +101 -70
@@ -1,62 +1,62 @@
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/documentlistindentcommand
7
- */
8
- import { Command, type Editor } from 'ckeditor5/src/core';
9
- import type { Element } from 'ckeditor5/src/engine';
10
- /**
11
- * The document list indent command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
12
- */
13
- export default class DocumentListIndentCommand extends Command {
14
- /**
15
- * Determines by how much the command will change the list item's indent attribute.
16
- */
17
- private readonly _direction;
18
- /**
19
- * Creates an instance of the command.
20
- *
21
- * @param editor The editor instance.
22
- * @param indentDirection The direction of indent. If it is equal to `backward`, the command
23
- * will outdent a list item.
24
- */
25
- constructor(editor: Editor, indentDirection: 'forward' | 'backward');
26
- /**
27
- * @inheritDoc
28
- */
29
- refresh(): void;
30
- /**
31
- * Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
32
- *
33
- * @fires execute
34
- * @fires afterExecute
35
- */
36
- execute(): void;
37
- /**
38
- * Fires the `afterExecute` event.
39
- *
40
- * @param changedBlocks The changed list elements.
41
- */
42
- private _fireAfterExecute;
43
- /**
44
- * Checks whether the command can be enabled in the current context.
45
- *
46
- * @returns Whether the command should be enabled.
47
- */
48
- private _checkEnabled;
49
- }
50
- /**
51
- * Event fired by the {@link ~DocumentListIndentCommand#execute} method.
52
- *
53
- * It allows to execute an action after executing the {@link module:list/documentlist/documentlistcommand~DocumentListCommand#execute}
54
- * method, for example adjusting attributes of changed list items.
55
- *
56
- * @internal
57
- * @eventName ~DocumentListIndentCommand#afterExecute
58
- */
59
- export type DocumentListIndentCommandAfterExecuteEvent = {
60
- name: 'afterExecute';
61
- args: [changedBlocks: Array<Element>];
62
- };
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/documentlistindentcommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core';
9
+ import type { Element } from 'ckeditor5/src/engine';
10
+ /**
11
+ * The document list indent command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
12
+ */
13
+ export default class DocumentListIndentCommand extends Command {
14
+ /**
15
+ * Determines by how much the command will change the list item's indent attribute.
16
+ */
17
+ private readonly _direction;
18
+ /**
19
+ * Creates an instance of the command.
20
+ *
21
+ * @param editor The editor instance.
22
+ * @param indentDirection The direction of indent. If it is equal to `backward`, the command
23
+ * will outdent a list item.
24
+ */
25
+ constructor(editor: Editor, indentDirection: 'forward' | 'backward');
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ refresh(): void;
30
+ /**
31
+ * Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
32
+ *
33
+ * @fires execute
34
+ * @fires afterExecute
35
+ */
36
+ execute(): void;
37
+ /**
38
+ * Fires the `afterExecute` event.
39
+ *
40
+ * @param changedBlocks The changed list elements.
41
+ */
42
+ private _fireAfterExecute;
43
+ /**
44
+ * Checks whether the command can be enabled in the current context.
45
+ *
46
+ * @returns Whether the command should be enabled.
47
+ */
48
+ private _checkEnabled;
49
+ }
50
+ /**
51
+ * Event fired by the {@link ~DocumentListIndentCommand#execute} method.
52
+ *
53
+ * It allows to execute an action after executing the {@link module:list/documentlist/documentlistcommand~DocumentListCommand#execute}
54
+ * method, for example adjusting attributes of changed list items.
55
+ *
56
+ * @internal
57
+ * @eventName ~DocumentListIndentCommand#afterExecute
58
+ */
59
+ export type DocumentListIndentCommandAfterExecuteEvent = {
60
+ name: 'afterExecute';
61
+ args: [changedBlocks: Array<Element>];
62
+ };
@@ -1,129 +1,129 @@
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/documentlistindentcommand
7
- */
8
- import { Command } from 'ckeditor5/src/core';
9
- import { expandListBlocksToCompleteItems, indentBlocks, isFirstBlockOfListItem, isListItemBlock, isSingleListItem, outdentBlocksWithMerge, sortBlocks, splitListItemBefore } from './utils/model';
10
- import ListWalker from './utils/listwalker';
11
- /**
12
- * The document list indent command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
13
- */
14
- export default class DocumentListIndentCommand extends Command {
15
- /**
16
- * Creates an instance of the command.
17
- *
18
- * @param editor The editor instance.
19
- * @param indentDirection The direction of indent. If it is equal to `backward`, the command
20
- * will outdent a list item.
21
- */
22
- constructor(editor, indentDirection) {
23
- super(editor);
24
- this._direction = indentDirection;
25
- }
26
- /**
27
- * @inheritDoc
28
- */
29
- refresh() {
30
- this.isEnabled = this._checkEnabled();
31
- }
32
- /**
33
- * Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
34
- *
35
- * @fires execute
36
- * @fires afterExecute
37
- */
38
- execute() {
39
- const model = this.editor.model;
40
- const blocks = getSelectedListBlocks(model.document.selection);
41
- model.change(writer => {
42
- const changedBlocks = [];
43
- // Handle selection contained in the single list item and starting in the following blocks.
44
- if (isSingleListItem(blocks) && !isFirstBlockOfListItem(blocks[0])) {
45
- // Allow increasing indent of following list item blocks.
46
- if (this._direction == 'forward') {
47
- changedBlocks.push(...indentBlocks(blocks, writer));
48
- }
49
- // For indent make sure that indented blocks have a new ID.
50
- // For outdent just split blocks from the list item (give them a new IDs).
51
- changedBlocks.push(...splitListItemBefore(blocks[0], writer));
52
- }
53
- // More than a single list item is selected, or the first block of list item is selected.
54
- else {
55
- // Now just update the attributes of blocks.
56
- if (this._direction == 'forward') {
57
- changedBlocks.push(...indentBlocks(blocks, writer, { expand: true }));
58
- }
59
- else {
60
- changedBlocks.push(...outdentBlocksWithMerge(blocks, writer));
61
- }
62
- }
63
- // Align the list item type to match the previous list item (from the same list).
64
- for (const block of changedBlocks) {
65
- // This block become a plain block (for example a paragraph).
66
- if (!block.hasAttribute('listType')) {
67
- continue;
68
- }
69
- const previousItemBlock = ListWalker.first(block, { sameIndent: true });
70
- if (previousItemBlock) {
71
- writer.setAttribute('listType', previousItemBlock.getAttribute('listType'), block);
72
- }
73
- }
74
- this._fireAfterExecute(changedBlocks);
75
- });
76
- }
77
- /**
78
- * Fires the `afterExecute` event.
79
- *
80
- * @param changedBlocks The changed list elements.
81
- */
82
- _fireAfterExecute(changedBlocks) {
83
- this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
84
- }
85
- /**
86
- * Checks whether the command can be enabled in the current context.
87
- *
88
- * @returns Whether the command should be enabled.
89
- */
90
- _checkEnabled() {
91
- // Check whether any of position's ancestor is a list item.
92
- let blocks = getSelectedListBlocks(this.editor.model.document.selection);
93
- let firstBlock = blocks[0];
94
- // If selection is not in a list item, the command is disabled.
95
- if (!firstBlock) {
96
- return false;
97
- }
98
- // If we are outdenting it is enough to be in list item. Every list item can always be outdented.
99
- if (this._direction == 'backward') {
100
- return true;
101
- }
102
- // A single block of a list item is selected, so it could be indented as a sublist.
103
- if (isSingleListItem(blocks) && !isFirstBlockOfListItem(blocks[0])) {
104
- return true;
105
- }
106
- blocks = expandListBlocksToCompleteItems(blocks);
107
- firstBlock = blocks[0];
108
- // Check if there is any list item before selected items that could become a parent of selected items.
109
- const siblingItem = ListWalker.first(firstBlock, { sameIndent: true });
110
- if (!siblingItem) {
111
- return false;
112
- }
113
- if (siblingItem.getAttribute('listType') == firstBlock.getAttribute('listType')) {
114
- return true;
115
- }
116
- return false;
117
- }
118
- }
119
- /**
120
- * Returns an array of selected blocks truncated to the first non list block element.
121
- */
122
- function getSelectedListBlocks(selection) {
123
- const blocks = Array.from(selection.getSelectedBlocks());
124
- const firstNonListBlockIndex = blocks.findIndex(block => !isListItemBlock(block));
125
- if (firstNonListBlockIndex != -1) {
126
- blocks.length = firstNonListBlockIndex;
127
- }
128
- return blocks;
129
- }
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/documentlistindentcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core';
9
+ import { expandListBlocksToCompleteItems, indentBlocks, isFirstBlockOfListItem, isListItemBlock, isSingleListItem, outdentBlocksWithMerge, sortBlocks, splitListItemBefore } from './utils/model';
10
+ import ListWalker from './utils/listwalker';
11
+ /**
12
+ * The document list indent command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
13
+ */
14
+ export default class DocumentListIndentCommand extends Command {
15
+ /**
16
+ * Creates an instance of the command.
17
+ *
18
+ * @param editor The editor instance.
19
+ * @param indentDirection The direction of indent. If it is equal to `backward`, the command
20
+ * will outdent a list item.
21
+ */
22
+ constructor(editor, indentDirection) {
23
+ super(editor);
24
+ this._direction = indentDirection;
25
+ }
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ refresh() {
30
+ this.isEnabled = this._checkEnabled();
31
+ }
32
+ /**
33
+ * Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
34
+ *
35
+ * @fires execute
36
+ * @fires afterExecute
37
+ */
38
+ execute() {
39
+ const model = this.editor.model;
40
+ const blocks = getSelectedListBlocks(model.document.selection);
41
+ model.change(writer => {
42
+ const changedBlocks = [];
43
+ // Handle selection contained in the single list item and starting in the following blocks.
44
+ if (isSingleListItem(blocks) && !isFirstBlockOfListItem(blocks[0])) {
45
+ // Allow increasing indent of following list item blocks.
46
+ if (this._direction == 'forward') {
47
+ changedBlocks.push(...indentBlocks(blocks, writer));
48
+ }
49
+ // For indent make sure that indented blocks have a new ID.
50
+ // For outdent just split blocks from the list item (give them a new IDs).
51
+ changedBlocks.push(...splitListItemBefore(blocks[0], writer));
52
+ }
53
+ // More than a single list item is selected, or the first block of list item is selected.
54
+ else {
55
+ // Now just update the attributes of blocks.
56
+ if (this._direction == 'forward') {
57
+ changedBlocks.push(...indentBlocks(blocks, writer, { expand: true }));
58
+ }
59
+ else {
60
+ changedBlocks.push(...outdentBlocksWithMerge(blocks, writer));
61
+ }
62
+ }
63
+ // Align the list item type to match the previous list item (from the same list).
64
+ for (const block of changedBlocks) {
65
+ // This block become a plain block (for example a paragraph).
66
+ if (!block.hasAttribute('listType')) {
67
+ continue;
68
+ }
69
+ const previousItemBlock = ListWalker.first(block, { sameIndent: true });
70
+ if (previousItemBlock) {
71
+ writer.setAttribute('listType', previousItemBlock.getAttribute('listType'), block);
72
+ }
73
+ }
74
+ this._fireAfterExecute(changedBlocks);
75
+ });
76
+ }
77
+ /**
78
+ * Fires the `afterExecute` event.
79
+ *
80
+ * @param changedBlocks The changed list elements.
81
+ */
82
+ _fireAfterExecute(changedBlocks) {
83
+ this.fire('afterExecute', sortBlocks(new Set(changedBlocks)));
84
+ }
85
+ /**
86
+ * Checks whether the command can be enabled in the current context.
87
+ *
88
+ * @returns Whether the command should be enabled.
89
+ */
90
+ _checkEnabled() {
91
+ // Check whether any of position's ancestor is a list item.
92
+ let blocks = getSelectedListBlocks(this.editor.model.document.selection);
93
+ let firstBlock = blocks[0];
94
+ // If selection is not in a list item, the command is disabled.
95
+ if (!firstBlock) {
96
+ return false;
97
+ }
98
+ // If we are outdenting it is enough to be in list item. Every list item can always be outdented.
99
+ if (this._direction == 'backward') {
100
+ return true;
101
+ }
102
+ // A single block of a list item is selected, so it could be indented as a sublist.
103
+ if (isSingleListItem(blocks) && !isFirstBlockOfListItem(blocks[0])) {
104
+ return true;
105
+ }
106
+ blocks = expandListBlocksToCompleteItems(blocks);
107
+ firstBlock = blocks[0];
108
+ // Check if there is any list item before selected items that could become a parent of selected items.
109
+ const siblingItem = ListWalker.first(firstBlock, { sameIndent: true });
110
+ if (!siblingItem) {
111
+ return false;
112
+ }
113
+ if (siblingItem.getAttribute('listType') == firstBlock.getAttribute('listType')) {
114
+ return true;
115
+ }
116
+ return false;
117
+ }
118
+ }
119
+ /**
120
+ * Returns an array of selected blocks truncated to the first non list block element.
121
+ */
122
+ function getSelectedListBlocks(selection) {
123
+ const blocks = Array.from(selection.getSelectedBlocks());
124
+ const firstNonListBlockIndex = blocks.findIndex(block => !isListItemBlock(block));
125
+ if (firstNonListBlockIndex != -1) {
126
+ blocks.length = firstNonListBlockIndex;
127
+ }
128
+ return blocks;
129
+ }
@@ -1,76 +1,76 @@
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/documentlistmergecommand
7
- */
8
- import { Command, type Editor } from 'ckeditor5/src/core';
9
- import type { Element } from 'ckeditor5/src/engine';
10
- /**
11
- * The document list merge command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
12
- */
13
- export default class DocumentListMergeCommand extends Command {
14
- /**
15
- * Whether list item should be merged before or after the selected block.
16
- */
17
- private readonly _direction;
18
- /**
19
- * Creates an instance of the command.
20
- *
21
- * @param editor The editor instance.
22
- * @param direction Whether list item should be merged before or after the selected block.
23
- */
24
- constructor(editor: Editor, direction: 'forward' | 'backward');
25
- /**
26
- * @inheritDoc
27
- */
28
- refresh(): void;
29
- /**
30
- * Merges list blocks together (depending on the {@link #constructor}'s `direction` parameter).
31
- *
32
- * @fires execute
33
- * @fires afterExecute
34
- * @param options Command options.
35
- * @param options.shouldMergeOnBlocksContentLevel When set `true`, merging will be performed together
36
- * with {@link module:engine/model/model~Model#deleteContent} to get rid of the inline content in the selection or take advantage
37
- * of the heuristics in `deleteContent()` that helps convert lists into paragraphs in certain cases.
38
- */
39
- execute({ shouldMergeOnBlocksContentLevel }?: {
40
- shouldMergeOnBlocksContentLevel?: boolean;
41
- }): void;
42
- /**
43
- * Fires the `afterExecute` event.
44
- *
45
- * @param changedBlocks The changed list elements.
46
- */
47
- private _fireAfterExecute;
48
- /**
49
- * Checks whether the command can be enabled in the current context.
50
- *
51
- * @returns Whether the command should be enabled.
52
- */
53
- private _checkEnabled;
54
- /**
55
- * Returns the boundary elements the merge should be executed for. These are not necessarily selection's first
56
- * and last position parents but sometimes sibling or even further blocks depending on the context.
57
- *
58
- * @param selection The selection the merge is executed for.
59
- * @param shouldMergeOnBlocksContentLevel When `true`, merge is performed together with
60
- * {@link module:engine/model/model~Model#deleteContent} to remove the inline content within the selection.
61
- */
62
- private _getMergeSubjectElements;
63
- }
64
- /**
65
- * Event fired by the {@link ~DocumentListMergeCommand#execute} method.
66
- *
67
- * It allows to execute an action after executing the {@link module:list/documentlist/documentlistcommand~DocumentListCommand#execute}
68
- * method, for example adjusting attributes of changed list items.
69
- *
70
- * @internal
71
- * @eventName ~DocumentListMergeCommand#afterExecute
72
- */
73
- export type DocumentListMergeCommandAfterExecuteEvent = {
74
- name: 'afterExecute';
75
- args: [changedBlocks: Array<Element>];
76
- };
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/documentlistmergecommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core';
9
+ import type { Element } from 'ckeditor5/src/engine';
10
+ /**
11
+ * The document list merge command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
12
+ */
13
+ export default class DocumentListMergeCommand extends Command {
14
+ /**
15
+ * Whether list item should be merged before or after the selected block.
16
+ */
17
+ private readonly _direction;
18
+ /**
19
+ * Creates an instance of the command.
20
+ *
21
+ * @param editor The editor instance.
22
+ * @param direction Whether list item should be merged before or after the selected block.
23
+ */
24
+ constructor(editor: Editor, direction: 'forward' | 'backward');
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ refresh(): void;
29
+ /**
30
+ * Merges list blocks together (depending on the {@link #constructor}'s `direction` parameter).
31
+ *
32
+ * @fires execute
33
+ * @fires afterExecute
34
+ * @param options Command options.
35
+ * @param options.shouldMergeOnBlocksContentLevel When set `true`, merging will be performed together
36
+ * with {@link module:engine/model/model~Model#deleteContent} to get rid of the inline content in the selection or take advantage
37
+ * of the heuristics in `deleteContent()` that helps convert lists into paragraphs in certain cases.
38
+ */
39
+ execute({ shouldMergeOnBlocksContentLevel }?: {
40
+ shouldMergeOnBlocksContentLevel?: boolean;
41
+ }): void;
42
+ /**
43
+ * Fires the `afterExecute` event.
44
+ *
45
+ * @param changedBlocks The changed list elements.
46
+ */
47
+ private _fireAfterExecute;
48
+ /**
49
+ * Checks whether the command can be enabled in the current context.
50
+ *
51
+ * @returns Whether the command should be enabled.
52
+ */
53
+ private _checkEnabled;
54
+ /**
55
+ * Returns the boundary elements the merge should be executed for. These are not necessarily selection's first
56
+ * and last position parents but sometimes sibling or even further blocks depending on the context.
57
+ *
58
+ * @param selection The selection the merge is executed for.
59
+ * @param shouldMergeOnBlocksContentLevel When `true`, merge is performed together with
60
+ * {@link module:engine/model/model~Model#deleteContent} to remove the inline content within the selection.
61
+ */
62
+ private _getMergeSubjectElements;
63
+ }
64
+ /**
65
+ * Event fired by the {@link ~DocumentListMergeCommand#execute} method.
66
+ *
67
+ * It allows to execute an action after executing the {@link module:list/documentlist/documentlistcommand~DocumentListCommand#execute}
68
+ * method, for example adjusting attributes of changed list items.
69
+ *
70
+ * @internal
71
+ * @eventName ~DocumentListMergeCommand#afterExecute
72
+ */
73
+ export type DocumentListMergeCommandAfterExecuteEvent = {
74
+ name: 'afterExecute';
75
+ args: [changedBlocks: Array<Element>];
76
+ };