@ckeditor/ckeditor5-image 36.0.1 → 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
@@ -0,0 +1,47 @@
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/imageupload/imageuploadprogress
7
+ */
8
+ import { type Editor, Plugin } from 'ckeditor5/src/core';
9
+ import '../../theme/imageuploadprogress.css';
10
+ import '../../theme/imageuploadicon.css';
11
+ import '../../theme/imageuploadloader.css';
12
+ /**
13
+ * The image upload progress plugin.
14
+ * It shows a placeholder when the image is read from the disk and a progress bar while the image is uploading.
15
+ */
16
+ export default class ImageUploadProgress extends Plugin {
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get pluginName(): 'ImageUploadProgress';
21
+ /**
22
+ * The image placeholder that is displayed before real image data can be accessed.
23
+ *
24
+ * For the record, this image is a 1x1 px GIF with an aspect ratio set by CSS.
25
+ */
26
+ private placeholder;
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ constructor(editor: Editor);
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ init(): void;
35
+ /**
36
+ * This method is called each time the image `uploadStatus` attribute is changed.
37
+ *
38
+ * @param evt An object containing information about the fired event.
39
+ * @param data Additional information about the change.
40
+ */
41
+ private uploadStatusChange;
42
+ }
43
+ declare module '@ckeditor/ckeditor5-core' {
44
+ interface PluginsMap {
45
+ [ImageUploadProgress.pluginName]: ImageUploadProgress;
46
+ }
47
+ }
@@ -2,291 +2,210 @@
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/imageupload/imageuploadprogress
8
7
  */
9
-
10
8
  /* globals setTimeout */
11
-
12
9
  import { Plugin } from 'ckeditor5/src/core';
13
10
  import { FileRepository } from 'ckeditor5/src/upload';
14
-
15
11
  import '../../theme/imageuploadprogress.css';
16
12
  import '../../theme/imageuploadicon.css';
17
13
  import '../../theme/imageuploadloader.css';
18
-
19
14
  /**
20
15
  * The image upload progress plugin.
21
16
  * It shows a placeholder when the image is read from the disk and a progress bar while the image is uploading.
22
- *
23
- * @extends module:core/plugin~Plugin
24
17
  */
25
18
  export default class ImageUploadProgress extends Plugin {
26
- /**
27
- * @inheritDoc
28
- */
29
- static get pluginName() {
30
- return 'ImageUploadProgress';
31
- }
32
-
33
- /**
34
- * @inheritDoc
35
- */
36
- constructor( editor ) {
37
- super( editor );
38
-
39
- /**
40
- * The image placeholder that is displayed before real image data can be accessed.
41
- *
42
- * For the record, this image is a 1x1 px GIF with an aspect ratio set by CSS.
43
- *
44
- * @protected
45
- * @member {String} #placeholder
46
- */
47
- this.placeholder = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
48
- }
49
-
50
- /**
51
- * @inheritDoc
52
- */
53
- init() {
54
- const editor = this.editor;
55
-
56
- // Upload status change - update image's view according to that status.
57
- if ( editor.plugins.has( 'ImageBlockEditing' ) ) {
58
- editor.editing.downcastDispatcher.on( 'attribute:uploadStatus:imageBlock', ( ...args ) => this.uploadStatusChange( ...args ) );
59
- }
60
-
61
- if ( editor.plugins.has( 'ImageInlineEditing' ) ) {
62
- editor.editing.downcastDispatcher.on( 'attribute:uploadStatus:imageInline', ( ...args ) => this.uploadStatusChange( ...args ) );
63
- }
64
- }
65
-
66
- /**
67
- * This method is called each time the image `uploadStatus` attribute is changed.
68
- *
69
- * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
70
- * @param {Object} data Additional information about the change.
71
- * @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi
72
- */
73
- uploadStatusChange( evt, data, conversionApi ) {
74
- const editor = this.editor;
75
- const modelImage = data.item;
76
- const uploadId = modelImage.getAttribute( 'uploadId' );
77
-
78
- if ( !conversionApi.consumable.consume( data.item, evt.name ) ) {
79
- return;
80
- }
81
-
82
- const imageUtils = editor.plugins.get( 'ImageUtils' );
83
- const fileRepository = editor.plugins.get( FileRepository );
84
- const status = uploadId ? data.attributeNewValue : null;
85
- const placeholder = this.placeholder;
86
- const viewFigure = editor.editing.mapper.toViewElement( modelImage );
87
- const viewWriter = conversionApi.writer;
88
-
89
- if ( status == 'reading' ) {
90
- // Start "appearing" effect and show placeholder with infinite progress bar on the top
91
- // while image is read from disk.
92
- _startAppearEffect( viewFigure, viewWriter );
93
- _showPlaceholder( imageUtils, placeholder, viewFigure, viewWriter );
94
-
95
- return;
96
- }
97
-
98
- // Show progress bar on the top of the image when image is uploading.
99
- if ( status == 'uploading' ) {
100
- const loader = fileRepository.loaders.get( uploadId );
101
-
102
- // Start appear effect if needed - see https://github.com/ckeditor/ckeditor5-image/issues/191.
103
- _startAppearEffect( viewFigure, viewWriter );
104
-
105
- if ( !loader ) {
106
- // There is no loader associated with uploadId - this means that image came from external changes.
107
- // In such cases we still want to show the placeholder until image is fully uploaded.
108
- // Show placeholder if needed - see https://github.com/ckeditor/ckeditor5-image/issues/191.
109
- _showPlaceholder( imageUtils, placeholder, viewFigure, viewWriter );
110
- } else {
111
- // Hide placeholder and initialize progress bar showing upload progress.
112
- _hidePlaceholder( viewFigure, viewWriter );
113
- _showProgressBar( viewFigure, viewWriter, loader, editor.editing.view );
114
- _displayLocalImage( imageUtils, viewFigure, viewWriter, loader );
115
- }
116
-
117
- return;
118
- }
119
-
120
- if ( status == 'complete' && fileRepository.loaders.get( uploadId ) ) {
121
- _showCompleteIcon( viewFigure, viewWriter, editor.editing.view );
122
- }
123
-
124
- // Clean up.
125
- _hideProgressBar( viewFigure, viewWriter );
126
- _hidePlaceholder( viewFigure, viewWriter );
127
- _stopAppearEffect( viewFigure, viewWriter );
128
- }
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName() {
23
+ return 'ImageUploadProgress';
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ constructor(editor) {
29
+ super(editor);
30
+ /**
31
+ * This method is called each time the image `uploadStatus` attribute is changed.
32
+ *
33
+ * @param evt An object containing information about the fired event.
34
+ * @param data Additional information about the change.
35
+ */
36
+ this.uploadStatusChange = (evt, data, conversionApi) => {
37
+ const editor = this.editor;
38
+ const modelImage = data.item;
39
+ const uploadId = modelImage.getAttribute('uploadId');
40
+ if (!conversionApi.consumable.consume(data.item, evt.name)) {
41
+ return;
42
+ }
43
+ const imageUtils = editor.plugins.get('ImageUtils');
44
+ const fileRepository = editor.plugins.get(FileRepository);
45
+ const status = uploadId ? data.attributeNewValue : null;
46
+ const placeholder = this.placeholder;
47
+ const viewFigure = editor.editing.mapper.toViewElement(modelImage);
48
+ const viewWriter = conversionApi.writer;
49
+ if (status == 'reading') {
50
+ // Start "appearing" effect and show placeholder with infinite progress bar on the top
51
+ // while image is read from disk.
52
+ _startAppearEffect(viewFigure, viewWriter);
53
+ _showPlaceholder(imageUtils, placeholder, viewFigure, viewWriter);
54
+ return;
55
+ }
56
+ // Show progress bar on the top of the image when image is uploading.
57
+ if (status == 'uploading') {
58
+ const loader = fileRepository.loaders.get(uploadId);
59
+ // Start appear effect if needed - see https://github.com/ckeditor/ckeditor5-image/issues/191.
60
+ _startAppearEffect(viewFigure, viewWriter);
61
+ if (!loader) {
62
+ // There is no loader associated with uploadId - this means that image came from external changes.
63
+ // In such cases we still want to show the placeholder until image is fully uploaded.
64
+ // Show placeholder if needed - see https://github.com/ckeditor/ckeditor5-image/issues/191.
65
+ _showPlaceholder(imageUtils, placeholder, viewFigure, viewWriter);
66
+ }
67
+ else {
68
+ // Hide placeholder and initialize progress bar showing upload progress.
69
+ _hidePlaceholder(viewFigure, viewWriter);
70
+ _showProgressBar(viewFigure, viewWriter, loader, editor.editing.view);
71
+ _displayLocalImage(imageUtils, viewFigure, viewWriter, loader);
72
+ }
73
+ return;
74
+ }
75
+ if (status == 'complete' && fileRepository.loaders.get(uploadId)) {
76
+ _showCompleteIcon(viewFigure, viewWriter, editor.editing.view);
77
+ }
78
+ // Clean up.
79
+ _hideProgressBar(viewFigure, viewWriter);
80
+ _hidePlaceholder(viewFigure, viewWriter);
81
+ _stopAppearEffect(viewFigure, viewWriter);
82
+ };
83
+ this.placeholder = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
84
+ }
85
+ /**
86
+ * @inheritDoc
87
+ */
88
+ init() {
89
+ const editor = this.editor;
90
+ // Upload status change - update image's view according to that status.
91
+ if (editor.plugins.has('ImageBlockEditing')) {
92
+ editor.editing.downcastDispatcher.on('attribute:uploadStatus:imageBlock', this.uploadStatusChange);
93
+ }
94
+ if (editor.plugins.has('ImageInlineEditing')) {
95
+ editor.editing.downcastDispatcher.on('attribute:uploadStatus:imageInline', this.uploadStatusChange);
96
+ }
97
+ }
129
98
  }
130
-
131
- // Adds ck-appear class to the image figure if one is not already applied.
132
- //
133
- // @param {module:engine/view/containerelement~ContainerElement} viewFigure
134
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
135
- function _startAppearEffect( viewFigure, writer ) {
136
- if ( !viewFigure.hasClass( 'ck-appear' ) ) {
137
- writer.addClass( 'ck-appear', viewFigure );
138
- }
99
+ /**
100
+ * Adds ck-appear class to the image figure if one is not already applied.
101
+ */
102
+ function _startAppearEffect(viewFigure, writer) {
103
+ if (!viewFigure.hasClass('ck-appear')) {
104
+ writer.addClass('ck-appear', viewFigure);
105
+ }
139
106
  }
140
-
141
- // Removes ck-appear class to the image figure if one is not already removed.
142
- //
143
- // @param {module:engine/view/containerelement~ContainerElement} viewFigure
144
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
145
- function _stopAppearEffect( viewFigure, writer ) {
146
- writer.removeClass( 'ck-appear', viewFigure );
107
+ /**
108
+ * Removes ck-appear class to the image figure if one is not already removed.
109
+ */
110
+ function _stopAppearEffect(viewFigure, writer) {
111
+ writer.removeClass('ck-appear', viewFigure);
147
112
  }
148
-
149
- // Shows placeholder together with infinite progress bar on given image figure.
150
- //
151
- // @param {module:image/imageutils~ImageUtils} imageUtils
152
- // @param {String} Data-uri with a svg placeholder.
153
- // @param {module:engine/view/containerelement~ContainerElement} viewFigure
154
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
155
- function _showPlaceholder( imageUtils, placeholder, viewFigure, writer ) {
156
- if ( !viewFigure.hasClass( 'ck-image-upload-placeholder' ) ) {
157
- writer.addClass( 'ck-image-upload-placeholder', viewFigure );
158
- }
159
-
160
- const viewImg = imageUtils.findViewImgElement( viewFigure );
161
-
162
- if ( viewImg.getAttribute( 'src' ) !== placeholder ) {
163
- writer.setAttribute( 'src', placeholder, viewImg );
164
- }
165
-
166
- if ( !_getUIElement( viewFigure, 'placeholder' ) ) {
167
- writer.insert( writer.createPositionAfter( viewImg ), _createPlaceholder( writer ) );
168
- }
113
+ /**
114
+ * Shows placeholder together with infinite progress bar on given image figure.
115
+ */
116
+ function _showPlaceholder(imageUtils, placeholder, viewFigure, writer) {
117
+ if (!viewFigure.hasClass('ck-image-upload-placeholder')) {
118
+ writer.addClass('ck-image-upload-placeholder', viewFigure);
119
+ }
120
+ const viewImg = imageUtils.findViewImgElement(viewFigure);
121
+ if (viewImg.getAttribute('src') !== placeholder) {
122
+ writer.setAttribute('src', placeholder, viewImg);
123
+ }
124
+ if (!_getUIElement(viewFigure, 'placeholder')) {
125
+ writer.insert(writer.createPositionAfter(viewImg), _createPlaceholder(writer));
126
+ }
169
127
  }
170
-
171
- // Removes placeholder together with infinite progress bar on given image figure.
172
- //
173
- // @param {module:engine/view/containerelement~ContainerElement} viewFigure
174
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
175
- function _hidePlaceholder( viewFigure, writer ) {
176
- if ( viewFigure.hasClass( 'ck-image-upload-placeholder' ) ) {
177
- writer.removeClass( 'ck-image-upload-placeholder', viewFigure );
178
- }
179
-
180
- _removeUIElement( viewFigure, writer, 'placeholder' );
128
+ /**
129
+ * Removes placeholder together with infinite progress bar on given image figure.
130
+ */
131
+ function _hidePlaceholder(viewFigure, writer) {
132
+ if (viewFigure.hasClass('ck-image-upload-placeholder')) {
133
+ writer.removeClass('ck-image-upload-placeholder', viewFigure);
134
+ }
135
+ _removeUIElement(viewFigure, writer, 'placeholder');
181
136
  }
182
-
183
- // Shows progress bar displaying upload progress.
184
- // Attaches it to the file loader to update when upload percentace is changed.
185
- //
186
- // @param {module:engine/view/containerelement~ContainerElement} viewFigure
187
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
188
- // @param {module:upload/filerepository~FileLoader} loader
189
- // @param {module:engine/view/view~View} view
190
- function _showProgressBar( viewFigure, writer, loader, view ) {
191
- const progressBar = _createProgressBar( writer );
192
- writer.insert( writer.createPositionAt( viewFigure, 'end' ), progressBar );
193
-
194
- // Update progress bar width when uploadedPercent is changed.
195
- loader.on( 'change:uploadedPercent', ( evt, name, value ) => {
196
- view.change( writer => {
197
- writer.setStyle( 'width', value + '%', progressBar );
198
- } );
199
- } );
137
+ /**
138
+ * Shows progress bar displaying upload progress.
139
+ * Attaches it to the file loader to update when upload percentace is changed.
140
+ */
141
+ function _showProgressBar(viewFigure, writer, loader, view) {
142
+ const progressBar = _createProgressBar(writer);
143
+ writer.insert(writer.createPositionAt(viewFigure, 'end'), progressBar);
144
+ // Update progress bar width when uploadedPercent is changed.
145
+ loader.on('change:uploadedPercent', (evt, name, value) => {
146
+ view.change(writer => {
147
+ writer.setStyle('width', value + '%', progressBar);
148
+ });
149
+ });
200
150
  }
201
-
202
- // Hides upload progress bar.
203
- //
204
- // @param {module:engine/view/containerelement~ContainerElement} viewFigure
205
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
206
- function _hideProgressBar( viewFigure, writer ) {
207
- _removeUIElement( viewFigure, writer, 'progressBar' );
151
+ /**
152
+ * Hides upload progress bar.
153
+ */
154
+ function _hideProgressBar(viewFigure, writer) {
155
+ _removeUIElement(viewFigure, writer, 'progressBar');
208
156
  }
209
-
210
- // Shows complete icon and hides after a certain amount of time.
211
- //
212
- // @param {module:engine/view/containerelement~ContainerElement} viewFigure
213
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
214
- // @param {module:engine/view/view~View} view
215
- function _showCompleteIcon( viewFigure, writer, view ) {
216
- const completeIcon = writer.createUIElement( 'div', { class: 'ck-image-upload-complete-icon' } );
217
-
218
- writer.insert( writer.createPositionAt( viewFigure, 'end' ), completeIcon );
219
-
220
- setTimeout( () => {
221
- view.change( writer => writer.remove( writer.createRangeOn( completeIcon ) ) );
222
- }, 3000 );
157
+ /**
158
+ * Shows complete icon and hides after a certain amount of time.
159
+ */
160
+ function _showCompleteIcon(viewFigure, writer, view) {
161
+ const completeIcon = writer.createUIElement('div', { class: 'ck-image-upload-complete-icon' });
162
+ writer.insert(writer.createPositionAt(viewFigure, 'end'), completeIcon);
163
+ setTimeout(() => {
164
+ view.change(writer => writer.remove(writer.createRangeOn(completeIcon)));
165
+ }, 3000);
223
166
  }
224
-
225
- // Create progress bar element using {@link module:engine/view/uielement~UIElement}.
226
- //
227
- // @private
228
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
229
- // @returns {module:engine/view/uielement~UIElement}
230
- function _createProgressBar( writer ) {
231
- const progressBar = writer.createUIElement( 'div', { class: 'ck-progress-bar' } );
232
-
233
- writer.setCustomProperty( 'progressBar', true, progressBar );
234
-
235
- return progressBar;
167
+ /**
168
+ * Create progress bar element using {@link module:engine/view/uielement~UIElement}.
169
+ */
170
+ function _createProgressBar(writer) {
171
+ const progressBar = writer.createUIElement('div', { class: 'ck-progress-bar' });
172
+ writer.setCustomProperty('progressBar', true, progressBar);
173
+ return progressBar;
236
174
  }
237
-
238
- // Create placeholder element using {@link module:engine/view/uielement~UIElement}.
239
- //
240
- // @private
241
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
242
- // @returns {module:engine/view/uielement~UIElement}
243
- function _createPlaceholder( writer ) {
244
- const placeholder = writer.createUIElement( 'div', { class: 'ck-upload-placeholder-loader' } );
245
-
246
- writer.setCustomProperty( 'placeholder', true, placeholder );
247
-
248
- return placeholder;
175
+ /**
176
+ * Create placeholder element using {@link module:engine/view/uielement~UIElement}.
177
+ */
178
+ function _createPlaceholder(writer) {
179
+ const placeholder = writer.createUIElement('div', { class: 'ck-upload-placeholder-loader' });
180
+ writer.setCustomProperty('placeholder', true, placeholder);
181
+ return placeholder;
249
182
  }
250
-
251
- // Returns {@link module:engine/view/uielement~UIElement} of given unique property from image figure element.
252
- // Returns `undefined` if element is not found.
253
- //
254
- // @private
255
- // @param {module:engine/view/element~Element} imageFigure
256
- // @param {String} uniqueProperty
257
- // @returns {module:engine/view/uielement~UIElement|undefined}
258
- function _getUIElement( imageFigure, uniqueProperty ) {
259
- for ( const child of imageFigure.getChildren() ) {
260
- if ( child.getCustomProperty( uniqueProperty ) ) {
261
- return child;
262
- }
263
- }
183
+ /**
184
+ * Returns {@link module:engine/view/uielement~UIElement} of given unique property from image figure element.
185
+ * Returns `undefined` if element is not found.
186
+ */
187
+ function _getUIElement(imageFigure, uniqueProperty) {
188
+ for (const child of imageFigure.getChildren()) {
189
+ if (child.getCustomProperty(uniqueProperty)) {
190
+ return child;
191
+ }
192
+ }
264
193
  }
265
-
266
- // Removes {@link module:engine/view/uielement~UIElement} of given unique property from image figure element.
267
- //
268
- // @private
269
- // @param {module:engine/view/element~Element} imageFigure
270
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
271
- // @param {String} uniqueProperty
272
- function _removeUIElement( viewFigure, writer, uniqueProperty ) {
273
- const element = _getUIElement( viewFigure, uniqueProperty );
274
-
275
- if ( element ) {
276
- writer.remove( writer.createRangeOn( element ) );
277
- }
194
+ /**
195
+ * Removes {@link module:engine/view/uielement~UIElement} of given unique property from image figure element.
196
+ */
197
+ function _removeUIElement(viewFigure, writer, uniqueProperty) {
198
+ const element = _getUIElement(viewFigure, uniqueProperty);
199
+ if (element) {
200
+ writer.remove(writer.createRangeOn(element));
201
+ }
278
202
  }
279
-
280
- // Displays local data from file loader.
281
- //
282
- // @param {module:image/imageutils~ImageUtils} imageUtils
283
- // @param {module:engine/view/element~Element} imageFigure
284
- // @param {module:engine/view/downcastwriter~DowncastWriter} writer
285
- // @param {module:upload/filerepository~FileLoader} loader
286
- function _displayLocalImage( imageUtils, viewFigure, writer, loader ) {
287
- if ( loader.data ) {
288
- const viewImg = imageUtils.findViewImgElement( viewFigure );
289
-
290
- writer.setAttribute( 'src', loader.data, viewImg );
291
- }
203
+ /**
204
+ * Displays local data from file loader.
205
+ */
206
+ function _displayLocalImage(imageUtils, viewFigure, writer, loader) {
207
+ if (loader.data) {
208
+ const viewImg = imageUtils.findViewImgElement(viewFigure);
209
+ writer.setAttribute('src', loader.data, viewImg);
210
+ }
292
211
  }
@@ -0,0 +1,29 @@
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
+ import { Plugin } from 'ckeditor5/src/core';
6
+ import '../imageconfig';
7
+ /**
8
+ * The image upload button plugin.
9
+ *
10
+ * For a detailed overview, check the {@glink features/images/image-upload/image-upload Image upload feature} documentation.
11
+ *
12
+ * Adds the `'uploadImage'` button to the {@link module:ui/componentfactory~ComponentFactory UI component factory}
13
+ * and also the `imageUpload` button as an alias for backward compatibility.
14
+ */
15
+ export default class ImageUploadUI extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName(): 'ImageUploadUI';
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ init(): void;
24
+ }
25
+ declare module '@ckeditor/ckeditor5-core' {
26
+ interface PluginsMap {
27
+ [ImageUploadUI.pluginName]: ImageUploadUI;
28
+ }
29
+ }