@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,209 +2,120 @@
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/imagetextalternative/ui/textalternativeformview
8
7
  */
9
-
10
- import {
11
- ButtonView,
12
- FocusCycler,
13
- LabeledFieldView,
14
- View,
15
- ViewCollection,
16
- createLabeledInputText,
17
- injectCssTransitionDisabler,
18
- submitHandler
19
- } from 'ckeditor5/src/ui';
8
+ import { ButtonView, FocusCycler, LabeledFieldView, View, ViewCollection, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui';
20
9
  import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';
21
10
  import { icons } from 'ckeditor5/src/core';
22
-
23
11
  import '../../../theme/textalternativeform.css';
24
-
25
12
  // See: #8833.
26
13
  // eslint-disable-next-line ckeditor5-rules/ckeditor-imports
27
14
  import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
28
-
29
15
  /**
30
16
  * The TextAlternativeFormView class.
31
- *
32
- * @extends module:ui/view~View
33
17
  */
34
18
  export default class TextAlternativeFormView extends View {
35
- /**
36
- * @inheritDoc
37
- */
38
- constructor( locale ) {
39
- super( locale );
40
-
41
- const t = this.locale.t;
42
-
43
- /**
44
- * Tracks information about the DOM focus in the form.
45
- *
46
- * @readonly
47
- * @member {module:utils/focustracker~FocusTracker}
48
- */
49
- this.focusTracker = new FocusTracker();
50
-
51
- /**
52
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
53
- *
54
- * @readonly
55
- * @member {module:utils/keystrokehandler~KeystrokeHandler}
56
- */
57
- this.keystrokes = new KeystrokeHandler();
58
-
59
- /**
60
- * An input with a label.
61
- *
62
- * @member {module:ui/labeledfield/labeledfieldview~LabeledFieldView} #labeledInput
63
- */
64
- this.labeledInput = this._createLabeledInputView();
65
-
66
- /**
67
- * A button used to submit the form.
68
- *
69
- * @member {module:ui/button/buttonview~ButtonView} #saveButtonView
70
- */
71
- this.saveButtonView = this._createButton( t( 'Save' ), icons.check, 'ck-button-save' );
72
- this.saveButtonView.type = 'submit';
73
-
74
- /**
75
- * A button used to cancel the form.
76
- *
77
- * @member {module:ui/button/buttonview~ButtonView} #cancelButtonView
78
- */
79
- this.cancelButtonView = this._createButton( t( 'Cancel' ), icons.cancel, 'ck-button-cancel', 'cancel' );
80
-
81
- /**
82
- * A collection of views which can be focused in the form.
83
- *
84
- * @readonly
85
- * @protected
86
- * @member {module:ui/viewcollection~ViewCollection}
87
- */
88
- this._focusables = new ViewCollection();
89
-
90
- /**
91
- * Helps cycling over {@link #_focusables} in the form.
92
- *
93
- * @readonly
94
- * @protected
95
- * @member {module:ui/focuscycler~FocusCycler}
96
- */
97
- this._focusCycler = new FocusCycler( {
98
- focusables: this._focusables,
99
- focusTracker: this.focusTracker,
100
- keystrokeHandler: this.keystrokes,
101
- actions: {
102
- // Navigate form fields backwards using the Shift + Tab keystroke.
103
- focusPrevious: 'shift + tab',
104
-
105
- // Navigate form fields forwards using the Tab key.
106
- focusNext: 'tab'
107
- }
108
- } );
109
-
110
- this.setTemplate( {
111
- tag: 'form',
112
-
113
- attributes: {
114
- class: [
115
- 'ck',
116
- 'ck-text-alternative-form',
117
- 'ck-responsive-form'
118
- ],
119
-
120
- // https://github.com/ckeditor/ckeditor5-image/issues/40
121
- tabindex: '-1'
122
- },
123
-
124
- children: [
125
- this.labeledInput,
126
- this.saveButtonView,
127
- this.cancelButtonView
128
- ]
129
- } );
130
-
131
- injectCssTransitionDisabler( this );
132
- }
133
-
134
- /**
135
- * @inheritDoc
136
- */
137
- render() {
138
- super.render();
139
-
140
- this.keystrokes.listenTo( this.element );
141
-
142
- submitHandler( { view: this } );
143
-
144
- [ this.labeledInput, this.saveButtonView, this.cancelButtonView ]
145
- .forEach( v => {
146
- // Register the view as focusable.
147
- this._focusables.add( v );
148
-
149
- // Register the view in the focus tracker.
150
- this.focusTracker.add( v.element );
151
- } );
152
- }
153
-
154
- /**
155
- * @inheritDoc
156
- */
157
- destroy() {
158
- super.destroy();
159
-
160
- this.focusTracker.destroy();
161
- this.keystrokes.destroy();
162
- }
163
-
164
- /**
165
- * Creates the button view.
166
- *
167
- * @private
168
- * @param {String} label The button label
169
- * @param {String} icon The button's icon.
170
- * @param {String} className The additional button CSS class name.
171
- * @param {String} [eventName] The event name that the ButtonView#execute event will be delegated to.
172
- * @returns {module:ui/button/buttonview~ButtonView} The button view instance.
173
- */
174
- _createButton( label, icon, className, eventName ) {
175
- const button = new ButtonView( this.locale );
176
-
177
- button.set( {
178
- label,
179
- icon,
180
- tooltip: true
181
- } );
182
-
183
- button.extendTemplate( {
184
- attributes: {
185
- class: className
186
- }
187
- } );
188
-
189
- if ( eventName ) {
190
- button.delegate( 'execute' ).to( this, eventName );
191
- }
192
-
193
- return button;
194
- }
195
-
196
- /**
197
- * Creates an input with a label.
198
- *
199
- * @private
200
- * @returns {module:ui/labeledfield/labeledfieldview~LabeledFieldView} Labeled field view instance.
201
- */
202
- _createLabeledInputView() {
203
- const t = this.locale.t;
204
- const labeledInput = new LabeledFieldView( this.locale, createLabeledInputText );
205
-
206
- labeledInput.label = t( 'Text alternative' );
207
-
208
- return labeledInput;
209
- }
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ constructor(locale) {
23
+ super(locale);
24
+ const t = this.locale.t;
25
+ this.focusTracker = new FocusTracker();
26
+ this.keystrokes = new KeystrokeHandler();
27
+ this.labeledInput = this._createLabeledInputView();
28
+ this.saveButtonView = this._createButton(t('Save'), icons.check, 'ck-button-save');
29
+ this.saveButtonView.type = 'submit';
30
+ this.cancelButtonView = this._createButton(t('Cancel'), icons.cancel, 'ck-button-cancel', 'cancel');
31
+ this._focusables = new ViewCollection();
32
+ this._focusCycler = new FocusCycler({
33
+ focusables: this._focusables,
34
+ focusTracker: this.focusTracker,
35
+ keystrokeHandler: this.keystrokes,
36
+ actions: {
37
+ // Navigate form fields backwards using the Shift + Tab keystroke.
38
+ focusPrevious: 'shift + tab',
39
+ // Navigate form fields forwards using the Tab key.
40
+ focusNext: 'tab'
41
+ }
42
+ });
43
+ this.setTemplate({
44
+ tag: 'form',
45
+ attributes: {
46
+ class: [
47
+ 'ck',
48
+ 'ck-text-alternative-form',
49
+ 'ck-responsive-form'
50
+ ],
51
+ // https://github.com/ckeditor/ckeditor5-image/issues/40
52
+ tabindex: '-1'
53
+ },
54
+ children: [
55
+ this.labeledInput,
56
+ this.saveButtonView,
57
+ this.cancelButtonView
58
+ ]
59
+ });
60
+ }
61
+ /**
62
+ * @inheritDoc
63
+ */
64
+ render() {
65
+ super.render();
66
+ this.keystrokes.listenTo(this.element);
67
+ submitHandler({ view: this });
68
+ [this.labeledInput, this.saveButtonView, this.cancelButtonView]
69
+ .forEach(v => {
70
+ // Register the view as focusable.
71
+ this._focusables.add(v);
72
+ // Register the view in the focus tracker.
73
+ this.focusTracker.add(v.element);
74
+ });
75
+ }
76
+ /**
77
+ * @inheritDoc
78
+ */
79
+ destroy() {
80
+ super.destroy();
81
+ this.focusTracker.destroy();
82
+ this.keystrokes.destroy();
83
+ }
84
+ /**
85
+ * Creates the button view.
86
+ *
87
+ * @param label The button label
88
+ * @param icon The button's icon.
89
+ * @param className The additional button CSS class name.
90
+ * @param eventName The event name that the ButtonView#execute event will be delegated to.
91
+ * @returns The button view instance.
92
+ */
93
+ _createButton(label, icon, className, eventName) {
94
+ const button = new ButtonView(this.locale);
95
+ button.set({
96
+ label,
97
+ icon,
98
+ tooltip: true
99
+ });
100
+ button.extendTemplate({
101
+ attributes: {
102
+ class: className
103
+ }
104
+ });
105
+ if (eventName) {
106
+ button.delegate('execute').to(this, eventName);
107
+ }
108
+ return button;
109
+ }
110
+ /**
111
+ * Creates an input with a label.
112
+ *
113
+ * @returns Labeled field view instance.
114
+ */
115
+ _createLabeledInputView() {
116
+ const t = this.locale.t;
117
+ const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
118
+ labeledInput.label = t('Text alternative');
119
+ return labeledInput;
120
+ }
210
121
  }
@@ -0,0 +1,32 @@
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/imagetextalternative
7
+ */
8
+ import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
9
+ /**
10
+ * The image text alternative plugin.
11
+ *
12
+ * For a detailed overview, check the {@glink features/images/images-styles image styles} documentation.
13
+ *
14
+ * This is a "glue" plugin which loads the
15
+ * {@link module:image/imagetextalternative/imagetextalternativeediting~ImageTextAlternativeEditing}
16
+ * and {@link module:image/imagetextalternative/imagetextalternativeui~ImageTextAlternativeUI} plugins.
17
+ */
18
+ export default class ImageTextAlternative extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): PluginDependencies;
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): 'ImageTextAlternative';
27
+ }
28
+ declare module '@ckeditor/ckeditor5-core' {
29
+ interface PluginsMap {
30
+ [ImageTextAlternative.pluginName]: ImageTextAlternative;
31
+ }
32
+ }
@@ -2,15 +2,12 @@
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/imagetextalternative
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import ImageTextAlternativeEditing from './imagetextalternative/imagetextalternativeediting';
12
10
  import ImageTextAlternativeUI from './imagetextalternative/imagetextalternativeui';
13
-
14
11
  /**
15
12
  * The image text alternative plugin.
16
13
  *
@@ -19,21 +16,18 @@ import ImageTextAlternativeUI from './imagetextalternative/imagetextalternativeu
19
16
  * This is a "glue" plugin which loads the
20
17
  * {@link module:image/imagetextalternative/imagetextalternativeediting~ImageTextAlternativeEditing}
21
18
  * and {@link module:image/imagetextalternative/imagetextalternativeui~ImageTextAlternativeUI} plugins.
22
- *
23
- * @extends module:core/plugin~Plugin
24
19
  */
25
20
  export default class ImageTextAlternative extends Plugin {
26
- /**
27
- * @inheritDoc
28
- */
29
- static get requires() {
30
- return [ ImageTextAlternativeEditing, ImageTextAlternativeUI ];
31
- }
32
-
33
- /**
34
- * @inheritDoc
35
- */
36
- static get pluginName() {
37
- return 'ImageTextAlternative';
38
- }
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get requires() {
25
+ return [ImageTextAlternativeEditing, ImageTextAlternativeUI];
26
+ }
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get pluginName() {
31
+ return 'ImageTextAlternative';
32
+ }
39
33
  }
@@ -0,0 +1,38 @@
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/imagetoolbar
7
+ */
8
+ import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
9
+ /**
10
+ * The image toolbar plugin. It creates and manages the image toolbar (the toolbar displayed when an image is selected).
11
+ *
12
+ * For an overview, check the {@glink features/images/images-overview#image-contextual-toolbar image contextual toolbar} documentation.
13
+ *
14
+ * Instances of toolbar components (e.g. buttons) are created using the editor's
15
+ * {@link module:ui/componentfactory~ComponentFactory component factory}
16
+ * based on the {@link module:image/imageconfig~ImageConfig#toolbar `image.toolbar` configuration option}.
17
+ *
18
+ * The toolbar uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
19
+ */
20
+ export default class ImageToolbar extends Plugin {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get requires(): PluginDependencies;
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName(): 'ImageToolbar';
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ afterInit(): void;
33
+ }
34
+ declare module '@ckeditor/ckeditor5-core' {
35
+ interface PluginsMap {
36
+ [ImageToolbar.pluginName]: ImageToolbar;
37
+ }
38
+ }
@@ -2,16 +2,13 @@
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/imagetoolbar
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import { WidgetToolbarRepository } from 'ckeditor5/src/widget';
12
10
  import ImageUtils from './imageutils';
13
11
  import { isObject } from 'lodash-es';
14
-
15
12
  /**
16
13
  * The image toolbar plugin. It creates and manages the image toolbar (the toolbar displayed when an image is selected).
17
14
  *
@@ -19,85 +16,42 @@ import { isObject } from 'lodash-es';
19
16
  *
20
17
  * Instances of toolbar components (e.g. buttons) are created using the editor's
21
18
  * {@link module:ui/componentfactory~ComponentFactory component factory}
22
- * based on the {@link module:image/image~ImageConfig#toolbar `image.toolbar` configuration option}.
19
+ * based on the {@link module:image/imageconfig~ImageConfig#toolbar `image.toolbar` configuration option}.
23
20
  *
24
21
  * The toolbar uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
25
- *
26
- * @extends module:core/plugin~Plugin
27
22
  */
28
23
  export default class ImageToolbar extends Plugin {
29
- /**
30
- * @inheritDoc
31
- */
32
- static get requires() {
33
- return [ WidgetToolbarRepository, ImageUtils ];
34
- }
35
-
36
- /**
37
- * @inheritDoc
38
- */
39
- static get pluginName() {
40
- return 'ImageToolbar';
41
- }
42
-
43
- /**
44
- * @inheritDoc
45
- */
46
- afterInit() {
47
- const editor = this.editor;
48
- const t = editor.t;
49
- const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
50
- const imageUtils = editor.plugins.get( 'ImageUtils' );
51
-
52
- widgetToolbarRepository.register( 'image', {
53
- ariaLabel: t( 'Image toolbar' ),
54
- items: normalizeDeclarativeConfig( editor.config.get( 'image.toolbar' ) || [] ),
55
- getRelatedElement: selection => imageUtils.getClosestSelectedImageWidget( selection )
56
- } );
57
- }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get requires() {
28
+ return [WidgetToolbarRepository, ImageUtils];
29
+ }
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get pluginName() {
34
+ return 'ImageToolbar';
35
+ }
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ afterInit() {
40
+ const editor = this.editor;
41
+ const t = editor.t;
42
+ const widgetToolbarRepository = editor.plugins.get(WidgetToolbarRepository);
43
+ const imageUtils = editor.plugins.get('ImageUtils');
44
+ widgetToolbarRepository.register('image', {
45
+ ariaLabel: t('Image toolbar'),
46
+ items: normalizeDeclarativeConfig(editor.config.get('image.toolbar') || []),
47
+ getRelatedElement: selection => imageUtils.getClosestSelectedImageWidget(selection)
48
+ });
49
+ }
58
50
  }
59
-
60
51
  /**
61
- * Items to be placed in the image toolbar.
62
- * This option is used by the {@link module:image/imagetoolbar~ImageToolbar} feature.
63
- *
64
- * Assuming that you use the following features:
65
- *
66
- * * {@link module:image/imagestyle~ImageStyle} (with a default configuration),
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},
75
- *
76
- * so you can configure the toolbar like this:
77
- *
78
- * const imageConfig = {
79
- * toolbar: [
80
- * 'imageStyle:inline', 'imageStyle:wrapText', 'imageStyle:breakText', '|',
81
- * 'toggleImageCaption', 'imageTextAlternative'
82
- * ]
83
- * };
84
- *
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}.
89
- *
90
- * Read more about configuring toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
91
- *
92
- * @member {Array.<String>} module:image/image~ImageConfig#toolbar
52
+ * Convert the dropdown definitions to their keys registered in the ComponentFactory.
53
+ * The registration precess should be handled by the plugin which handles the UI of a particular feature.
93
54
  */
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 );
55
+ function normalizeDeclarativeConfig(config) {
56
+ return config.map(item => isObject(item) ? item.name : item);
103
57
  }