@ckeditor/ckeditor5-list 29.2.0 → 32.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -2
- package/build/list.js +3 -3
- package/build/translations/ar.js +1 -1
- package/build/translations/ast.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/eo.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/eu.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/km.js +1 -1
- package/build/translations/kn.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/si.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/ckeditor5-metadata.json +8 -4
- package/lang/contexts.json +5 -1
- package/lang/translations/ar.po +17 -1
- package/lang/translations/ast.po +17 -1
- package/lang/translations/az.po +17 -1
- package/lang/translations/bg.po +17 -1
- package/lang/translations/cs.po +17 -1
- package/lang/translations/da.po +17 -1
- package/lang/translations/de-ch.po +17 -1
- package/lang/translations/de.po +17 -1
- package/lang/translations/el.po +17 -1
- package/lang/translations/en-au.po +17 -1
- package/lang/translations/en-gb.po +17 -1
- package/lang/translations/en.po +17 -1
- package/lang/translations/eo.po +17 -1
- package/lang/translations/es.po +20 -4
- package/lang/translations/et.po +17 -1
- package/lang/translations/eu.po +17 -1
- package/lang/translations/fa.po +17 -1
- package/lang/translations/fi.po +17 -1
- package/lang/translations/fr.po +17 -1
- package/lang/translations/gl.po +17 -1
- package/lang/translations/he.po +17 -1
- package/lang/translations/hi.po +17 -1
- package/lang/translations/hr.po +17 -1
- package/lang/translations/hu.po +17 -1
- package/lang/translations/id.po +17 -1
- package/lang/translations/it.po +17 -1
- package/lang/translations/ja.po +17 -1
- package/lang/translations/km.po +17 -1
- package/lang/translations/kn.po +17 -1
- package/lang/translations/ko.po +17 -1
- package/lang/translations/ku.po +17 -1
- package/lang/translations/lt.po +17 -1
- package/lang/translations/lv.po +17 -1
- package/lang/translations/nb.po +17 -1
- package/lang/translations/ne.po +17 -1
- package/lang/translations/nl.po +21 -5
- package/lang/translations/no.po +17 -1
- package/lang/translations/pl.po +17 -1
- package/lang/translations/pt-br.po +17 -1
- package/lang/translations/pt.po +17 -1
- package/lang/translations/ro.po +17 -1
- package/lang/translations/ru.po +17 -1
- package/lang/translations/si.po +17 -1
- package/lang/translations/sk.po +17 -1
- package/lang/translations/sq.po +17 -1
- package/lang/translations/sr-latn.po +17 -1
- package/lang/translations/sr.po +17 -1
- package/lang/translations/sv.po +17 -1
- package/lang/translations/tk.po +17 -1
- package/lang/translations/tr.po +17 -1
- package/lang/translations/ug.po +17 -1
- package/lang/translations/uk.po +17 -1
- package/lang/translations/uz.po +125 -0
- package/lang/translations/vi.po +17 -1
- package/lang/translations/zh-cn.po +17 -1
- package/lang/translations/zh.po +36 -20
- package/package.json +27 -27
- package/src/checktodolistcommand.js +1 -1
- package/src/converters.js +14 -15
- package/src/indentcommand.js +1 -1
- package/src/index.js +4 -4
- package/src/list.js +24 -1
- package/src/listcommand.js +2 -2
- package/src/listediting.js +1 -1
- package/src/listproperties.js +96 -0
- package/src/{liststyleediting.js → listpropertiesediting.js} +299 -122
- package/src/listpropertiesui.js +314 -0
- package/src/listreversedcommand.js +64 -0
- package/src/liststartcommand.js +63 -0
- package/src/liststyle.js +12 -6
- package/src/liststylecommand.js +5 -22
- package/src/listui.js +1 -1
- package/src/todolist.js +1 -1
- package/src/todolistconverters.js +1 -1
- package/src/todolistediting.js +1 -1
- package/src/todolistui.js +1 -1
- package/src/ui/collapsibleview.js +152 -0
- package/src/ui/listpropertiesview.js +405 -0
- package/src/utils.js +49 -4
- package/theme/collapsible.css +10 -0
- package/theme/listproperties.css +10 -0
- package/theme/liststyles.css +2 -6
- package/theme/todolist.css +1 -1
- package/CHANGELOG.md +0 -272
- package/src/liststyleui.js +0 -225
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
/**
|
|
7
|
+
* @module list/listpropertiesui
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
+
import { ButtonView, SplitButtonView, createDropdown } from 'ckeditor5/src/ui';
|
|
12
|
+
|
|
13
|
+
import ListPropertiesView from './ui/listpropertiesview';
|
|
14
|
+
|
|
15
|
+
import bulletedListIcon from '../theme/icons/bulletedlist.svg';
|
|
16
|
+
import numberedListIcon from '../theme/icons/numberedlist.svg';
|
|
17
|
+
|
|
18
|
+
import listStyleDiscIcon from '../theme/icons/liststyledisc.svg';
|
|
19
|
+
import listStyleCircleIcon from '../theme/icons/liststylecircle.svg';
|
|
20
|
+
import listStyleSquareIcon from '../theme/icons/liststylesquare.svg';
|
|
21
|
+
import listStyleDecimalIcon from '../theme/icons/liststyledecimal.svg';
|
|
22
|
+
import listStyleDecimalWithLeadingZeroIcon from '../theme/icons/liststyledecimalleadingzero.svg';
|
|
23
|
+
import listStyleLowerRomanIcon from '../theme/icons/liststylelowerroman.svg';
|
|
24
|
+
import listStyleUpperRomanIcon from '../theme/icons/liststyleupperroman.svg';
|
|
25
|
+
import listStyleLowerLatinIcon from '../theme/icons/liststylelowerlatin.svg';
|
|
26
|
+
import listStyleUpperLatinIcon from '../theme/icons/liststyleupperlatin.svg';
|
|
27
|
+
|
|
28
|
+
import '../theme/liststyles.css';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The list properties UI plugin. It introduces the extended `'bulletedList'` and `'numberedList'` toolbar
|
|
32
|
+
* buttons that allow users to control such aspects of list as the marker, start index or order.
|
|
33
|
+
*
|
|
34
|
+
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/listui~ListUI}
|
|
35
|
+
* (because they share the same names).
|
|
36
|
+
*
|
|
37
|
+
* @extends module:core/plugin~Plugin
|
|
38
|
+
*/
|
|
39
|
+
export default class ListPropertiesUI extends Plugin {
|
|
40
|
+
/**
|
|
41
|
+
* @inheritDoc
|
|
42
|
+
*/
|
|
43
|
+
static get pluginName() {
|
|
44
|
+
return 'ListPropertiesUI';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
init() {
|
|
48
|
+
const editor = this.editor;
|
|
49
|
+
const t = editor.locale.t;
|
|
50
|
+
const enabledProperties = editor.config.get( 'list.properties' );
|
|
51
|
+
|
|
52
|
+
// Note: When this plugin does not register the "bulletedList" dropdown due to properties configuration,
|
|
53
|
+
// a simple button will be still registered under the same name by ListUI as a fallback. This should happen
|
|
54
|
+
// in most editor configuration because the List plugin automatically requires ListUI.
|
|
55
|
+
if ( enabledProperties.styles ) {
|
|
56
|
+
editor.ui.componentFactory.add( 'bulletedList', getDropdownViewCreator( {
|
|
57
|
+
editor,
|
|
58
|
+
parentCommandName: 'bulletedList',
|
|
59
|
+
buttonLabel: t( 'Bulleted List' ),
|
|
60
|
+
buttonIcon: bulletedListIcon,
|
|
61
|
+
styleGridAriaLabel: t( 'Bulleted list styles toolbar' ),
|
|
62
|
+
styleDefinitions: [
|
|
63
|
+
{
|
|
64
|
+
label: t( 'Toggle the disc list style' ),
|
|
65
|
+
tooltip: t( 'Disc' ),
|
|
66
|
+
type: 'disc',
|
|
67
|
+
icon: listStyleDiscIcon
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: t( 'Toggle the circle list style' ),
|
|
71
|
+
tooltip: t( 'Circle' ),
|
|
72
|
+
type: 'circle',
|
|
73
|
+
icon: listStyleCircleIcon
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: t( 'Toggle the square list style' ),
|
|
77
|
+
tooltip: t( 'Square' ),
|
|
78
|
+
type: 'square',
|
|
79
|
+
icon: listStyleSquareIcon
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
} ) );
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Note: When this plugin does not register the "numberedList" dropdown due to properties configuration,
|
|
86
|
+
// a simple button will be still registered under the same name by ListUI as a fallback. This should happen
|
|
87
|
+
// in most editor configuration because the List plugin automatically requires ListUI.
|
|
88
|
+
if ( enabledProperties.styles || enabledProperties.startIndex || enabledProperties.reversed ) {
|
|
89
|
+
editor.ui.componentFactory.add( 'numberedList', getDropdownViewCreator( {
|
|
90
|
+
editor,
|
|
91
|
+
parentCommandName: 'numberedList',
|
|
92
|
+
buttonLabel: t( 'Numbered List' ),
|
|
93
|
+
buttonIcon: numberedListIcon,
|
|
94
|
+
styleGridAriaLabel: t( 'Numbered list styles toolbar' ),
|
|
95
|
+
styleDefinitions: [
|
|
96
|
+
{
|
|
97
|
+
label: t( 'Toggle the decimal list style' ),
|
|
98
|
+
tooltip: t( 'Decimal' ),
|
|
99
|
+
type: 'decimal',
|
|
100
|
+
icon: listStyleDecimalIcon
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: t( 'Toggle the decimal with leading zero list style' ),
|
|
104
|
+
tooltip: t( 'Decimal with leading zero' ),
|
|
105
|
+
type: 'decimal-leading-zero',
|
|
106
|
+
icon: listStyleDecimalWithLeadingZeroIcon
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: t( 'Toggle the lower–roman list style' ),
|
|
110
|
+
tooltip: t( 'Lower–roman' ),
|
|
111
|
+
type: 'lower-roman',
|
|
112
|
+
icon: listStyleLowerRomanIcon
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: t( 'Toggle the upper–roman list style' ),
|
|
116
|
+
tooltip: t( 'Upper-roman' ),
|
|
117
|
+
type: 'upper-roman',
|
|
118
|
+
icon: listStyleUpperRomanIcon
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
label: t( 'Toggle the lower–latin list style' ),
|
|
122
|
+
tooltip: t( 'Lower-latin' ),
|
|
123
|
+
type: 'lower-latin',
|
|
124
|
+
icon: listStyleLowerLatinIcon
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
label: t( 'Toggle the upper–latin list style' ),
|
|
128
|
+
tooltip: t( 'Upper-latin' ),
|
|
129
|
+
type: 'upper-latin',
|
|
130
|
+
icon: listStyleUpperLatinIcon
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
} ) );
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// A helper that returns a function that creates a split button with a toolbar in the dropdown,
|
|
139
|
+
// which in turn contains buttons allowing users to change list styles in the context of the current selection.
|
|
140
|
+
//
|
|
141
|
+
// @param {Object} options
|
|
142
|
+
// @param {module:core/editor/editor~Editor} options.editor
|
|
143
|
+
// @param {'bulletedList'|'numberedList'} options.parentCommandName The name of the higher-order editor command associated with
|
|
144
|
+
// the set of particular list styles (e.g. "bulletedList" for "disc", "circle", and "square" styles).
|
|
145
|
+
// @param {String} options.buttonLabel Label of the main part of the split button.
|
|
146
|
+
// @param {String} options.buttonIcon The SVG string of an icon for the main part of the split button.
|
|
147
|
+
// @param {String} options.styleGridAriaLabel The ARIA label for the styles grid in the split button dropdown.
|
|
148
|
+
// @param {Object} options.styleDefinitions Definitions of the style buttons.
|
|
149
|
+
// @returns {Function} A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.
|
|
150
|
+
function getDropdownViewCreator( { editor, parentCommandName, buttonLabel, buttonIcon, styleGridAriaLabel, styleDefinitions } ) {
|
|
151
|
+
const parentCommand = editor.commands.get( parentCommandName );
|
|
152
|
+
|
|
153
|
+
// @param {module:utils/locale~Locale} locale
|
|
154
|
+
// @returns {module:ui/dropdown/dropdownview~DropdownView}
|
|
155
|
+
return locale => {
|
|
156
|
+
const dropdownView = createDropdown( locale, SplitButtonView );
|
|
157
|
+
const mainButtonView = dropdownView.buttonView;
|
|
158
|
+
|
|
159
|
+
dropdownView.bind( 'isEnabled' ).to( parentCommand );
|
|
160
|
+
dropdownView.class = 'ck-list-styles-dropdown';
|
|
161
|
+
|
|
162
|
+
// Main button was clicked.
|
|
163
|
+
mainButtonView.on( 'execute', () => {
|
|
164
|
+
editor.execute( parentCommandName );
|
|
165
|
+
editor.editing.view.focus();
|
|
166
|
+
} );
|
|
167
|
+
|
|
168
|
+
mainButtonView.set( {
|
|
169
|
+
label: buttonLabel,
|
|
170
|
+
icon: buttonIcon,
|
|
171
|
+
tooltip: true,
|
|
172
|
+
isToggleable: true
|
|
173
|
+
} );
|
|
174
|
+
|
|
175
|
+
mainButtonView.bind( 'isOn' ).to( parentCommand, 'value', value => !!value );
|
|
176
|
+
|
|
177
|
+
const listPropertiesView = createListPropertiesView( {
|
|
178
|
+
editor,
|
|
179
|
+
dropdownView,
|
|
180
|
+
parentCommandName,
|
|
181
|
+
styleGridAriaLabel,
|
|
182
|
+
styleDefinitions
|
|
183
|
+
} );
|
|
184
|
+
|
|
185
|
+
dropdownView.panelView.children.add( listPropertiesView );
|
|
186
|
+
|
|
187
|
+
return dropdownView;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// A helper that returns a function (factory) that creates individual buttons used by users to change styles
|
|
192
|
+
// of lists.
|
|
193
|
+
//
|
|
194
|
+
// @param {Object} options
|
|
195
|
+
// @param {module:core/editor/editor~Editor} options.editor
|
|
196
|
+
// @param {module:list/liststylecommand~ListStylesCommand} options.listStyleCommand The instance of the `ListStylesCommand` class.
|
|
197
|
+
// @param {'bulletedList'|'numberedList'} options.parentCommandName The name of the higher-order command associated with a
|
|
198
|
+
// particular list style (e.g. "bulletedList" is associated with "square" and "numberedList" is associated with "roman").
|
|
199
|
+
// @returns {Function} A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.
|
|
200
|
+
function getStyleButtonCreator( { editor, listStyleCommand, parentCommandName } ) {
|
|
201
|
+
const locale = editor.locale;
|
|
202
|
+
const parentCommand = editor.commands.get( parentCommandName );
|
|
203
|
+
|
|
204
|
+
// @param {String} label The label of the style button.
|
|
205
|
+
// @param {String} type The type of the style button (e.g. "roman" or "circle").
|
|
206
|
+
// @param {String} icon The SVG string of an icon of the style button.
|
|
207
|
+
// @param {String} tooltip The tooltip text of the button (shorter than verbose label).
|
|
208
|
+
// @returns {module:ui/button/buttonview~ButtonView}
|
|
209
|
+
return ( { label, type, icon, tooltip } ) => {
|
|
210
|
+
const button = new ButtonView( locale );
|
|
211
|
+
|
|
212
|
+
button.set( { label, icon, tooltip } );
|
|
213
|
+
|
|
214
|
+
listStyleCommand.on( 'change:value', () => {
|
|
215
|
+
button.isOn = listStyleCommand.value === type;
|
|
216
|
+
} );
|
|
217
|
+
|
|
218
|
+
button.on( 'execute', () => {
|
|
219
|
+
// If the content the selection is anchored to is a list, let's change its style.
|
|
220
|
+
if ( parentCommand.value ) {
|
|
221
|
+
// If the current list style is not set in the model or the style is different than the
|
|
222
|
+
// one to be applied, simply apply the new style.
|
|
223
|
+
if ( listStyleCommand.value !== type ) {
|
|
224
|
+
editor.execute( 'listStyle', { type } );
|
|
225
|
+
}
|
|
226
|
+
// If the style was the same, remove it (the button works as an off toggle).
|
|
227
|
+
else {
|
|
228
|
+
editor.execute( 'listStyle', { type: listStyleCommand._defaultType } );
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// If the content the selection is anchored to is not a list, let's create a list of a desired style.
|
|
232
|
+
else {
|
|
233
|
+
editor.model.change( () => {
|
|
234
|
+
editor.execute( parentCommandName );
|
|
235
|
+
editor.execute( 'listStyle', { type } );
|
|
236
|
+
} );
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
editor.editing.view.focus();
|
|
240
|
+
} );
|
|
241
|
+
|
|
242
|
+
return button;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// A helper that creates the properties view for the individual style dropdown.
|
|
247
|
+
//
|
|
248
|
+
// @param {Object} options
|
|
249
|
+
// @param {module:core/editor/editor~Editor} options.editor Editor instance.
|
|
250
|
+
// @param {module:ui/dropdown/dropdownview~DropdownView} options.dropdownView Styles dropdown view that hosts the properties view.
|
|
251
|
+
// @param {'bulletedList'|'numberedList'} options.parentCommandName The name of the higher-order editor command associated with
|
|
252
|
+
// the set of particular list styles (e.g. "bulletedList" for "disc", "circle", and "square" styles).
|
|
253
|
+
// @param {Object} options.styleDefinitions Definitions of the style buttons.
|
|
254
|
+
// @param {String} options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).
|
|
255
|
+
// @returns {module:list/ui/listpropertiesview~ListPropertiesView}
|
|
256
|
+
function createListPropertiesView( {
|
|
257
|
+
editor,
|
|
258
|
+
dropdownView,
|
|
259
|
+
parentCommandName,
|
|
260
|
+
styleDefinitions,
|
|
261
|
+
styleGridAriaLabel
|
|
262
|
+
} ) {
|
|
263
|
+
const locale = editor.locale;
|
|
264
|
+
const enabledProperties = editor.config.get( 'list.properties' );
|
|
265
|
+
let styleButtonViews;
|
|
266
|
+
|
|
267
|
+
if ( parentCommandName != 'numberedList' ) {
|
|
268
|
+
enabledProperties.startIndex = false;
|
|
269
|
+
enabledProperties.reversed = false;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if ( enabledProperties.styles ) {
|
|
273
|
+
const listStyleCommand = editor.commands.get( 'listStyle' );
|
|
274
|
+
|
|
275
|
+
const styleButtonCreator = getStyleButtonCreator( {
|
|
276
|
+
editor,
|
|
277
|
+
parentCommandName,
|
|
278
|
+
listStyleCommand
|
|
279
|
+
} );
|
|
280
|
+
|
|
281
|
+
styleButtonViews = styleDefinitions.map( styleButtonCreator );
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const listPropertiesView = new ListPropertiesView( locale, {
|
|
285
|
+
styleGridAriaLabel,
|
|
286
|
+
enabledProperties,
|
|
287
|
+
styleButtonViews
|
|
288
|
+
} );
|
|
289
|
+
|
|
290
|
+
if ( enabledProperties.startIndex ) {
|
|
291
|
+
const listStartCommand = editor.commands.get( 'listStart' );
|
|
292
|
+
|
|
293
|
+
listPropertiesView.startIndexFieldView.bind( 'isEnabled' ).to( listStartCommand );
|
|
294
|
+
listPropertiesView.startIndexFieldView.fieldView.bind( 'value' ).to( listStartCommand );
|
|
295
|
+
listPropertiesView.on( 'listStart', ( evt, data ) => editor.execute( 'listStart', data ) );
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if ( enabledProperties.reversed ) {
|
|
299
|
+
const listReversedCommand = editor.commands.get( 'listReversed' );
|
|
300
|
+
|
|
301
|
+
listPropertiesView.reversedSwitchButtonView.bind( 'isEnabled' ).to( listReversedCommand );
|
|
302
|
+
listPropertiesView.reversedSwitchButtonView.bind( 'isOn' ).to( listReversedCommand, 'value' );
|
|
303
|
+
listPropertiesView.on( 'listReversed', () => {
|
|
304
|
+
const isReversed = listReversedCommand.value;
|
|
305
|
+
|
|
306
|
+
editor.execute( 'listReversed', { reversed: !isReversed } );
|
|
307
|
+
} );
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Make sure applying styles closes the dropdown.
|
|
311
|
+
listPropertiesView.delegate( 'execute' ).to( dropdownView );
|
|
312
|
+
|
|
313
|
+
return listPropertiesView;
|
|
314
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
/**
|
|
7
|
+
* @module list/listreversedcommand
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
|
11
|
+
import { getSelectedListItems } from './utils';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The reversed list command. It changes the `listReversed` attribute of the selected list items. As a result, the list order will be
|
|
15
|
+
* reversed.
|
|
16
|
+
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
17
|
+
*
|
|
18
|
+
* @extends module:core/command~Command
|
|
19
|
+
*/
|
|
20
|
+
export default class ListReversedCommand extends Command {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
refresh() {
|
|
25
|
+
const value = this._getValue();
|
|
26
|
+
this.value = value;
|
|
27
|
+
this.isEnabled = value != null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Executes the command.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} options
|
|
34
|
+
* @param {Boolean} [options.reversed=false] Whether the list should be reversed.
|
|
35
|
+
* @protected
|
|
36
|
+
*/
|
|
37
|
+
execute( options = {} ) {
|
|
38
|
+
const model = this.editor.model;
|
|
39
|
+
const listItems = getSelectedListItems( model )
|
|
40
|
+
.filter( item => item.getAttribute( 'listType' ) == 'numbered' );
|
|
41
|
+
|
|
42
|
+
model.change( writer => {
|
|
43
|
+
for ( const item of listItems ) {
|
|
44
|
+
writer.setAttribute( 'listReversed', !!options.reversed, item );
|
|
45
|
+
}
|
|
46
|
+
} );
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Checks the command's {@link #value}.
|
|
51
|
+
*
|
|
52
|
+
* @private
|
|
53
|
+
* @returns {Boolean|null} The current value.
|
|
54
|
+
*/
|
|
55
|
+
_getValue() {
|
|
56
|
+
const listItem = this.editor.model.document.selection.getFirstPosition().parent;
|
|
57
|
+
|
|
58
|
+
if ( listItem && listItem.is( 'element', 'listItem' ) && listItem.getAttribute( 'listType' ) == 'numbered' ) {
|
|
59
|
+
return listItem.getAttribute( 'listReversed' );
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
/**
|
|
7
|
+
* @module list/liststartcommand
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
|
11
|
+
import { getSelectedListItems } from './utils';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The list start index command. It changes the `listStart` attribute of the selected list items.
|
|
15
|
+
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
16
|
+
*
|
|
17
|
+
* @extends module:core/command~Command
|
|
18
|
+
*/
|
|
19
|
+
export default class ListStartCommand extends Command {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
refresh() {
|
|
24
|
+
const value = this._getValue();
|
|
25
|
+
this.value = value;
|
|
26
|
+
this.isEnabled = value != null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Executes the command.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} options
|
|
33
|
+
* @param {Number} [options.startIndex=1] The list start index.
|
|
34
|
+
* @protected
|
|
35
|
+
*/
|
|
36
|
+
execute( options = {} ) {
|
|
37
|
+
const model = this.editor.model;
|
|
38
|
+
const listItems = getSelectedListItems( model )
|
|
39
|
+
.filter( item => item.getAttribute( 'listType' ) == 'numbered' );
|
|
40
|
+
|
|
41
|
+
model.change( writer => {
|
|
42
|
+
for ( const item of listItems ) {
|
|
43
|
+
writer.setAttribute( 'listStart', options.startIndex || 1, item );
|
|
44
|
+
}
|
|
45
|
+
} );
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Checks the command's {@link #value}.
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
* @returns {Boolean|null} The current value.
|
|
53
|
+
*/
|
|
54
|
+
_getValue() {
|
|
55
|
+
const listItem = this.editor.model.document.selection.getFirstPosition().parent;
|
|
56
|
+
|
|
57
|
+
if ( listItem && listItem.is( 'element', 'listItem' ) && listItem.getAttribute( 'listType' ) == 'numbered' ) {
|
|
58
|
+
return listItem.getAttribute( 'listStart' );
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/liststyle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
11
|
+
import ListProperties from './listproperties';
|
|
12
|
+
import { logWarning } from 'ckeditor5/src/utils';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The list style feature.
|
|
16
16
|
*
|
|
17
|
-
* This is
|
|
18
|
-
*
|
|
17
|
+
* This is an obsolete plugin that exists for backward compatibility only.
|
|
18
|
+
* Use the {@link module:list/listproperties~ListProperties list properties plugin} instead.
|
|
19
19
|
*
|
|
20
20
|
* @extends module:core/plugin~Plugin
|
|
21
21
|
*/
|
|
@@ -24,7 +24,7 @@ export default class ListStyle extends Plugin {
|
|
|
24
24
|
* @inheritDoc
|
|
25
25
|
*/
|
|
26
26
|
static get requires() {
|
|
27
|
-
return [
|
|
27
|
+
return [ ListProperties ];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -33,4 +33,10 @@ export default class ListStyle extends Plugin {
|
|
|
33
33
|
static get pluginName() {
|
|
34
34
|
return 'ListStyle';
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
constructor( editor ) {
|
|
38
|
+
super( editor );
|
|
39
|
+
|
|
40
|
+
logWarning( 'The `ListStyle` plugin is obsolete. Use `ListProperties` instead.' );
|
|
41
|
+
}
|
|
36
42
|
}
|
package/src/liststylecommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
import {
|
|
11
|
+
import { getSelectedListItems } from './utils';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* The list style command. It
|
|
14
|
+
* The list style command. It changes the `listStyle` attribute of the selected list items.
|
|
15
|
+
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
15
16
|
*
|
|
16
17
|
* @extends module:core/command~Command
|
|
17
18
|
*/
|
|
@@ -53,25 +54,7 @@ export default class ListStyleCommand extends Command {
|
|
|
53
54
|
*/
|
|
54
55
|
execute( options = {} ) {
|
|
55
56
|
const model = this.editor.model;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
// For all selected blocks find all list items that are being selected
|
|
59
|
-
// and update the `listStyle` attribute in those lists.
|
|
60
|
-
let listItems = [ ...document.selection.getSelectedBlocks() ]
|
|
61
|
-
.filter( element => element.is( 'element', 'listItem' ) )
|
|
62
|
-
.map( element => {
|
|
63
|
-
const position = model.change( writer => writer.createPositionAt( element, 0 ) );
|
|
64
|
-
|
|
65
|
-
return [
|
|
66
|
-
...getSiblingNodes( position, 'backward' ),
|
|
67
|
-
...getSiblingNodes( position, 'forward' )
|
|
68
|
-
];
|
|
69
|
-
} )
|
|
70
|
-
.flat();
|
|
71
|
-
|
|
72
|
-
// Since `getSelectedBlocks()` can return items that belong to the same list, and
|
|
73
|
-
// `getSiblingNodes()` returns the entire list, we need to remove duplicated items.
|
|
74
|
-
listItems = [ ...new Set( listItems ) ];
|
|
57
|
+
const listItems = getSelectedListItems( model );
|
|
75
58
|
|
|
76
59
|
if ( !listItems.length ) {
|
|
77
60
|
return;
|
package/src/listui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/todolist.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/todolistediting.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/todolistui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|