@ckeditor/ckeditor5-list 31.1.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 -1
- 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 +17 -1
- 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 +17 -1
- 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 +17 -1
- package/lang/translations/vi.po +17 -1
- package/lang/translations/zh-cn.po +17 -1
- package/lang/translations/zh.po +17 -1
- package/package.json +27 -27
- package/src/checktodolistcommand.js +1 -1
- package/src/converters.js +13 -1
- 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/src/liststyleui.js +0 -225
package/src/liststyleui.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @module list/liststyleui
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
import { ButtonView, SplitButtonView, createDropdown, addToolbarToDropdown } from 'ckeditor5/src/ui';
|
|
12
|
-
|
|
13
|
-
import bulletedListIcon from '../theme/icons/bulletedlist.svg';
|
|
14
|
-
import numberedListIcon from '../theme/icons/numberedlist.svg';
|
|
15
|
-
|
|
16
|
-
import listStyleDiscIcon from '../theme/icons/liststyledisc.svg';
|
|
17
|
-
import listStyleCircleIcon from '../theme/icons/liststylecircle.svg';
|
|
18
|
-
import listStyleSquareIcon from '../theme/icons/liststylesquare.svg';
|
|
19
|
-
import listStyleDecimalIcon from '../theme/icons/liststyledecimal.svg';
|
|
20
|
-
import listStyleDecimalWithLeadingZeroIcon from '../theme/icons/liststyledecimalleadingzero.svg';
|
|
21
|
-
import listStyleLowerRomanIcon from '../theme/icons/liststylelowerroman.svg';
|
|
22
|
-
import listStyleUpperRomanIcon from '../theme/icons/liststyleupperroman.svg';
|
|
23
|
-
import listStyleLowerLatinIcon from '../theme/icons/liststylelowerlatin.svg';
|
|
24
|
-
import listStyleUpperLatinIcon from '../theme/icons/liststyleupperlatin.svg';
|
|
25
|
-
|
|
26
|
-
import '../theme/liststyles.css';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The list style UI plugin. It introduces the extended `'bulletedList'` and `'numberedList'` toolbar
|
|
30
|
-
* buttons that allow users to change styles of individual lists in the content.
|
|
31
|
-
*
|
|
32
|
-
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/listui~ListUI}
|
|
33
|
-
* (because they share the same names).
|
|
34
|
-
*
|
|
35
|
-
* @extends module:core/plugin~Plugin
|
|
36
|
-
*/
|
|
37
|
-
export default class ListStyleUI extends Plugin {
|
|
38
|
-
/**
|
|
39
|
-
* @inheritDoc
|
|
40
|
-
*/
|
|
41
|
-
static get pluginName() {
|
|
42
|
-
return 'ListStyleUI';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
init() {
|
|
46
|
-
const editor = this.editor;
|
|
47
|
-
const t = editor.locale.t;
|
|
48
|
-
|
|
49
|
-
editor.ui.componentFactory.add( 'bulletedList', getSplitButtonCreator( {
|
|
50
|
-
editor,
|
|
51
|
-
parentCommandName: 'bulletedList',
|
|
52
|
-
buttonLabel: t( 'Bulleted List' ),
|
|
53
|
-
buttonIcon: bulletedListIcon,
|
|
54
|
-
toolbarAriaLabel: t( 'Bulleted list styles toolbar' ),
|
|
55
|
-
styleDefinitions: [
|
|
56
|
-
{
|
|
57
|
-
label: t( 'Toggle the disc list style' ),
|
|
58
|
-
tooltip: t( 'Disc' ),
|
|
59
|
-
type: 'disc',
|
|
60
|
-
icon: listStyleDiscIcon
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
label: t( 'Toggle the circle list style' ),
|
|
64
|
-
tooltip: t( 'Circle' ),
|
|
65
|
-
type: 'circle',
|
|
66
|
-
icon: listStyleCircleIcon
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
label: t( 'Toggle the square list style' ),
|
|
70
|
-
tooltip: t( 'Square' ),
|
|
71
|
-
type: 'square',
|
|
72
|
-
icon: listStyleSquareIcon
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
} ) );
|
|
76
|
-
|
|
77
|
-
editor.ui.componentFactory.add( 'numberedList', getSplitButtonCreator( {
|
|
78
|
-
editor,
|
|
79
|
-
parentCommandName: 'numberedList',
|
|
80
|
-
buttonLabel: t( 'Numbered List' ),
|
|
81
|
-
buttonIcon: numberedListIcon,
|
|
82
|
-
toolbarAriaLabel: t( 'Numbered list styles toolbar' ),
|
|
83
|
-
styleDefinitions: [
|
|
84
|
-
{
|
|
85
|
-
label: t( 'Toggle the decimal list style' ),
|
|
86
|
-
tooltip: t( 'Decimal' ),
|
|
87
|
-
type: 'decimal',
|
|
88
|
-
icon: listStyleDecimalIcon
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: t( 'Toggle the decimal with leading zero list style' ),
|
|
92
|
-
tooltip: t( 'Decimal with leading zero' ),
|
|
93
|
-
type: 'decimal-leading-zero',
|
|
94
|
-
icon: listStyleDecimalWithLeadingZeroIcon
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
label: t( 'Toggle the lower–roman list style' ),
|
|
98
|
-
tooltip: t( 'Lower–roman' ),
|
|
99
|
-
type: 'lower-roman',
|
|
100
|
-
icon: listStyleLowerRomanIcon
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
label: t( 'Toggle the upper–roman list style' ),
|
|
104
|
-
tooltip: t( 'Upper-roman' ),
|
|
105
|
-
type: 'upper-roman',
|
|
106
|
-
icon: listStyleUpperRomanIcon
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
label: t( 'Toggle the lower–latin list style' ),
|
|
110
|
-
tooltip: t( 'Lower-latin' ),
|
|
111
|
-
type: 'lower-latin',
|
|
112
|
-
icon: listStyleLowerLatinIcon
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
label: t( 'Toggle the upper–latin list style' ),
|
|
116
|
-
tooltip: t( 'Upper-latin' ),
|
|
117
|
-
type: 'upper-latin',
|
|
118
|
-
icon: listStyleUpperLatinIcon
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
} ) );
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// A helper that returns a function that creates a split button with a toolbar in the dropdown,
|
|
126
|
-
// which in turn contains buttons allowing users to change list styles in the context of the current selection.
|
|
127
|
-
//
|
|
128
|
-
// @param {Object} options
|
|
129
|
-
// @param {module:core/editor/editor~Editor} options.editor
|
|
130
|
-
// @param {'bulletedList'|'numberedList'} options.parentCommandName The name of the higher-order editor command associated with
|
|
131
|
-
// the set of particular list styles (e.g. "bulletedList" for "disc", "circle", and "square" styles).
|
|
132
|
-
// @param {String} options.buttonLabel Label of the main part of the split button.
|
|
133
|
-
// @param {String} options.buttonIcon The SVG string of an icon for the main part of the split button.
|
|
134
|
-
// @param {String} options.toolbarAriaLabel The ARIA label for the toolbar in the split button dropdown.
|
|
135
|
-
// @param {Object} options.styleDefinitions Definitions of the style buttons.
|
|
136
|
-
// @returns {Function} A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.
|
|
137
|
-
function getSplitButtonCreator( { editor, parentCommandName, buttonLabel, buttonIcon, toolbarAriaLabel, styleDefinitions } ) {
|
|
138
|
-
const parentCommand = editor.commands.get( parentCommandName );
|
|
139
|
-
const listStyleCommand = editor.commands.get( 'listStyle' );
|
|
140
|
-
|
|
141
|
-
// @param {module:utils/locale~Locale} locale
|
|
142
|
-
// @returns {module:ui/dropdown/dropdownview~DropdownView}
|
|
143
|
-
return locale => {
|
|
144
|
-
const dropdownView = createDropdown( locale, SplitButtonView );
|
|
145
|
-
const splitButtonView = dropdownView.buttonView;
|
|
146
|
-
const styleButtonCreator = getStyleButtonCreator( { editor, parentCommandName, listStyleCommand } );
|
|
147
|
-
|
|
148
|
-
addToolbarToDropdown( dropdownView, styleDefinitions.map( styleButtonCreator ) );
|
|
149
|
-
|
|
150
|
-
dropdownView.bind( 'isEnabled' ).to( parentCommand );
|
|
151
|
-
dropdownView.toolbarView.ariaLabel = toolbarAriaLabel;
|
|
152
|
-
dropdownView.class = 'ck-list-styles-dropdown';
|
|
153
|
-
|
|
154
|
-
splitButtonView.on( 'execute', () => {
|
|
155
|
-
editor.execute( parentCommandName );
|
|
156
|
-
editor.editing.view.focus();
|
|
157
|
-
} );
|
|
158
|
-
|
|
159
|
-
splitButtonView.set( {
|
|
160
|
-
label: buttonLabel,
|
|
161
|
-
icon: buttonIcon,
|
|
162
|
-
tooltip: true,
|
|
163
|
-
isToggleable: true
|
|
164
|
-
} );
|
|
165
|
-
|
|
166
|
-
splitButtonView.bind( 'isOn' ).to( parentCommand, 'value', value => !!value );
|
|
167
|
-
|
|
168
|
-
return dropdownView;
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// A helper that returns a function (factory) that creates individual buttons used by users to change styles
|
|
173
|
-
// of lists.
|
|
174
|
-
//
|
|
175
|
-
// @param {Object} options
|
|
176
|
-
// @param {module:core/editor/editor~Editor} options.editor
|
|
177
|
-
// @param {module:list/liststylecommand~ListStylesCommand} options.listStyleCommand The instance of the `ListStylesCommand` class.
|
|
178
|
-
// @param {'bulletedList'|'numberedList'} options.parentCommandName The name of the higher-order command associated with a
|
|
179
|
-
// particular list style (e.g. "bulletedList" is associated with "square" and "numberedList" is associated with "roman").
|
|
180
|
-
// @returns {Function} A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.
|
|
181
|
-
function getStyleButtonCreator( { editor, listStyleCommand, parentCommandName } ) {
|
|
182
|
-
const locale = editor.locale;
|
|
183
|
-
const parentCommand = editor.commands.get( parentCommandName );
|
|
184
|
-
|
|
185
|
-
// @param {String} label The label of the style button.
|
|
186
|
-
// @param {String} type The type of the style button (e.g. "roman" or "circle").
|
|
187
|
-
// @param {String} icon The SVG string of an icon of the style button.
|
|
188
|
-
// @param {String} tooltip The tooltip text of the button (shorter than verbose label).
|
|
189
|
-
// @returns {module:ui/button/buttonview~ButtonView}
|
|
190
|
-
return ( { label, type, icon, tooltip } ) => {
|
|
191
|
-
const button = new ButtonView( locale );
|
|
192
|
-
|
|
193
|
-
button.set( { label, icon, tooltip } );
|
|
194
|
-
|
|
195
|
-
listStyleCommand.on( 'change:value', () => {
|
|
196
|
-
button.isOn = listStyleCommand.value === type;
|
|
197
|
-
} );
|
|
198
|
-
|
|
199
|
-
button.on( 'execute', () => {
|
|
200
|
-
// If the content the selection is anchored to is a list, let's change its style.
|
|
201
|
-
if ( parentCommand.value ) {
|
|
202
|
-
// If the current list style is not set in the model or the style is different than the
|
|
203
|
-
// one to be applied, simply apply the new style.
|
|
204
|
-
if ( listStyleCommand.value !== type ) {
|
|
205
|
-
editor.execute( 'listStyle', { type } );
|
|
206
|
-
}
|
|
207
|
-
// If the style was the same, remove it (the button works as an off toggle).
|
|
208
|
-
else {
|
|
209
|
-
editor.execute( 'listStyle', { type: listStyleCommand._defaultType } );
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
// If the content the selection is anchored to is not a list, let's create a list of a desired style.
|
|
213
|
-
else {
|
|
214
|
-
editor.model.change( () => {
|
|
215
|
-
editor.execute( parentCommandName );
|
|
216
|
-
editor.execute( 'listStyle', { type } );
|
|
217
|
-
} );
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
editor.editing.view.focus();
|
|
221
|
-
} );
|
|
222
|
-
|
|
223
|
-
return button;
|
|
224
|
-
};
|
|
225
|
-
}
|