@ckeditor/ckeditor5-image 36.0.0 → 37.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/build/image.js +1 -1
- package/package.json +40 -35
- package/src/autoimage.d.ts +53 -0
- package/src/autoimage.js +111 -160
- package/src/image/converters.d.ts +66 -0
- package/src/image/converters.js +200 -261
- package/src/image/imageblockediting.d.ts +57 -0
- package/src/image/imageblockediting.js +111 -155
- package/src/image/imageediting.d.ts +34 -0
- package/src/image/imageediting.js +53 -67
- package/src/image/imageinlineediting.d.ts +53 -0
- package/src/image/imageinlineediting.js +135 -180
- package/src/image/imageloadobserver.d.ts +44 -0
- package/src/image/imageloadobserver.js +28 -47
- package/src/image/imagetypecommand.d.ts +46 -0
- package/src/image/imagetypecommand.js +67 -95
- package/src/image/insertimagecommand.d.ts +72 -0
- package/src/image/insertimagecommand.js +95 -101
- package/src/image/replaceimagesourcecommand.d.ts +39 -0
- package/src/image/replaceimagesourcecommand.js +28 -33
- package/src/image/ui/utils.d.ts +25 -0
- package/src/image/ui/utils.js +25 -35
- package/src/image/utils.d.ts +52 -0
- package/src/image/utils.js +63 -90
- package/src/image.d.ts +38 -0
- package/src/image.js +13 -43
- package/src/imageblock.d.ts +35 -0
- package/src/imageblock.js +12 -21
- package/src/imagecaption/imagecaptionediting.d.ts +92 -0
- package/src/imagecaption/imagecaptionediting.js +203 -262
- package/src/imagecaption/imagecaptionui.d.ts +30 -0
- package/src/imagecaption/imagecaptionui.js +46 -63
- package/src/imagecaption/imagecaptionutils.d.ts +42 -0
- package/src/imagecaption/imagecaptionutils.js +51 -78
- package/src/imagecaption/toggleimagecaptioncommand.d.ts +71 -0
- package/src/imagecaption/toggleimagecaptioncommand.js +112 -138
- package/src/imagecaption.d.ts +29 -0
- package/src/imagecaption.js +12 -19
- package/src/imageconfig.d.ts +723 -0
- package/src/imageconfig.js +5 -0
- package/src/imageinline.d.ts +35 -0
- package/src/imageinline.js +12 -21
- package/src/imageinsert/imageinsertui.d.ts +49 -0
- package/src/imageinsert/imageinsertui.js +120 -158
- package/src/imageinsert/ui/imageinsertformrowview.d.ts +61 -0
- package/src/imageinsert/ui/imageinsertformrowview.js +37 -86
- package/src/imageinsert/ui/imageinsertpanelview.d.ts +106 -0
- package/src/imageinsert/ui/imageinsertpanelview.js +148 -258
- package/src/imageinsert/utils.d.ts +26 -0
- package/src/imageinsert/utils.js +42 -58
- package/src/imageinsert.d.ts +35 -0
- package/src/imageinsert.js +13 -84
- package/src/imageinsertviaurl.d.ts +34 -0
- package/src/imageinsertviaurl.js +12 -18
- package/src/imageresize/imageresizebuttons.d.ts +66 -0
- package/src/imageresize/imageresizebuttons.js +190 -255
- package/src/imageresize/imageresizeediting.d.ts +42 -0
- package/src/imageresize/imageresizeediting.js +100 -125
- package/src/imageresize/imageresizehandles.d.ts +30 -0
- package/src/imageresize/imageresizehandles.js +91 -123
- package/src/imageresize/resizeimagecommand.d.ts +47 -0
- package/src/imageresize/resizeimagecommand.js +48 -55
- package/src/imageresize.d.ts +29 -0
- package/src/imageresize.js +12 -209
- package/src/imagestyle/converters.d.ts +24 -0
- package/src/imagestyle/converters.js +60 -78
- package/src/imagestyle/imagestylecommand.d.ts +70 -0
- package/src/imagestyle/imagestylecommand.js +88 -124
- package/src/imagestyle/imagestyleediting.d.ts +54 -0
- package/src/imagestyle/imagestyleediting.js +90 -137
- package/src/imagestyle/imagestyleui.d.ts +60 -0
- package/src/imagestyle/imagestyleui.js +169 -277
- package/src/imagestyle/utils.d.ts +61 -0
- package/src/imagestyle/utils.js +253 -306
- package/src/imagestyle.d.ts +35 -0
- package/src/imagestyle.js +13 -261
- package/src/imagetextalternative/imagetextalternativecommand.d.ts +39 -0
- package/src/imagetextalternative/imagetextalternativecommand.js +31 -47
- package/src/imagetextalternative/imagetextalternativeediting.d.ts +32 -0
- package/src/imagetextalternative/imagetextalternativeediting.js +18 -25
- package/src/imagetextalternative/imagetextalternativeui.d.ts +72 -0
- package/src/imagetextalternative/imagetextalternativeui.js +156 -219
- package/src/imagetextalternative/ui/textalternativeformview.d.ts +72 -0
- package/src/imagetextalternative/ui/textalternativeformview.js +103 -192
- package/src/imagetextalternative.d.ts +32 -0
- package/src/imagetextalternative.js +12 -18
- package/src/imagetoolbar.d.ts +38 -0
- package/src/imagetoolbar.js +31 -77
- package/src/imageupload/imageuploadediting.d.ts +114 -0
- package/src/imageupload/imageuploadediting.js +308 -427
- package/src/imageupload/imageuploadprogress.d.ts +47 -0
- package/src/imageupload/imageuploadprogress.js +180 -261
- package/src/imageupload/imageuploadui.d.ts +29 -0
- package/src/imageupload/imageuploadui.js +41 -57
- package/src/imageupload/uploadimagecommand.d.ts +65 -0
- package/src/imageupload/uploadimagecommand.js +73 -87
- package/src/imageupload/utils.d.ts +33 -0
- package/src/imageupload/utils.js +87 -112
- package/src/imageupload.d.ts +34 -0
- package/src/imageupload.js +12 -61
- package/src/imageutils.d.ts +108 -0
- package/src/imageutils.js +233 -329
- package/src/index.d.ts +31 -0
- package/src/index.js +0 -2
- package/src/pictureediting.d.ts +86 -0
- package/src/pictureediting.js +101 -120
|
@@ -2,299 +2,191 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, 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
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module image/imagestyle/imagestyleui
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import { ButtonView, createDropdown, addToolbarToDropdown, SplitButtonView } from 'ckeditor5/src/ui';
|
|
10
|
+
import { isObject, identity } from 'lodash-es';
|
|
12
11
|
import ImageStyleEditing from './imagestyleediting';
|
|
13
12
|
import utils from './utils';
|
|
14
|
-
import { isObject, identity } from 'lodash-es';
|
|
15
|
-
|
|
16
13
|
import '../../theme/imagestyle.css';
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* The image style UI plugin.
|
|
20
16
|
*
|
|
21
|
-
* It registers buttons corresponding to the {@link module:image/
|
|
17
|
+
* It registers buttons corresponding to the {@link module:image/imageconfig~ImageConfig#styles} configuration.
|
|
22
18
|
* It also registers the {@link module:image/imagestyle/utils~DEFAULT_DROPDOWN_DEFINITIONS default drop-downs} and the
|
|
23
|
-
* custom drop-downs defined by the developer in the {@link module:image/
|
|
24
|
-
*
|
|
25
|
-
* @extends module:core/plugin~Plugin
|
|
19
|
+
* custom drop-downs defined by the developer in the {@link module:image/imageconfig~ImageConfig#toolbar} configuration.
|
|
26
20
|
*/
|
|
27
21
|
export default class ImageStyleUI extends Plugin {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
.toMany( buttonViews, 'isEnabled', ( ...areEnabled ) => areEnabled.some( identity ) );
|
|
174
|
-
|
|
175
|
-
// Focus the editable after executing the command.
|
|
176
|
-
// Overrides a default behaviour where the focus is moved to the dropdown button (#12125).
|
|
177
|
-
this.listenTo( dropdownView, 'execute', () => {
|
|
178
|
-
this.editor.editing.view.focus();
|
|
179
|
-
} );
|
|
180
|
-
|
|
181
|
-
return dropdownView;
|
|
182
|
-
} );
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Creates a button and stores it in the editor {@link module:ui/componentfactory~ComponentFactory}.
|
|
187
|
-
*
|
|
188
|
-
* @private
|
|
189
|
-
* @param {module:image/imagestyle~ImageStyleOptionDefinition} buttonConfig
|
|
190
|
-
*/
|
|
191
|
-
_createButton( buttonConfig ) {
|
|
192
|
-
const buttonName = buttonConfig.name;
|
|
193
|
-
|
|
194
|
-
this.editor.ui.componentFactory.add( getUIComponentName( buttonName ), locale => {
|
|
195
|
-
const command = this.editor.commands.get( 'imageStyle' );
|
|
196
|
-
const view = new ButtonView( locale );
|
|
197
|
-
|
|
198
|
-
view.set( {
|
|
199
|
-
label: buttonConfig.title,
|
|
200
|
-
icon: buttonConfig.icon,
|
|
201
|
-
tooltip: true,
|
|
202
|
-
isToggleable: true
|
|
203
|
-
} );
|
|
204
|
-
|
|
205
|
-
view.bind( 'isEnabled' ).to( command, 'isEnabled' );
|
|
206
|
-
view.bind( 'isOn' ).to( command, 'value', value => value === buttonName );
|
|
207
|
-
view.on( 'execute', this._executeCommand.bind( this, buttonName ) );
|
|
208
|
-
|
|
209
|
-
return view;
|
|
210
|
-
} );
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
_executeCommand( name ) {
|
|
214
|
-
this.editor.execute( 'imageStyle', { value: name } );
|
|
215
|
-
this.editor.editing.view.focus();
|
|
216
|
-
}
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires() {
|
|
26
|
+
return [ImageStyleEditing];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
static get pluginName() {
|
|
32
|
+
return 'ImageStyleUI';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the default localized style titles provided by the plugin.
|
|
36
|
+
*
|
|
37
|
+
* The following localized titles corresponding with
|
|
38
|
+
* {@link module:image/imagestyle/utils~DEFAULT_OPTIONS} are available:
|
|
39
|
+
*
|
|
40
|
+
* * `'Wrap text'`,
|
|
41
|
+
* * `'Break text'`,
|
|
42
|
+
* * `'In line'`,
|
|
43
|
+
* * `'Full size image'`,
|
|
44
|
+
* * `'Side image'`,
|
|
45
|
+
* * `'Left aligned image'`,
|
|
46
|
+
* * `'Centered image'`,
|
|
47
|
+
* * `'Right aligned image'`
|
|
48
|
+
*/
|
|
49
|
+
get localizedDefaultStylesTitles() {
|
|
50
|
+
const t = this.editor.t;
|
|
51
|
+
return {
|
|
52
|
+
'Wrap text': t('Wrap text'),
|
|
53
|
+
'Break text': t('Break text'),
|
|
54
|
+
'In line': t('In line'),
|
|
55
|
+
'Full size image': t('Full size image'),
|
|
56
|
+
'Side image': t('Side image'),
|
|
57
|
+
'Left aligned image': t('Left aligned image'),
|
|
58
|
+
'Centered image': t('Centered image'),
|
|
59
|
+
'Right aligned image': t('Right aligned image')
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @inheritDoc
|
|
64
|
+
*/
|
|
65
|
+
init() {
|
|
66
|
+
const plugins = this.editor.plugins;
|
|
67
|
+
const toolbarConfig = this.editor.config.get('image.toolbar') || [];
|
|
68
|
+
const imageStyleEditing = plugins.get('ImageStyleEditing');
|
|
69
|
+
const definedStyles = translateStyles(imageStyleEditing.normalizedStyles, this.localizedDefaultStylesTitles);
|
|
70
|
+
for (const styleConfig of definedStyles) {
|
|
71
|
+
this._createButton(styleConfig);
|
|
72
|
+
}
|
|
73
|
+
const definedDropdowns = translateStyles([
|
|
74
|
+
...toolbarConfig.filter(isObject),
|
|
75
|
+
...utils.getDefaultDropdownDefinitions(plugins)
|
|
76
|
+
], this.localizedDefaultStylesTitles);
|
|
77
|
+
for (const dropdownConfig of definedDropdowns) {
|
|
78
|
+
this._createDropdown(dropdownConfig, definedStyles);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a dropdown and stores it in the editor {@link module:ui/componentfactory~ComponentFactory}.
|
|
83
|
+
*/
|
|
84
|
+
_createDropdown(dropdownConfig, definedStyles) {
|
|
85
|
+
const factory = this.editor.ui.componentFactory;
|
|
86
|
+
factory.add(dropdownConfig.name, locale => {
|
|
87
|
+
let defaultButton;
|
|
88
|
+
const { defaultItem, items, title } = dropdownConfig;
|
|
89
|
+
const buttonViews = items
|
|
90
|
+
.filter(itemName => definedStyles.find(({ name }) => getUIComponentName(name) === itemName))
|
|
91
|
+
.map(buttonName => {
|
|
92
|
+
const button = factory.create(buttonName);
|
|
93
|
+
if (buttonName === defaultItem) {
|
|
94
|
+
defaultButton = button;
|
|
95
|
+
}
|
|
96
|
+
return button;
|
|
97
|
+
});
|
|
98
|
+
if (items.length !== buttonViews.length) {
|
|
99
|
+
utils.warnInvalidStyle({ dropdown: dropdownConfig });
|
|
100
|
+
}
|
|
101
|
+
const dropdownView = createDropdown(locale, SplitButtonView);
|
|
102
|
+
const splitButtonView = dropdownView.buttonView;
|
|
103
|
+
const splitButtonViewArrow = splitButtonView.arrowView;
|
|
104
|
+
addToolbarToDropdown(dropdownView, buttonViews, { enableActiveItemFocusOnDropdownOpen: true });
|
|
105
|
+
splitButtonView.set({
|
|
106
|
+
label: getDropdownButtonTitle(title, defaultButton.label),
|
|
107
|
+
class: null,
|
|
108
|
+
tooltip: true
|
|
109
|
+
});
|
|
110
|
+
splitButtonViewArrow.unbind('label');
|
|
111
|
+
splitButtonViewArrow.set({
|
|
112
|
+
label: title
|
|
113
|
+
});
|
|
114
|
+
splitButtonView.bind('icon').toMany(buttonViews, 'isOn', (...areOn) => {
|
|
115
|
+
const index = areOn.findIndex(identity);
|
|
116
|
+
return (index < 0) ? defaultButton.icon : buttonViews[index].icon;
|
|
117
|
+
});
|
|
118
|
+
splitButtonView.bind('label').toMany(buttonViews, 'isOn', (...areOn) => {
|
|
119
|
+
const index = areOn.findIndex(identity);
|
|
120
|
+
return getDropdownButtonTitle(title, (index < 0) ? defaultButton.label : buttonViews[index].label);
|
|
121
|
+
});
|
|
122
|
+
splitButtonView.bind('isOn').toMany(buttonViews, 'isOn', (...areOn) => areOn.some(identity));
|
|
123
|
+
splitButtonView.bind('class')
|
|
124
|
+
.toMany(buttonViews, 'isOn', (...areOn) => areOn.some(identity) ? 'ck-splitbutton_flatten' : undefined);
|
|
125
|
+
splitButtonView.on('execute', () => {
|
|
126
|
+
if (!buttonViews.some(({ isOn }) => isOn)) {
|
|
127
|
+
defaultButton.fire('execute');
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
dropdownView.isOpen = !dropdownView.isOpen;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
dropdownView.bind('isEnabled')
|
|
134
|
+
.toMany(buttonViews, 'isEnabled', (...areEnabled) => areEnabled.some(identity));
|
|
135
|
+
// Focus the editable after executing the command.
|
|
136
|
+
// Overrides a default behaviour where the focus is moved to the dropdown button (#12125).
|
|
137
|
+
this.listenTo(dropdownView, 'execute', () => {
|
|
138
|
+
this.editor.editing.view.focus();
|
|
139
|
+
});
|
|
140
|
+
return dropdownView;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates a button and stores it in the editor {@link module:ui/componentfactory~ComponentFactory}.
|
|
145
|
+
*/
|
|
146
|
+
_createButton(buttonConfig) {
|
|
147
|
+
const buttonName = buttonConfig.name;
|
|
148
|
+
this.editor.ui.componentFactory.add(getUIComponentName(buttonName), locale => {
|
|
149
|
+
const command = this.editor.commands.get('imageStyle');
|
|
150
|
+
const view = new ButtonView(locale);
|
|
151
|
+
view.set({
|
|
152
|
+
label: buttonConfig.title,
|
|
153
|
+
icon: buttonConfig.icon,
|
|
154
|
+
tooltip: true,
|
|
155
|
+
isToggleable: true
|
|
156
|
+
});
|
|
157
|
+
view.bind('isEnabled').to(command, 'isEnabled');
|
|
158
|
+
view.bind('isOn').to(command, 'value', value => value === buttonName);
|
|
159
|
+
view.on('execute', this._executeCommand.bind(this, buttonName));
|
|
160
|
+
return view;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
_executeCommand(name) {
|
|
164
|
+
this.editor.execute('imageStyle', { value: name });
|
|
165
|
+
this.editor.editing.view.focus();
|
|
166
|
+
}
|
|
217
167
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
if ( titles[ style.title ] ) {
|
|
231
|
-
style.title = titles[ style.title ];
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return styles;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Returns the image style component name with the "imageStyle:" prefix.
|
|
239
|
-
//
|
|
240
|
-
// @param {String} name
|
|
241
|
-
// @returns {String}
|
|
242
|
-
function getUIComponentName( name ) {
|
|
243
|
-
return `imageStyle:${ name }`;
|
|
168
|
+
/**
|
|
169
|
+
* Returns the translated `title` from the passed styles array.
|
|
170
|
+
*/
|
|
171
|
+
function translateStyles(styles, titles) {
|
|
172
|
+
for (const style of styles) {
|
|
173
|
+
// Localize the titles of the styles, if a title corresponds with
|
|
174
|
+
// a localized default provided by the plugin.
|
|
175
|
+
if (titles[style.title]) {
|
|
176
|
+
style.title = titles[style.title];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return styles;
|
|
244
180
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// @returns {String}
|
|
251
|
-
function getDropdownButtonTitle( dropdownTitle, buttonTitle ) {
|
|
252
|
-
return ( dropdownTitle ? dropdownTitle + ': ' : '' ) + buttonTitle;
|
|
181
|
+
/**
|
|
182
|
+
* Returns the image style component name with the "imageStyle:" prefix.
|
|
183
|
+
*/
|
|
184
|
+
function getUIComponentName(name) {
|
|
185
|
+
return `imageStyle:${name}`;
|
|
253
186
|
}
|
|
254
|
-
|
|
255
187
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* This definition can be implemented in the {@link module:image/image~ImageConfig#toolbar image toolbar configuration}
|
|
259
|
-
* to define a completely custom drop-down in the image toolbar.
|
|
260
|
-
*
|
|
261
|
-
* ClassicEditor.create( editorElement, {
|
|
262
|
-
* image: { toolbar: [
|
|
263
|
-
* // One of the predefined drop-downs
|
|
264
|
-
* 'imageStyle:wrapText',
|
|
265
|
-
* // Custom drop-down
|
|
266
|
-
* {
|
|
267
|
-
* name: 'imageStyle:customDropdown',
|
|
268
|
-
* title: Custom drop-down title,
|
|
269
|
-
* items: [ 'imageStyle:alignLeft', 'imageStyle:alignRight' ],
|
|
270
|
-
* defaultItem: 'imageStyle:alignLeft'
|
|
271
|
-
* }
|
|
272
|
-
* ] }
|
|
273
|
-
* } );
|
|
274
|
-
*
|
|
275
|
-
* **Note:** At the moment it is possible to populate the custom drop-down with only the buttons registered by the `ImageStyle` plugin.
|
|
276
|
-
*
|
|
277
|
-
* The defined drop-down will be registered
|
|
278
|
-
* as the {@link module:ui/dropdown/dropdownview~DropdownView}
|
|
279
|
-
* with the {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} under the provided name in the
|
|
280
|
-
* {@link module:ui/componentfactory~ComponentFactory}
|
|
281
|
-
*
|
|
282
|
-
* @property {String} name The unique name of the drop-down. It is recommended to precede it with the "imageStyle:" prefix
|
|
283
|
-
* to avoid collision with the components' names registered by other plugins.
|
|
284
|
-
*
|
|
285
|
-
* @property {String} [title] The drop-down's title. It will be used as the split button label along with the title of the default item
|
|
286
|
-
* in the following manner: "Custom drop-down title: Default item title".
|
|
287
|
-
*
|
|
288
|
-
* Setting `title` to one of
|
|
289
|
-
* {@link module:image/imagestyle/imagestyleui~ImageStyleUI#localizedDefaultStylesTitles}
|
|
290
|
-
* will automatically translate it to the language of the editor.
|
|
291
|
-
*
|
|
292
|
-
* @property {Array.<String>} items The list of the names of the buttons that will be placed in the drop-down's toolbar.
|
|
293
|
-
* Each of the buttons has to be one of the {@link module:image/image~ImageConfig#styles default image style buttons}
|
|
294
|
-
* or to be defined as the {@link module:image/imagestyle~ImageStyleOptionDefinition image styling option}.
|
|
295
|
-
*
|
|
296
|
-
* @property {String} defaultItem The name of one of the buttons from the items list,
|
|
297
|
-
* which will be used as a default button for the drop-down's split button.
|
|
298
|
-
*
|
|
299
|
-
* @typedef {Object} module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition
|
|
188
|
+
* Returns title for the splitbutton containing the dropdown title and default action item title.
|
|
300
189
|
*/
|
|
190
|
+
function getDropdownButtonTitle(dropdownTitle, buttonTitle) {
|
|
191
|
+
return (dropdownTitle ? dropdownTitle + ': ' : '') + buttonTitle;
|
|
192
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module image/imagestyle/utils
|
|
7
|
+
*/
|
|
8
|
+
import { type Editor, type PluginCollection } from 'ckeditor5/src/core';
|
|
9
|
+
import type { ImageStyleConfig, ImageStyleDropdownDefinition, ImageStyleOptionDefinition } from '../imageconfig';
|
|
10
|
+
/**
|
|
11
|
+
* Returns a list of the normalized and validated image style options.
|
|
12
|
+
*
|
|
13
|
+
* @param config
|
|
14
|
+
* @param config.isInlinePluginLoaded
|
|
15
|
+
* Determines whether the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin has been loaded.
|
|
16
|
+
* @param config.isBlockPluginLoaded
|
|
17
|
+
* Determines whether the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin has been loaded.
|
|
18
|
+
* @param config.configuredStyles
|
|
19
|
+
* The image styles configuration provided in the image styles {@link module:image/imageconfig~ImageConfig#styles configuration}
|
|
20
|
+
* as a default or custom value.
|
|
21
|
+
* @returns
|
|
22
|
+
* * Each of options contains a complete icon markup.
|
|
23
|
+
* * The image style options not supported by any of the loaded plugins are filtered out.
|
|
24
|
+
*/
|
|
25
|
+
declare function normalizeStyles(config: {
|
|
26
|
+
isInlinePluginLoaded: boolean;
|
|
27
|
+
isBlockPluginLoaded: boolean;
|
|
28
|
+
configuredStyles: ImageStyleConfig;
|
|
29
|
+
}): Array<ImageStyleOptionDefinition>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the default image styles configuration depending on the loaded image editing plugins.
|
|
32
|
+
*
|
|
33
|
+
* @param isInlinePluginLoaded
|
|
34
|
+
* Determines whether the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin has been loaded.
|
|
35
|
+
*
|
|
36
|
+
* @param isBlockPluginLoaded
|
|
37
|
+
* Determines whether the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin has been loaded.
|
|
38
|
+
*
|
|
39
|
+
* @returns
|
|
40
|
+
* It returns an object with the lists of the image style options and groups defined as strings related to the
|
|
41
|
+
* {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default options}
|
|
42
|
+
*/
|
|
43
|
+
declare function getDefaultStylesConfiguration(isBlockPluginLoaded: boolean, isInlinePluginLoaded: boolean): ImageStyleConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a list of the available predefined drop-downs' definitions depending on the loaded image editing plugins.
|
|
46
|
+
*/
|
|
47
|
+
declare function getDefaultDropdownDefinitions(pluginCollection: PluginCollection<Editor>): Array<ImageStyleDropdownDefinition>;
|
|
48
|
+
/**
|
|
49
|
+
* Displays a console warning with the 'image-style-configuration-definition-invalid' error.
|
|
50
|
+
*/
|
|
51
|
+
declare function warnInvalidStyle(info: object): void;
|
|
52
|
+
declare const _default: {
|
|
53
|
+
normalizeStyles: typeof normalizeStyles;
|
|
54
|
+
getDefaultStylesConfiguration: typeof getDefaultStylesConfiguration;
|
|
55
|
+
getDefaultDropdownDefinitions: typeof getDefaultDropdownDefinitions;
|
|
56
|
+
warnInvalidStyle: typeof warnInvalidStyle;
|
|
57
|
+
DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition>;
|
|
58
|
+
DEFAULT_ICONS: Record<string, string>;
|
|
59
|
+
DEFAULT_DROPDOWN_DEFINITIONS: ImageStyleDropdownDefinition[];
|
|
60
|
+
};
|
|
61
|
+
export default _default;
|