@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.
Files changed (106) hide show
  1. package/build/image.js +1 -1
  2. package/package.json +40 -35
  3. package/src/autoimage.d.ts +53 -0
  4. package/src/autoimage.js +111 -160
  5. package/src/image/converters.d.ts +66 -0
  6. package/src/image/converters.js +200 -261
  7. package/src/image/imageblockediting.d.ts +57 -0
  8. package/src/image/imageblockediting.js +111 -155
  9. package/src/image/imageediting.d.ts +34 -0
  10. package/src/image/imageediting.js +53 -67
  11. package/src/image/imageinlineediting.d.ts +53 -0
  12. package/src/image/imageinlineediting.js +135 -180
  13. package/src/image/imageloadobserver.d.ts +44 -0
  14. package/src/image/imageloadobserver.js +28 -47
  15. package/src/image/imagetypecommand.d.ts +46 -0
  16. package/src/image/imagetypecommand.js +67 -95
  17. package/src/image/insertimagecommand.d.ts +72 -0
  18. package/src/image/insertimagecommand.js +95 -101
  19. package/src/image/replaceimagesourcecommand.d.ts +39 -0
  20. package/src/image/replaceimagesourcecommand.js +28 -33
  21. package/src/image/ui/utils.d.ts +25 -0
  22. package/src/image/ui/utils.js +25 -35
  23. package/src/image/utils.d.ts +52 -0
  24. package/src/image/utils.js +63 -90
  25. package/src/image.d.ts +38 -0
  26. package/src/image.js +13 -43
  27. package/src/imageblock.d.ts +35 -0
  28. package/src/imageblock.js +12 -21
  29. package/src/imagecaption/imagecaptionediting.d.ts +92 -0
  30. package/src/imagecaption/imagecaptionediting.js +203 -262
  31. package/src/imagecaption/imagecaptionui.d.ts +30 -0
  32. package/src/imagecaption/imagecaptionui.js +46 -63
  33. package/src/imagecaption/imagecaptionutils.d.ts +42 -0
  34. package/src/imagecaption/imagecaptionutils.js +51 -78
  35. package/src/imagecaption/toggleimagecaptioncommand.d.ts +71 -0
  36. package/src/imagecaption/toggleimagecaptioncommand.js +112 -138
  37. package/src/imagecaption.d.ts +29 -0
  38. package/src/imagecaption.js +12 -19
  39. package/src/imageconfig.d.ts +723 -0
  40. package/src/imageconfig.js +5 -0
  41. package/src/imageinline.d.ts +35 -0
  42. package/src/imageinline.js +12 -21
  43. package/src/imageinsert/imageinsertui.d.ts +49 -0
  44. package/src/imageinsert/imageinsertui.js +120 -158
  45. package/src/imageinsert/ui/imageinsertformrowview.d.ts +61 -0
  46. package/src/imageinsert/ui/imageinsertformrowview.js +37 -86
  47. package/src/imageinsert/ui/imageinsertpanelview.d.ts +106 -0
  48. package/src/imageinsert/ui/imageinsertpanelview.js +148 -258
  49. package/src/imageinsert/utils.d.ts +26 -0
  50. package/src/imageinsert/utils.js +42 -58
  51. package/src/imageinsert.d.ts +35 -0
  52. package/src/imageinsert.js +13 -84
  53. package/src/imageinsertviaurl.d.ts +34 -0
  54. package/src/imageinsertviaurl.js +12 -18
  55. package/src/imageresize/imageresizebuttons.d.ts +66 -0
  56. package/src/imageresize/imageresizebuttons.js +190 -255
  57. package/src/imageresize/imageresizeediting.d.ts +42 -0
  58. package/src/imageresize/imageresizeediting.js +100 -125
  59. package/src/imageresize/imageresizehandles.d.ts +30 -0
  60. package/src/imageresize/imageresizehandles.js +91 -123
  61. package/src/imageresize/resizeimagecommand.d.ts +47 -0
  62. package/src/imageresize/resizeimagecommand.js +48 -55
  63. package/src/imageresize.d.ts +29 -0
  64. package/src/imageresize.js +12 -209
  65. package/src/imagestyle/converters.d.ts +24 -0
  66. package/src/imagestyle/converters.js +60 -78
  67. package/src/imagestyle/imagestylecommand.d.ts +70 -0
  68. package/src/imagestyle/imagestylecommand.js +88 -124
  69. package/src/imagestyle/imagestyleediting.d.ts +54 -0
  70. package/src/imagestyle/imagestyleediting.js +90 -137
  71. package/src/imagestyle/imagestyleui.d.ts +60 -0
  72. package/src/imagestyle/imagestyleui.js +169 -277
  73. package/src/imagestyle/utils.d.ts +61 -0
  74. package/src/imagestyle/utils.js +253 -306
  75. package/src/imagestyle.d.ts +35 -0
  76. package/src/imagestyle.js +13 -261
  77. package/src/imagetextalternative/imagetextalternativecommand.d.ts +39 -0
  78. package/src/imagetextalternative/imagetextalternativecommand.js +31 -47
  79. package/src/imagetextalternative/imagetextalternativeediting.d.ts +32 -0
  80. package/src/imagetextalternative/imagetextalternativeediting.js +18 -25
  81. package/src/imagetextalternative/imagetextalternativeui.d.ts +72 -0
  82. package/src/imagetextalternative/imagetextalternativeui.js +156 -219
  83. package/src/imagetextalternative/ui/textalternativeformview.d.ts +72 -0
  84. package/src/imagetextalternative/ui/textalternativeformview.js +103 -192
  85. package/src/imagetextalternative.d.ts +32 -0
  86. package/src/imagetextalternative.js +12 -18
  87. package/src/imagetoolbar.d.ts +38 -0
  88. package/src/imagetoolbar.js +31 -77
  89. package/src/imageupload/imageuploadediting.d.ts +114 -0
  90. package/src/imageupload/imageuploadediting.js +308 -427
  91. package/src/imageupload/imageuploadprogress.d.ts +47 -0
  92. package/src/imageupload/imageuploadprogress.js +180 -261
  93. package/src/imageupload/imageuploadui.d.ts +29 -0
  94. package/src/imageupload/imageuploadui.js +41 -57
  95. package/src/imageupload/uploadimagecommand.d.ts +65 -0
  96. package/src/imageupload/uploadimagecommand.js +73 -87
  97. package/src/imageupload/utils.d.ts +33 -0
  98. package/src/imageupload/utils.js +87 -112
  99. package/src/imageupload.d.ts +34 -0
  100. package/src/imageupload.js +12 -61
  101. package/src/imageutils.d.ts +108 -0
  102. package/src/imageutils.js +233 -329
  103. package/src/index.d.ts +31 -0
  104. package/src/index.js +0 -2
  105. package/src/pictureediting.d.ts +86 -0
  106. 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/image~ImageConfig#styles} configuration.
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/image~ImageConfig#toolbar} configuration.
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
- * @inheritDoc
30
- */
31
- static get requires() {
32
- return [ ImageStyleEditing ];
33
- }
34
-
35
- /**
36
- * @inheritDoc
37
- */
38
- static get pluginName() {
39
- return 'ImageStyleUI';
40
- }
41
-
42
- /**
43
- * Returns the default localized style titles provided by the plugin.
44
- *
45
- * The following localized titles corresponding with
46
- * {@link module:image/imagestyle/utils~DEFAULT_OPTIONS} are available:
47
- *
48
- * * `'Wrap text'`,
49
- * * `'Break text'`,
50
- * * `'In line'`,
51
- * * `'Full size image'`,
52
- * * `'Side image'`,
53
- * * `'Left aligned image'`,
54
- * * `'Centered image'`,
55
- * * `'Right aligned image'`
56
- *
57
- * @returns {Object.<String,String>}
58
- */
59
- get localizedDefaultStylesTitles() {
60
- const t = this.editor.t;
61
-
62
- return {
63
- 'Wrap text': t( 'Wrap text' ),
64
- 'Break text': t( 'Break text' ),
65
- 'In line': t( 'In line' ),
66
- 'Full size image': t( 'Full size image' ),
67
- 'Side image': t( 'Side image' ),
68
- 'Left aligned image': t( 'Left aligned image' ),
69
- 'Centered image': t( 'Centered image' ),
70
- 'Right aligned image': t( 'Right aligned image' )
71
- };
72
- }
73
-
74
- /**
75
- * @inheritDoc
76
- */
77
- init() {
78
- const plugins = this.editor.plugins;
79
- const toolbarConfig = this.editor.config.get( 'image.toolbar' ) || [];
80
-
81
- const definedStyles = translateStyles(
82
- plugins.get( 'ImageStyleEditing' ).normalizedStyles,
83
- this.localizedDefaultStylesTitles
84
- );
85
-
86
- for ( const styleConfig of definedStyles ) {
87
- this._createButton( styleConfig );
88
- }
89
-
90
- const definedDropdowns = translateStyles(
91
- [ ...toolbarConfig.filter( isObject ), ...utils.getDefaultDropdownDefinitions( plugins ) ],
92
- this.localizedDefaultStylesTitles
93
- );
94
-
95
- for ( const dropdownConfig of definedDropdowns ) {
96
- this._createDropdown( dropdownConfig, definedStyles );
97
- }
98
- }
99
-
100
- /**
101
- * Creates a dropdown and stores it in the editor {@link module:ui/componentfactory~ComponentFactory}.
102
- *
103
- * @private
104
- * @param {module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition} dropdownConfig
105
- * @param {Array.<module:image/imagestyle~ImageStyleOptionDefinition>} definedStyles
106
- */
107
- _createDropdown( dropdownConfig, definedStyles ) {
108
- const factory = this.editor.ui.componentFactory;
109
-
110
- factory.add( dropdownConfig.name, locale => {
111
- let defaultButton;
112
-
113
- const { defaultItem, items, title } = dropdownConfig;
114
- const buttonViews = items
115
- .filter( itemName => definedStyles.find( ( { name } ) => getUIComponentName( name ) === itemName ) )
116
- .map( buttonName => {
117
- const button = factory.create( buttonName );
118
-
119
- if ( buttonName === defaultItem ) {
120
- defaultButton = button;
121
- }
122
-
123
- return button;
124
- } );
125
-
126
- if ( items.length !== buttonViews.length ) {
127
- utils.warnInvalidStyle( { dropdown: dropdownConfig } );
128
- }
129
-
130
- const dropdownView = createDropdown( locale, SplitButtonView );
131
- const splitButtonView = dropdownView.buttonView;
132
- const splitButtonViewArrow = splitButtonView.arrowView;
133
-
134
- addToolbarToDropdown( dropdownView, buttonViews, { enableActiveItemFocusOnDropdownOpen: true } );
135
-
136
- splitButtonView.set( {
137
- label: getDropdownButtonTitle( title, defaultButton.label ),
138
- class: null,
139
- tooltip: true
140
- } );
141
-
142
- splitButtonViewArrow.unbind( 'label' );
143
- splitButtonViewArrow.set( {
144
- label: title
145
- } );
146
-
147
- splitButtonView.bind( 'icon' ).toMany( buttonViews, 'isOn', ( ...areOn ) => {
148
- const index = areOn.findIndex( identity );
149
-
150
- return ( index < 0 ) ? defaultButton.icon : buttonViews[ index ].icon;
151
- } );
152
-
153
- splitButtonView.bind( 'label' ).toMany( buttonViews, 'isOn', ( ...areOn ) => {
154
- const index = areOn.findIndex( identity );
155
-
156
- return getDropdownButtonTitle( title, ( index < 0 ) ? defaultButton.label : buttonViews[ index ].label );
157
- } );
158
-
159
- splitButtonView.bind( 'isOn' ).toMany( buttonViews, 'isOn', ( ...areOn ) => areOn.some( identity ) );
160
-
161
- splitButtonView.bind( 'class' )
162
- .toMany( buttonViews, 'isOn', ( ...areOn ) => areOn.some( identity ) ? 'ck-splitbutton_flatten' : null );
163
-
164
- splitButtonView.on( 'execute', () => {
165
- if ( !buttonViews.some( ( { isOn } ) => isOn ) ) {
166
- defaultButton.fire( 'execute' );
167
- } else {
168
- dropdownView.isOpen = !dropdownView.isOpen;
169
- }
170
- } );
171
-
172
- dropdownView.bind( 'isEnabled' )
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
- // Returns the translated `title` from the passed styles array.
220
- //
221
- // @param {Array.<module:image/imagestyle~ImageStyleOptionDefinition|
222
- // module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition>} styles
223
- // @param {Object.<String,String>} titles
224
- //
225
- // @returns {Array.<module:image/imagestyle~ImageStyleOptionDefinition|module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition>}
226
- function translateStyles( styles, titles ) {
227
- for ( const style of styles ) {
228
- // Localize the titles of the styles, if a title corresponds with
229
- // a localized default provided by the plugin.
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
- // Returns title for the splitbutton containing the dropdown title and default action item title.
247
- //
248
- // @param {String|undefined} dropdownTitle
249
- // @param {String} buttonTitle
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
- * # **The image style custom drop-down definition descriptor**
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;