@ckeditor/ckeditor5-image 27.1.0 → 29.2.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.
Files changed (167) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/image.js +1 -1
  4. package/build/translations/ar.js +1 -0
  5. package/build/translations/ast.js +1 -0
  6. package/build/translations/az.js +1 -0
  7. package/build/translations/bg.js +1 -0
  8. package/build/translations/cs.js +1 -0
  9. package/build/translations/da.js +1 -0
  10. package/build/translations/de-ch.js +1 -0
  11. package/build/translations/de.js +1 -0
  12. package/build/translations/el.js +1 -0
  13. package/build/translations/en-au.js +1 -0
  14. package/build/translations/en-gb.js +1 -0
  15. package/build/translations/eo.js +1 -0
  16. package/build/translations/es.js +1 -0
  17. package/build/translations/et.js +1 -0
  18. package/build/translations/eu.js +1 -0
  19. package/build/translations/fa.js +1 -0
  20. package/build/translations/fi.js +1 -0
  21. package/build/translations/fr.js +1 -0
  22. package/build/translations/gl.js +1 -0
  23. package/build/translations/he.js +1 -0
  24. package/build/translations/hi.js +1 -0
  25. package/build/translations/hr.js +1 -0
  26. package/build/translations/hu.js +1 -0
  27. package/build/translations/id.js +1 -0
  28. package/build/translations/it.js +1 -0
  29. package/build/translations/ja.js +1 -0
  30. package/build/translations/km.js +1 -0
  31. package/build/translations/kn.js +1 -0
  32. package/build/translations/ko.js +1 -0
  33. package/build/translations/ku.js +1 -0
  34. package/build/translations/lt.js +1 -0
  35. package/build/translations/lv.js +1 -0
  36. package/build/translations/nb.js +1 -0
  37. package/build/translations/ne.js +1 -0
  38. package/build/translations/nl.js +1 -0
  39. package/build/translations/no.js +1 -0
  40. package/build/translations/pl.js +1 -0
  41. package/build/translations/pt-br.js +1 -0
  42. package/build/translations/pt.js +1 -0
  43. package/build/translations/ro.js +1 -0
  44. package/build/translations/ru.js +1 -0
  45. package/build/translations/si.js +1 -0
  46. package/build/translations/sk.js +1 -0
  47. package/build/translations/sq.js +1 -0
  48. package/build/translations/sr-latn.js +1 -0
  49. package/build/translations/sr.js +1 -0
  50. package/build/translations/sv.js +1 -0
  51. package/build/translations/th.js +1 -0
  52. package/build/translations/tk.js +1 -0
  53. package/build/translations/tr.js +1 -0
  54. package/build/translations/ug.js +1 -0
  55. package/build/translations/uk.js +1 -0
  56. package/build/translations/vi.js +1 -0
  57. package/build/translations/zh-cn.js +1 -0
  58. package/build/translations/zh.js +1 -0
  59. package/ckeditor5-metadata.json +233 -0
  60. package/lang/contexts.json +3 -0
  61. package/lang/translations/ar.po +12 -0
  62. package/lang/translations/ast.po +12 -0
  63. package/lang/translations/az.po +12 -0
  64. package/lang/translations/bg.po +12 -0
  65. package/lang/translations/cs.po +12 -0
  66. package/lang/translations/da.po +12 -0
  67. package/lang/translations/de-ch.po +113 -0
  68. package/lang/translations/de.po +15 -3
  69. package/lang/translations/el.po +12 -0
  70. package/lang/translations/en-au.po +12 -0
  71. package/lang/translations/en-gb.po +12 -0
  72. package/lang/translations/en.po +12 -0
  73. package/lang/translations/eo.po +12 -0
  74. package/lang/translations/es.po +12 -0
  75. package/lang/translations/et.po +12 -0
  76. package/lang/translations/eu.po +12 -0
  77. package/lang/translations/fa.po +12 -0
  78. package/lang/translations/fi.po +12 -0
  79. package/lang/translations/fr.po +12 -0
  80. package/lang/translations/gl.po +12 -0
  81. package/lang/translations/he.po +12 -0
  82. package/lang/translations/hi.po +12 -0
  83. package/lang/translations/hr.po +12 -0
  84. package/lang/translations/hu.po +13 -1
  85. package/lang/translations/id.po +21 -9
  86. package/lang/translations/it.po +12 -0
  87. package/lang/translations/ja.po +12 -0
  88. package/lang/translations/km.po +12 -0
  89. package/lang/translations/kn.po +12 -0
  90. package/lang/translations/ko.po +12 -0
  91. package/lang/translations/ku.po +12 -0
  92. package/lang/translations/lt.po +12 -0
  93. package/lang/translations/lv.po +12 -0
  94. package/lang/translations/nb.po +12 -0
  95. package/lang/translations/ne.po +12 -0
  96. package/lang/translations/nl.po +12 -0
  97. package/lang/translations/no.po +12 -0
  98. package/lang/translations/pl.po +20 -8
  99. package/lang/translations/pt-br.po +12 -0
  100. package/lang/translations/pt.po +12 -0
  101. package/lang/translations/ro.po +21 -9
  102. package/lang/translations/ru.po +12 -0
  103. package/lang/translations/si.po +12 -0
  104. package/lang/translations/sk.po +12 -0
  105. package/lang/translations/sq.po +12 -0
  106. package/lang/translations/sr-latn.po +12 -0
  107. package/lang/translations/sr.po +12 -0
  108. package/lang/translations/sv.po +12 -0
  109. package/lang/translations/th.po +12 -0
  110. package/lang/translations/tk.po +12 -0
  111. package/lang/translations/tr.po +12 -0
  112. package/lang/translations/ug.po +12 -0
  113. package/lang/translations/uk.po +12 -0
  114. package/lang/translations/vi.po +12 -0
  115. package/lang/translations/zh-cn.po +12 -0
  116. package/lang/translations/zh.po +12 -0
  117. package/package.json +36 -29
  118. package/src/autoimage.js +6 -4
  119. package/src/image/converters.js +192 -13
  120. package/src/image/imageblockediting.js +179 -0
  121. package/src/image/imageediting.js +13 -70
  122. package/src/image/imageinlineediting.js +204 -0
  123. package/src/image/imagetypecommand.js +105 -0
  124. package/src/image/insertimagecommand.js +77 -10
  125. package/src/image/ui/utils.js +3 -3
  126. package/src/image/utils.js +70 -121
  127. package/src/image.js +7 -19
  128. package/src/imageblock.js +46 -0
  129. package/src/imagecaption/imagecaptionediting.js +202 -230
  130. package/src/imagecaption/imagecaptionui.js +78 -0
  131. package/src/imagecaption/toggleimagecaptioncommand.js +165 -0
  132. package/src/imagecaption/utils.js +25 -40
  133. package/src/imagecaption.js +3 -2
  134. package/src/imageinline.js +46 -0
  135. package/src/imageinsert/imageinsertui.js +5 -6
  136. package/src/imageinsert.js +16 -4
  137. package/src/imageresize/imageresizebuttons.js +1 -1
  138. package/src/imageresize/imageresizeediting.js +21 -8
  139. package/src/imageresize/imageresizehandles.js +30 -8
  140. package/src/imageresize/resizeimagecommand.js +8 -5
  141. package/src/imagestyle/converters.js +25 -17
  142. package/src/imagestyle/imagestylecommand.js +73 -33
  143. package/src/imagestyle/imagestyleediting.js +113 -52
  144. package/src/imagestyle/imagestyleui.js +197 -31
  145. package/src/imagestyle/utils.js +300 -85
  146. package/src/imagestyle.js +218 -47
  147. package/src/imagetextalternative/imagetextalternativecommand.js +10 -7
  148. package/src/imagetextalternative/imagetextalternativeediting.js +9 -1
  149. package/src/imagetextalternative/imagetextalternativeui.js +2 -2
  150. package/src/imagetextalternative.js +1 -1
  151. package/src/imagetoolbar.js +33 -11
  152. package/src/imageupload/imageuploadediting.js +91 -31
  153. package/src/imageupload/imageuploadprogress.js +17 -9
  154. package/src/imageupload/imageuploadui.js +1 -1
  155. package/src/imageupload/uploadimagecommand.js +50 -24
  156. package/src/imageupload/utils.js +3 -2
  157. package/src/imageupload.js +1 -1
  158. package/src/imageutils.js +342 -0
  159. package/src/index.js +22 -47
  160. package/src/pictureediting.js +149 -0
  161. package/theme/image.css +101 -21
  162. package/theme/imagecaption.css +24 -2
  163. package/theme/imageresize.css +11 -0
  164. package/theme/imagestyle.css +76 -0
  165. package/theme/imageuploadicon.css +8 -2
  166. package/theme/imageuploadprogress.css +12 -8
  167. package/build/image.js.map +0 -1
@@ -7,145 +7,360 @@
7
7
  * @module image/imagestyle/utils
8
8
  */
9
9
 
10
- import { logWarning } from 'ckeditor5/src/utils';
11
10
  import { icons } from 'ckeditor5/src/core';
11
+ import { logWarning } from 'ckeditor5/src/utils';
12
+
13
+ const {
14
+ objectFullWidth,
15
+ objectInline,
16
+ objectLeft, objectRight, objectCenter,
17
+ objectBlockLeft, objectBlockRight
18
+ } = icons;
12
19
 
13
20
  /**
14
- * Default image styles provided by the plugin that can be referred in the
15
- * {@link module:image/image~ImageConfig#styles} configuration.
21
+ * Default image style options provided by the plugin that can be referred in the {@link module:image/image~ImageConfig#styles}
22
+ * configuration.
16
23
  *
17
- * Among them, 2 default semantic content styles are available:
24
+ * There are available 5 styles focused on formatting:
18
25
  *
19
- * * `full` is a full–width image without any CSS class,
20
- * * `side` is a side image styled with the `image-style-side` CSS class.
26
+ * * **`'alignLeft'`** aligns the inline or block image to the left and wraps it with the text using the `image-style-align-left` class,
27
+ * * **`'alignRight'`** aligns the inline or block image to the right and wraps it with the text using the `image-style-align-right` class,
28
+ * * **`'alignCenter'`** centers the block image using the `image-style-align-center` class,
29
+ * * **`'alignBlockLeft'`** aligns the block image to the left using the `image-style-block-align-left` class,
30
+ * * **`'alignBlockRight'`** aligns the block image to the right using the `image-style-block-align-right` class,
21
31
  *
22
- * There are also 3 styles focused on formatting:
32
+ * and 3 semantic styles:
23
33
  *
24
- * * `alignLeft` aligns the image to the left using the `image-style-align-left` class,
25
- * * `alignCenter` centers the image using the `image-style-align-center` class,
26
- * * `alignRight` aligns the image to the right using the `image-style-align-right` class,
34
+ * * **`'inline'`** is an inline image without any CSS class,
35
+ * * **`'block'`** is a block image without any CSS class,
36
+ * * **`'side'`** is a block image styled with the `image-style-side` CSS class.
27
37
  *
28
- * @member {Object.<String,Object>}
38
+ * @readonly
39
+ * @type {Object.<String,module:image/imagestyle~ImageStyleOptionDefinition>}
29
40
  */
30
- const defaultStyles = {
31
- // This option is equal to the situation when no style is applied.
32
- full: {
33
- name: 'full',
34
- title: 'Full size image',
35
- icon: icons.objectFullWidth,
41
+ const DEFAULT_OPTIONS = {
42
+ // This style represents an image placed in the line of text.
43
+ inline: {
44
+ name: 'inline',
45
+ title: 'In line',
46
+ icon: objectInline,
47
+ modelElements: [ 'imageInline' ],
36
48
  isDefault: true
37
49
  },
38
50
 
39
- // This represents a side image.
40
- side: {
41
- name: 'side',
42
- title: 'Side image',
43
- icon: icons.objectRight,
44
- className: 'image-style-side'
45
- },
46
-
47
- // This style represents an image aligned to the left.
51
+ // This style represents an image aligned to the left and wrapped with text.
48
52
  alignLeft: {
49
53
  name: 'alignLeft',
50
54
  title: 'Left aligned image',
51
- icon: icons.objectLeft,
55
+ icon: objectLeft,
56
+ modelElements: [ 'imageBlock', 'imageInline' ],
52
57
  className: 'image-style-align-left'
53
58
  },
54
59
 
60
+ // This style represents an image aligned to the left.
61
+ alignBlockLeft: {
62
+ name: 'alignBlockLeft',
63
+ title: 'Left aligned image',
64
+ icon: objectBlockLeft,
65
+ modelElements: [ 'imageBlock' ],
66
+ className: 'image-style-block-align-left'
67
+ },
68
+
55
69
  // This style represents a centered image.
56
70
  alignCenter: {
57
71
  name: 'alignCenter',
58
72
  title: 'Centered image',
59
- icon: icons.objectCenter,
73
+ icon: objectCenter,
74
+ modelElements: [ 'imageBlock' ],
60
75
  className: 'image-style-align-center'
61
76
  },
62
77
 
63
- // This style represents an image aligned to the right.
78
+ // This style represents an image aligned to the right and wrapped with text.
64
79
  alignRight: {
65
80
  name: 'alignRight',
66
81
  title: 'Right aligned image',
67
- icon: icons.objectRight,
82
+ icon: objectRight,
83
+ modelElements: [ 'imageBlock', 'imageInline' ],
68
84
  className: 'image-style-align-right'
85
+ },
86
+
87
+ // This style represents an image aligned to the right.
88
+ alignBlockRight: {
89
+ name: 'alignBlockRight',
90
+ title: 'Right aligned image',
91
+ icon: objectBlockRight,
92
+ modelElements: [ 'imageBlock' ],
93
+ className: 'image-style-block-align-right'
94
+ },
95
+
96
+ // This option is equal to the situation when no style is applied.
97
+ block: {
98
+ name: 'block',
99
+ title: 'Centered image',
100
+ icon: objectCenter,
101
+ modelElements: [ 'imageBlock' ],
102
+ isDefault: true
103
+ },
104
+
105
+ // This represents a side image.
106
+ side: {
107
+ name: 'side',
108
+ title: 'Side image',
109
+ icon: objectRight,
110
+ modelElements: [ 'imageBlock' ],
111
+ className: 'image-style-side'
69
112
  }
70
113
  };
71
114
 
72
115
  /**
73
- * Default image style icons provided by the plugin that can be referred in the
74
- * {@link module:image/image~ImageConfig#styles} configuration.
116
+ * Default image style icons provided by the plugin that can be referred in the {@link module:image/image~ImageConfig#styles}
117
+ * configuration.
118
+ *
119
+ * See {@link module:image/imagestyle~ImageStyleOptionDefinition#icon} to learn more.
75
120
  *
76
- * There are 4 icons available: `'full'`, `'left'`, `'center'` and `'right'`.
121
+ * There are 7 default icons available: `'full'`, `'left'`, `'inlineLeft'`, `'center'`, `'right'`, `'inlineRight'`, and `'inline'`.
77
122
  *
78
- * @member {Object.<String, String>}
123
+ * @readonly
124
+ * @type {Object.<String,String>}
79
125
  */
80
- const defaultIcons = {
81
- full: icons.objectFullWidth,
82
- left: icons.objectLeft,
83
- right: icons.objectRight,
84
- center: icons.objectCenter
126
+ const DEFAULT_ICONS = {
127
+ full: objectFullWidth,
128
+ left: objectBlockLeft,
129
+ right: objectBlockRight,
130
+ center: objectCenter,
131
+ inlineLeft: objectLeft,
132
+ inlineRight: objectRight,
133
+ inline: objectInline
85
134
  };
86
135
 
87
136
  /**
88
- * Returns a {@link module:image/image~ImageConfig#styles} array with items normalized in the
89
- * {@link module:image/imagestyle/imagestyleediting~ImageStyleFormat} format and a complete `icon` markup for each style.
137
+ * Default drop-downs provided by the plugin that can be referred in the {@link module:image/image~ImageConfig#toolbar}
138
+ * configuration. The drop-downs are containers for the {@link module:image/imagestyle~ImageStyleConfig#options image style options}.
139
+ *
140
+ * If both of the `ImageEditing` plugins are loaded, there are 2 predefined drop-downs available:
90
141
  *
91
- * @returns {Array.<module:image/imagestyle/imagestyleediting~ImageStyleFormat>}
142
+ * * **`'imageStyle:wrapText'`**, which contains the `alignLeft` and `alignRight` options, that is,
143
+ * those that wraps the text around the image,
144
+ * * **`'imageStyle:breakText'`**, which contains the `alignBlockLeft`, `alignCenter` and `alignBlockRight` options, that is,
145
+ * those that breaks the text around the image.
146
+ *
147
+ * @readonly
148
+ * @type {Array.<module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition>}
149
+ */
150
+ const DEFAULT_DROPDOWN_DEFINITIONS = [ {
151
+ name: 'imageStyle:wrapText',
152
+ title: 'Wrap text',
153
+ defaultItem: 'imageStyle:alignLeft',
154
+ items: [ 'imageStyle:alignLeft', 'imageStyle:alignRight' ]
155
+ }, {
156
+ name: 'imageStyle:breakText',
157
+ title: 'Break text',
158
+ defaultItem: 'imageStyle:block',
159
+ items: [ 'imageStyle:alignBlockLeft', 'imageStyle:block', 'imageStyle:alignBlockRight' ]
160
+ } ];
161
+
162
+ /**
163
+ * Returns a list of the normalized and validated image style options.
164
+ *
165
+ * @protected
166
+ * @param {Object} config
167
+ * @param {Boolean} config.isInlinePluginLoaded
168
+ * Determines whether the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin has been loaded.
169
+ * @param {Boolean} config.isBlockPluginLoaded
170
+ * Determines whether the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin has been loaded.
171
+ * @param {module:image/imagestyle~ImageStyleConfig} config.configuredStyles
172
+ * The image styles configuration provided in the image styles {@link module:image/image~ImageConfig#styles configuration}
173
+ * as a default or custom value.
174
+ * @returns {module:image/imagestyle~ImageStyleConfig}
175
+ * * Each of options contains a complete icon markup.
176
+ * * The image style options not supported by any of the loaded plugins are filtered out.
92
177
  */
93
- export function normalizeImageStyles( configuredStyles = [] ) {
94
- return configuredStyles.map( _normalizeStyle );
178
+ function normalizeStyles( config ) {
179
+ const configuredStyles = config.configuredStyles.options || [];
180
+
181
+ const styles = configuredStyles
182
+ .map( arrangement => normalizeDefinition( arrangement ) )
183
+ .filter( arrangement => isValidOption( arrangement, config ) );
184
+
185
+ return styles;
95
186
  }
96
187
 
97
- // Normalizes an image style provided in the {@link module:image/image~ImageConfig#styles}
98
- // and returns it in a {@link module:image/imagestyle/imagestyleediting~ImageStyleFormat}.
188
+ /**
189
+ * Returns the default image styles configuration depending on the loaded image editing plugins.
190
+ * @protected
191
+ *
192
+ * @param {Boolean} isInlinePluginLoaded
193
+ * Determines whether the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin has been loaded.
194
+ *
195
+ * @param {Boolean} isBlockPluginLoaded
196
+ * Determines whether the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin has been loaded.
197
+ *
198
+ * @returns {Object<String,Array>}
199
+ * It returns an object with the lists of the image style options and groups defined as strings related to the
200
+ * {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default options}
201
+ */
202
+ function getDefaultStylesConfiguration( isBlockPluginLoaded, isInlinePluginLoaded ) {
203
+ if ( isBlockPluginLoaded && isInlinePluginLoaded ) {
204
+ return {
205
+ options: [
206
+ 'inline', 'alignLeft', 'alignRight',
207
+ 'alignCenter', 'alignBlockLeft', 'alignBlockRight',
208
+ 'block', 'side'
209
+ ]
210
+ };
211
+ } else if ( isBlockPluginLoaded ) {
212
+ return {
213
+ options: [ 'block', 'side' ]
214
+ };
215
+ } else if ( isInlinePluginLoaded ) {
216
+ return {
217
+ options: [ 'inline', 'alignLeft', 'alignRight' ]
218
+ };
219
+ }
220
+
221
+ return {};
222
+ }
223
+
224
+ /**
225
+ * Returns a list of the available predefined drop-downs' definitions depending on the loaded image editing plugins.
226
+ * @protected
227
+ *
228
+ * @param {module:core/plugincollection~PluginCollection} pluginCollection
229
+ * @returns {Array.<module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition>}
230
+ */
231
+ function getDefaultDropdownDefinitions( pluginCollection ) {
232
+ if ( pluginCollection.has( 'ImageBlockEditing' ) && pluginCollection.has( 'ImageInlineEditing' ) ) {
233
+ return [ ...DEFAULT_DROPDOWN_DEFINITIONS ];
234
+ } else {
235
+ return [];
236
+ }
237
+ }
238
+
239
+ // Normalizes an image style option or group provided in the {@link module:image/image~ImageConfig#styles}
240
+ // and returns it in a {@link module:image/imagestyle~ImageStyleOptionDefinition}/
99
241
  //
100
- // @param {Object} style
101
- // @returns {@link module:image/imagestyle/imagestyleediting~ImageStyleFormat}
102
- function _normalizeStyle( style ) {
103
- // Just the name of the style has been passed.
104
- if ( typeof style == 'string' ) {
105
- const styleName = style;
106
-
107
- // If it's one of the defaults, just use it.
108
- if ( defaultStyles[ styleName ] ) {
109
- // Clone the style to avoid overriding defaults.
110
- style = Object.assign( {}, defaultStyles[ styleName ] );
242
+ // @param {Object|String} definition
243
+ //
244
+ // @returns {module:image/imagestyle~ImageStyleOptionDefinition}}
245
+ function normalizeDefinition( definition ) {
246
+ if ( typeof definition === 'string' ) {
247
+ // Just the name of the style has been passed, but none of the defaults.
248
+ if ( !DEFAULT_OPTIONS[ definition ] ) {
249
+ // Normalize the style anyway to prevent errors.
250
+ definition = { name: definition };
111
251
  }
112
- // If it's just a name but none of the defaults, warn because probably it's a mistake.
252
+ // Just the name of the style has been passed and it's one of the defaults, just use it.
253
+ // Clone the style to avoid overriding defaults.
113
254
  else {
255
+ definition = { ...DEFAULT_OPTIONS[ definition ] };
256
+ }
257
+ } else {
258
+ // If an object style has been passed and if the name matches one of the defaults,
259
+ // extend it with defaults – the user wants to customize a default style.
260
+ // Note: Don't override the user–defined style object, clone it instead.
261
+ definition = extendStyle( DEFAULT_OPTIONS[ definition.name ], definition );
262
+ }
263
+
264
+ // If an icon is defined as a string and correspond with a name
265
+ // in default icons, use the default icon provided by the plugin.
266
+ if ( typeof definition.icon === 'string' ) {
267
+ definition.icon = DEFAULT_ICONS[ definition.icon ] || definition.icon;
268
+ }
269
+
270
+ return definition;
271
+ }
272
+
273
+ // Checks if the image style option is valid:
274
+ // * if it has the modelElements fields defined and filled,
275
+ // * if the defined modelElements are supported by any of the loaded image editing plugins.
276
+ // It also displays a console warning these conditions are not met.
277
+ //
278
+ // @param {module:image/imagestyle~ImageStyleOptionDefinition} image style option
279
+ // @param {Object.<String,Boolean>} { isBlockPluginLoaded, isInlinePluginLoaded }
280
+ //
281
+ // @returns Boolean
282
+ function isValidOption( option, { isBlockPluginLoaded, isInlinePluginLoaded } ) {
283
+ const { modelElements, name } = option;
284
+
285
+ if ( !modelElements || !modelElements.length || !name ) {
286
+ warnInvalidStyle( { style: option } );
287
+
288
+ return false;
289
+ } else {
290
+ const supportedElements = [ isBlockPluginLoaded ? 'imageBlock' : null, isInlinePluginLoaded ? 'imageInline' : null ];
291
+
292
+ // Check if the option is supported by any of the loaded plugins.
293
+ if ( !modelElements.some( elementName => supportedElements.includes( elementName ) ) ) {
114
294
  /**
115
- * There is no such image style of given name.
295
+ * In order to work correctly, each image style {@link module:image/imagestyle~ImageStyleOptionDefinition option}
296
+ * requires specific model elements (also: types of images) to be supported by the editor.
297
+ *
298
+ * Model element names to which the image style option can be applied are defined in the
299
+ * {@link module:image/imagestyle~ImageStyleOptionDefinition#modelElements} property of the style option
300
+ * definition.
116
301
  *
117
- * @error image-style-not-found
118
- * @param {String} name Name of a missing style name.
302
+ * Explore the warning in the console to find out precisely which option is not supported and which editor plugins
303
+ * are missing. Make sure these plugins are loaded in your editor to get this image style option working.
304
+ *
305
+ * @error image-style-missing-dependency
306
+ * @param {String} [option] The name of the unsupported option.
307
+ * @param {String} [missingPlugins] The names of the plugins one of which has to be loaded for the particular option.
119
308
  */
120
- logWarning( 'image-style-not-found', { name: styleName } );
309
+ logWarning( 'image-style-missing-dependency', {
310
+ style: option,
311
+ missingPlugins: modelElements.map( name => name === 'imageBlock' ? 'ImageBlockEditing' : 'ImageInlineEditing' )
312
+ } );
121
313
 
122
- // Normalize the style anyway to prevent errors.
123
- style = {
124
- name: styleName
125
- };
314
+ return false;
126
315
  }
127
316
  }
128
- // If an object style has been passed and if the name matches one of the defaults,
129
- // extend it with defaults – the user wants to customize a default style.
130
- // Note: Don't override the user–defined style object, clone it instead.
131
- else if ( defaultStyles[ style.name ] ) {
132
- const defaultStyle = defaultStyles[ style.name ];
133
- const extendedStyle = Object.assign( {}, style );
134
-
135
- for ( const prop in defaultStyle ) {
136
- if ( !Object.prototype.hasOwnProperty.call( style, prop ) ) {
137
- extendedStyle[ prop ] = defaultStyle[ prop ];
138
- }
139
- }
140
317
 
141
- style = extendedStyle;
142
- }
318
+ return true;
319
+ }
143
320
 
144
- // If an icon is defined as a string and correspond with a name
145
- // in default icons, use the default icon provided by the plugin.
146
- if ( typeof style.icon == 'string' && defaultIcons[ style.icon ] ) {
147
- style.icon = defaultIcons[ style.icon ];
321
+ // Extends the default style with a style provided by the developer.
322
+ // Note: Don't override the custom–defined style object, clone it instead.
323
+ //
324
+ // @param {module:image/imagestyle~ImageStyleOptionDefinition} source
325
+ // @param {Object} style
326
+ //
327
+ // @returns {module:image/imagestyle~ImageStyleOptionDefinition}
328
+ function extendStyle( source, style ) {
329
+ const extendedStyle = { ...style };
330
+
331
+ for ( const prop in source ) {
332
+ if ( !Object.prototype.hasOwnProperty.call( style, prop ) ) {
333
+ extendedStyle[ prop ] = source[ prop ];
334
+ }
148
335
  }
149
336
 
150
- return style;
337
+ return extendedStyle;
338
+ }
339
+
340
+ // Displays a console warning with the 'image-style-configuration-definition-invalid' error.
341
+ // @param {Object} info
342
+ function warnInvalidStyle( info ) {
343
+ /**
344
+ * The image style definition provided in the configuration is invalid.
345
+ *
346
+ * Please make sure the definition implements properly one of the following:
347
+ *
348
+ * * {@link module:image/imagestyle~ImageStyleOptionDefinition image style option definition},
349
+ * * {@link module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition image style dropdown definition}
350
+ *
351
+ * @error image-style-configuration-definition-invalid
352
+ * @param {String} [dropdown] The name of the invalid drop-down
353
+ * @param {String} [style] The name of the invalid image style option
354
+ */
355
+ logWarning( 'image-style-configuration-definition-invalid', info );
151
356
  }
357
+
358
+ export default {
359
+ normalizeStyles,
360
+ getDefaultStylesConfiguration,
361
+ getDefaultDropdownDefinitions,
362
+ warnInvalidStyle,
363
+ DEFAULT_OPTIONS,
364
+ DEFAULT_ICONS,
365
+ DEFAULT_DROPDOWN_DEFINITIONS
366
+ };