@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.
- package/build/list.js +1 -1
- package/build/list.js.map +1 -0
- package/build/translations/fi.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/ckeditor5-metadata.json +44 -0
- package/lang/translations/fi.po +1 -1
- package/lang/translations/pt-br.po +10 -10
- package/package.json +3 -3
- package/src/augmentation.d.ts +52 -50
- package/src/augmentation.js +5 -5
- package/src/documentlist/adjacentlistssupport.d.ts +15 -15
- package/src/documentlist/adjacentlistssupport.js +81 -81
- package/src/documentlist/converters.d.ts +65 -63
- package/src/documentlist/converters.js +441 -354
- package/src/documentlist/documentlistcommand.d.ts +80 -80
- package/src/documentlist/documentlistcommand.js +150 -145
- package/src/documentlist/documentlistediting.d.ts +212 -154
- package/src/documentlist/documentlistediting.js +645 -565
- package/src/documentlist/documentlistindentcommand.d.ts +62 -62
- package/src/documentlist/documentlistindentcommand.js +129 -129
- package/src/documentlist/documentlistmergecommand.d.ts +76 -76
- package/src/documentlist/documentlistmergecommand.js +174 -174
- package/src/documentlist/documentlistsplitcommand.d.ts +67 -67
- package/src/documentlist/documentlistsplitcommand.js +70 -70
- package/src/documentlist/documentlistutils.d.ts +46 -46
- package/src/documentlist/documentlistutils.js +50 -50
- package/src/documentlist/utils/listwalker.d.ts +145 -141
- package/src/documentlist/utils/listwalker.js +182 -162
- package/src/documentlist/utils/model.d.ts +202 -193
- package/src/documentlist/utils/model.js +455 -435
- package/src/documentlist/utils/postfixers.d.ts +37 -37
- package/src/documentlist/utils/postfixers.js +126 -118
- package/src/documentlist/utils/view.d.ts +81 -81
- package/src/documentlist/utils/view.js +117 -117
- package/src/documentlist.d.ts +26 -26
- package/src/documentlist.js +30 -30
- package/src/documentlistproperties/converters.d.ts +19 -19
- package/src/documentlistproperties/converters.js +43 -43
- package/src/documentlistproperties/documentlistpropertiesediting.d.ts +88 -88
- package/src/documentlistproperties/documentlistpropertiesediting.js +266 -289
- package/src/documentlistproperties/documentlistpropertiesutils.d.ts +33 -33
- package/src/documentlistproperties/documentlistpropertiesutils.js +44 -44
- package/src/documentlistproperties/documentlistreversedcommand.d.ts +36 -36
- package/src/documentlistproperties/documentlistreversedcommand.js +55 -55
- package/src/documentlistproperties/documentliststartcommand.d.ts +38 -38
- package/src/documentlistproperties/documentliststartcommand.js +57 -57
- package/src/documentlistproperties/documentliststylecommand.d.ts +72 -72
- package/src/documentlistproperties/documentliststylecommand.js +113 -113
- package/src/documentlistproperties/utils/style.d.ts +20 -20
- package/src/documentlistproperties/utils/style.js +54 -54
- package/src/documentlistproperties.d.ts +27 -27
- package/src/documentlistproperties.js +31 -31
- package/src/index.d.ts +43 -40
- package/src/index.js +29 -27
- package/src/list/converters.d.ts +196 -196
- package/src/list/converters.js +905 -905
- package/src/list/indentcommand.d.ts +37 -37
- package/src/list/indentcommand.js +107 -107
- package/src/list/listcommand.d.ts +55 -55
- package/src/list/listcommand.js +274 -274
- package/src/list/listediting.d.ts +32 -32
- package/src/list/listediting.js +161 -161
- package/src/list/listui.d.ts +19 -19
- package/src/list/listui.js +32 -32
- package/src/list/listutils.d.ts +41 -41
- package/src/list/listutils.js +46 -46
- package/src/list/utils.d.ts +112 -112
- package/src/list/utils.js +374 -374
- package/src/list.d.ts +26 -26
- package/src/list.js +30 -30
- package/src/listconfig.d.ts +132 -122
- package/src/listconfig.js +5 -5
- package/src/listproperties/listpropertiesediting.d.ts +72 -72
- package/src/listproperties/listpropertiesediting.js +696 -696
- package/src/listproperties/listpropertiesui.d.ts +23 -23
- package/src/listproperties/listpropertiesui.js +277 -277
- package/src/listproperties/listreversedcommand.d.ts +38 -38
- package/src/listproperties/listreversedcommand.js +52 -52
- package/src/listproperties/liststartcommand.d.ts +37 -37
- package/src/listproperties/liststartcommand.js +51 -51
- package/src/listproperties/liststylecommand.d.ts +67 -67
- package/src/listproperties/liststylecommand.js +99 -99
- package/src/listproperties/ui/collapsibleview.d.ts +63 -63
- package/src/listproperties/ui/collapsibleview.js +89 -89
- package/src/listproperties/ui/listpropertiesview.d.ts +157 -157
- package/src/listproperties/ui/listpropertiesview.js +299 -299
- package/src/listproperties.d.ts +26 -26
- package/src/listproperties.js +30 -30
- package/src/liststyle.d.ts +28 -28
- package/src/liststyle.js +36 -36
- package/src/tododocumentlist/checktododocumentlistcommand.d.ts +49 -0
- package/src/tododocumentlist/checktododocumentlistcommand.js +82 -0
- package/src/tododocumentlist/todocheckboxchangeobserver.d.ts +41 -0
- package/src/tododocumentlist/todocheckboxchangeobserver.js +37 -0
- package/src/tododocumentlist/tododocumentlistediting.d.ts +38 -0
- package/src/tododocumentlist/tododocumentlistediting.js +399 -0
- package/src/tododocumentlist.d.ts +27 -0
- package/src/tododocumentlist.js +31 -0
- package/src/todolist/checktodolistcommand.d.ts +52 -52
- package/src/todolist/checktodolistcommand.js +76 -76
- package/src/todolist/todolistconverters.d.ts +82 -82
- package/src/todolist/todolistconverters.js +260 -260
- package/src/todolist/todolistediting.d.ts +39 -39
- package/src/todolist/todolistediting.js +161 -161
- package/src/todolist/todolistui.d.ts +19 -19
- package/src/todolist/todolistui.js +29 -29
- package/src/todolist.d.ts +27 -27
- package/src/todolist.js +31 -31
- package/theme/todolist.css +101 -70
|
@@ -1,44 +1,44 @@
|
|
|
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/documentlistpropertiesutils
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import { getAllSupportedStyleTypes, getListStyleTypeFromTypeAttribute, getListTypeFromListStyleType, getTypeAttributeFromListStyleType } from './utils/style';
|
|
10
|
-
/**
|
|
11
|
-
* A set of helpers related to document lists.
|
|
12
|
-
*/
|
|
13
|
-
export default class DocumentListPropertiesUtils extends Plugin {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
static get pluginName() {
|
|
18
|
-
return 'DocumentListPropertiesUtils';
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Gets all the style types supported by given list type.
|
|
22
|
-
*/
|
|
23
|
-
getAllSupportedStyleTypes() {
|
|
24
|
-
return getAllSupportedStyleTypes();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
28
|
-
*/
|
|
29
|
-
getListTypeFromListStyleType(listStyleType) {
|
|
30
|
-
return getListTypeFromListStyleType(listStyleType);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
34
|
-
*/
|
|
35
|
-
getListStyleTypeFromTypeAttribute(value) {
|
|
36
|
-
return getListStyleTypeFromTypeAttribute(value);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
40
|
-
*/
|
|
41
|
-
getTypeAttributeFromListStyleType(value) {
|
|
42
|
-
return getTypeAttributeFromListStyleType(value);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
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/documentlistpropertiesutils
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import { getAllSupportedStyleTypes, getListStyleTypeFromTypeAttribute, getListTypeFromListStyleType, getTypeAttributeFromListStyleType } from './utils/style';
|
|
10
|
+
/**
|
|
11
|
+
* A set of helpers related to document lists.
|
|
12
|
+
*/
|
|
13
|
+
export default class DocumentListPropertiesUtils extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName() {
|
|
18
|
+
return 'DocumentListPropertiesUtils';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets all the style types supported by given list type.
|
|
22
|
+
*/
|
|
23
|
+
getAllSupportedStyleTypes() {
|
|
24
|
+
return getAllSupportedStyleTypes();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
28
|
+
*/
|
|
29
|
+
getListTypeFromListStyleType(listStyleType) {
|
|
30
|
+
return getListTypeFromListStyleType(listStyleType);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
34
|
+
*/
|
|
35
|
+
getListStyleTypeFromTypeAttribute(value) {
|
|
36
|
+
return getListStyleTypeFromTypeAttribute(value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
40
|
+
*/
|
|
41
|
+
getTypeAttributeFromListStyleType(value) {
|
|
42
|
+
return getTypeAttributeFromListStyleType(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
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
|
+
/**
|
|
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 +1,55 @@
|
|
|
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
|
+
/**
|
|
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,38 +1,38 @@
|
|
|
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
|
-
/**
|
|
10
|
-
* The list start index command. It changes the `listStart` attribute of the selected list items,
|
|
11
|
-
* letting the user to choose the starting point of an ordered list.
|
|
12
|
-
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
13
|
-
*/
|
|
14
|
-
export default class DocumentListStartCommand extends Command {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
value: number | null;
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
refresh(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Executes the command.
|
|
25
|
-
*
|
|
26
|
-
* @fires execute
|
|
27
|
-
* @param options.startIndex The list start index.
|
|
28
|
-
*/
|
|
29
|
-
execute({ startIndex }?: {
|
|
30
|
-
startIndex?: number;
|
|
31
|
-
}): void;
|
|
32
|
-
/**
|
|
33
|
-
* Checks the command's {@link #value}.
|
|
34
|
-
*
|
|
35
|
-
* @returns The current value.
|
|
36
|
-
*/
|
|
37
|
-
private _getValue;
|
|
38
|
-
}
|
|
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
|
+
/**
|
|
10
|
+
* The list start index command. It changes the `listStart` attribute of the selected list items,
|
|
11
|
+
* letting the user to choose the starting point of an ordered list.
|
|
12
|
+
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
13
|
+
*/
|
|
14
|
+
export default class DocumentListStartCommand extends Command {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
value: number | null;
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
refresh(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Executes the command.
|
|
25
|
+
*
|
|
26
|
+
* @fires execute
|
|
27
|
+
* @param options.startIndex The list start index.
|
|
28
|
+
*/
|
|
29
|
+
execute({ startIndex }?: {
|
|
30
|
+
startIndex?: number;
|
|
31
|
+
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* Checks the command's {@link #value}.
|
|
34
|
+
*
|
|
35
|
+
* @returns The current value.
|
|
36
|
+
*/
|
|
37
|
+
private _getValue;
|
|
38
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
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/documentliststylecommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
9
|
-
/**
|
|
10
|
-
* The list style command. It changes `listStyle` attribute of the selected list items,
|
|
11
|
-
* letting the user choose styles for the list item markers.
|
|
12
|
-
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
13
|
-
*/
|
|
14
|
-
export default class DocumentListStyleCommand extends Command {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
value: string | null;
|
|
19
|
-
/**
|
|
20
|
-
* The default type of the list style.
|
|
21
|
-
*/
|
|
22
|
-
readonly defaultType: string;
|
|
23
|
-
/**
|
|
24
|
-
* The list of supported style types by this command.
|
|
25
|
-
*/
|
|
26
|
-
private _supportedTypes;
|
|
27
|
-
/**
|
|
28
|
-
* Creates an instance of the command.
|
|
29
|
-
*
|
|
30
|
-
* @param editor The editor instance.
|
|
31
|
-
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
32
|
-
* the command execution.
|
|
33
|
-
* @param supportedTypes The list of supported style types by this command.
|
|
34
|
-
*/
|
|
35
|
-
constructor(editor: Editor, defaultType: string, supportedTypes?: Array<string>);
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
refresh(): void;
|
|
40
|
-
/**
|
|
41
|
-
* Executes the command.
|
|
42
|
-
*
|
|
43
|
-
* @fires execute
|
|
44
|
-
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
45
|
-
* style will be applied.
|
|
46
|
-
*/
|
|
47
|
-
execute(options?: {
|
|
48
|
-
type?: string | null;
|
|
49
|
-
}): void;
|
|
50
|
-
/**
|
|
51
|
-
* Checks if the given style type is supported by this plugin.
|
|
52
|
-
*/
|
|
53
|
-
isStyleTypeSupported(value: string): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Checks the command's {@link #value}.
|
|
56
|
-
*
|
|
57
|
-
* @returns The current value.
|
|
58
|
-
*/
|
|
59
|
-
private _getValue;
|
|
60
|
-
/**
|
|
61
|
-
* Checks whether the command can be enabled in the current context.
|
|
62
|
-
*
|
|
63
|
-
* @returns Whether the command should be enabled.
|
|
64
|
-
*/
|
|
65
|
-
private _checkEnabled;
|
|
66
|
-
/**
|
|
67
|
-
* Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
|
|
68
|
-
*
|
|
69
|
-
* @param options.type The type of the list style. If `null` is specified, the function does nothing.
|
|
70
|
-
*/
|
|
71
|
-
private _tryToConvertItemsToList;
|
|
72
|
-
}
|
|
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/documentliststylecommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The list style command. It changes `listStyle` attribute of the selected list items,
|
|
11
|
+
* letting the user choose styles for the list item markers.
|
|
12
|
+
* It is used by the {@link module:list/documentlistproperties~DocumentListProperties list properties feature}.
|
|
13
|
+
*/
|
|
14
|
+
export default class DocumentListStyleCommand extends Command {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
value: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* The default type of the list style.
|
|
21
|
+
*/
|
|
22
|
+
readonly defaultType: string;
|
|
23
|
+
/**
|
|
24
|
+
* The list of supported style types by this command.
|
|
25
|
+
*/
|
|
26
|
+
private _supportedTypes;
|
|
27
|
+
/**
|
|
28
|
+
* Creates an instance of the command.
|
|
29
|
+
*
|
|
30
|
+
* @param editor The editor instance.
|
|
31
|
+
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
32
|
+
* the command execution.
|
|
33
|
+
* @param supportedTypes The list of supported style types by this command.
|
|
34
|
+
*/
|
|
35
|
+
constructor(editor: Editor, defaultType: string, supportedTypes?: Array<string>);
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
refresh(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Executes the command.
|
|
42
|
+
*
|
|
43
|
+
* @fires execute
|
|
44
|
+
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
45
|
+
* style will be applied.
|
|
46
|
+
*/
|
|
47
|
+
execute(options?: {
|
|
48
|
+
type?: string | null;
|
|
49
|
+
}): void;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if the given style type is supported by this plugin.
|
|
52
|
+
*/
|
|
53
|
+
isStyleTypeSupported(value: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Checks the command's {@link #value}.
|
|
56
|
+
*
|
|
57
|
+
* @returns The current value.
|
|
58
|
+
*/
|
|
59
|
+
private _getValue;
|
|
60
|
+
/**
|
|
61
|
+
* Checks whether the command can be enabled in the current context.
|
|
62
|
+
*
|
|
63
|
+
* @returns Whether the command should be enabled.
|
|
64
|
+
*/
|
|
65
|
+
private _checkEnabled;
|
|
66
|
+
/**
|
|
67
|
+
* Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
|
|
68
|
+
*
|
|
69
|
+
* @param options.type The type of the list style. If `null` is specified, the function does nothing.
|
|
70
|
+
*/
|
|
71
|
+
private _tryToConvertItemsToList;
|
|
72
|
+
}
|