@ckeditor/ckeditor5-list 47.6.1-alpha.1 → 48.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/ckeditor5-metadata.json +21 -18
- package/dist/index-content.css +135 -111
- package/dist/index-editor.css +152 -73
- package/dist/index.css +204 -238
- package/dist/index.css.map +1 -1
- package/dist/index.js.map +1 -1
- package/{src → dist}/legacylist/legacyconverters.d.ts +2 -2
- package/{src → dist}/legacylist/legacyindentcommand.d.ts +1 -1
- package/{src → dist}/legacylist/legacylistcommand.d.ts +1 -1
- package/{src → dist}/legacylist/legacylistediting.d.ts +3 -3
- package/{src → dist}/legacylist/legacylistutils.d.ts +2 -2
- package/{src → dist}/legacylist/legacyutils.d.ts +1 -1
- package/{src → dist}/legacylist.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacylistpropertiesediting.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacylistreversedcommand.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacyliststartcommand.d.ts +1 -1
- package/{src → dist}/legacylistproperties/legacyliststylecommand.d.ts +1 -1
- package/{src → dist}/legacylistproperties.d.ts +1 -1
- package/{src → dist}/legacytodolist/legacychecktodolistcommand.d.ts +2 -2
- package/{src → dist}/legacytodolist/legacytodolistconverters.d.ts +2 -2
- package/{src → dist}/legacytodolist/legacytodolistediting.d.ts +1 -1
- package/{src → dist}/legacytodolist.d.ts +1 -1
- package/{src → dist}/list/adjacentlistssupport.d.ts +1 -1
- package/{src → dist}/list/converters.d.ts +2 -2
- package/{src → dist}/list/listcommand.d.ts +2 -2
- package/{src → dist}/list/listediting.d.ts +5 -5
- package/{src → dist}/list/listindentcommand.d.ts +2 -2
- package/{src → dist}/list/listmergecommand.d.ts +2 -2
- package/{src → dist}/list/listsplitcommand.d.ts +2 -2
- package/{src → dist}/list/listui.d.ts +1 -1
- package/{src → dist}/list/listutils.d.ts +3 -3
- package/{src → dist}/list/utils/listwalker.d.ts +2 -2
- package/{src → dist}/list/utils/model.d.ts +2 -2
- package/{src → dist}/list/utils/postfixers.d.ts +1 -1
- package/{src → dist}/list/utils/view.d.ts +1 -1
- package/{src → dist}/list/utils.d.ts +1 -1
- package/{src → dist}/list.d.ts +1 -1
- package/{src → dist}/listconfig.d.ts +1 -1
- package/{src → dist}/listformatting/listitemboldintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemfontcolorintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemfontfamilyintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemfontsizeintegration.d.ts +1 -1
- package/{src → dist}/listformatting/listitemitalicintegration.d.ts +1 -1
- package/{src → dist}/listformatting.d.ts +1 -1
- package/{src → dist}/listproperties/converters.d.ts +2 -2
- package/{src → dist}/listproperties/listpropertiesediting.d.ts +2 -2
- package/{src → dist}/listproperties/listpropertiesui.d.ts +1 -1
- package/{src → dist}/listproperties/listpropertiesutils.d.ts +1 -1
- package/{src → dist}/listproperties/listreversedcommand.d.ts +1 -1
- package/{src → dist}/listproperties/liststartcommand.d.ts +1 -1
- package/{src → dist}/listproperties/liststylecommand.d.ts +1 -1
- package/{src → dist}/listproperties/ui/listpropertiesview.d.ts +2 -2
- package/{src → dist}/listproperties.d.ts +1 -1
- package/{src → dist}/todolist/checktodolistcommand.d.ts +1 -1
- package/{src → dist}/todolist/todocheckboxchangeobserver.d.ts +1 -1
- package/{src → dist}/todolist/todolistediting.d.ts +1 -1
- package/{src → dist}/todolist/todolistui.d.ts +1 -1
- package/{src → dist}/todolist.d.ts +1 -1
- package/package.json +28 -52
- package/build/list.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/lang/contexts.json +0 -37
- package/lang/translations/af.po +0 -152
- package/lang/translations/ar.po +0 -152
- package/lang/translations/ast.po +0 -152
- package/lang/translations/az.po +0 -152
- package/lang/translations/be.po +0 -152
- package/lang/translations/bg.po +0 -152
- package/lang/translations/bn.po +0 -152
- package/lang/translations/bs.po +0 -152
- package/lang/translations/ca.po +0 -152
- package/lang/translations/cs.po +0 -152
- package/lang/translations/da.po +0 -152
- package/lang/translations/de-ch.po +0 -152
- package/lang/translations/de.po +0 -152
- package/lang/translations/el.po +0 -152
- package/lang/translations/en-au.po +0 -152
- package/lang/translations/en-gb.po +0 -152
- package/lang/translations/en.po +0 -152
- package/lang/translations/eo.po +0 -152
- package/lang/translations/es-co.po +0 -152
- package/lang/translations/es.po +0 -152
- package/lang/translations/et.po +0 -152
- package/lang/translations/eu.po +0 -152
- package/lang/translations/fa.po +0 -152
- package/lang/translations/fi.po +0 -152
- package/lang/translations/fr.po +0 -152
- package/lang/translations/gl.po +0 -152
- package/lang/translations/gu.po +0 -152
- package/lang/translations/he.po +0 -152
- package/lang/translations/hi.po +0 -152
- package/lang/translations/hr.po +0 -152
- package/lang/translations/hu.po +0 -152
- package/lang/translations/hy.po +0 -152
- package/lang/translations/id.po +0 -152
- package/lang/translations/it.po +0 -152
- package/lang/translations/ja.po +0 -152
- package/lang/translations/jv.po +0 -152
- package/lang/translations/kk.po +0 -152
- package/lang/translations/km.po +0 -152
- package/lang/translations/kn.po +0 -152
- package/lang/translations/ko.po +0 -152
- package/lang/translations/ku.po +0 -152
- package/lang/translations/lt.po +0 -152
- package/lang/translations/lv.po +0 -152
- package/lang/translations/ms.po +0 -152
- package/lang/translations/nb.po +0 -152
- package/lang/translations/ne.po +0 -152
- package/lang/translations/nl.po +0 -152
- package/lang/translations/no.po +0 -152
- package/lang/translations/oc.po +0 -152
- package/lang/translations/pl.po +0 -152
- package/lang/translations/pt-br.po +0 -152
- package/lang/translations/pt.po +0 -152
- package/lang/translations/ro.po +0 -152
- package/lang/translations/ru.po +0 -152
- package/lang/translations/si.po +0 -152
- package/lang/translations/sk.po +0 -152
- package/lang/translations/sl.po +0 -152
- package/lang/translations/sq.po +0 -152
- package/lang/translations/sr-latn.po +0 -152
- package/lang/translations/sr.po +0 -152
- package/lang/translations/sv.po +0 -152
- package/lang/translations/th.po +0 -152
- package/lang/translations/ti.po +0 -152
- package/lang/translations/tk.po +0 -152
- package/lang/translations/tr.po +0 -152
- package/lang/translations/tt.po +0 -152
- package/lang/translations/ug.po +0 -152
- package/lang/translations/uk.po +0 -152
- package/lang/translations/ur.po +0 -152
- package/lang/translations/uz.po +0 -152
- package/lang/translations/vi.po +0 -152
- package/lang/translations/zh-cn.po +0 -152
- package/lang/translations/zh.po +0 -152
- package/src/augmentation.js +0 -5
- package/src/index.js +0 -67
- package/src/legacyerrors.js +0 -28
- package/src/legacylist/legacyconverters.js +0 -921
- package/src/legacylist/legacyindentcommand.js +0 -111
- package/src/legacylist/legacylistcommand.js +0 -278
- package/src/legacylist/legacylistediting.js +0 -167
- package/src/legacylist/legacylistutils.js +0 -52
- package/src/legacylist/legacyutils.js +0 -357
- package/src/legacylist.js +0 -36
- package/src/legacylistproperties/legacylistpropertiesediting.js +0 -703
- package/src/legacylistproperties/legacylistreversedcommand.js +0 -52
- package/src/legacylistproperties/legacyliststartcommand.js +0 -52
- package/src/legacylistproperties/legacyliststylecommand.js +0 -105
- package/src/legacylistproperties.js +0 -37
- package/src/legacytodolist/legacychecktodolistcommand.js +0 -82
- package/src/legacytodolist/legacytodolistconverters.js +0 -268
- package/src/legacytodolist/legacytodolistediting.js +0 -199
- package/src/legacytodolist.js +0 -37
- package/src/list/adjacentlistssupport.js +0 -87
- package/src/list/converters.js +0 -533
- package/src/list/listcommand.js +0 -176
- package/src/list/listediting.js +0 -696
- package/src/list/listindentcommand.js +0 -136
- package/src/list/listmergecommand.js +0 -182
- package/src/list/listsplitcommand.js +0 -74
- package/src/list/listui.js +0 -42
- package/src/list/listutils.js +0 -68
- package/src/list/utils/listwalker.js +0 -236
- package/src/list/utils/model.js +0 -487
- package/src/list/utils/postfixers.js +0 -131
- package/src/list/utils/view.js +0 -117
- package/src/list/utils.js +0 -51
- package/src/list.js +0 -36
- package/src/listconfig.js +0 -5
- package/src/listformatting/listitemboldintegration.js +0 -88
- package/src/listformatting/listitemfontcolorintegration.js +0 -92
- package/src/listformatting/listitemfontfamilyintegration.js +0 -93
- package/src/listformatting/listitemfontsizeintegration.js +0 -124
- package/src/listformatting/listitemitalicintegration.js +0 -88
- package/src/listformatting.js +0 -248
- package/src/listproperties/converters.js +0 -43
- package/src/listproperties/listpropertiesediting.js +0 -291
- package/src/listproperties/listpropertiesui.js +0 -385
- package/src/listproperties/listpropertiesutils.js +0 -50
- package/src/listproperties/listreversedcommand.js +0 -55
- package/src/listproperties/liststartcommand.js +0 -61
- package/src/listproperties/liststylecommand.js +0 -121
- package/src/listproperties/ui/listpropertiesview.js +0 -318
- package/src/listproperties/utils/config.js +0 -84
- package/src/listproperties/utils/style.js +0 -85
- package/src/listproperties.js +0 -37
- package/src/todolist/checktodolistcommand.js +0 -82
- package/src/todolist/todocheckboxchangeobserver.js +0 -36
- package/src/todolist/todolistediting.js +0 -470
- package/src/todolist/todolistui.js +0 -35
- package/src/todolist.js +0 -37
- package/theme/documentlist.css +0 -8
- package/theme/list.css +0 -40
- package/theme/listformatting.css +0 -66
- package/theme/listproperties.css +0 -10
- package/theme/liststyles.css +0 -8
- package/theme/todolist.css +0 -140
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/legacyerrors.d.ts +0 -0
- /package/{src → dist}/listproperties/utils/config.d.ts +0 -0
- /package/{src → dist}/listproperties/utils/style.d.ts +0 -0
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import { getCode, parseKeystroke, getLocalizedArrowKeyCodeDirection } from 'ckeditor5/src/utils.js';
|
|
7
|
-
import { LegacyListCommand } from '../legacylist/legacylistcommand.js';
|
|
8
|
-
import { LegacyListEditing } from '../legacylist/legacylistediting.js';
|
|
9
|
-
import { LegacyCheckTodoListCommand } from './legacychecktodolistcommand.js';
|
|
10
|
-
import { dataModelViewInsertion, dataViewModelCheckmarkInsertion, mapModelToViewPosition, modelViewChangeChecked, modelViewChangeType, modelViewInsertion } from './legacytodolistconverters.js';
|
|
11
|
-
const ITEM_TOGGLE_KEYSTROKE = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
12
|
-
/**
|
|
13
|
-
* The engine of the to-do list feature. It handles creating, editing and removing to-do lists and their items.
|
|
14
|
-
*
|
|
15
|
-
* It registers the entire functionality of the {@link module:list/legacylist/legacylistediting~LegacyListEditing legacy list editing
|
|
16
|
-
* plugin} and extends it with the commands:
|
|
17
|
-
*
|
|
18
|
-
* - `'todoList'`,
|
|
19
|
-
* - `'checkTodoList'`,
|
|
20
|
-
* - `'todoListCheck'` as an alias for `checkTodoList` command.
|
|
21
|
-
*/
|
|
22
|
-
export class LegacyTodoListEditing extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName() {
|
|
27
|
-
return 'LegacyTodoListEditing';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
static get isOfficialPlugin() {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
static get requires() {
|
|
39
|
-
return [LegacyListEditing];
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @inheritDoc
|
|
43
|
-
*/
|
|
44
|
-
init() {
|
|
45
|
-
const editor = this.editor;
|
|
46
|
-
const { editing, data, model } = editor;
|
|
47
|
-
// Extend schema.
|
|
48
|
-
model.schema.extend('listItem', {
|
|
49
|
-
allowAttributes: ['todoListChecked']
|
|
50
|
-
});
|
|
51
|
-
// Disallow todoListChecked attribute on other nodes than listItem with to-do listType.
|
|
52
|
-
model.schema.addAttributeCheck((context, attributeName) => {
|
|
53
|
-
const item = context.last;
|
|
54
|
-
if (attributeName == 'todoListChecked' && item.name == 'listItem' && item.getAttribute('listType') != 'todo') {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
// Register `todoList` command.
|
|
59
|
-
editor.commands.add('todoList', new LegacyListCommand(editor, 'todo'));
|
|
60
|
-
const checkTodoListCommand = new LegacyCheckTodoListCommand(editor);
|
|
61
|
-
// Register `checkTodoList` command and add `todoListCheck` command as an alias for backward compatibility.
|
|
62
|
-
editor.commands.add('checkTodoList', checkTodoListCommand);
|
|
63
|
-
editor.commands.add('todoListCheck', checkTodoListCommand);
|
|
64
|
-
// Define converters.
|
|
65
|
-
data.downcastDispatcher.on('insert:listItem', dataModelViewInsertion(model), { priority: 'high' });
|
|
66
|
-
data.upcastDispatcher.on('element:input', dataViewModelCheckmarkInsertion, { priority: 'high' });
|
|
67
|
-
editing.downcastDispatcher.on('insert:listItem', modelViewInsertion(model, listItem => this._handleCheckmarkChange(listItem)), { priority: 'high' });
|
|
68
|
-
editing.downcastDispatcher.on('attribute:listType:listItem', modelViewChangeType(listItem => this._handleCheckmarkChange(listItem), editing.view));
|
|
69
|
-
editing.downcastDispatcher.on('attribute:todoListChecked:listItem', modelViewChangeChecked(listItem => this._handleCheckmarkChange(listItem)));
|
|
70
|
-
editing.mapper.on('modelToViewPosition', mapModelToViewPosition(editing.view));
|
|
71
|
-
data.mapper.on('modelToViewPosition', mapModelToViewPosition(editing.view));
|
|
72
|
-
// Jump at the end of the previous node on left arrow key press, when selection is after the checkbox.
|
|
73
|
-
//
|
|
74
|
-
// <blockquote><p>Foo</p></blockquote>
|
|
75
|
-
// <ul><li><checkbox/>{}Bar</li></ul>
|
|
76
|
-
//
|
|
77
|
-
// press: `<-`
|
|
78
|
-
//
|
|
79
|
-
// <blockquote><p>Foo{}</p></blockquote>
|
|
80
|
-
// <ul><li><checkbox/>Bar</li></ul>
|
|
81
|
-
//
|
|
82
|
-
this.listenTo(editing.view.document, 'arrowKey', jumpOverCheckmarkOnSideArrowKeyPress(model, editor.locale), { context: 'li' });
|
|
83
|
-
// Toggle check state of selected to-do list items on keystroke.
|
|
84
|
-
this.listenTo(editing.view.document, 'keydown', (evt, data) => {
|
|
85
|
-
if (getCode(data) === ITEM_TOGGLE_KEYSTROKE) {
|
|
86
|
-
editor.execute('checkTodoList');
|
|
87
|
-
evt.stop();
|
|
88
|
-
}
|
|
89
|
-
}, { priority: 'high' });
|
|
90
|
-
// Remove `todoListChecked` attribute when a host element is no longer a to-do list item.
|
|
91
|
-
const listItemsToFix = new Set();
|
|
92
|
-
this.listenTo(model, 'applyOperation', (evt, args) => {
|
|
93
|
-
const operation = args[0];
|
|
94
|
-
if (operation.type == 'rename' && operation.oldName == 'listItem') {
|
|
95
|
-
const item = operation.position.nodeAfter;
|
|
96
|
-
if (item.hasAttribute('todoListChecked')) {
|
|
97
|
-
listItemsToFix.add(item);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (operation.type == 'changeAttribute' && operation.key == 'listType' && operation.oldValue === 'todo') {
|
|
101
|
-
for (const item of operation.range.getItems()) {
|
|
102
|
-
if (item.hasAttribute('todoListChecked') && item.getAttribute('listType') !== 'todo') {
|
|
103
|
-
listItemsToFix.add(item);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
model.document.registerPostFixer(writer => {
|
|
109
|
-
let hasChanged = false;
|
|
110
|
-
for (const listItem of listItemsToFix) {
|
|
111
|
-
writer.removeAttribute('todoListChecked', listItem);
|
|
112
|
-
hasChanged = true;
|
|
113
|
-
}
|
|
114
|
-
listItemsToFix.clear();
|
|
115
|
-
return hasChanged;
|
|
116
|
-
});
|
|
117
|
-
this._initAriaAnnouncements();
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Handles the checkbox element change, moves the selection to the corresponding model item to make it possible
|
|
121
|
-
* to toggle the `todoListChecked` attribute using the command, and restores the selection position.
|
|
122
|
-
*
|
|
123
|
-
* Some say it's a hack :) Moving the selection only for executing the command on a certain node and restoring it after,
|
|
124
|
-
* is not a clear solution. We need to design an API for using commands beyond the selection range.
|
|
125
|
-
* See https://github.com/ckeditor/ckeditor5/issues/1954.
|
|
126
|
-
*/
|
|
127
|
-
_handleCheckmarkChange(listItem) {
|
|
128
|
-
const editor = this.editor;
|
|
129
|
-
const model = editor.model;
|
|
130
|
-
const previousSelectionRanges = Array.from(model.document.selection.getRanges());
|
|
131
|
-
model.change(writer => {
|
|
132
|
-
writer.setSelection(listItem, 'end');
|
|
133
|
-
editor.execute('checkTodoList');
|
|
134
|
-
writer.setSelection(previousSelectionRanges);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Observe when user enters or leaves todo list and set proper aria value in global live announcer.
|
|
139
|
-
* This allows screen readers to indicate when the user has entered and left the specified todo list.
|
|
140
|
-
*
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
_initAriaAnnouncements() {
|
|
144
|
-
const { model, ui, t } = this.editor;
|
|
145
|
-
let lastFocusedCodeBlock = null;
|
|
146
|
-
if (!ui) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
model.document.selection.on('change:range', () => {
|
|
150
|
-
const focusParent = model.document.selection.focus.parent;
|
|
151
|
-
const lastElementIsTodoList = isLegacyTodoListItemElement(lastFocusedCodeBlock);
|
|
152
|
-
const currentElementIsTodoList = isLegacyTodoListItemElement(focusParent);
|
|
153
|
-
if (lastElementIsTodoList && !currentElementIsTodoList) {
|
|
154
|
-
ui.ariaLiveAnnouncer.announce(t('Leaving a to-do list'));
|
|
155
|
-
}
|
|
156
|
-
else if (!lastElementIsTodoList && currentElementIsTodoList) {
|
|
157
|
-
ui.ariaLiveAnnouncer.announce(t('Entering a to-do list'));
|
|
158
|
-
}
|
|
159
|
-
lastFocusedCodeBlock = focusParent;
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Handles the left/right (LTR/RTL content) arrow key and moves the selection at the end of the previous block element
|
|
165
|
-
* if the selection is just after the checkbox element. In other words, it jumps over the checkbox element when
|
|
166
|
-
* moving the selection to the left/right (LTR/RTL).
|
|
167
|
-
*
|
|
168
|
-
* @returns Callback for 'keydown' events.
|
|
169
|
-
*/
|
|
170
|
-
function jumpOverCheckmarkOnSideArrowKeyPress(model, locale) {
|
|
171
|
-
return (eventInfo, domEventData) => {
|
|
172
|
-
const direction = getLocalizedArrowKeyCodeDirection(domEventData.keyCode, locale.contentLanguageDirection);
|
|
173
|
-
if (direction != 'left') {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const schema = model.schema;
|
|
177
|
-
const selection = model.document.selection;
|
|
178
|
-
if (!selection.isCollapsed) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
const position = selection.getFirstPosition();
|
|
182
|
-
const parent = position.parent;
|
|
183
|
-
if (parent.name === 'listItem' && parent.getAttribute('listType') == 'todo' && position.isAtStart) {
|
|
184
|
-
const newRange = schema.getNearestSelectionRange(model.createPositionBefore(parent), 'backward');
|
|
185
|
-
if (newRange) {
|
|
186
|
-
model.change(writer => writer.setSelection(newRange));
|
|
187
|
-
}
|
|
188
|
-
domEventData.preventDefault();
|
|
189
|
-
domEventData.stopPropagation();
|
|
190
|
-
eventInfo.stop();
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Returns true if the given element is a list item model element of a to-do list.
|
|
196
|
-
*/
|
|
197
|
-
function isLegacyTodoListItemElement(element) {
|
|
198
|
-
return !!element && element.is('element', 'listItem') && element.getAttribute('listType') === 'todo';
|
|
199
|
-
}
|
package/src/legacytodolist.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module list/legacytodolist
|
|
7
|
-
*/
|
|
8
|
-
import { LegacyTodoListEditing } from './legacytodolist/legacytodolistediting.js';
|
|
9
|
-
import { TodoListUI } from './todolist/todolistui.js';
|
|
10
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
11
|
-
import '../theme/todolist.css';
|
|
12
|
-
/**
|
|
13
|
-
* The legacy to-do list feature.
|
|
14
|
-
*
|
|
15
|
-
* This is a "glue" plugin that loads the {@link module:list/legacytodolist/legacytodolistediting~LegacyTodoListEditing legacy to-do list
|
|
16
|
-
* editing feature} and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
17
|
-
*/
|
|
18
|
-
export class LegacyTodoList extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get requires() {
|
|
23
|
-
return [LegacyTodoListEditing, TodoListUI];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
static get pluginName() {
|
|
29
|
-
return 'LegacyTodoList';
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
static get isOfficialPlugin() {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
export class AdjacentListsSupport extends Plugin {
|
|
7
|
-
/**
|
|
8
|
-
* @inheritDoc
|
|
9
|
-
*/
|
|
10
|
-
static get pluginName() {
|
|
11
|
-
return 'AdjacentListsSupport';
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @inheritDoc
|
|
15
|
-
*/
|
|
16
|
-
static get isOfficialPlugin() {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
init() {
|
|
23
|
-
const editor = this.editor;
|
|
24
|
-
const model = editor.model;
|
|
25
|
-
model.schema.register('listSeparator', {
|
|
26
|
-
allowWhere: '$block',
|
|
27
|
-
isBlock: true
|
|
28
|
-
});
|
|
29
|
-
editor.conversion.for('upcast')
|
|
30
|
-
// Add a list separator element between similar list elements on upcast.
|
|
31
|
-
.add(dispatcher => {
|
|
32
|
-
dispatcher.on('element:ol', listSeparatorUpcastConverter());
|
|
33
|
-
dispatcher.on('element:ul', listSeparatorUpcastConverter());
|
|
34
|
-
})
|
|
35
|
-
// View-to-model transformation.
|
|
36
|
-
.elementToElement({
|
|
37
|
-
model: 'listSeparator',
|
|
38
|
-
view: 'ck-list-separator'
|
|
39
|
-
});
|
|
40
|
-
// The list separator element should exist in the view, but should be invisible (hidden).
|
|
41
|
-
editor.conversion.for('editingDowncast').elementToElement({
|
|
42
|
-
model: 'listSeparator',
|
|
43
|
-
view: {
|
|
44
|
-
name: 'div',
|
|
45
|
-
classes: ['ck-list-separator', 'ck-hidden']
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
// The list separator element should not exist in the output data.
|
|
49
|
-
editor.conversion.for('dataDowncast').elementToElement({
|
|
50
|
-
model: 'listSeparator',
|
|
51
|
-
view: (modelElement, conversionApi) => {
|
|
52
|
-
const viewElement = conversionApi.writer.createContainerElement('ck-list-separator');
|
|
53
|
-
conversionApi.writer.setCustomProperty('dataPipeline:transparentRendering', true, viewElement);
|
|
54
|
-
viewElement.getFillerOffset = () => null;
|
|
55
|
-
return viewElement;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Inserts a list separator element between two lists of the same type (`ol` + `ol` or `ul` + `ul`).
|
|
62
|
-
*/
|
|
63
|
-
function listSeparatorUpcastConverter() {
|
|
64
|
-
return (evt, data, conversionApi) => {
|
|
65
|
-
const element = data.viewItem;
|
|
66
|
-
const nextSibling = element.nextSibling;
|
|
67
|
-
if (!nextSibling) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (element.name !== nextSibling.name) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (!data.modelRange) {
|
|
74
|
-
Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));
|
|
75
|
-
}
|
|
76
|
-
const writer = conversionApi.writer;
|
|
77
|
-
const modelElement = writer.createElement('listSeparator');
|
|
78
|
-
// Try to insert a list separator element on the current model cursor position.
|
|
79
|
-
if (!conversionApi.safeInsert(modelElement, data.modelCursor)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const parts = conversionApi.getSplitParts(modelElement);
|
|
83
|
-
// Extend the model range with the range of the created list separator element.
|
|
84
|
-
data.modelRange = writer.createRange(data.modelRange.start, writer.createPositionAfter(parts[parts.length - 1]));
|
|
85
|
-
conversionApi.updateConversionResult(modelElement, data);
|
|
86
|
-
};
|
|
87
|
-
}
|