@ckeditor/ckeditor5-list 47.6.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,385 +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/listproperties/listpropertiesui
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { IconBulletedList, IconNumberedList, IconListStyleCircle, IconListStyleDecimal, IconListStyleDecimalLeadingZero, IconListStyleDisc, IconListStyleLowerLatin, IconListStyleLowerRoman, IconListStyleSquare, IconListStyleUpperLatin, IconListStyleUpperRoman, IconListStyleArabicIndic } from 'ckeditor5/src/icons.js';
|
|
10
|
-
import { ButtonView, SplitButtonView, createDropdown, focusChildOnDropdownOpen, MenuBarMenuView } from 'ckeditor5/src/ui.js';
|
|
11
|
-
import { ListPropertiesView } from './ui/listpropertiesview.js';
|
|
12
|
-
import { getNormalizedConfig } from './utils/config.js';
|
|
13
|
-
import '../../theme/liststyles.css';
|
|
14
|
-
/**
|
|
15
|
-
* The list properties UI plugin. It introduces the extended `'bulletedList'` and `'numberedList'` toolbar
|
|
16
|
-
* buttons that allow users to control such aspects of list as the marker, start index or order.
|
|
17
|
-
*
|
|
18
|
-
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/list/listui~ListUI}
|
|
19
|
-
* (because they share the same names).
|
|
20
|
-
*/
|
|
21
|
-
export class ListPropertiesUI extends Plugin {
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
static get pluginName() {
|
|
26
|
-
return 'ListPropertiesUI';
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
static get isOfficialPlugin() {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
init() {
|
|
35
|
-
const editor = this.editor;
|
|
36
|
-
const t = editor.locale.t;
|
|
37
|
-
const propertiesConfig = editor.config.get('list.properties');
|
|
38
|
-
const normalizedConfig = getNormalizedConfig(propertiesConfig);
|
|
39
|
-
const stylesListTypes = normalizedConfig.styles.listTypes;
|
|
40
|
-
// Note: When this plugin does not register the "bulletedList" dropdown due to properties configuration,
|
|
41
|
-
// a simple button will be still registered under the same name by ListUI as a fallback. This should happen
|
|
42
|
-
// in most editor configuration because the List plugin automatically requires ListUI.
|
|
43
|
-
if (stylesListTypes.includes('bulleted')) {
|
|
44
|
-
const styleDefinitions = [
|
|
45
|
-
{
|
|
46
|
-
label: t('Toggle the disc list style'),
|
|
47
|
-
tooltip: t('Disc'),
|
|
48
|
-
type: 'disc',
|
|
49
|
-
icon: IconListStyleDisc
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
label: t('Toggle the circle list style'),
|
|
53
|
-
tooltip: t('Circle'),
|
|
54
|
-
type: 'circle',
|
|
55
|
-
icon: IconListStyleCircle
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
label: t('Toggle the square list style'),
|
|
59
|
-
tooltip: t('Square'),
|
|
60
|
-
type: 'square',
|
|
61
|
-
icon: IconListStyleSquare
|
|
62
|
-
}
|
|
63
|
-
];
|
|
64
|
-
const buttonLabel = t('Bulleted List');
|
|
65
|
-
const styleGridAriaLabel = t('Bulleted list styles toolbar');
|
|
66
|
-
const commandName = 'bulletedList';
|
|
67
|
-
editor.ui.componentFactory.add(commandName, getDropdownViewCreator({
|
|
68
|
-
editor,
|
|
69
|
-
normalizedConfig,
|
|
70
|
-
parentCommandName: commandName,
|
|
71
|
-
buttonLabel,
|
|
72
|
-
buttonIcon: IconBulletedList,
|
|
73
|
-
styleGridAriaLabel,
|
|
74
|
-
styleDefinitions
|
|
75
|
-
}));
|
|
76
|
-
// Add the menu bar item for bulleted list.
|
|
77
|
-
editor.ui.componentFactory.add(`menuBar:${commandName}`, getMenuBarStylesMenuCreator({
|
|
78
|
-
editor,
|
|
79
|
-
normalizedConfig,
|
|
80
|
-
parentCommandName: commandName,
|
|
81
|
-
buttonLabel,
|
|
82
|
-
styleGridAriaLabel,
|
|
83
|
-
styleDefinitions
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
// Note: When this plugin does not register the "numberedList" dropdown due to properties configuration,
|
|
87
|
-
// a simple button will be still registered under the same name by ListUI as a fallback. This should happen
|
|
88
|
-
// in most editor configuration because the List plugin automatically requires ListUI.
|
|
89
|
-
if (stylesListTypes.includes('numbered') || propertiesConfig.startIndex || propertiesConfig.reversed) {
|
|
90
|
-
const styleDefinitions = [
|
|
91
|
-
{
|
|
92
|
-
label: t('Toggle the decimal list style'),
|
|
93
|
-
tooltip: t('Decimal'),
|
|
94
|
-
type: 'decimal',
|
|
95
|
-
icon: IconListStyleDecimal
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: t('Toggle the decimal with leading zero list style'),
|
|
99
|
-
tooltip: t('Decimal with leading zero'),
|
|
100
|
-
type: 'decimal-leading-zero',
|
|
101
|
-
icon: IconListStyleDecimalLeadingZero
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
label: t('Toggle the lower–roman list style'),
|
|
105
|
-
tooltip: t('Lower–roman'),
|
|
106
|
-
type: 'lower-roman',
|
|
107
|
-
icon: IconListStyleLowerRoman
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
label: t('Toggle the upper–roman list style'),
|
|
111
|
-
tooltip: t('Upper-roman'),
|
|
112
|
-
type: 'upper-roman',
|
|
113
|
-
icon: IconListStyleUpperRoman
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
label: t('Toggle the lower–latin list style'),
|
|
117
|
-
tooltip: t('Lower-latin'),
|
|
118
|
-
type: 'lower-latin',
|
|
119
|
-
icon: IconListStyleLowerLatin
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
label: t('Toggle the upper–latin list style'),
|
|
123
|
-
tooltip: t('Upper-latin'),
|
|
124
|
-
type: 'upper-latin',
|
|
125
|
-
icon: IconListStyleUpperLatin
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
label: t('Toggle the arabic-indic list style'),
|
|
129
|
-
tooltip: t('Arabic-indic'),
|
|
130
|
-
type: 'arabic-indic',
|
|
131
|
-
icon: IconListStyleArabicIndic
|
|
132
|
-
}
|
|
133
|
-
];
|
|
134
|
-
const buttonLabel = t('Numbered List');
|
|
135
|
-
const styleGridAriaLabel = t('Numbered list styles toolbar');
|
|
136
|
-
const commandName = 'numberedList';
|
|
137
|
-
editor.ui.componentFactory.add(commandName, getDropdownViewCreator({
|
|
138
|
-
editor,
|
|
139
|
-
normalizedConfig,
|
|
140
|
-
parentCommandName: commandName,
|
|
141
|
-
buttonLabel,
|
|
142
|
-
buttonIcon: IconNumberedList,
|
|
143
|
-
styleGridAriaLabel,
|
|
144
|
-
styleDefinitions
|
|
145
|
-
}));
|
|
146
|
-
// Menu bar menu does not display list start index or reverse UI. If there are no styles enabled,
|
|
147
|
-
// the menu makes no sense and should be omitted.
|
|
148
|
-
if (stylesListTypes.includes('numbered')) {
|
|
149
|
-
editor.ui.componentFactory.add(`menuBar:${commandName}`, getMenuBarStylesMenuCreator({
|
|
150
|
-
editor,
|
|
151
|
-
normalizedConfig,
|
|
152
|
-
parentCommandName: commandName,
|
|
153
|
-
buttonLabel,
|
|
154
|
-
styleGridAriaLabel,
|
|
155
|
-
styleDefinitions
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* A helper that returns a function that creates a split button with a toolbar in the dropdown,
|
|
163
|
-
* which in turn contains buttons allowing users to change list styles in the context of the current selection.
|
|
164
|
-
*
|
|
165
|
-
* @param options.editor
|
|
166
|
-
* @param options.normalizedConfig List properties configuration.
|
|
167
|
-
* @param options.parentCommandName The name of the higher-order editor command associated with
|
|
168
|
-
* the set of particular list styles (e.g. "bulletedList" for "disc", "circle", and "square" styles).
|
|
169
|
-
* @param options.buttonLabel Label of the main part of the split button.
|
|
170
|
-
* @param options.buttonIcon The SVG string of an icon for the main part of the split button.
|
|
171
|
-
* @param options.styleGridAriaLabel The ARIA label for the styles grid in the split button dropdown.
|
|
172
|
-
* @param options.styleDefinitions Definitions of the style buttons.
|
|
173
|
-
* @returns A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.
|
|
174
|
-
*/
|
|
175
|
-
function getDropdownViewCreator({ editor, normalizedConfig, parentCommandName, buttonLabel, buttonIcon, styleGridAriaLabel, styleDefinitions }) {
|
|
176
|
-
const parentCommand = editor.commands.get(parentCommandName);
|
|
177
|
-
return (locale) => {
|
|
178
|
-
const dropdownView = createDropdown(locale, SplitButtonView);
|
|
179
|
-
const mainButtonView = dropdownView.buttonView;
|
|
180
|
-
dropdownView.bind('isEnabled').to(parentCommand);
|
|
181
|
-
dropdownView.class = 'ck-list-styles-dropdown';
|
|
182
|
-
// Main button was clicked.
|
|
183
|
-
mainButtonView.on('execute', () => {
|
|
184
|
-
editor.execute(parentCommandName);
|
|
185
|
-
editor.editing.view.focus();
|
|
186
|
-
});
|
|
187
|
-
mainButtonView.set({
|
|
188
|
-
label: buttonLabel,
|
|
189
|
-
icon: buttonIcon,
|
|
190
|
-
tooltip: true,
|
|
191
|
-
isToggleable: true
|
|
192
|
-
});
|
|
193
|
-
mainButtonView.bind('isOn').to(parentCommand, 'value', value => !!value);
|
|
194
|
-
dropdownView.once('change:isOpen', () => {
|
|
195
|
-
const listPropertiesView = createListPropertiesView({
|
|
196
|
-
editor,
|
|
197
|
-
normalizedConfig,
|
|
198
|
-
dropdownView,
|
|
199
|
-
parentCommandName,
|
|
200
|
-
styleGridAriaLabel,
|
|
201
|
-
styleDefinitions
|
|
202
|
-
});
|
|
203
|
-
dropdownView.panelView.children.add(listPropertiesView);
|
|
204
|
-
});
|
|
205
|
-
// Focus the editable after executing the command.
|
|
206
|
-
// Overrides a default behaviour where the focus is moved to the dropdown button (#12125).
|
|
207
|
-
dropdownView.on('execute', () => {
|
|
208
|
-
editor.editing.view.focus();
|
|
209
|
-
});
|
|
210
|
-
return dropdownView;
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* A helper that returns a function (factory) that creates individual buttons used by users to change styles
|
|
215
|
-
* of lists.
|
|
216
|
-
*
|
|
217
|
-
* @param options.editor
|
|
218
|
-
* @param options.listStyleCommand The instance of the `ListStylesCommand` class.
|
|
219
|
-
* @param options.parentCommandName The name of the higher-order command associated with a
|
|
220
|
-
* particular list style (e.g. "bulletedList" is associated with "square" and "numberedList" is associated with "roman").
|
|
221
|
-
* @returns A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.
|
|
222
|
-
*/
|
|
223
|
-
function getStyleButtonCreator({ editor, listStyleCommand, parentCommandName }) {
|
|
224
|
-
const locale = editor.locale;
|
|
225
|
-
const parentCommand = editor.commands.get(parentCommandName);
|
|
226
|
-
return ({ label, type, icon, tooltip }) => {
|
|
227
|
-
const button = new ButtonView(locale);
|
|
228
|
-
button.set({ label, icon, tooltip });
|
|
229
|
-
button.bind('isOn').to(listStyleCommand, 'value', value => value === type);
|
|
230
|
-
button.on('execute', () => {
|
|
231
|
-
// If the content the selection is anchored to is a list, let's change its style.
|
|
232
|
-
if (parentCommand.value) {
|
|
233
|
-
// Remove the list when the current list style is the same as the one that would normally be applied.
|
|
234
|
-
if (listStyleCommand.value === type) {
|
|
235
|
-
editor.execute(parentCommandName);
|
|
236
|
-
}
|
|
237
|
-
// If the current list style is not set in the model or the style is different than the
|
|
238
|
-
// one to be applied, simply apply the new style.
|
|
239
|
-
else if (listStyleCommand.value !== type) {
|
|
240
|
-
editor.execute('listStyle', { type });
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
// Otherwise, leave the creation of the styled list to the `ListStyleCommand`.
|
|
244
|
-
else {
|
|
245
|
-
editor.model.change(() => {
|
|
246
|
-
editor.execute('listStyle', { type });
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
return button;
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* A helper that creates the properties view for the individual style dropdown.
|
|
255
|
-
*
|
|
256
|
-
* @param options.editor Editor instance.
|
|
257
|
-
* @param options.normalizedConfig List properties configuration.
|
|
258
|
-
* @param options.dropdownView Styles dropdown view that hosts the properties view.
|
|
259
|
-
* @param options.parentCommandName The name of the higher-order editor command associated with
|
|
260
|
-
* the set of particular list styles (e.g. "bulletedList" for "disc", "circle", and "square" styles).
|
|
261
|
-
* @param options.styleDefinitions Definitions of the style buttons.
|
|
262
|
-
* @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).
|
|
263
|
-
*/
|
|
264
|
-
function createListPropertiesView({ editor, normalizedConfig, dropdownView, parentCommandName, styleDefinitions, styleGridAriaLabel }) {
|
|
265
|
-
const locale = editor.locale;
|
|
266
|
-
const enabledProperties = {
|
|
267
|
-
...normalizedConfig,
|
|
268
|
-
...(parentCommandName != 'numberedList' ? {
|
|
269
|
-
startIndex: false,
|
|
270
|
-
reversed: false
|
|
271
|
-
} : null)
|
|
272
|
-
};
|
|
273
|
-
const listType = parentCommandName.replace('List', '');
|
|
274
|
-
let styleButtonViews = null;
|
|
275
|
-
if (normalizedConfig.styles.listTypes.includes(listType)) {
|
|
276
|
-
const listStyleCommand = editor.commands.get('listStyle');
|
|
277
|
-
const styleButtonCreator = getStyleButtonCreator({
|
|
278
|
-
editor,
|
|
279
|
-
parentCommandName,
|
|
280
|
-
listStyleCommand
|
|
281
|
-
});
|
|
282
|
-
const configuredListStylesTypes = normalizedConfig.styles.listStyleTypes;
|
|
283
|
-
let filteredDefinitions = styleDefinitions;
|
|
284
|
-
if (configuredListStylesTypes) {
|
|
285
|
-
const allowedTypes = configuredListStylesTypes[listType];
|
|
286
|
-
if (allowedTypes) {
|
|
287
|
-
filteredDefinitions = styleDefinitions.filter(def => allowedTypes.includes(def.type));
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
const isStyleTypeSupported = getStyleTypeSupportChecker(listStyleCommand);
|
|
291
|
-
styleButtonViews = filteredDefinitions
|
|
292
|
-
.filter(isStyleTypeSupported)
|
|
293
|
-
.map(styleButtonCreator);
|
|
294
|
-
}
|
|
295
|
-
const listPropertiesView = new ListPropertiesView(locale, {
|
|
296
|
-
styleGridAriaLabel,
|
|
297
|
-
enabledProperties,
|
|
298
|
-
styleButtonViews
|
|
299
|
-
});
|
|
300
|
-
if (normalizedConfig.styles.listTypes.includes(listType)) {
|
|
301
|
-
// Accessibility: focus the first active style when opening the dropdown.
|
|
302
|
-
focusChildOnDropdownOpen(dropdownView, () => {
|
|
303
|
-
return listPropertiesView.stylesView.children.find((child) => child.isOn);
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
if (enabledProperties.startIndex) {
|
|
307
|
-
const listStartCommand = editor.commands.get('listStart');
|
|
308
|
-
listPropertiesView.startIndexFieldView.bind('isEnabled').to(listStartCommand);
|
|
309
|
-
listPropertiesView.startIndexFieldView.fieldView.bind('value').to(listStartCommand);
|
|
310
|
-
listPropertiesView.on('listStart', (evt, data) => editor.execute('listStart', data));
|
|
311
|
-
}
|
|
312
|
-
if (enabledProperties.reversed) {
|
|
313
|
-
const listReversedCommand = editor.commands.get('listReversed');
|
|
314
|
-
listPropertiesView.reversedSwitchButtonView.bind('isEnabled').to(listReversedCommand);
|
|
315
|
-
listPropertiesView.reversedSwitchButtonView.bind('isOn').to(listReversedCommand, 'value', value => !!value);
|
|
316
|
-
listPropertiesView.on('listReversed', () => {
|
|
317
|
-
const isReversed = listReversedCommand.value;
|
|
318
|
-
editor.execute('listReversed', { reversed: !isReversed });
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
// Make sure applying styles closes the dropdown.
|
|
322
|
-
listPropertiesView.delegate('execute').to(dropdownView);
|
|
323
|
-
return listPropertiesView;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* A helper that creates the list style submenu for menu bar.
|
|
327
|
-
*
|
|
328
|
-
* @param editor Editor instance.
|
|
329
|
-
* @param normalizedConfig List properties configuration.
|
|
330
|
-
* @param parentCommandName Name of the list command.
|
|
331
|
-
* @param buttonLabel Label of the menu button.
|
|
332
|
-
* @param styleGridAriaLabel ARIA label of the styles grid.
|
|
333
|
-
*/
|
|
334
|
-
function getMenuBarStylesMenuCreator({ editor, normalizedConfig, parentCommandName, buttonLabel, styleGridAriaLabel, styleDefinitions }) {
|
|
335
|
-
return (locale) => {
|
|
336
|
-
const menuView = new MenuBarMenuView(locale);
|
|
337
|
-
const listCommand = editor.commands.get(parentCommandName);
|
|
338
|
-
const listStyleCommand = editor.commands.get('listStyle');
|
|
339
|
-
const isStyleTypeSupported = getStyleTypeSupportChecker(listStyleCommand);
|
|
340
|
-
const styleButtonCreator = getStyleButtonCreator({
|
|
341
|
-
editor,
|
|
342
|
-
parentCommandName,
|
|
343
|
-
listStyleCommand
|
|
344
|
-
});
|
|
345
|
-
const configuredListStylesTypes = normalizedConfig.styles.listStyleTypes;
|
|
346
|
-
let filteredDefinitions = styleDefinitions;
|
|
347
|
-
if (configuredListStylesTypes) {
|
|
348
|
-
const listType = listCommand.type;
|
|
349
|
-
const allowedTypes = configuredListStylesTypes[listType];
|
|
350
|
-
if (allowedTypes) {
|
|
351
|
-
filteredDefinitions = styleDefinitions.filter(def => allowedTypes.includes(def.type));
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
const styleButtonViews = filteredDefinitions.filter(isStyleTypeSupported).map(styleButtonCreator);
|
|
355
|
-
const listPropertiesView = new ListPropertiesView(locale, {
|
|
356
|
-
styleGridAriaLabel,
|
|
357
|
-
enabledProperties: {
|
|
358
|
-
...normalizedConfig,
|
|
359
|
-
// Disable list start index and reversed in the menu bar.
|
|
360
|
-
startIndex: false,
|
|
361
|
-
reversed: false
|
|
362
|
-
},
|
|
363
|
-
styleButtonViews
|
|
364
|
-
});
|
|
365
|
-
listPropertiesView.delegate('execute').to(menuView);
|
|
366
|
-
menuView.buttonView.set({
|
|
367
|
-
label: buttonLabel,
|
|
368
|
-
icon: parentCommandName === 'bulletedList' ? IconBulletedList : IconNumberedList
|
|
369
|
-
});
|
|
370
|
-
menuView.panelView.children.add(listPropertiesView);
|
|
371
|
-
menuView.bind('isEnabled').to(listCommand, 'isEnabled');
|
|
372
|
-
menuView.on('execute', () => {
|
|
373
|
-
editor.editing.view.focus();
|
|
374
|
-
});
|
|
375
|
-
return menuView;
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
function getStyleTypeSupportChecker(listStyleCommand) {
|
|
379
|
-
if (typeof listStyleCommand.isStyleTypeSupported == 'function') {
|
|
380
|
-
return (styleDefinition) => listStyleCommand.isStyleTypeSupported(styleDefinition.type);
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
return () => true;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
@@ -1,50 +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/listproperties/listpropertiesutils
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { getAllSupportedStyleTypes, getListStyleTypeFromTypeAttribute, getListTypeFromListStyleType, getTypeAttributeFromListStyleType } from './utils/style.js';
|
|
10
|
-
/**
|
|
11
|
-
* A set of helpers related to document lists.
|
|
12
|
-
*/
|
|
13
|
-
export class ListPropertiesUtils extends Plugin {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
static get pluginName() {
|
|
18
|
-
return 'ListPropertiesUtils';
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
static get isOfficialPlugin() {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Gets all the style types supported by given list type.
|
|
28
|
-
*/
|
|
29
|
-
getAllSupportedStyleTypes() {
|
|
30
|
-
return getAllSupportedStyleTypes();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
34
|
-
*/
|
|
35
|
-
getListTypeFromListStyleType(listStyleType) {
|
|
36
|
-
return getListTypeFromListStyleType(listStyleType);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
40
|
-
*/
|
|
41
|
-
getListStyleTypeFromTypeAttribute(value) {
|
|
42
|
-
return getListStyleTypeFromTypeAttribute(value);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
46
|
-
*/
|
|
47
|
-
getTypeAttributeFromListStyleType(value) {
|
|
48
|
-
return getTypeAttributeFromListStyleType(value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,55 +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/listproperties/listreversedcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { first } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import { expandListBlocksToCompleteList, isListItemBlock } from '../list/utils/model.js';
|
|
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/listproperties~ListProperties list properties feature}.
|
|
15
|
-
*/
|
|
16
|
-
export class ListReversedCommand 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,61 +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/listproperties/liststartcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { first } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import { expandListBlocksToCompleteList, isListItemBlock, isNumberedListType } from '../list/utils/model.js';
|
|
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/listproperties~ListProperties list properties feature}.
|
|
15
|
-
*/
|
|
16
|
-
export class ListStartCommand 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 Execute options.
|
|
30
|
-
* @param options.startIndex The list start index.
|
|
31
|
-
*/
|
|
32
|
-
execute({ startIndex = 1 } = {}) {
|
|
33
|
-
const model = this.editor.model;
|
|
34
|
-
const document = model.document;
|
|
35
|
-
let blocks = Array.from(document.selection.getSelectedBlocks())
|
|
36
|
-
.filter(block => isListItemBlock(block) &&
|
|
37
|
-
isNumberedListType(block.getAttribute('listType')));
|
|
38
|
-
blocks = expandListBlocksToCompleteList(blocks);
|
|
39
|
-
model.change(writer => {
|
|
40
|
-
for (const block of blocks) {
|
|
41
|
-
writer.setAttribute('listStart', startIndex >= 0 ? startIndex : 1, block);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Checks the command's {@link #value}.
|
|
47
|
-
*
|
|
48
|
-
* @returns The current value.
|
|
49
|
-
*/
|
|
50
|
-
_getValue() {
|
|
51
|
-
const model = this.editor.model;
|
|
52
|
-
const document = model.document;
|
|
53
|
-
const block = first(document.selection.getSelectedBlocks());
|
|
54
|
-
if (block &&
|
|
55
|
-
isListItemBlock(block) &&
|
|
56
|
-
isNumberedListType(block.getAttribute('listType'))) {
|
|
57
|
-
return block.getAttribute('listStart');
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,121 +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/listproperties/liststylecommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { first } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import { expandListBlocksToCompleteList, isListItemBlock } from '../list/utils/model.js';
|
|
11
|
-
import { getListTypeFromListStyleType } from './utils/style.js';
|
|
12
|
-
/**
|
|
13
|
-
* The list style command. It changes `listStyle` attribute of the selected list items,
|
|
14
|
-
* letting the user choose styles for the list item markers.
|
|
15
|
-
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
16
|
-
*/
|
|
17
|
-
export class ListStyleCommand extends Command {
|
|
18
|
-
/**
|
|
19
|
-
* The default type of the list style.
|
|
20
|
-
*/
|
|
21
|
-
defaultType;
|
|
22
|
-
/**
|
|
23
|
-
* The list of supported style types by this command.
|
|
24
|
-
*/
|
|
25
|
-
_supportedTypes;
|
|
26
|
-
/**
|
|
27
|
-
* Creates an instance of the command.
|
|
28
|
-
*
|
|
29
|
-
* @param editor The editor instance.
|
|
30
|
-
* @param defaultType The list type that will be used by default if the value was not specified during
|
|
31
|
-
* the command execution.
|
|
32
|
-
* @param supportedTypes The list of supported style types by this command.
|
|
33
|
-
*/
|
|
34
|
-
constructor(editor, defaultType, supportedTypes) {
|
|
35
|
-
super(editor);
|
|
36
|
-
this.defaultType = defaultType;
|
|
37
|
-
this._supportedTypes = supportedTypes;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
refresh() {
|
|
43
|
-
this.value = this._getValue();
|
|
44
|
-
this.isEnabled = this._checkEnabled();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Executes the command.
|
|
48
|
-
*
|
|
49
|
-
* @fires execute
|
|
50
|
-
* @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
|
|
51
|
-
* style will be applied.
|
|
52
|
-
*/
|
|
53
|
-
execute(options = {}) {
|
|
54
|
-
const model = this.editor.model;
|
|
55
|
-
const document = model.document;
|
|
56
|
-
model.change(writer => {
|
|
57
|
-
this._tryToConvertItemsToList(options);
|
|
58
|
-
let blocks = Array.from(document.selection.getSelectedBlocks())
|
|
59
|
-
.filter(block => block.hasAttribute('listType'));
|
|
60
|
-
if (!blocks.length) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
blocks = expandListBlocksToCompleteList(blocks);
|
|
64
|
-
for (const block of blocks) {
|
|
65
|
-
writer.setAttribute('listStyle', options.type || this.defaultType, block);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if the given style type is supported by this plugin.
|
|
71
|
-
*/
|
|
72
|
-
isStyleTypeSupported(value) {
|
|
73
|
-
if (!this._supportedTypes) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
return this._supportedTypes.includes(value);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Checks the command's {@link #value}.
|
|
80
|
-
*
|
|
81
|
-
* @returns The current value.
|
|
82
|
-
*/
|
|
83
|
-
_getValue() {
|
|
84
|
-
const listItem = first(this.editor.model.document.selection.getSelectedBlocks());
|
|
85
|
-
if (isListItemBlock(listItem)) {
|
|
86
|
-
return listItem.getAttribute('listStyle');
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Checks whether the command can be enabled in the current context.
|
|
92
|
-
*
|
|
93
|
-
* @returns Whether the command should be enabled.
|
|
94
|
-
*/
|
|
95
|
-
_checkEnabled() {
|
|
96
|
-
const editor = this.editor;
|
|
97
|
-
const numberedList = editor.commands.get('numberedList');
|
|
98
|
-
const bulletedList = editor.commands.get('bulletedList');
|
|
99
|
-
return numberedList.isEnabled || bulletedList.isEnabled;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
|
|
103
|
-
*
|
|
104
|
-
* @param options.type The type of the list style. If `null` is specified, the function does nothing.
|
|
105
|
-
*/
|
|
106
|
-
_tryToConvertItemsToList(options) {
|
|
107
|
-
if (!options.type) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const listType = getListTypeFromListStyleType(options.type);
|
|
111
|
-
if (!listType) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const editor = this.editor;
|
|
115
|
-
const commandName = `${listType}List`;
|
|
116
|
-
const command = editor.commands.get(commandName);
|
|
117
|
-
if (!command.value) {
|
|
118
|
-
editor.execute(commandName);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|