@ckeditor/ckeditor5-image 36.0.1 → 37.0.0-alpha.1

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 (108) hide show
  1. package/build/image.js +1 -1
  2. package/package.json +40 -35
  3. package/src/augmentation.d.ts +55 -0
  4. package/src/augmentation.js +5 -0
  5. package/src/autoimage.d.ts +48 -0
  6. package/src/autoimage.js +111 -160
  7. package/src/image/converters.d.ts +66 -0
  8. package/src/image/converters.js +200 -261
  9. package/src/image/imageblockediting.d.ts +52 -0
  10. package/src/image/imageblockediting.js +111 -155
  11. package/src/image/imageediting.d.ts +29 -0
  12. package/src/image/imageediting.js +53 -67
  13. package/src/image/imageinlineediting.d.ts +53 -0
  14. package/src/image/imageinlineediting.js +135 -180
  15. package/src/image/imageloadobserver.d.ts +44 -0
  16. package/src/image/imageloadobserver.js +28 -47
  17. package/src/image/imagetypecommand.d.ts +40 -0
  18. package/src/image/imagetypecommand.js +67 -95
  19. package/src/image/insertimagecommand.d.ts +66 -0
  20. package/src/image/insertimagecommand.js +94 -101
  21. package/src/image/replaceimagesourcecommand.d.ts +34 -0
  22. package/src/image/replaceimagesourcecommand.js +28 -33
  23. package/src/image/ui/utils.d.ts +25 -0
  24. package/src/image/ui/utils.js +25 -35
  25. package/src/image/utils.d.ts +52 -0
  26. package/src/image/utils.js +63 -90
  27. package/src/image.d.ts +32 -0
  28. package/src/image.js +12 -43
  29. package/src/imageblock.d.ts +30 -0
  30. package/src/imageblock.js +12 -21
  31. package/src/imagecaption/imagecaptionediting.d.ts +87 -0
  32. package/src/imagecaption/imagecaptionediting.js +203 -262
  33. package/src/imagecaption/imagecaptionui.d.ts +25 -0
  34. package/src/imagecaption/imagecaptionui.js +46 -63
  35. package/src/imagecaption/imagecaptionutils.d.ts +37 -0
  36. package/src/imagecaption/imagecaptionutils.js +51 -78
  37. package/src/imagecaption/toggleimagecaptioncommand.d.ts +66 -0
  38. package/src/imagecaption/toggleimagecaptioncommand.js +112 -138
  39. package/src/imagecaption.d.ts +24 -0
  40. package/src/imagecaption.js +12 -19
  41. package/src/imageconfig.d.ts +713 -0
  42. package/src/imageconfig.js +5 -0
  43. package/src/imageinline.d.ts +30 -0
  44. package/src/imageinline.js +12 -21
  45. package/src/imageinsert/imageinsertui.d.ts +44 -0
  46. package/src/imageinsert/imageinsertui.js +120 -158
  47. package/src/imageinsert/ui/imageinsertformrowview.d.ts +61 -0
  48. package/src/imageinsert/ui/imageinsertformrowview.js +37 -86
  49. package/src/imageinsert/ui/imageinsertpanelview.d.ts +106 -0
  50. package/src/imageinsert/ui/imageinsertpanelview.js +148 -258
  51. package/src/imageinsert/utils.d.ts +25 -0
  52. package/src/imageinsert/utils.js +41 -58
  53. package/src/imageinsert.d.ts +30 -0
  54. package/src/imageinsert.js +13 -84
  55. package/src/imageinsertviaurl.d.ts +29 -0
  56. package/src/imageinsertviaurl.js +12 -18
  57. package/src/imageresize/imageresizebuttons.d.ts +66 -0
  58. package/src/imageresize/imageresizebuttons.js +190 -255
  59. package/src/imageresize/imageresizeediting.d.ts +36 -0
  60. package/src/imageresize/imageresizeediting.js +99 -125
  61. package/src/imageresize/imageresizehandles.d.ts +29 -0
  62. package/src/imageresize/imageresizehandles.js +90 -123
  63. package/src/imageresize/resizeimagecommand.d.ts +42 -0
  64. package/src/imageresize/resizeimagecommand.js +48 -55
  65. package/src/imageresize.d.ts +24 -0
  66. package/src/imageresize.js +12 -209
  67. package/src/imagestyle/converters.d.ts +24 -0
  68. package/src/imagestyle/converters.js +60 -78
  69. package/src/imagestyle/imagestylecommand.d.ts +65 -0
  70. package/src/imagestyle/imagestylecommand.js +88 -124
  71. package/src/imagestyle/imagestyleediting.d.ts +49 -0
  72. package/src/imagestyle/imagestyleediting.js +90 -137
  73. package/src/imagestyle/imagestyleui.d.ts +55 -0
  74. package/src/imagestyle/imagestyleui.js +170 -278
  75. package/src/imagestyle/utils.d.ts +101 -0
  76. package/src/imagestyle/utils.js +256 -309
  77. package/src/imagestyle.d.ts +30 -0
  78. package/src/imagestyle.js +13 -261
  79. package/src/imagetextalternative/imagetextalternativecommand.d.ts +34 -0
  80. package/src/imagetextalternative/imagetextalternativecommand.js +31 -47
  81. package/src/imagetextalternative/imagetextalternativeediting.d.ts +27 -0
  82. package/src/imagetextalternative/imagetextalternativeediting.js +18 -25
  83. package/src/imagetextalternative/imagetextalternativeui.d.ts +67 -0
  84. package/src/imagetextalternative/imagetextalternativeui.js +156 -219
  85. package/src/imagetextalternative/ui/textalternativeformview.d.ts +72 -0
  86. package/src/imagetextalternative/ui/textalternativeformview.js +103 -192
  87. package/src/imagetextalternative.d.ts +27 -0
  88. package/src/imagetextalternative.js +12 -18
  89. package/src/imagetoolbar.d.ts +33 -0
  90. package/src/imagetoolbar.js +31 -77
  91. package/src/imageupload/imageuploadediting.d.ts +108 -0
  92. package/src/imageupload/imageuploadediting.js +307 -427
  93. package/src/imageupload/imageuploadprogress.d.ts +42 -0
  94. package/src/imageupload/imageuploadprogress.js +180 -261
  95. package/src/imageupload/imageuploadui.d.ts +23 -0
  96. package/src/imageupload/imageuploadui.js +40 -57
  97. package/src/imageupload/uploadimagecommand.d.ts +60 -0
  98. package/src/imageupload/uploadimagecommand.js +73 -87
  99. package/src/imageupload/utils.d.ts +33 -0
  100. package/src/imageupload/utils.js +87 -112
  101. package/src/imageupload.d.ts +29 -0
  102. package/src/imageupload.js +12 -61
  103. package/src/imageutils.d.ts +102 -0
  104. package/src/imageutils.js +232 -329
  105. package/src/index.d.ts +47 -0
  106. package/src/index.js +1 -2
  107. package/src/pictureediting.d.ts +86 -0
  108. 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.
22
- * 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
17
+ * It registers buttons corresponding to the {@link module:image/imageconfig~ImageConfig#styles} configuration.
18
+ * It also registers the {@link module:image/imagestyle/utils#DEFAULT_DROPDOWN_DEFINITIONS default drop-downs} and the
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,101 @@
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
+ * Default image style options provided by the plugin that can be referred in the {@link module:image/imageconfig~ImageConfig#styles}
12
+ * configuration.
13
+ *
14
+ * There are available 5 styles focused on formatting:
15
+ *
16
+ * * **`'alignLeft'`** aligns the inline or block image to the left and wraps it with the text using the `image-style-align-left` class,
17
+ * * **`'alignRight'`** aligns the inline or block image to the right and wraps it with the text using the `image-style-align-right` class,
18
+ * * **`'alignCenter'`** centers the block image using the `image-style-align-center` class,
19
+ * * **`'alignBlockLeft'`** aligns the block image to the left using the `image-style-block-align-left` class,
20
+ * * **`'alignBlockRight'`** aligns the block image to the right using the `image-style-block-align-right` class,
21
+ *
22
+ * and 3 semantic styles:
23
+ *
24
+ * * **`'inline'`** is an inline image without any CSS class,
25
+ * * **`'block'`** is a block image without any CSS class,
26
+ * * **`'side'`** is a block image styled with the `image-style-side` CSS class.
27
+ */
28
+ export declare const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition>;
29
+ /**
30
+ * Default image style icons provided by the plugin that can be referred in the {@link module:image/imageconfig~ImageConfig#styles}
31
+ * configuration.
32
+ *
33
+ * See {@link module:image/imageconfig~ImageStyleOptionDefinition#icon} to learn more.
34
+ *
35
+ * There are 7 default icons available: `'full'`, `'left'`, `'inlineLeft'`, `'center'`, `'right'`, `'inlineRight'`, and `'inline'`.
36
+ */
37
+ export declare const DEFAULT_ICONS: Record<string, string>;
38
+ /**
39
+ * Default drop-downs provided by the plugin that can be referred in the {@link module:image/imageconfig~ImageConfig#toolbar}
40
+ * configuration. The drop-downs are containers for the {@link module:image/imageconfig~ImageStyleConfig#options image style options}.
41
+ *
42
+ * If both of the `ImageEditing` plugins are loaded, there are 2 predefined drop-downs available:
43
+ *
44
+ * * **`'imageStyle:wrapText'`**, which contains the `alignLeft` and `alignRight` options, that is,
45
+ * those that wraps the text around the image,
46
+ * * **`'imageStyle:breakText'`**, which contains the `alignBlockLeft`, `alignCenter` and `alignBlockRight` options, that is,
47
+ * those that breaks the text around the image.
48
+ */
49
+ export declare const DEFAULT_DROPDOWN_DEFINITIONS: Array<ImageStyleDropdownDefinition>;
50
+ /**
51
+ * Returns a list of the normalized and validated image style options.
52
+ *
53
+ * @param config
54
+ * @param config.isInlinePluginLoaded
55
+ * Determines whether the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin has been loaded.
56
+ * @param config.isBlockPluginLoaded
57
+ * Determines whether the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin has been loaded.
58
+ * @param config.configuredStyles
59
+ * The image styles configuration provided in the image styles {@link module:image/imageconfig~ImageConfig#styles configuration}
60
+ * as a default or custom value.
61
+ * @returns
62
+ * * Each of options contains a complete icon markup.
63
+ * * The image style options not supported by any of the loaded plugins are filtered out.
64
+ */
65
+ declare function normalizeStyles(config: {
66
+ isInlinePluginLoaded: boolean;
67
+ isBlockPluginLoaded: boolean;
68
+ configuredStyles: ImageStyleConfig;
69
+ }): Array<ImageStyleOptionDefinition>;
70
+ /**
71
+ * Returns the default image styles configuration depending on the loaded image editing plugins.
72
+ *
73
+ * @param isInlinePluginLoaded
74
+ * Determines whether the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin has been loaded.
75
+ *
76
+ * @param isBlockPluginLoaded
77
+ * Determines whether the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin has been loaded.
78
+ *
79
+ * @returns
80
+ * It returns an object with the lists of the image style options and groups defined as strings related to the
81
+ * {@link module:image/imagestyle/utils#DEFAULT_OPTIONS default options}
82
+ */
83
+ declare function getDefaultStylesConfiguration(isBlockPluginLoaded: boolean, isInlinePluginLoaded: boolean): ImageStyleConfig;
84
+ /**
85
+ * Returns a list of the available predefined drop-downs' definitions depending on the loaded image editing plugins.
86
+ */
87
+ declare function getDefaultDropdownDefinitions(pluginCollection: PluginCollection<Editor>): Array<ImageStyleDropdownDefinition>;
88
+ /**
89
+ * Displays a console warning with the 'image-style-configuration-definition-invalid' error.
90
+ */
91
+ declare function warnInvalidStyle(info: object): void;
92
+ declare const _default: {
93
+ normalizeStyles: typeof normalizeStyles;
94
+ getDefaultStylesConfiguration: typeof getDefaultStylesConfiguration;
95
+ getDefaultDropdownDefinitions: typeof getDefaultDropdownDefinitions;
96
+ warnInvalidStyle: typeof warnInvalidStyle;
97
+ DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition>;
98
+ DEFAULT_ICONS: Record<string, string>;
99
+ DEFAULT_DROPDOWN_DEFINITIONS: ImageStyleDropdownDefinition[];
100
+ };
101
+ export default _default;