@ckeditor/ckeditor5-list 40.0.0 → 40.2.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/CHANGELOG.md +25 -25
- package/LICENSE.md +2 -2
- package/build/list.js +1 -1
- package/build/translations/ug.js +1 -1
- package/lang/translations/ug.po +3 -3
- package/package.json +2 -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/listpropertiesview.d.ts +156 -157
- package/src/listproperties/ui/listpropertiesview.js +298 -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
- package/src/listproperties/ui/collapsibleview.d.ts +0 -63
- package/src/listproperties/ui/collapsibleview.js +0 -89
- package/theme/collapsible.css +0 -10
|
@@ -1,27 +1,27 @@
|
|
|
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/tododocumentlist
|
|
7
|
-
*/
|
|
8
|
-
import TodoDocumentListEditing from './tododocumentlist/tododocumentlistediting';
|
|
9
|
-
import TodoListUI from './todolist/todolistui';
|
|
10
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import '../theme/todolist.css';
|
|
12
|
-
/**
|
|
13
|
-
* The to-do list feature.
|
|
14
|
-
*
|
|
15
|
-
* This is a "glue" plugin that loads the {@link module:list/todolist/todolistediting~TodoListEditing to-do list editing feature}
|
|
16
|
-
* and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
17
|
-
*/
|
|
18
|
-
export default class TodoDocumentList extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get requires(): readonly [typeof TodoDocumentListEditing, typeof TodoListUI];
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName(): "TodoDocumentList";
|
|
27
|
-
}
|
|
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/tododocumentlist
|
|
7
|
+
*/
|
|
8
|
+
import TodoDocumentListEditing from './tododocumentlist/tododocumentlistediting';
|
|
9
|
+
import TodoListUI from './todolist/todolistui';
|
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
+
import '../theme/todolist.css';
|
|
12
|
+
/**
|
|
13
|
+
* The to-do list feature.
|
|
14
|
+
*
|
|
15
|
+
* This is a "glue" plugin that loads the {@link module:list/todolist/todolistediting~TodoListEditing to-do list editing feature}
|
|
16
|
+
* and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
17
|
+
*/
|
|
18
|
+
export default class TodoDocumentList extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get requires(): readonly [typeof TodoDocumentListEditing, typeof TodoListUI];
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName(): "TodoDocumentList";
|
|
27
|
+
}
|
package/src/tododocumentlist.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
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/tododocumentlist
|
|
7
|
-
*/
|
|
8
|
-
import TodoDocumentListEditing from './tododocumentlist/tododocumentlistediting';
|
|
9
|
-
import TodoListUI from './todolist/todolistui';
|
|
10
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import '../theme/todolist.css';
|
|
12
|
-
/**
|
|
13
|
-
* The to-do list feature.
|
|
14
|
-
*
|
|
15
|
-
* This is a "glue" plugin that loads the {@link module:list/todolist/todolistediting~TodoListEditing to-do list editing feature}
|
|
16
|
-
* and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
17
|
-
*/
|
|
18
|
-
export default class TodoDocumentList extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get requires() {
|
|
23
|
-
return [TodoDocumentListEditing, TodoListUI];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
static get pluginName() {
|
|
29
|
-
return 'TodoDocumentList';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
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/tododocumentlist
|
|
7
|
+
*/
|
|
8
|
+
import TodoDocumentListEditing from './tododocumentlist/tododocumentlistediting';
|
|
9
|
+
import TodoListUI from './todolist/todolistui';
|
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
+
import '../theme/todolist.css';
|
|
12
|
+
/**
|
|
13
|
+
* The to-do list feature.
|
|
14
|
+
*
|
|
15
|
+
* This is a "glue" plugin that loads the {@link module:list/todolist/todolistediting~TodoListEditing to-do list editing feature}
|
|
16
|
+
* and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
17
|
+
*/
|
|
18
|
+
export default class TodoDocumentList extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get requires() {
|
|
23
|
+
return [TodoDocumentListEditing, TodoListUI];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get pluginName() {
|
|
29
|
+
return 'TodoDocumentList';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
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/todolist/checktodolistcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
9
|
-
import type { Element } from 'ckeditor5/src/engine';
|
|
10
|
-
/**
|
|
11
|
-
* The check to-do command.
|
|
12
|
-
*
|
|
13
|
-
* The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
|
|
14
|
-
* the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
|
|
15
|
-
*/
|
|
16
|
-
export default class CheckTodoListCommand extends Command {
|
|
17
|
-
/**
|
|
18
|
-
* A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
19
|
-
*
|
|
20
|
-
* @observable
|
|
21
|
-
* @readonly
|
|
22
|
-
*/
|
|
23
|
-
value: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
_selectedElements: Array<Element>;
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
constructor(editor: Editor);
|
|
34
|
-
/**
|
|
35
|
-
* Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
|
|
36
|
-
*/
|
|
37
|
-
refresh(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
40
|
-
*/
|
|
41
|
-
private _getSelectedItems;
|
|
42
|
-
/**
|
|
43
|
-
* Executes the command.
|
|
44
|
-
*
|
|
45
|
-
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
|
|
46
|
-
* the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
|
|
47
|
-
* value to decide what it should do.
|
|
48
|
-
*/
|
|
49
|
-
execute(options?: {
|
|
50
|
-
forceValue?: boolean;
|
|
51
|
-
}): void;
|
|
52
|
-
}
|
|
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/todolist/checktodolistcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
import type { Element } from 'ckeditor5/src/engine';
|
|
10
|
+
/**
|
|
11
|
+
* The check to-do command.
|
|
12
|
+
*
|
|
13
|
+
* The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
|
|
14
|
+
* the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
|
|
15
|
+
*/
|
|
16
|
+
export default class CheckTodoListCommand extends Command {
|
|
17
|
+
/**
|
|
18
|
+
* A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
19
|
+
*
|
|
20
|
+
* @observable
|
|
21
|
+
* @readonly
|
|
22
|
+
*/
|
|
23
|
+
value: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
_selectedElements: Array<Element>;
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
constructor(editor: Editor);
|
|
34
|
+
/**
|
|
35
|
+
* Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
|
|
36
|
+
*/
|
|
37
|
+
refresh(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
40
|
+
*/
|
|
41
|
+
private _getSelectedItems;
|
|
42
|
+
/**
|
|
43
|
+
* Executes the command.
|
|
44
|
+
*
|
|
45
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
|
|
46
|
+
* the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
|
|
47
|
+
* value to decide what it should do.
|
|
48
|
+
*/
|
|
49
|
+
execute(options?: {
|
|
50
|
+
forceValue?: boolean;
|
|
51
|
+
}): void;
|
|
52
|
+
}
|
|
@@ -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/todolist/checktodolistcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
const attributeKey = 'todoListChecked';
|
|
10
|
-
/**
|
|
11
|
-
* The check to-do command.
|
|
12
|
-
*
|
|
13
|
-
* The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
|
|
14
|
-
* the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
|
|
15
|
-
*/
|
|
16
|
-
export default class CheckTodoListCommand extends Command {
|
|
17
|
-
/**
|
|
18
|
-
* @inheritDoc
|
|
19
|
-
*/
|
|
20
|
-
constructor(editor) {
|
|
21
|
-
super(editor);
|
|
22
|
-
this._selectedElements = [];
|
|
23
|
-
// Refresh command before executing to be sure all values are up to date.
|
|
24
|
-
// It is needed when selection has changed before command execution, in the same change block.
|
|
25
|
-
this.on('execute', () => {
|
|
26
|
-
this.refresh();
|
|
27
|
-
}, { priority: 'highest' });
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
|
|
31
|
-
*/
|
|
32
|
-
refresh() {
|
|
33
|
-
this._selectedElements = this._getSelectedItems();
|
|
34
|
-
this.value = this._selectedElements.every(element => !!element.getAttribute(attributeKey));
|
|
35
|
-
this.isEnabled = !!this._selectedElements.length;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
39
|
-
*/
|
|
40
|
-
_getSelectedItems() {
|
|
41
|
-
const model = this.editor.model;
|
|
42
|
-
const schema = model.schema;
|
|
43
|
-
const selectionRange = model.document.selection.getFirstRange();
|
|
44
|
-
const startElement = selectionRange.start.parent;
|
|
45
|
-
const elements = [];
|
|
46
|
-
if (schema.checkAttribute(startElement, attributeKey)) {
|
|
47
|
-
elements.push(startElement);
|
|
48
|
-
}
|
|
49
|
-
for (const item of selectionRange.getItems()) {
|
|
50
|
-
if (schema.checkAttribute(item, attributeKey) && !elements.includes(item)) {
|
|
51
|
-
elements.push(item);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return elements;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Executes the command.
|
|
58
|
-
*
|
|
59
|
-
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
|
|
60
|
-
* the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
|
|
61
|
-
* value to decide what it should do.
|
|
62
|
-
*/
|
|
63
|
-
execute(options = {}) {
|
|
64
|
-
this.editor.model.change(writer => {
|
|
65
|
-
for (const element of this._selectedElements) {
|
|
66
|
-
const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
|
|
67
|
-
if (value) {
|
|
68
|
-
writer.setAttribute(attributeKey, true, element);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
writer.removeAttribute(attributeKey, element);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
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/todolist/checktodolistcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
const attributeKey = 'todoListChecked';
|
|
10
|
+
/**
|
|
11
|
+
* The check to-do command.
|
|
12
|
+
*
|
|
13
|
+
* The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
|
|
14
|
+
* the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
|
|
15
|
+
*/
|
|
16
|
+
export default class CheckTodoListCommand extends Command {
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
constructor(editor) {
|
|
21
|
+
super(editor);
|
|
22
|
+
this._selectedElements = [];
|
|
23
|
+
// Refresh command before executing to be sure all values are up to date.
|
|
24
|
+
// It is needed when selection has changed before command execution, in the same change block.
|
|
25
|
+
this.on('execute', () => {
|
|
26
|
+
this.refresh();
|
|
27
|
+
}, { priority: 'highest' });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
|
|
31
|
+
*/
|
|
32
|
+
refresh() {
|
|
33
|
+
this._selectedElements = this._getSelectedItems();
|
|
34
|
+
this.value = this._selectedElements.every(element => !!element.getAttribute(attributeKey));
|
|
35
|
+
this.isEnabled = !!this._selectedElements.length;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
|
|
39
|
+
*/
|
|
40
|
+
_getSelectedItems() {
|
|
41
|
+
const model = this.editor.model;
|
|
42
|
+
const schema = model.schema;
|
|
43
|
+
const selectionRange = model.document.selection.getFirstRange();
|
|
44
|
+
const startElement = selectionRange.start.parent;
|
|
45
|
+
const elements = [];
|
|
46
|
+
if (schema.checkAttribute(startElement, attributeKey)) {
|
|
47
|
+
elements.push(startElement);
|
|
48
|
+
}
|
|
49
|
+
for (const item of selectionRange.getItems()) {
|
|
50
|
+
if (schema.checkAttribute(item, attributeKey) && !elements.includes(item)) {
|
|
51
|
+
elements.push(item);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return elements;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Executes the command.
|
|
58
|
+
*
|
|
59
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
|
|
60
|
+
* the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
|
|
61
|
+
* value to decide what it should do.
|
|
62
|
+
*/
|
|
63
|
+
execute(options = {}) {
|
|
64
|
+
this.editor.model.change(writer => {
|
|
65
|
+
for (const element of this._selectedElements) {
|
|
66
|
+
const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
|
|
67
|
+
if (value) {
|
|
68
|
+
writer.setAttribute(attributeKey, true, element);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
writer.removeAttribute(attributeKey, element);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
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/todolist/todolistconverters
|
|
7
|
-
*/
|
|
8
|
-
import type { DowncastAttributeEvent, DowncastInsertEvent, Element, MapperModelToViewPositionEvent, Model, UpcastElementEvent, View } from 'ckeditor5/src/engine';
|
|
9
|
-
import { type GetCallback } from 'ckeditor5/src/utils';
|
|
10
|
-
/**
|
|
11
|
-
* A model-to-view converter for the `listItem` model element insertion.
|
|
12
|
-
*
|
|
13
|
-
* It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~UIElement checkbox element}
|
|
14
|
-
* at the beginning of each list item. It also merges the list with surrounding lists (if available).
|
|
15
|
-
*
|
|
16
|
-
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
17
|
-
*
|
|
18
|
-
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
19
|
-
* @param model Model instance.
|
|
20
|
-
* @param onCheckboxChecked Callback function.
|
|
21
|
-
* @returns Returns a conversion callback.
|
|
22
|
-
*/
|
|
23
|
-
export declare function modelViewInsertion(model: Model, onCheckboxChecked: (element: Element) => void): GetCallback<DowncastInsertEvent<Element>>;
|
|
24
|
-
/**
|
|
25
|
-
* A model-to-view converter for the `listItem` model element insertion.
|
|
26
|
-
*
|
|
27
|
-
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
28
|
-
*
|
|
29
|
-
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
30
|
-
* @param model Model instance.
|
|
31
|
-
* @returns Returns a conversion callback.
|
|
32
|
-
*/
|
|
33
|
-
export declare function dataModelViewInsertion(model: Model): GetCallback<DowncastInsertEvent<Element>>;
|
|
34
|
-
/**
|
|
35
|
-
* A view-to-model converter for the checkbox element inside a view list item.
|
|
36
|
-
*
|
|
37
|
-
* It changes the `listType` of the model `listItem` to a `todo` value.
|
|
38
|
-
* When a view checkbox element is marked as checked, an additional `todoListChecked="true"` attribute is added to the model item.
|
|
39
|
-
*
|
|
40
|
-
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
41
|
-
*
|
|
42
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
43
|
-
*/
|
|
44
|
-
export declare const dataViewModelCheckmarkInsertion: GetCallback<UpcastElementEvent>;
|
|
45
|
-
/**
|
|
46
|
-
* A model-to-view converter for the `listType` attribute change on the `listItem` model element.
|
|
47
|
-
*
|
|
48
|
-
* This change means that the `<li>` element parent changes to `<ul class="todo-list">` and a
|
|
49
|
-
* {@link module:engine/view/uielement~UIElement checkbox UI element} is added at the beginning
|
|
50
|
-
* of the list item element (or vice versa).
|
|
51
|
-
*
|
|
52
|
-
* This converter is preceded by {@link module:list/list/converters~modelViewChangeType} and followed by
|
|
53
|
-
* {@link module:list/list/converters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists of the same type.
|
|
54
|
-
*
|
|
55
|
-
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
56
|
-
*
|
|
57
|
-
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
58
|
-
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
59
|
-
* @param view Editing view controller.
|
|
60
|
-
* @returns Returns a conversion callback.
|
|
61
|
-
*/
|
|
62
|
-
export declare function modelViewChangeType(onCheckedChange: (element: Element) => void, view: View): GetCallback<DowncastAttributeEvent<Element>>;
|
|
63
|
-
/**
|
|
64
|
-
* A model-to-view converter for the `todoListChecked` attribute change on the `listItem` model element.
|
|
65
|
-
*
|
|
66
|
-
* It marks the {@link module:engine/view/uielement~UIElement checkbox UI element} as checked.
|
|
67
|
-
*
|
|
68
|
-
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
69
|
-
*
|
|
70
|
-
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
71
|
-
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
72
|
-
* @returns Returns a conversion callback.
|
|
73
|
-
*/
|
|
74
|
-
export declare function modelViewChangeChecked(onCheckedChange: (element: Element) => void): GetCallback<DowncastAttributeEvent<Element>>;
|
|
75
|
-
/**
|
|
76
|
-
* A model-to-view position at zero offset mapper.
|
|
77
|
-
*
|
|
78
|
-
* This helper ensures that position inside todo-list in the view is mapped after the checkbox.
|
|
79
|
-
*
|
|
80
|
-
* It only handles the position at the beginning of a list item as other positions are properly mapped be the default mapper.
|
|
81
|
-
*/
|
|
82
|
-
export declare function mapModelToViewPosition(view: View): GetCallback<MapperModelToViewPositionEvent>;
|
|
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/todolist/todolistconverters
|
|
7
|
+
*/
|
|
8
|
+
import type { DowncastAttributeEvent, DowncastInsertEvent, Element, MapperModelToViewPositionEvent, Model, UpcastElementEvent, View } from 'ckeditor5/src/engine';
|
|
9
|
+
import { type GetCallback } from 'ckeditor5/src/utils';
|
|
10
|
+
/**
|
|
11
|
+
* A model-to-view converter for the `listItem` model element insertion.
|
|
12
|
+
*
|
|
13
|
+
* It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~UIElement checkbox element}
|
|
14
|
+
* at the beginning of each list item. It also merges the list with surrounding lists (if available).
|
|
15
|
+
*
|
|
16
|
+
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
17
|
+
*
|
|
18
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
19
|
+
* @param model Model instance.
|
|
20
|
+
* @param onCheckboxChecked Callback function.
|
|
21
|
+
* @returns Returns a conversion callback.
|
|
22
|
+
*/
|
|
23
|
+
export declare function modelViewInsertion(model: Model, onCheckboxChecked: (element: Element) => void): GetCallback<DowncastInsertEvent<Element>>;
|
|
24
|
+
/**
|
|
25
|
+
* A model-to-view converter for the `listItem` model element insertion.
|
|
26
|
+
*
|
|
27
|
+
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
28
|
+
*
|
|
29
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
30
|
+
* @param model Model instance.
|
|
31
|
+
* @returns Returns a conversion callback.
|
|
32
|
+
*/
|
|
33
|
+
export declare function dataModelViewInsertion(model: Model): GetCallback<DowncastInsertEvent<Element>>;
|
|
34
|
+
/**
|
|
35
|
+
* A view-to-model converter for the checkbox element inside a view list item.
|
|
36
|
+
*
|
|
37
|
+
* It changes the `listType` of the model `listItem` to a `todo` value.
|
|
38
|
+
* When a view checkbox element is marked as checked, an additional `todoListChecked="true"` attribute is added to the model item.
|
|
39
|
+
*
|
|
40
|
+
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
41
|
+
*
|
|
42
|
+
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
43
|
+
*/
|
|
44
|
+
export declare const dataViewModelCheckmarkInsertion: GetCallback<UpcastElementEvent>;
|
|
45
|
+
/**
|
|
46
|
+
* A model-to-view converter for the `listType` attribute change on the `listItem` model element.
|
|
47
|
+
*
|
|
48
|
+
* This change means that the `<li>` element parent changes to `<ul class="todo-list">` and a
|
|
49
|
+
* {@link module:engine/view/uielement~UIElement checkbox UI element} is added at the beginning
|
|
50
|
+
* of the list item element (or vice versa).
|
|
51
|
+
*
|
|
52
|
+
* This converter is preceded by {@link module:list/list/converters~modelViewChangeType} and followed by
|
|
53
|
+
* {@link module:list/list/converters~modelViewMergeAfterChangeType} to handle splitting and merging surrounding lists of the same type.
|
|
54
|
+
*
|
|
55
|
+
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
56
|
+
*
|
|
57
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
58
|
+
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
59
|
+
* @param view Editing view controller.
|
|
60
|
+
* @returns Returns a conversion callback.
|
|
61
|
+
*/
|
|
62
|
+
export declare function modelViewChangeType(onCheckedChange: (element: Element) => void, view: View): GetCallback<DowncastAttributeEvent<Element>>;
|
|
63
|
+
/**
|
|
64
|
+
* A model-to-view converter for the `todoListChecked` attribute change on the `listItem` model element.
|
|
65
|
+
*
|
|
66
|
+
* It marks the {@link module:engine/view/uielement~UIElement checkbox UI element} as checked.
|
|
67
|
+
*
|
|
68
|
+
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
69
|
+
*
|
|
70
|
+
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
71
|
+
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
72
|
+
* @returns Returns a conversion callback.
|
|
73
|
+
*/
|
|
74
|
+
export declare function modelViewChangeChecked(onCheckedChange: (element: Element) => void): GetCallback<DowncastAttributeEvent<Element>>;
|
|
75
|
+
/**
|
|
76
|
+
* A model-to-view position at zero offset mapper.
|
|
77
|
+
*
|
|
78
|
+
* This helper ensures that position inside todo-list in the view is mapped after the checkbox.
|
|
79
|
+
*
|
|
80
|
+
* It only handles the position at the beginning of a list item as other positions are properly mapped be the default mapper.
|
|
81
|
+
*/
|
|
82
|
+
export declare function mapModelToViewPosition(view: View): GetCallback<MapperModelToViewPositionEvent>;
|