@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,276 +2,211 @@
|
|
|
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/imageresize/imageresizebuttons
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin, icons } from 'ckeditor5/src/core';
|
|
11
9
|
import { ButtonView, DropdownButtonView, Model, createDropdown, addListToDropdown } from 'ckeditor5/src/ui';
|
|
12
10
|
import { CKEditorError, Collection } from 'ckeditor5/src/utils';
|
|
13
|
-
|
|
14
11
|
import ImageResizeEditing from './imageresizeediting';
|
|
15
|
-
|
|
16
12
|
const RESIZE_ICONS = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
small: icons.objectSizeSmall,
|
|
14
|
+
medium: icons.objectSizeMedium,
|
|
15
|
+
large: icons.objectSizeLarge,
|
|
16
|
+
original: icons.objectSizeFull
|
|
21
17
|
};
|
|
22
|
-
|
|
23
18
|
/**
|
|
24
19
|
* The image resize buttons plugin.
|
|
25
20
|
*
|
|
26
21
|
* It adds a possibility to resize images using the toolbar dropdown or individual buttons, depending on the plugin configuration.
|
|
27
|
-
*
|
|
28
|
-
* @extends module:core/plugin~Plugin
|
|
29
22
|
*/
|
|
30
23
|
export default class ImageResizeButtons extends Plugin {
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
} else {
|
|
209
|
-
if ( option.value ) {
|
|
210
|
-
return option.value + this._resizeUnit;
|
|
211
|
-
} else {
|
|
212
|
-
return t( 'Original' );
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* A helper function that parses the resize options and returns list item definitions ready for use in the dropdown.
|
|
219
|
-
*
|
|
220
|
-
* @private
|
|
221
|
-
* @param {Array.<module:image/imageresize/imageresizebuttons~ImageResizeOption>} options The resize options.
|
|
222
|
-
* @param {module:image/imageresize/resizeimagecommand~ResizeImageCommand} command The resize image command.
|
|
223
|
-
* @returns {Iterable.<module:ui/dropdown/utils~ListDropdownItemDefinition>} Dropdown item definitions.
|
|
224
|
-
*/
|
|
225
|
-
_getResizeDropdownListItemDefinitions( options, command ) {
|
|
226
|
-
const itemDefinitions = new Collection();
|
|
227
|
-
|
|
228
|
-
options.map( option => {
|
|
229
|
-
const optionValueWithUnit = option.value ? option.value + this._resizeUnit : null;
|
|
230
|
-
const definition = {
|
|
231
|
-
type: 'button',
|
|
232
|
-
model: new Model( {
|
|
233
|
-
commandName: 'resizeImage',
|
|
234
|
-
commandValue: optionValueWithUnit,
|
|
235
|
-
label: this._getOptionLabelValue( option ),
|
|
236
|
-
withText: true,
|
|
237
|
-
icon: null
|
|
238
|
-
} )
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
definition.model.bind( 'isOn' ).to( command, 'value', getIsOnButtonCallback( optionValueWithUnit ) );
|
|
242
|
-
|
|
243
|
-
itemDefinitions.add( definition );
|
|
244
|
-
} );
|
|
245
|
-
|
|
246
|
-
return itemDefinitions;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// A helper function for setting the `isOn` state of buttons in value bindings.
|
|
251
|
-
function getIsOnButtonCallback( value ) {
|
|
252
|
-
return commandValue => {
|
|
253
|
-
if ( value === null && commandValue === value ) {
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return commandValue && commandValue.width === value;
|
|
258
|
-
};
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires() {
|
|
28
|
+
return [ImageResizeEditing];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
static get pluginName() {
|
|
34
|
+
return 'ImageResizeButtons';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
constructor(editor) {
|
|
40
|
+
super(editor);
|
|
41
|
+
this._resizeUnit = editor.config.get('image.resizeUnit');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @inheritDoc
|
|
45
|
+
*/
|
|
46
|
+
init() {
|
|
47
|
+
const editor = this.editor;
|
|
48
|
+
const options = editor.config.get('image.resizeOptions');
|
|
49
|
+
const command = editor.commands.get('resizeImage');
|
|
50
|
+
this.bind('isEnabled').to(command);
|
|
51
|
+
for (const option of options) {
|
|
52
|
+
this._registerImageResizeButton(option);
|
|
53
|
+
}
|
|
54
|
+
this._registerImageResizeDropdown(options);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A helper function that creates a standalone button component for the plugin.
|
|
58
|
+
*
|
|
59
|
+
* @param resizeOption A model of the resize option.
|
|
60
|
+
*/
|
|
61
|
+
_registerImageResizeButton(option) {
|
|
62
|
+
const editor = this.editor;
|
|
63
|
+
const { name, value, icon } = option;
|
|
64
|
+
const optionValueWithUnit = value ? value + this._resizeUnit : null;
|
|
65
|
+
editor.ui.componentFactory.add(name, locale => {
|
|
66
|
+
const button = new ButtonView(locale);
|
|
67
|
+
const command = editor.commands.get('resizeImage');
|
|
68
|
+
const labelText = this._getOptionLabelValue(option, true);
|
|
69
|
+
if (!RESIZE_ICONS[icon]) {
|
|
70
|
+
/**
|
|
71
|
+
* When configuring {@link module:image/imageconfig~ImageConfig#resizeOptions `config.image.resizeOptions`} for standalone
|
|
72
|
+
* buttons, a valid `icon` token must be set for each option.
|
|
73
|
+
*
|
|
74
|
+
* See all valid options described in the
|
|
75
|
+
* {@link module:image/imageconfig~ImageResizeOption plugin configuration}.
|
|
76
|
+
*
|
|
77
|
+
* @error imageresizebuttons-missing-icon
|
|
78
|
+
* @param option Invalid image resize option.
|
|
79
|
+
*/
|
|
80
|
+
throw new CKEditorError('imageresizebuttons-missing-icon', editor, option);
|
|
81
|
+
}
|
|
82
|
+
button.set({
|
|
83
|
+
// Use the `label` property for a verbose description (because of ARIA).
|
|
84
|
+
label: labelText,
|
|
85
|
+
icon: RESIZE_ICONS[icon],
|
|
86
|
+
tooltip: labelText,
|
|
87
|
+
isToggleable: true
|
|
88
|
+
});
|
|
89
|
+
// Bind button to the command.
|
|
90
|
+
button.bind('isEnabled').to(this);
|
|
91
|
+
button.bind('isOn').to(command, 'value', getIsOnButtonCallback(optionValueWithUnit));
|
|
92
|
+
this.listenTo(button, 'execute', () => {
|
|
93
|
+
editor.execute('resizeImage', { width: optionValueWithUnit });
|
|
94
|
+
});
|
|
95
|
+
return button;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A helper function that creates a dropdown component for the plugin containing all the resize options defined in
|
|
100
|
+
* the editor configuration.
|
|
101
|
+
*
|
|
102
|
+
* @param options An array of configured options.
|
|
103
|
+
*/
|
|
104
|
+
_registerImageResizeDropdown(options) {
|
|
105
|
+
const editor = this.editor;
|
|
106
|
+
const t = editor.t;
|
|
107
|
+
const originalSizeOption = options.find(option => !option.value);
|
|
108
|
+
const componentCreator = (locale) => {
|
|
109
|
+
const command = editor.commands.get('resizeImage');
|
|
110
|
+
const dropdownView = createDropdown(locale, DropdownButtonView);
|
|
111
|
+
const dropdownButton = dropdownView.buttonView;
|
|
112
|
+
dropdownButton.set({
|
|
113
|
+
tooltip: t('Resize image'),
|
|
114
|
+
commandValue: originalSizeOption.value,
|
|
115
|
+
icon: RESIZE_ICONS.medium,
|
|
116
|
+
isToggleable: true,
|
|
117
|
+
label: this._getOptionLabelValue(originalSizeOption),
|
|
118
|
+
withText: true,
|
|
119
|
+
class: 'ck-resize-image-button'
|
|
120
|
+
});
|
|
121
|
+
dropdownButton.bind('label').to(command, 'value', commandValue => {
|
|
122
|
+
if (commandValue && commandValue.width) {
|
|
123
|
+
return commandValue.width;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return this._getOptionLabelValue(originalSizeOption);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
dropdownView.bind('isEnabled').to(this);
|
|
130
|
+
addListToDropdown(dropdownView, () => this._getResizeDropdownListItemDefinitions(options, command), {
|
|
131
|
+
ariaLabel: t('Image resize list')
|
|
132
|
+
});
|
|
133
|
+
// Execute command when an item from the dropdown is selected.
|
|
134
|
+
this.listenTo(dropdownView, 'execute', evt => {
|
|
135
|
+
editor.execute(evt.source.commandName, { width: evt.source.commandValue });
|
|
136
|
+
editor.editing.view.focus();
|
|
137
|
+
});
|
|
138
|
+
return dropdownView;
|
|
139
|
+
};
|
|
140
|
+
// Register `resizeImage` dropdown and add `imageResize` dropdown as an alias for backward compatibility.
|
|
141
|
+
editor.ui.componentFactory.add('resizeImage', componentCreator);
|
|
142
|
+
editor.ui.componentFactory.add('imageResize', componentCreator);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A helper function for creating an option label value string.
|
|
146
|
+
*
|
|
147
|
+
* @param option A resize option object.
|
|
148
|
+
* @param forTooltip An optional flag for creating a tooltip label.
|
|
149
|
+
* @returns A user-defined label combined from the numeric value and the resize unit or the default label
|
|
150
|
+
* for reset options (`Original`).
|
|
151
|
+
*/
|
|
152
|
+
_getOptionLabelValue(option, forTooltip = false) {
|
|
153
|
+
const t = this.editor.t;
|
|
154
|
+
if (option.label) {
|
|
155
|
+
return option.label;
|
|
156
|
+
}
|
|
157
|
+
else if (forTooltip) {
|
|
158
|
+
if (option.value) {
|
|
159
|
+
return t('Resize image to %0', option.value + this._resizeUnit);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return t('Resize image to the original size');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
if (option.value) {
|
|
167
|
+
return option.value + this._resizeUnit;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
return t('Original');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* A helper function that parses the resize options and returns list item definitions ready for use in the dropdown.
|
|
176
|
+
*
|
|
177
|
+
* @param options The resize options.
|
|
178
|
+
* @param command The resize image command.
|
|
179
|
+
* @returns Dropdown item definitions.
|
|
180
|
+
*/
|
|
181
|
+
_getResizeDropdownListItemDefinitions(options, command) {
|
|
182
|
+
const itemDefinitions = new Collection();
|
|
183
|
+
options.map(option => {
|
|
184
|
+
const optionValueWithUnit = option.value ? option.value + this._resizeUnit : null;
|
|
185
|
+
const definition = {
|
|
186
|
+
type: 'button',
|
|
187
|
+
model: new Model({
|
|
188
|
+
commandName: 'resizeImage',
|
|
189
|
+
commandValue: optionValueWithUnit,
|
|
190
|
+
label: this._getOptionLabelValue(option),
|
|
191
|
+
withText: true,
|
|
192
|
+
icon: null
|
|
193
|
+
})
|
|
194
|
+
};
|
|
195
|
+
definition.model.bind('isOn').to(command, 'value', getIsOnButtonCallback(optionValueWithUnit));
|
|
196
|
+
itemDefinitions.add(definition);
|
|
197
|
+
});
|
|
198
|
+
return itemDefinitions;
|
|
199
|
+
}
|
|
259
200
|
}
|
|
260
|
-
|
|
261
201
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* @typedef {Object} module:image/imageresize/imageresizebuttons~ImageResizeOption
|
|
265
|
-
* @property {String} name The name of the UI component that changes the image size.
|
|
266
|
-
* * If you configure the feature using individual resize buttons, you can refer to this name in the
|
|
267
|
-
* {@link module:image/image~ImageConfig#toolbar image toolbar configuration}.
|
|
268
|
-
* * If you configure the feature using the resize dropdown, this name will be used for a list item in the dropdown.
|
|
269
|
-
* @property {String} value The value of the resize option without the unit
|
|
270
|
-
* ({@link module:image/image~ImageConfig#resizeUnit configured separately}). `null` resets an image to its original size.
|
|
271
|
-
* @property {String} [icon] An icon used by an individual resize button (see the `name` property to learn more).
|
|
272
|
-
* Available icons are: `'small'`, `'medium'`, `'large'`, `'original'`.
|
|
273
|
-
* @property {String} [label] An option label displayed in the dropdown or, if the feature is configured using
|
|
274
|
-
* individual buttons, a {@link module:ui/button/buttonview~ButtonView#tooltip} and an ARIA attribute of a button.
|
|
275
|
-
* If not specified, the label is generated automatically based on the `value` option and the
|
|
276
|
-
* {@link module:image/image~ImageConfig#resizeUnit `config.image.resizeUnit`}.
|
|
202
|
+
* A helper function for setting the `isOn` state of buttons in value bindings.
|
|
277
203
|
*/
|
|
204
|
+
function getIsOnButtonCallback(value) {
|
|
205
|
+
return (commandValue) => {
|
|
206
|
+
const objectCommandValue = commandValue;
|
|
207
|
+
if (value === null && objectCommandValue === value) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
return objectCommandValue !== null && objectCommandValue.width === value;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
import { type Editor, Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
6
|
+
import '../imageconfig';
|
|
7
|
+
/**
|
|
8
|
+
* The image resize editing feature.
|
|
9
|
+
*
|
|
10
|
+
* It adds the ability to resize each image using handles or manually by
|
|
11
|
+
* {@link module:image/imageresize/imageresizebuttons~ImageResizeButtons} buttons.
|
|
12
|
+
*/
|
|
13
|
+
export default class ImageResizeEditing extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get requires(): PluginDependencies;
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): 'ImageResizeEditing';
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
constructor(editor: Editor);
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
private _registerSchema;
|
|
31
|
+
/**
|
|
32
|
+
* Registers image resize converters.
|
|
33
|
+
*
|
|
34
|
+
* @param imageType The type of the image.
|
|
35
|
+
*/
|
|
36
|
+
private _registerConverters;
|
|
37
|
+
}
|
|
38
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
39
|
+
interface PluginsMap {
|
|
40
|
+
[ImageResizeEditing.pluginName]: ImageResizeEditing;
|
|
41
|
+
}
|
|
42
|
+
}
|