@ckeditor/ckeditor5-list 40.0.0 → 40.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -2
- package/build/list.js +1 -1
- package/package.json +3 -3
- package/src/augmentation.d.ts +52 -52
- 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 -65
- package/src/documentlist/converters.js +441 -441
- package/src/documentlist/documentlistcommand.d.ts +80 -80
- package/src/documentlist/documentlistcommand.js +150 -150
- package/src/documentlist/documentlistediting.d.ts +212 -212
- package/src/documentlist/documentlistediting.js +646 -645
- 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 -145
- package/src/documentlist/utils/listwalker.js +182 -182
- package/src/documentlist/utils/model.d.ts +202 -202
- package/src/documentlist/utils/model.js +455 -455
- package/src/documentlist/utils/postfixers.d.ts +37 -37
- package/src/documentlist/utils/postfixers.js +126 -126
- 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 -266
- 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 -43
- package/src/index.js +29 -29
- 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 -132
- 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 -49
- package/src/tododocumentlist/checktododocumentlistcommand.js +82 -82
- package/src/tododocumentlist/todocheckboxchangeobserver.d.ts +41 -41
- package/src/tododocumentlist/todocheckboxchangeobserver.js +37 -37
- package/src/tododocumentlist/tododocumentlistediting.d.ts +38 -38
- package/src/tododocumentlist/tododocumentlistediting.js +399 -399
- package/src/tododocumentlist.d.ts +27 -27
- package/src/tododocumentlist.js +31 -31
- 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/build/list.js.map +0 -1
|
@@ -1,99 +1,99 @@
|
|
|
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/listproperties/liststylecommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
import { getListTypeFromListStyleType, getSelectedListItems } from '../list/utils';
|
|
10
|
-
/**
|
|
11
|
-
* The list style command. It changes the `listStyle` attribute of the selected list items.
|
|
12
|
-
*
|
|
13
|
-
* If the list type (numbered or bulleted) can be inferred from the passed style type,
|
|
14
|
-
* the command tries to convert selected items to a list of that type.
|
|
15
|
-
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
16
|
-
*/
|
|
17
|
-
export default class ListStyleCommand extends Command {
|
|
18
|
-
/**
|
|
19
|
-
* Creates an instance of the command.
|
|
20
|
-
*
|
|
21
|
-
* @param editor The editor instance.
|
|
22
|
-
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
23
|
-
* the command execution.
|
|
24
|
-
*/
|
|
25
|
-
constructor(editor, defaultType) {
|
|
26
|
-
super(editor);
|
|
27
|
-
this.defaultType = defaultType;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
refresh() {
|
|
33
|
-
this.value = this._getValue();
|
|
34
|
-
this.isEnabled = this._checkEnabled();
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Executes the command.
|
|
38
|
-
*
|
|
39
|
-
* @fires execute
|
|
40
|
-
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
41
|
-
* style will be applied.
|
|
42
|
-
*/
|
|
43
|
-
execute(options = {}) {
|
|
44
|
-
this._tryToConvertItemsToList(options);
|
|
45
|
-
const model = this.editor.model;
|
|
46
|
-
const listItems = getSelectedListItems(model);
|
|
47
|
-
if (!listItems.length) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
model.change(writer => {
|
|
51
|
-
for (const item of listItems) {
|
|
52
|
-
writer.setAttribute('listStyle', options.type || this.defaultType, item);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Checks the command's {@link #value}.
|
|
58
|
-
*
|
|
59
|
-
* @returns The current value.
|
|
60
|
-
*/
|
|
61
|
-
_getValue() {
|
|
62
|
-
const listItem = this.editor.model.document.selection.getFirstPosition().parent;
|
|
63
|
-
if (listItem && listItem.is('element', 'listItem')) {
|
|
64
|
-
return listItem.getAttribute('listStyle');
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Checks whether the command can be enabled in the current context.
|
|
70
|
-
*
|
|
71
|
-
* @returns Whether the command should be enabled.
|
|
72
|
-
*/
|
|
73
|
-
_checkEnabled() {
|
|
74
|
-
const editor = this.editor;
|
|
75
|
-
const numberedList = editor.commands.get('numberedList');
|
|
76
|
-
const bulletedList = editor.commands.get('bulletedList');
|
|
77
|
-
return numberedList.isEnabled || bulletedList.isEnabled;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Checks if the provided list style is valid. Also changes the selection to a list if it's not set yet.
|
|
81
|
-
*
|
|
82
|
-
* @param The type of the list style. If `null` is specified, the function does nothing.
|
|
83
|
-
*/
|
|
84
|
-
_tryToConvertItemsToList(options) {
|
|
85
|
-
if (!options.type) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const listType = getListTypeFromListStyleType(options.type);
|
|
89
|
-
if (!listType) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const editor = this.editor;
|
|
93
|
-
const commandName = `${listType}List`;
|
|
94
|
-
const command = editor.commands.get(commandName);
|
|
95
|
-
if (!command.value) {
|
|
96
|
-
editor.execute(commandName);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
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/listproperties/liststylecommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
import { getListTypeFromListStyleType, getSelectedListItems } from '../list/utils';
|
|
10
|
+
/**
|
|
11
|
+
* The list style command. It changes the `listStyle` attribute of the selected list items.
|
|
12
|
+
*
|
|
13
|
+
* If the list type (numbered or bulleted) can be inferred from the passed style type,
|
|
14
|
+
* the command tries to convert selected items to a list of that type.
|
|
15
|
+
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
16
|
+
*/
|
|
17
|
+
export default class ListStyleCommand extends Command {
|
|
18
|
+
/**
|
|
19
|
+
* Creates an instance of the command.
|
|
20
|
+
*
|
|
21
|
+
* @param editor The editor instance.
|
|
22
|
+
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
23
|
+
* the command execution.
|
|
24
|
+
*/
|
|
25
|
+
constructor(editor, defaultType) {
|
|
26
|
+
super(editor);
|
|
27
|
+
this.defaultType = defaultType;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
refresh() {
|
|
33
|
+
this.value = this._getValue();
|
|
34
|
+
this.isEnabled = this._checkEnabled();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Executes the command.
|
|
38
|
+
*
|
|
39
|
+
* @fires execute
|
|
40
|
+
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
41
|
+
* style will be applied.
|
|
42
|
+
*/
|
|
43
|
+
execute(options = {}) {
|
|
44
|
+
this._tryToConvertItemsToList(options);
|
|
45
|
+
const model = this.editor.model;
|
|
46
|
+
const listItems = getSelectedListItems(model);
|
|
47
|
+
if (!listItems.length) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
model.change(writer => {
|
|
51
|
+
for (const item of listItems) {
|
|
52
|
+
writer.setAttribute('listStyle', options.type || this.defaultType, item);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks the command's {@link #value}.
|
|
58
|
+
*
|
|
59
|
+
* @returns The current value.
|
|
60
|
+
*/
|
|
61
|
+
_getValue() {
|
|
62
|
+
const listItem = this.editor.model.document.selection.getFirstPosition().parent;
|
|
63
|
+
if (listItem && listItem.is('element', 'listItem')) {
|
|
64
|
+
return listItem.getAttribute('listStyle');
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks whether the command can be enabled in the current context.
|
|
70
|
+
*
|
|
71
|
+
* @returns Whether the command should be enabled.
|
|
72
|
+
*/
|
|
73
|
+
_checkEnabled() {
|
|
74
|
+
const editor = this.editor;
|
|
75
|
+
const numberedList = editor.commands.get('numberedList');
|
|
76
|
+
const bulletedList = editor.commands.get('bulletedList');
|
|
77
|
+
return numberedList.isEnabled || bulletedList.isEnabled;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Checks if the provided list style is valid. Also changes the selection to a list if it's not set yet.
|
|
81
|
+
*
|
|
82
|
+
* @param The type of the list style. If `null` is specified, the function does nothing.
|
|
83
|
+
*/
|
|
84
|
+
_tryToConvertItemsToList(options) {
|
|
85
|
+
if (!options.type) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const listType = getListTypeFromListStyleType(options.type);
|
|
89
|
+
if (!listType) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const editor = this.editor;
|
|
93
|
+
const commandName = `${listType}List`;
|
|
94
|
+
const command = editor.commands.get(commandName);
|
|
95
|
+
if (!command.value) {
|
|
96
|
+
editor.execute(commandName);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
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/listproperties/ui/collapsibleview
|
|
7
|
-
*/
|
|
8
|
-
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
-
import { View, ButtonView, type ViewCollection } from 'ckeditor5/src/ui';
|
|
10
|
-
import '../../../theme/collapsible.css';
|
|
11
|
-
/**
|
|
12
|
-
* A collapsible UI component. Consists of a labeled button and a container which can be collapsed
|
|
13
|
-
* by clicking the button. The collapsible container can be a host to other UI views.
|
|
14
|
-
*
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export default class CollapsibleView extends View {
|
|
18
|
-
/**
|
|
19
|
-
* `true` when the container with {@link #children} is collapsed. `false` otherwise.
|
|
20
|
-
*
|
|
21
|
-
* @observable
|
|
22
|
-
*/
|
|
23
|
-
isCollapsed: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* The text label of the {@link #buttonView}.
|
|
26
|
-
*
|
|
27
|
-
* @observable
|
|
28
|
-
* @default 'Show more'
|
|
29
|
-
*/
|
|
30
|
-
label: string;
|
|
31
|
-
/**
|
|
32
|
-
* The ID of the label inside the {@link #buttonView} that describes the collapsible
|
|
33
|
-
* container for assistive technologies. Set after the button was {@link #render rendered}.
|
|
34
|
-
*
|
|
35
|
-
* @internal
|
|
36
|
-
* @readonly
|
|
37
|
-
* @observable
|
|
38
|
-
*/
|
|
39
|
-
_collapsibleAriaLabelUid: string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* The main button that, when clicked, collapses or expands the container with {@link #children}.
|
|
42
|
-
*/
|
|
43
|
-
readonly buttonView: ButtonView;
|
|
44
|
-
/**
|
|
45
|
-
* A collection of the child views that can be collapsed by clicking the {@link #buttonView}.
|
|
46
|
-
*/
|
|
47
|
-
readonly children: ViewCollection;
|
|
48
|
-
/**
|
|
49
|
-
* Creates an instance of the collapsible view.
|
|
50
|
-
*
|
|
51
|
-
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
52
|
-
* @param childViews An optional array of initial child views to be inserted into the collapsible.
|
|
53
|
-
*/
|
|
54
|
-
constructor(locale: Locale, childViews?: Array<View>);
|
|
55
|
-
/**
|
|
56
|
-
* @inheritDoc
|
|
57
|
-
*/
|
|
58
|
-
render(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Creates the main {@link #buttonView} of the collapsible.
|
|
61
|
-
*/
|
|
62
|
-
private _createButtonView;
|
|
63
|
-
}
|
|
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/listproperties/ui/collapsibleview
|
|
7
|
+
*/
|
|
8
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { View, ButtonView, type ViewCollection } from 'ckeditor5/src/ui';
|
|
10
|
+
import '../../../theme/collapsible.css';
|
|
11
|
+
/**
|
|
12
|
+
* A collapsible UI component. Consists of a labeled button and a container which can be collapsed
|
|
13
|
+
* by clicking the button. The collapsible container can be a host to other UI views.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export default class CollapsibleView extends View {
|
|
18
|
+
/**
|
|
19
|
+
* `true` when the container with {@link #children} is collapsed. `false` otherwise.
|
|
20
|
+
*
|
|
21
|
+
* @observable
|
|
22
|
+
*/
|
|
23
|
+
isCollapsed: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The text label of the {@link #buttonView}.
|
|
26
|
+
*
|
|
27
|
+
* @observable
|
|
28
|
+
* @default 'Show more'
|
|
29
|
+
*/
|
|
30
|
+
label: string;
|
|
31
|
+
/**
|
|
32
|
+
* The ID of the label inside the {@link #buttonView} that describes the collapsible
|
|
33
|
+
* container for assistive technologies. Set after the button was {@link #render rendered}.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
* @readonly
|
|
37
|
+
* @observable
|
|
38
|
+
*/
|
|
39
|
+
_collapsibleAriaLabelUid: string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The main button that, when clicked, collapses or expands the container with {@link #children}.
|
|
42
|
+
*/
|
|
43
|
+
readonly buttonView: ButtonView;
|
|
44
|
+
/**
|
|
45
|
+
* A collection of the child views that can be collapsed by clicking the {@link #buttonView}.
|
|
46
|
+
*/
|
|
47
|
+
readonly children: ViewCollection;
|
|
48
|
+
/**
|
|
49
|
+
* Creates an instance of the collapsible view.
|
|
50
|
+
*
|
|
51
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
52
|
+
* @param childViews An optional array of initial child views to be inserted into the collapsible.
|
|
53
|
+
*/
|
|
54
|
+
constructor(locale: Locale, childViews?: Array<View>);
|
|
55
|
+
/**
|
|
56
|
+
* @inheritDoc
|
|
57
|
+
*/
|
|
58
|
+
render(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Creates the main {@link #buttonView} of the collapsible.
|
|
61
|
+
*/
|
|
62
|
+
private _createButtonView;
|
|
63
|
+
}
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
import { View, ButtonView } from 'ckeditor5/src/ui';
|
|
6
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
7
|
-
import dropdownArrowIcon from '@ckeditor/ckeditor5-ui/theme/icons/dropdown-arrow.svg';
|
|
8
|
-
import '../../../theme/collapsible.css';
|
|
9
|
-
/**
|
|
10
|
-
* A collapsible UI component. Consists of a labeled button and a container which can be collapsed
|
|
11
|
-
* by clicking the button. The collapsible container can be a host to other UI views.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export default class CollapsibleView extends View {
|
|
16
|
-
/**
|
|
17
|
-
* Creates an instance of the collapsible view.
|
|
18
|
-
*
|
|
19
|
-
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
20
|
-
* @param childViews An optional array of initial child views to be inserted into the collapsible.
|
|
21
|
-
*/
|
|
22
|
-
constructor(locale, childViews) {
|
|
23
|
-
super(locale);
|
|
24
|
-
const bind = this.bindTemplate;
|
|
25
|
-
this.set('isCollapsed', false);
|
|
26
|
-
this.set('label', '');
|
|
27
|
-
this.buttonView = this._createButtonView();
|
|
28
|
-
this.children = this.createCollection();
|
|
29
|
-
this.set('_collapsibleAriaLabelUid', undefined);
|
|
30
|
-
if (childViews) {
|
|
31
|
-
this.children.addMany(childViews);
|
|
32
|
-
}
|
|
33
|
-
this.setTemplate({
|
|
34
|
-
tag: 'div',
|
|
35
|
-
attributes: {
|
|
36
|
-
class: [
|
|
37
|
-
'ck',
|
|
38
|
-
'ck-collapsible',
|
|
39
|
-
bind.if('isCollapsed', 'ck-collapsible_collapsed')
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
children: [
|
|
43
|
-
this.buttonView,
|
|
44
|
-
{
|
|
45
|
-
tag: 'div',
|
|
46
|
-
attributes: {
|
|
47
|
-
class: [
|
|
48
|
-
'ck',
|
|
49
|
-
'ck-collapsible__children'
|
|
50
|
-
],
|
|
51
|
-
role: 'region',
|
|
52
|
-
hidden: bind.if('isCollapsed', 'hidden'),
|
|
53
|
-
'aria-labelledby': bind.to('_collapsibleAriaLabelUid')
|
|
54
|
-
},
|
|
55
|
-
children: this.children
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @inheritDoc
|
|
62
|
-
*/
|
|
63
|
-
render() {
|
|
64
|
-
super.render();
|
|
65
|
-
this._collapsibleAriaLabelUid = this.buttonView.labelView.element.id;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Creates the main {@link #buttonView} of the collapsible.
|
|
69
|
-
*/
|
|
70
|
-
_createButtonView() {
|
|
71
|
-
const buttonView = new ButtonView(this.locale);
|
|
72
|
-
const bind = buttonView.bindTemplate;
|
|
73
|
-
buttonView.set({
|
|
74
|
-
withText: true,
|
|
75
|
-
icon: dropdownArrowIcon
|
|
76
|
-
});
|
|
77
|
-
buttonView.extendTemplate({
|
|
78
|
-
attributes: {
|
|
79
|
-
'aria-expanded': bind.to('isOn', value => String(value))
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
buttonView.bind('label').to(this);
|
|
83
|
-
buttonView.bind('isOn').to(this, 'isCollapsed', isCollapsed => !isCollapsed);
|
|
84
|
-
buttonView.on('execute', () => {
|
|
85
|
-
this.isCollapsed = !this.isCollapsed;
|
|
86
|
-
});
|
|
87
|
-
return buttonView;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import { View, ButtonView } from 'ckeditor5/src/ui';
|
|
6
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
7
|
+
import dropdownArrowIcon from '@ckeditor/ckeditor5-ui/theme/icons/dropdown-arrow.svg';
|
|
8
|
+
import '../../../theme/collapsible.css';
|
|
9
|
+
/**
|
|
10
|
+
* A collapsible UI component. Consists of a labeled button and a container which can be collapsed
|
|
11
|
+
* by clicking the button. The collapsible container can be a host to other UI views.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export default class CollapsibleView extends View {
|
|
16
|
+
/**
|
|
17
|
+
* Creates an instance of the collapsible view.
|
|
18
|
+
*
|
|
19
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
20
|
+
* @param childViews An optional array of initial child views to be inserted into the collapsible.
|
|
21
|
+
*/
|
|
22
|
+
constructor(locale, childViews) {
|
|
23
|
+
super(locale);
|
|
24
|
+
const bind = this.bindTemplate;
|
|
25
|
+
this.set('isCollapsed', false);
|
|
26
|
+
this.set('label', '');
|
|
27
|
+
this.buttonView = this._createButtonView();
|
|
28
|
+
this.children = this.createCollection();
|
|
29
|
+
this.set('_collapsibleAriaLabelUid', undefined);
|
|
30
|
+
if (childViews) {
|
|
31
|
+
this.children.addMany(childViews);
|
|
32
|
+
}
|
|
33
|
+
this.setTemplate({
|
|
34
|
+
tag: 'div',
|
|
35
|
+
attributes: {
|
|
36
|
+
class: [
|
|
37
|
+
'ck',
|
|
38
|
+
'ck-collapsible',
|
|
39
|
+
bind.if('isCollapsed', 'ck-collapsible_collapsed')
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
children: [
|
|
43
|
+
this.buttonView,
|
|
44
|
+
{
|
|
45
|
+
tag: 'div',
|
|
46
|
+
attributes: {
|
|
47
|
+
class: [
|
|
48
|
+
'ck',
|
|
49
|
+
'ck-collapsible__children'
|
|
50
|
+
],
|
|
51
|
+
role: 'region',
|
|
52
|
+
hidden: bind.if('isCollapsed', 'hidden'),
|
|
53
|
+
'aria-labelledby': bind.to('_collapsibleAriaLabelUid')
|
|
54
|
+
},
|
|
55
|
+
children: this.children
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
render() {
|
|
64
|
+
super.render();
|
|
65
|
+
this._collapsibleAriaLabelUid = this.buttonView.labelView.element.id;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates the main {@link #buttonView} of the collapsible.
|
|
69
|
+
*/
|
|
70
|
+
_createButtonView() {
|
|
71
|
+
const buttonView = new ButtonView(this.locale);
|
|
72
|
+
const bind = buttonView.bindTemplate;
|
|
73
|
+
buttonView.set({
|
|
74
|
+
withText: true,
|
|
75
|
+
icon: dropdownArrowIcon
|
|
76
|
+
});
|
|
77
|
+
buttonView.extendTemplate({
|
|
78
|
+
attributes: {
|
|
79
|
+
'aria-expanded': bind.to('isOn', value => String(value))
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
buttonView.bind('label').to(this);
|
|
83
|
+
buttonView.bind('isOn').to(this, 'isCollapsed', isCollapsed => !isCollapsed);
|
|
84
|
+
buttonView.on('execute', () => {
|
|
85
|
+
this.isCollapsed = !this.isCollapsed;
|
|
86
|
+
});
|
|
87
|
+
return buttonView;
|
|
88
|
+
}
|
|
89
|
+
}
|