@ckeditor/ckeditor5-image 28.0.0 → 30.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 +1 -1
- package/README.md +3 -3
- package/build/image.js +1 -1
- package/build/translations/ar.js +1 -0
- package/build/translations/ast.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/eo.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/eu.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/km.js +1 -0
- package/build/translations/kn.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/nb.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/si.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +233 -0
- package/lang/contexts.json +3 -0
- package/lang/translations/ar.po +12 -0
- package/lang/translations/ast.po +12 -0
- package/lang/translations/az.po +12 -0
- package/lang/translations/bg.po +12 -0
- package/lang/translations/cs.po +12 -0
- package/lang/translations/da.po +12 -0
- package/lang/translations/de-ch.po +12 -0
- package/lang/translations/de.po +15 -3
- package/lang/translations/el.po +12 -0
- package/lang/translations/en-au.po +12 -0
- package/lang/translations/en-gb.po +12 -0
- package/lang/translations/en.po +12 -0
- package/lang/translations/eo.po +12 -0
- package/lang/translations/es.po +12 -0
- package/lang/translations/et.po +12 -0
- package/lang/translations/eu.po +12 -0
- package/lang/translations/fa.po +12 -0
- package/lang/translations/fi.po +12 -0
- package/lang/translations/fr.po +12 -0
- package/lang/translations/gl.po +12 -0
- package/lang/translations/he.po +12 -0
- package/lang/translations/hi.po +12 -0
- package/lang/translations/hr.po +12 -0
- package/lang/translations/hu.po +13 -1
- package/lang/translations/id.po +21 -9
- package/lang/translations/it.po +12 -0
- package/lang/translations/ja.po +12 -0
- package/lang/translations/km.po +12 -0
- package/lang/translations/kn.po +12 -0
- package/lang/translations/ko.po +12 -0
- package/lang/translations/ku.po +12 -0
- package/lang/translations/lt.po +12 -0
- package/lang/translations/lv.po +12 -0
- package/lang/translations/nb.po +12 -0
- package/lang/translations/ne.po +12 -0
- package/lang/translations/nl.po +14 -2
- package/lang/translations/no.po +12 -0
- package/lang/translations/pl.po +20 -8
- package/lang/translations/pt-br.po +12 -0
- package/lang/translations/pt.po +12 -0
- package/lang/translations/ro.po +21 -9
- package/lang/translations/ru.po +12 -0
- package/lang/translations/si.po +12 -0
- package/lang/translations/sk.po +12 -0
- package/lang/translations/sq.po +12 -0
- package/lang/translations/sr-latn.po +12 -0
- package/lang/translations/sr.po +12 -0
- package/lang/translations/sv.po +12 -0
- package/lang/translations/th.po +12 -0
- package/lang/translations/tk.po +12 -0
- package/lang/translations/tr.po +12 -0
- package/lang/translations/ug.po +12 -0
- package/lang/translations/uk.po +12 -0
- package/lang/translations/vi.po +12 -0
- package/lang/translations/zh-cn.po +12 -0
- package/lang/translations/zh.po +12 -0
- package/package.json +36 -29
- package/src/autoimage.js +9 -4
- package/src/image/converters.js +191 -15
- package/src/image/imageblockediting.js +182 -0
- package/src/image/imageediting.js +13 -70
- package/src/image/imageinlineediting.js +207 -0
- package/src/image/imagetypecommand.js +105 -0
- package/src/image/insertimagecommand.js +77 -10
- package/src/image/ui/utils.js +5 -4
- package/src/image/utils.js +65 -121
- package/src/image.js +7 -19
- package/src/imageblock.js +46 -0
- package/src/imagecaption/imagecaptionediting.js +183 -227
- package/src/imagecaption/imagecaptionui.js +78 -0
- package/src/imagecaption/toggleimagecaptioncommand.js +165 -0
- package/src/imagecaption/utils.js +25 -40
- package/src/imagecaption.js +3 -2
- package/src/imageinline.js +46 -0
- package/src/imageinsert/imageinsertui.js +5 -6
- package/src/imageinsert.js +16 -4
- package/src/imageresize/imageresizebuttons.js +1 -1
- package/src/imageresize/imageresizeediting.js +21 -8
- package/src/imageresize/imageresizehandles.js +30 -8
- package/src/imageresize/resizeimagecommand.js +8 -5
- package/src/imagestyle/converters.js +26 -17
- package/src/imagestyle/imagestylecommand.js +73 -33
- package/src/imagestyle/imagestyleediting.js +113 -52
- package/src/imagestyle/imagestyleui.js +197 -31
- package/src/imagestyle/utils.js +300 -85
- package/src/imagestyle.js +218 -47
- package/src/imagetextalternative/imagetextalternativecommand.js +10 -7
- package/src/imagetextalternative/imagetextalternativeediting.js +9 -1
- package/src/imagetextalternative/imagetextalternativeui.js +2 -2
- package/src/imagetextalternative.js +1 -1
- package/src/imagetoolbar.js +33 -11
- package/src/imageupload/imageuploadediting.js +90 -30
- package/src/imageupload/imageuploadprogress.js +17 -9
- package/src/imageupload/imageuploadui.js +1 -1
- package/src/imageupload/uploadimagecommand.js +50 -24
- package/src/imageupload/utils.js +3 -2
- package/src/imageupload.js +1 -1
- package/src/imageutils.js +342 -0
- package/src/pictureediting.js +149 -0
- package/theme/image.css +101 -21
- package/theme/imagecaption.css +24 -2
- package/theme/imageresize.css +11 -0
- package/theme/imagestyle.css +76 -0
- package/theme/imageuploadicon.css +8 -2
- package/theme/imageuploadprogress.css +12 -8
- package/CHANGELOG.md +0 -423
- package/build/image.js.map +0 -1
package/src/imagestyle.js
CHANGED
|
@@ -14,10 +14,14 @@ import ImageStyleUI from './imagestyle/imagestyleui';
|
|
|
14
14
|
/**
|
|
15
15
|
* The image style plugin.
|
|
16
16
|
*
|
|
17
|
-
* For a detailed overview, check the {@glink features/
|
|
17
|
+
* For a detailed overview of the image styles feature, check the {@glink features/images/images-styles documentation}.
|
|
18
18
|
*
|
|
19
|
-
* This is a "glue" plugin which loads the
|
|
20
|
-
*
|
|
19
|
+
* This is a "glue" plugin which loads the following plugins:
|
|
20
|
+
* * {@link module:image/imagestyle/imagestyleediting~ImageStyleEditing},
|
|
21
|
+
* * {@link module:image/imagestyle/imagestyleui~ImageStyleUI}
|
|
22
|
+
*
|
|
23
|
+
* It provides a default configuration, which can be extended or overwritten.
|
|
24
|
+
* Read more about the {@link module:image/image~ImageConfig#styles image styles configuration}.
|
|
21
25
|
*
|
|
22
26
|
* @extends module:core/plugin~Plugin
|
|
23
27
|
*/
|
|
@@ -38,76 +42,243 @@ export default class ImageStyle extends Plugin {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
|
-
*
|
|
45
|
+
* The configuration for the {@link module:image/imagestyle~ImageStyle} plugin that should be provided
|
|
46
|
+
* while creating the editor instance.
|
|
47
|
+
*
|
|
48
|
+
* A detailed information about the default configuration and customization can be found in
|
|
49
|
+
* {@link module:image/image~ImageConfig#styles `ImageConfig#styles`}.
|
|
50
|
+
*
|
|
51
|
+
* @interface ImageStyleConfig
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A list of the image style options.
|
|
56
|
+
*
|
|
57
|
+
* @member {Array.<module:image/imagestyle~ImageStyleOptionDefinition>} module:image/imagestyle~ImageStyleConfig#options
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The {@link module:image/imagestyle `ImageStyle`} plugin requires a list of the
|
|
62
|
+
* {@link module:image/imagestyle~ImageStyleConfig#options image style options} to work properly.
|
|
63
|
+
* The default configuration is provided (listed below) and can be customized while creating the editor instance.
|
|
64
|
+
*
|
|
65
|
+
* # **Command**
|
|
66
|
+
*
|
|
67
|
+
* The {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand `imageStyleCommand`}
|
|
68
|
+
* is configured based on the defined options,
|
|
69
|
+
* so you can change the style of the selected image by executing the following command:
|
|
42
70
|
*
|
|
43
|
-
*
|
|
71
|
+
* editor.execute( 'imageStyle' { value: 'alignLeft' } );
|
|
44
72
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
73
|
+
* # **Buttons**
|
|
74
|
+
*
|
|
75
|
+
* All of the image style options provided in the configuration are registered
|
|
76
|
+
* in the {@link module:ui/componentfactory~ComponentFactory UI components factory} with the "imageStyle:" prefixes and can be used
|
|
77
|
+
* in the {@link module:image/image~ImageConfig#toolbar image toolbar configuration}. The buttons available by default depending
|
|
78
|
+
* on the loaded plugins are listed in the next section.
|
|
79
|
+
*
|
|
80
|
+
* Read more about styling images in the {@glink features/images/images-styles Image styles guide}.
|
|
81
|
+
*
|
|
82
|
+
* # **Default options and buttons**
|
|
83
|
+
*
|
|
84
|
+
* If the custom configuration is not provided, the default configuration will be used depending on the loaded
|
|
85
|
+
* image editing plugins.
|
|
86
|
+
*
|
|
87
|
+
* * If both {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} and
|
|
88
|
+
* {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugins are loaded
|
|
89
|
+
* (which is usually the default editor configuration), the following options will be available for the toolbar
|
|
90
|
+
* configuration. These options will be registered as the buttons with the "imageStyle:" prefixes.
|
|
91
|
+
*
|
|
92
|
+
* const imageDefaultConfig = {
|
|
93
|
+
* styles: {
|
|
94
|
+
* options: [
|
|
95
|
+
* 'inline', 'alignLeft', 'alignRight',
|
|
96
|
+
* 'alignCenter', 'alignBlockLeft', 'alignBlockRight',
|
|
97
|
+
* 'block', 'side'
|
|
98
|
+
* ]
|
|
99
|
+
* }
|
|
47
100
|
* };
|
|
48
101
|
*
|
|
49
|
-
*
|
|
102
|
+
* * If only the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin is loaded,
|
|
103
|
+
* the following buttons (options) and groups will be available for the toolbar configuration.
|
|
104
|
+
* These options will be registered as the buttons with the "imageStyle:" prefixes.
|
|
105
|
+
*
|
|
106
|
+
* const imageDefaultConfig = {
|
|
107
|
+
* styles: {
|
|
108
|
+
* options: [ 'block', 'side' ]
|
|
109
|
+
* }
|
|
110
|
+
* };
|
|
111
|
+
*
|
|
112
|
+
* * If only the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin is loaded,
|
|
113
|
+
* the following buttons (options) and groups will available for the toolbar configuration.
|
|
114
|
+
* These options will be registered as the buttons with the "imageStyle:" prefixes.
|
|
115
|
+
*
|
|
116
|
+
* const imageDefaultConfig = {
|
|
117
|
+
* styles: {
|
|
118
|
+
* options: [ 'inline', 'alignLeft', 'alignRight' ]
|
|
119
|
+
* }
|
|
120
|
+
* };
|
|
50
121
|
*
|
|
51
|
-
*
|
|
52
|
-
* * the "side" style with the `.image-style-side` CSS class.
|
|
122
|
+
* Read more about the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options}.
|
|
53
123
|
*
|
|
54
|
-
*
|
|
55
|
-
* styles provided by the image feature.
|
|
124
|
+
* # **Custom configuration**
|
|
56
125
|
*
|
|
57
|
-
* The
|
|
58
|
-
*
|
|
59
|
-
* {@link module:image/imagestyle/utils~
|
|
126
|
+
* The image styles configuration can be customized in several ways:
|
|
127
|
+
*
|
|
128
|
+
* * Any of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options}
|
|
129
|
+
* can be loaded by the reference to its name as follows:
|
|
130
|
+
*
|
|
131
|
+
* ClassicEditor
|
|
132
|
+
* .create( editorElement, {
|
|
133
|
+
* image: {
|
|
134
|
+
* styles: {
|
|
135
|
+
* options: [ 'alignLeft', 'alignRight' ]
|
|
136
|
+
* }
|
|
137
|
+
* }
|
|
138
|
+
* } );
|
|
139
|
+
*
|
|
140
|
+
* * Each of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default image style options} can be customized,
|
|
141
|
+
* e.g. to change the `icon`, `title` or CSS `className` of the style. The feature also provides several
|
|
142
|
+
* {@link module:image/imagestyle/utils~DEFAULT_ICONS default icons} to choose from.
|
|
60
143
|
*
|
|
61
144
|
* import customIcon from 'custom-icon.svg';
|
|
62
145
|
*
|
|
63
146
|
* // ...
|
|
64
147
|
*
|
|
65
|
-
*
|
|
66
|
-
* styles:
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
148
|
+
* ClassicEditor.create( editorElement, { image:
|
|
149
|
+
* styles: {
|
|
150
|
+
* options: {
|
|
151
|
+
* // This will only customize the icon of the "block" style.
|
|
152
|
+
* // Note: 'right' is one of default icons provided by the feature.
|
|
153
|
+
* {
|
|
154
|
+
* name: 'block',
|
|
155
|
+
* icon: 'right'
|
|
156
|
+
* },
|
|
70
157
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
158
|
+
* // This will customize the icon, title and CSS class of the default "side" style.
|
|
159
|
+
* {
|
|
160
|
+
* name: 'side',
|
|
161
|
+
* icon: customIcon,
|
|
162
|
+
* title: 'My side style',
|
|
163
|
+
* className: 'custom-side-image'
|
|
164
|
+
* }
|
|
165
|
+
* }
|
|
166
|
+
* }
|
|
167
|
+
* } );
|
|
75
168
|
*
|
|
76
|
-
* If none of the
|
|
169
|
+
* * If none of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default image style options}
|
|
170
|
+
* works for the integration, it is possible to define independent custom styles, too.
|
|
77
171
|
*
|
|
78
|
-
*
|
|
172
|
+
* See the documentation about the image style {@link module:image/imagestyle~ImageStyleOptionDefinition options}
|
|
173
|
+
* to define the custom image style configuration properly.
|
|
79
174
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
175
|
+
* import redIcon from 'red-icon.svg';
|
|
176
|
+
* import blueIcon from 'blue-icon.svg';
|
|
82
177
|
*
|
|
83
178
|
* // ...
|
|
84
179
|
*
|
|
85
|
-
*
|
|
86
|
-
* styles:
|
|
87
|
-
* // A completely custom
|
|
88
|
-
*
|
|
180
|
+
* ClassicEditor.create( editorElement, { image:
|
|
181
|
+
* styles: {
|
|
182
|
+
* // A list of completely custom styling options.
|
|
183
|
+
* options: [
|
|
184
|
+
* {
|
|
185
|
+
* name: 'regular',
|
|
186
|
+
* modelElements: [ 'imageBlock', 'imageInline' ],
|
|
187
|
+
* title: 'Regular image',
|
|
188
|
+
* icon: 'full',
|
|
189
|
+
* isDefault: true
|
|
190
|
+
* }, {
|
|
191
|
+
* name: 'blue',
|
|
192
|
+
* modelElements: [ 'imageInline' ],
|
|
193
|
+
* title: 'Blue image',
|
|
194
|
+
* icon: blueIcon,
|
|
195
|
+
* className: 'image-blue'
|
|
196
|
+
* }, {
|
|
197
|
+
* name: 'red',
|
|
198
|
+
* modelElements: [ 'imageBlock' ],
|
|
199
|
+
* title: 'Red image',
|
|
200
|
+
* icon: redIcon,
|
|
201
|
+
* className: 'image-red'
|
|
202
|
+
* }
|
|
203
|
+
* ]
|
|
204
|
+
* }
|
|
205
|
+
* } );
|
|
89
206
|
*
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
207
|
+
* @member {module:image/imagestyle~ImageStyleConfig} module:image/image~ImageConfig#styles
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The image styling option definition descriptor.
|
|
212
|
+
*
|
|
213
|
+
* This definition should be implemented in the `Image` plugin {@link module:image/image~ImageConfig#styles configuration} for:
|
|
214
|
+
*
|
|
215
|
+
* * customizing one of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} by providing the proper name
|
|
216
|
+
* of the default style and the properties that should be overridden,
|
|
217
|
+
* * or defining a completely custom styling option by providing a custom name and implementing the following properties.
|
|
218
|
+
*
|
|
219
|
+
* import fullSizeIcon from 'path/to/icon.svg';
|
|
93
220
|
*
|
|
94
|
-
*
|
|
221
|
+
* const imageStyleOptionDefinition = {
|
|
222
|
+
* name: 'fullSize',
|
|
223
|
+
* icon: fullSizeIcon,
|
|
224
|
+
* title: 'Full size image',
|
|
225
|
+
* className: 'image-full-size',
|
|
226
|
+
* modelElements: [ 'imageBlock', 'imageInline' ]
|
|
227
|
+
* }
|
|
228
|
+
*
|
|
229
|
+
* The styling option will be registered as the button under the name `'imageStyle:{name}'` in the
|
|
230
|
+
* {@link module:ui/componentfactory~ComponentFactory UI components factory} (this functionality is provided by the
|
|
231
|
+
* {@link module:image/imagestyle/imagestyleui~ImageStyleUI} plugin).
|
|
232
|
+
*
|
|
233
|
+
* @property {String} name The unique name of the styling option. It will be used to:
|
|
234
|
+
*
|
|
235
|
+
* * refer to one of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} or define the custom style,
|
|
236
|
+
* * store the chosen style in the model by setting the `imageStyle` attribute of the model image element,
|
|
237
|
+
* * as a value of the {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute `imageStyle` command},
|
|
238
|
+
* * when registering a button for the style in the following manner: (`'imageStyle:{name}'`).
|
|
239
|
+
*
|
|
240
|
+
* @property {Boolean} [isDefault] When set, the style will be used as the default one for the model elements
|
|
241
|
+
* listed in the `modelElements` property. A default style does not apply any CSS class to the view element.
|
|
242
|
+
*
|
|
243
|
+
* If this property is not defined, its value is inherited
|
|
244
|
+
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
245
|
+
*
|
|
246
|
+
* @property {String} icon One of the following to be used when creating the styles's button:
|
|
247
|
+
*
|
|
248
|
+
* * an SVG icon source (as an XML string),
|
|
249
|
+
* * one of the keys in {@link module:image/imagestyle/utils~DEFAULT_ICONS} to use one of default icons provided by the plugin.
|
|
250
|
+
*
|
|
251
|
+
* If this property is not defined, its value is inherited
|
|
252
|
+
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
253
|
+
*
|
|
254
|
+
* @property {String} title The styles's title. Setting `title` to one of
|
|
255
|
+
* {@link module:image/imagestyle/imagestyleui~ImageStyleUI#localizedDefaultStylesTitles}
|
|
95
256
|
* will automatically translate it to the language of the editor.
|
|
96
257
|
*
|
|
97
|
-
*
|
|
258
|
+
* If this property is not defined, its value is inherited
|
|
259
|
+
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
98
260
|
*
|
|
99
|
-
*
|
|
100
|
-
* the
|
|
261
|
+
* @property {String} [className] The CSS class used to represent the style in the view.
|
|
262
|
+
* It should be used only for the non-default styles.
|
|
101
263
|
*
|
|
102
|
-
*
|
|
264
|
+
* If this property is not defined, its value is inherited
|
|
265
|
+
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
103
266
|
*
|
|
104
|
-
* The
|
|
105
|
-
*
|
|
106
|
-
*
|
|
267
|
+
* @property {Array.<String>} modelElements The list of the names of the model elements that are supported by the style.
|
|
268
|
+
* The possible values are:
|
|
269
|
+
* * `[ 'imageBlock' ]` if the style can be applied to the image type introduced by the
|
|
270
|
+
* {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin,
|
|
271
|
+
* * `[ 'imageInline' ]` if the style can be applied to the image type introduced by the
|
|
272
|
+
* {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin,
|
|
273
|
+
* * `[ 'imageInline', 'imageBlock' ]` if the style can be applied to both image types introduced by the plugins mentioned above.
|
|
107
274
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
275
|
+
* This property determines which model element names work with the style. If the model element name of the currently selected
|
|
276
|
+
* image is different, upon executing the
|
|
277
|
+
* {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute `imageStyle`} command the image type (model element name)
|
|
278
|
+
* will automatically change.
|
|
279
|
+
*
|
|
280
|
+
* If this property is not defined, its value is inherited
|
|
281
|
+
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
111
282
|
*
|
|
112
|
-
* @
|
|
283
|
+
* @typedef {Object} module:image/imagestyle~ImageStyleOptionDefinition
|
|
113
284
|
*/
|
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
import { isImage } from '../image/utils';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
|
-
* The image text alternative command. It is used to change the `alt` attribute of `<
|
|
13
|
+
* The image text alternative command. It is used to change the `alt` attribute of `<imageBlock>` and `<imageInline>` model elements.
|
|
15
14
|
*
|
|
16
15
|
* @extends module:core/command~Command
|
|
17
16
|
*/
|
|
@@ -28,11 +27,13 @@ export default class ImageTextAlternativeCommand extends Command {
|
|
|
28
27
|
* @inheritDoc
|
|
29
28
|
*/
|
|
30
29
|
refresh() {
|
|
31
|
-
const
|
|
30
|
+
const editor = this.editor;
|
|
31
|
+
const imageUtils = editor.plugins.get( 'ImageUtils' );
|
|
32
|
+
const element = imageUtils.getClosestSelectedImageElement( this.editor.model.document.selection );
|
|
32
33
|
|
|
33
|
-
this.isEnabled =
|
|
34
|
+
this.isEnabled = !!element;
|
|
34
35
|
|
|
35
|
-
if (
|
|
36
|
+
if ( this.isEnabled && element.hasAttribute( 'alt' ) ) {
|
|
36
37
|
this.value = element.getAttribute( 'alt' );
|
|
37
38
|
} else {
|
|
38
39
|
this.value = false;
|
|
@@ -47,8 +48,10 @@ export default class ImageTextAlternativeCommand extends Command {
|
|
|
47
48
|
* @param {String} options.newValue The new value of the `alt` attribute to set.
|
|
48
49
|
*/
|
|
49
50
|
execute( options ) {
|
|
50
|
-
const
|
|
51
|
-
const
|
|
51
|
+
const editor = this.editor;
|
|
52
|
+
const imageUtils = editor.plugins.get( 'ImageUtils' );
|
|
53
|
+
const model = editor.model;
|
|
54
|
+
const imageElement = imageUtils.getClosestSelectedImageElement( model.document.selection );
|
|
52
55
|
|
|
53
56
|
model.change( writer => {
|
|
54
57
|
writer.setAttribute( 'alt', options.newValue, imageElement );
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* @module image/imagetextalternative/imagetextalternativeediting
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import ImageTextAlternativeCommand from './imagetextalternativecommand';
|
|
11
10
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
+
import ImageTextAlternativeCommand from './imagetextalternativecommand';
|
|
12
|
+
import ImageUtils from '../imageutils';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* The image text alternative editing plugin.
|
|
@@ -18,6 +19,13 @@ import { Plugin } from 'ckeditor5/src/core';
|
|
|
18
19
|
* @extends module:core/plugin~Plugin
|
|
19
20
|
*/
|
|
20
21
|
export default class ImageTextAlternativeEditing extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires() {
|
|
26
|
+
return [ ImageUtils ];
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
/**
|
|
22
30
|
* @inheritDoc
|
|
23
31
|
*/
|
|
@@ -12,7 +12,6 @@ import { ButtonView, ContextualBalloon, clickOutsideHandler } from 'ckeditor5/sr
|
|
|
12
12
|
|
|
13
13
|
import TextAlternativeFormView from './ui/textalternativeformview';
|
|
14
14
|
import { repositionContextualBalloon, getBalloonPositionData } from '../image/ui/utils';
|
|
15
|
-
import { getSelectedImageWidget } from '../image/utils';
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* The image text alternative UI plugin.
|
|
@@ -94,6 +93,7 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
94
93
|
const editor = this.editor;
|
|
95
94
|
const view = editor.editing.view;
|
|
96
95
|
const viewDocument = view.document;
|
|
96
|
+
const imageUtils = editor.plugins.get( 'ImageUtils' );
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* The contextual balloon plugin instance.
|
|
@@ -133,7 +133,7 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
133
133
|
|
|
134
134
|
// Reposition the balloon or hide the form if an image widget is no longer selected.
|
|
135
135
|
this.listenTo( editor.ui, 'update', () => {
|
|
136
|
-
if ( !
|
|
136
|
+
if ( !imageUtils.getClosestSelectedImageWidget( viewDocument.selection ) ) {
|
|
137
137
|
this._hideForm( true );
|
|
138
138
|
} else if ( this._isVisible ) {
|
|
139
139
|
repositionContextualBalloon( editor );
|
|
@@ -14,7 +14,7 @@ import ImageTextAlternativeUI from './imagetextalternative/imagetextalternativeu
|
|
|
14
14
|
/**
|
|
15
15
|
* The image text alternative plugin.
|
|
16
16
|
*
|
|
17
|
-
* For a detailed overview, check the {@glink features/
|
|
17
|
+
* For a detailed overview, check the {@glink features/images/images-styles image styles} documentation.
|
|
18
18
|
*
|
|
19
19
|
* This is a "glue" plugin which loads the
|
|
20
20
|
* {@link module:image/imagetextalternative/imagetextalternativeediting~ImageTextAlternativeEditing}
|
package/src/imagetoolbar.js
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
11
|
import { WidgetToolbarRepository } from 'ckeditor5/src/widget';
|
|
12
|
-
|
|
13
|
-
import {
|
|
12
|
+
import ImageUtils from './imageutils';
|
|
13
|
+
import { isObject } from 'lodash-es';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The image toolbar plugin. It creates and manages the image toolbar (the toolbar displayed when an image is selected).
|
|
17
17
|
*
|
|
18
|
-
* For
|
|
18
|
+
* For an overview, check the {@glink features/images/images-overview#image-contextual-toolbar image contextual toolbar} documentation.
|
|
19
19
|
*
|
|
20
20
|
* Instances of toolbar components (e.g. buttons) are created using the editor's
|
|
21
21
|
* {@link module:ui/componentfactory~ComponentFactory component factory}
|
|
@@ -30,7 +30,7 @@ export default class ImageToolbar extends Plugin {
|
|
|
30
30
|
* @inheritDoc
|
|
31
31
|
*/
|
|
32
32
|
static get requires() {
|
|
33
|
-
return [ WidgetToolbarRepository ];
|
|
33
|
+
return [ WidgetToolbarRepository, ImageUtils ];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -47,11 +47,12 @@ export default class ImageToolbar extends Plugin {
|
|
|
47
47
|
const editor = this.editor;
|
|
48
48
|
const t = editor.t;
|
|
49
49
|
const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
|
|
50
|
+
const imageUtils = editor.plugins.get( 'ImageUtils' );
|
|
50
51
|
|
|
51
52
|
widgetToolbarRepository.register( 'image', {
|
|
52
53
|
ariaLabel: t( 'Image toolbar' ),
|
|
53
|
-
items: editor.config.get( 'image.toolbar' ) || [],
|
|
54
|
-
getRelatedElement:
|
|
54
|
+
items: normalizeDeclarativeConfig( editor.config.get( 'image.toolbar' ) || [] ),
|
|
55
|
+
getRelatedElement: selection => imageUtils.getClosestSelectedImageWidget( selection )
|
|
55
56
|
} );
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -64,18 +65,39 @@ export default class ImageToolbar extends Plugin {
|
|
|
64
65
|
*
|
|
65
66
|
* * {@link module:image/imagestyle~ImageStyle} (with a default configuration),
|
|
66
67
|
* * {@link module:image/imagetextalternative~ImageTextAlternative},
|
|
68
|
+
* * {@link module:image/imagecaption~ImageCaption},
|
|
69
|
+
*
|
|
70
|
+
* the following toolbar items will be available in {@link module:ui/componentfactory~ComponentFactory}:
|
|
71
|
+
* * `'imageTextAlternative'`,
|
|
72
|
+
* * `'toggleImageCaption'`,
|
|
73
|
+
* * {@link module:image/image~ImageConfig#styles buttons provided by the `ImageStyle` plugin},
|
|
74
|
+
* * {@link module:image/imagestyle/utils~DEFAULT_DROPDOWN_DEFINITIONS drop-downs provided by the `ImageStyle` plugin},
|
|
67
75
|
*
|
|
68
|
-
*
|
|
69
|
-
* `'imageStyle:full'`, `'imageStyle:side'`, and `'imageTextAlternative'` so you can configure the toolbar like this:
|
|
76
|
+
* so you can configure the toolbar like this:
|
|
70
77
|
*
|
|
71
78
|
* const imageConfig = {
|
|
72
|
-
* toolbar: [
|
|
79
|
+
* toolbar: [
|
|
80
|
+
* 'imageStyle:inline', 'imageStyle:wrapText', 'imageStyle:breakText', '|',
|
|
81
|
+
* 'toggleImageCaption', 'imageTextAlternative'
|
|
82
|
+
* ]
|
|
73
83
|
* };
|
|
74
84
|
*
|
|
75
|
-
*
|
|
76
|
-
* {@link module:
|
|
85
|
+
* Besides that, the `ImageStyle` plugin allows to define a
|
|
86
|
+
* {@link module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition custom drop-down} while configuring the toolbar.
|
|
87
|
+
*
|
|
88
|
+
* The same items can also be used in the {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
|
|
77
89
|
*
|
|
78
90
|
* Read more about configuring toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
|
|
79
91
|
*
|
|
80
92
|
* @member {Array.<String>} module:image/image~ImageConfig#toolbar
|
|
81
93
|
*/
|
|
94
|
+
|
|
95
|
+
// Convert the dropdown definitions to their keys registered in the ComponentFactory.
|
|
96
|
+
// The registration precess should be handled by the plugin which handles the UI of a particular feature.
|
|
97
|
+
//
|
|
98
|
+
// @param {Array.<String|module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition>} config
|
|
99
|
+
//
|
|
100
|
+
// @returns {Array.<String>}
|
|
101
|
+
function normalizeDeclarativeConfig( config ) {
|
|
102
|
+
return config.map( item => isObject( item ) ? item.name : item );
|
|
103
|
+
}
|