@ckeditor/ckeditor5-image 44.0.0-alpha.9 → 44.1.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.
- package/build/image.js +1 -1
- package/dist/augmentation.d.ts +1 -1
- package/dist/autoimage.d.ts +1 -1
- package/dist/image/converters.d.ts +1 -1
- package/dist/image/imageblockediting.d.ts +1 -1
- package/dist/image/imageediting.d.ts +1 -1
- package/dist/image/imageinlineediting.d.ts +1 -1
- package/dist/image/imageloadobserver.d.ts +1 -1
- package/dist/image/imageplaceholder.d.ts +1 -1
- package/dist/image/imagetypecommand.d.ts +1 -1
- package/dist/image/insertimagecommand.d.ts +1 -1
- package/dist/image/replaceimagesourcecommand.d.ts +1 -1
- package/dist/image/ui/utils.d.ts +1 -1
- package/dist/image/utils.d.ts +1 -1
- package/dist/image.d.ts +1 -1
- package/dist/imageblock.d.ts +1 -1
- package/dist/imagecaption/imagecaptionediting.d.ts +1 -1
- package/dist/imagecaption/imagecaptionui.d.ts +1 -1
- package/dist/imagecaption/imagecaptionutils.d.ts +1 -1
- package/dist/imagecaption/toggleimagecaptioncommand.d.ts +1 -1
- package/dist/imagecaption.d.ts +1 -1
- package/dist/imageconfig.d.ts +1 -1
- package/dist/imageinline.d.ts +1 -1
- package/dist/imageinsert/imageinsertui.d.ts +1 -1
- package/dist/imageinsert/imageinsertviaurlui.d.ts +1 -1
- package/dist/imageinsert/ui/imageinsertformview.d.ts +1 -1
- package/dist/imageinsert/ui/imageinserturlview.d.ts +1 -1
- package/dist/imageinsert.d.ts +1 -1
- package/dist/imageinsertviaurl.d.ts +1 -1
- package/dist/imageresize/imagecustomresizeui.d.ts +1 -1
- package/dist/imageresize/imageresizebuttons.d.ts +1 -1
- package/dist/imageresize/imageresizeediting.d.ts +1 -1
- package/dist/imageresize/imageresizehandles.d.ts +1 -1
- package/dist/imageresize/resizeimagecommand.d.ts +1 -1
- package/dist/imageresize/ui/imagecustomresizeformview.d.ts +1 -1
- package/dist/imageresize/utils/getselectedimageeditornodes.d.ts +1 -1
- package/dist/imageresize/utils/getselectedimagepossibleresizerange.d.ts +1 -1
- package/dist/imageresize/utils/getselectedimagewidthinunits.d.ts +1 -1
- package/dist/imageresize/utils/tryparsedimensionwithunit.d.ts +1 -1
- package/dist/imageresize.d.ts +1 -1
- package/dist/imagesizeattributes.d.ts +1 -1
- package/dist/imagestyle/converters.d.ts +1 -1
- package/dist/imagestyle/imagestylecommand.d.ts +1 -1
- package/dist/imagestyle/imagestyleediting.d.ts +1 -1
- package/dist/imagestyle/imagestyleui.d.ts +1 -1
- package/dist/imagestyle/utils.d.ts +1 -1
- package/dist/imagestyle.d.ts +1 -1
- package/dist/imagetextalternative/imagetextalternativecommand.d.ts +1 -1
- package/dist/imagetextalternative/imagetextalternativeediting.d.ts +1 -1
- package/dist/imagetextalternative/imagetextalternativeui.d.ts +1 -1
- package/dist/imagetextalternative/ui/textalternativeformview.d.ts +1 -1
- package/dist/imagetextalternative.d.ts +1 -1
- package/dist/imagetoolbar.d.ts +1 -1
- package/dist/imageupload/imageuploadediting.d.ts +14 -1
- package/dist/imageupload/imageuploadprogress.d.ts +1 -1
- package/dist/imageupload/imageuploadui.d.ts +1 -1
- package/dist/imageupload/uploadimagecommand.d.ts +1 -1
- package/dist/imageupload/utils.d.ts +1 -1
- package/dist/imageupload.d.ts +1 -1
- package/dist/imageutils.d.ts +1 -1
- package/dist/index.css +16 -16
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +158 -48
- package/dist/index.js.map +1 -1
- package/dist/pictureediting.d.ts +1 -1
- package/package.json +11 -11
- package/src/augmentation.d.ts +1 -1
- package/src/augmentation.js +1 -1
- package/src/autoimage.d.ts +1 -1
- package/src/autoimage.js +1 -1
- package/src/image/converters.d.ts +1 -1
- package/src/image/converters.js +1 -1
- package/src/image/imageblockediting.d.ts +1 -1
- package/src/image/imageblockediting.js +1 -1
- package/src/image/imageediting.d.ts +1 -1
- package/src/image/imageediting.js +1 -1
- package/src/image/imageinlineediting.d.ts +1 -1
- package/src/image/imageinlineediting.js +1 -1
- package/src/image/imageloadobserver.d.ts +1 -1
- package/src/image/imageloadobserver.js +1 -1
- package/src/image/imageplaceholder.d.ts +1 -1
- package/src/image/imageplaceholder.js +1 -1
- package/src/image/imagetypecommand.d.ts +1 -1
- package/src/image/imagetypecommand.js +1 -1
- package/src/image/insertimagecommand.d.ts +1 -1
- package/src/image/insertimagecommand.js +1 -1
- package/src/image/replaceimagesourcecommand.d.ts +1 -1
- package/src/image/replaceimagesourcecommand.js +1 -1
- package/src/image/ui/utils.d.ts +1 -1
- package/src/image/ui/utils.js +1 -1
- package/src/image/utils.d.ts +1 -1
- package/src/image/utils.js +1 -1
- package/src/image.d.ts +1 -1
- package/src/image.js +1 -1
- package/src/imageblock.d.ts +1 -1
- package/src/imageblock.js +1 -1
- package/src/imagecaption/imagecaptionediting.d.ts +1 -1
- package/src/imagecaption/imagecaptionediting.js +1 -1
- package/src/imagecaption/imagecaptionui.d.ts +1 -1
- package/src/imagecaption/imagecaptionui.js +1 -1
- package/src/imagecaption/imagecaptionutils.d.ts +1 -1
- package/src/imagecaption/imagecaptionutils.js +1 -1
- package/src/imagecaption/toggleimagecaptioncommand.d.ts +1 -1
- package/src/imagecaption/toggleimagecaptioncommand.js +1 -1
- package/src/imagecaption.d.ts +1 -1
- package/src/imagecaption.js +1 -1
- package/src/imageconfig.d.ts +1 -1
- package/src/imageconfig.js +1 -1
- package/src/imageinline.d.ts +1 -1
- package/src/imageinline.js +1 -1
- package/src/imageinsert/imageinsertui.d.ts +1 -1
- package/src/imageinsert/imageinsertui.js +1 -1
- package/src/imageinsert/imageinsertviaurlui.d.ts +1 -1
- package/src/imageinsert/imageinsertviaurlui.js +1 -1
- package/src/imageinsert/ui/imageinsertformview.d.ts +1 -1
- package/src/imageinsert/ui/imageinsertformview.js +1 -1
- package/src/imageinsert/ui/imageinserturlview.d.ts +1 -1
- package/src/imageinsert/ui/imageinserturlview.js +1 -1
- package/src/imageinsert.d.ts +1 -1
- package/src/imageinsert.js +1 -1
- package/src/imageinsertviaurl.d.ts +1 -1
- package/src/imageinsertviaurl.js +1 -1
- package/src/imageresize/imagecustomresizeui.d.ts +1 -1
- package/src/imageresize/imagecustomresizeui.js +1 -1
- package/src/imageresize/imageresizebuttons.d.ts +1 -1
- package/src/imageresize/imageresizebuttons.js +1 -1
- package/src/imageresize/imageresizeediting.d.ts +1 -1
- package/src/imageresize/imageresizeediting.js +1 -1
- package/src/imageresize/imageresizehandles.d.ts +1 -1
- package/src/imageresize/imageresizehandles.js +1 -1
- package/src/imageresize/resizeimagecommand.d.ts +1 -1
- package/src/imageresize/resizeimagecommand.js +1 -1
- package/src/imageresize/ui/imagecustomresizeformview.d.ts +1 -1
- package/src/imageresize/ui/imagecustomresizeformview.js +1 -1
- package/src/imageresize/utils/getselectedimageeditornodes.d.ts +1 -1
- package/src/imageresize/utils/getselectedimageeditornodes.js +1 -1
- package/src/imageresize/utils/getselectedimagepossibleresizerange.d.ts +1 -1
- package/src/imageresize/utils/getselectedimagepossibleresizerange.js +1 -1
- package/src/imageresize/utils/getselectedimagewidthinunits.d.ts +1 -1
- package/src/imageresize/utils/getselectedimagewidthinunits.js +1 -1
- package/src/imageresize/utils/tryparsedimensionwithunit.d.ts +1 -1
- package/src/imageresize/utils/tryparsedimensionwithunit.js +1 -1
- package/src/imageresize.d.ts +1 -1
- package/src/imageresize.js +1 -1
- package/src/imagesizeattributes.d.ts +1 -1
- package/src/imagesizeattributes.js +1 -1
- package/src/imagestyle/converters.d.ts +1 -1
- package/src/imagestyle/converters.js +1 -1
- package/src/imagestyle/imagestylecommand.d.ts +1 -1
- package/src/imagestyle/imagestylecommand.js +1 -1
- package/src/imagestyle/imagestyleediting.d.ts +1 -1
- package/src/imagestyle/imagestyleediting.js +1 -1
- package/src/imagestyle/imagestyleui.d.ts +1 -1
- package/src/imagestyle/imagestyleui.js +1 -1
- package/src/imagestyle/utils.d.ts +1 -1
- package/src/imagestyle/utils.js +1 -1
- package/src/imagestyle.d.ts +1 -1
- package/src/imagestyle.js +1 -1
- package/src/imagetextalternative/imagetextalternativecommand.d.ts +1 -1
- package/src/imagetextalternative/imagetextalternativecommand.js +1 -1
- package/src/imagetextalternative/imagetextalternativeediting.d.ts +1 -1
- package/src/imagetextalternative/imagetextalternativeediting.js +1 -1
- package/src/imagetextalternative/imagetextalternativeui.d.ts +1 -1
- package/src/imagetextalternative/imagetextalternativeui.js +1 -1
- package/src/imagetextalternative/ui/textalternativeformview.d.ts +1 -1
- package/src/imagetextalternative/ui/textalternativeformview.js +1 -1
- package/src/imagetextalternative.d.ts +1 -1
- package/src/imagetextalternative.js +1 -1
- package/src/imagetoolbar.d.ts +1 -1
- package/src/imagetoolbar.js +1 -1
- package/src/imageupload/imageuploadediting.d.ts +14 -1
- package/src/imageupload/imageuploadediting.js +143 -43
- package/src/imageupload/imageuploadprogress.d.ts +1 -1
- package/src/imageupload/imageuploadprogress.js +1 -1
- package/src/imageupload/imageuploadui.d.ts +1 -1
- package/src/imageupload/imageuploadui.js +1 -1
- package/src/imageupload/uploadimagecommand.d.ts +1 -1
- package/src/imageupload/uploadimagecommand.js +1 -1
- package/src/imageupload/utils.d.ts +1 -1
- package/src/imageupload/utils.js +1 -1
- package/src/imageupload.d.ts +1 -1
- package/src/imageupload.js +1 -1
- package/src/imageutils.d.ts +1 -1
- package/src/imageutils.js +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/pictureediting.d.ts +1 -1
- package/src/pictureediting.js +1 -1
- package/theme/image.css +1 -1
- package/theme/imagecaption.css +1 -1
- package/theme/imagecustomresizeform.css +1 -1
- package/theme/imageinsert.css +1 -1
- package/theme/imageplaceholder.css +1 -1
- package/theme/imageresize.css +1 -1
- package/theme/imagestyle.css +1 -1
- package/theme/imageuploadicon.css +1 -1
- package/theme/imageuploadloader.css +1 -1
- package/theme/imageuploadprogress.css +1 -1
- package/theme/textalternativeform.css +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload/imageuploadediting
|
|
@@ -43,6 +43,13 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
43
43
|
*/
|
|
44
44
|
constructor(editor) {
|
|
45
45
|
super(editor);
|
|
46
|
+
/**
|
|
47
|
+
* An internal mapping of {@link module:upload/filerepository~FileLoader#id file loader UIDs} and
|
|
48
|
+
* upload responses for handling images dragged during their upload process. When such images are later
|
|
49
|
+
* dropped, their original upload IDs no longer exist in the registry (as the original upload completed).
|
|
50
|
+
* This map preserves the upload responses to properly handle such cases.
|
|
51
|
+
*/
|
|
52
|
+
this._uploadedImages = new Map();
|
|
46
53
|
editor.config.define('image', {
|
|
47
54
|
upload: {
|
|
48
55
|
types: ['jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff']
|
|
@@ -73,7 +80,30 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
73
80
|
key: 'uploadId'
|
|
74
81
|
},
|
|
75
82
|
model: 'uploadId'
|
|
76
|
-
})
|
|
83
|
+
})
|
|
84
|
+
// Handle the case when the image is not fully uploaded yet but it's being moved.
|
|
85
|
+
// See more: https://github.com/ckeditor/ckeditor5/pull/17327
|
|
86
|
+
.add(dispatcher => dispatcher.on('element:img', (evt, data, conversionApi) => {
|
|
87
|
+
if (!conversionApi.consumable.test(data.viewItem, { attributes: ['data-ck-upload-id'] })) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const uploadId = data.viewItem.getAttribute('data-ck-upload-id');
|
|
91
|
+
if (!uploadId) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const [modelElement] = Array.from(data.modelRange.getItems({ shallow: true }));
|
|
95
|
+
const loader = fileRepository.loaders.get(uploadId);
|
|
96
|
+
if (modelElement) {
|
|
97
|
+
// Handle case when `uploadId` is set on the image element but the loader is not present in the registry.
|
|
98
|
+
// It may happen when the image was successfully uploaded and the loader was removed from the registry.
|
|
99
|
+
// It's still present in the `_uploadedImages` map though. It's why we do not place this line in the condition below.
|
|
100
|
+
conversionApi.writer.setAttribute('uploadId', uploadId, modelElement);
|
|
101
|
+
conversionApi.consumable.consume(data.viewItem, { attributes: ['data-ck-upload-id'] });
|
|
102
|
+
if (loader && loader.data) {
|
|
103
|
+
conversionApi.writer.setAttribute('uploadStatus', loader.status, modelElement);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, { priority: 'low' }));
|
|
77
107
|
// Handle pasted images.
|
|
78
108
|
// For every image file, a new file loader is created and a placeholder image is
|
|
79
109
|
// inserted into the content. Then, those images are uploaded once they appear in the model
|
|
@@ -160,13 +190,38 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
160
190
|
// Check if the image is loaded on this client.
|
|
161
191
|
const loader = fileRepository.loaders.get(uploadId);
|
|
162
192
|
if (!loader) {
|
|
193
|
+
// If the loader does not exist, it means that the image was already uploaded
|
|
194
|
+
// and the loader promise was removed from the registry. In that scenario we need
|
|
195
|
+
// to restore response object from the internal map.
|
|
196
|
+
if (!isInsertedInGraveyard && this._uploadedImages.has(uploadId)) {
|
|
197
|
+
// Fire `uploadComplete` to set proper attributes on the image element.
|
|
198
|
+
editor.model.enqueueChange({ isUndoable: false }, writer => {
|
|
199
|
+
writer.setAttribute('uploadStatus', 'complete', imageElement);
|
|
200
|
+
this.fire('uploadComplete', {
|
|
201
|
+
data: this._uploadedImages.get(uploadId),
|
|
202
|
+
imageElement: imageElement
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
// While it makes sense to remove the image from the `_uploadedImages` map here,
|
|
206
|
+
// it's counterintuitive for the user that pastes image in uploading several times.
|
|
207
|
+
// It'll work the first time, but the next time the image will be empty because the
|
|
208
|
+
// `_uploadedImages` no longer contain the response.
|
|
209
|
+
}
|
|
163
210
|
continue;
|
|
164
211
|
}
|
|
165
212
|
if (isInsertedInGraveyard) {
|
|
166
213
|
// If the image was inserted to the graveyard for good (**not** replaced by another image),
|
|
167
214
|
// only then abort the loading process.
|
|
168
215
|
if (!insertedImagesIds.has(uploadId)) {
|
|
169
|
-
loader.
|
|
216
|
+
// ... but abort it only if all remain images that share the same loader are in the graveyard too.
|
|
217
|
+
// This is to prevent situation when we have two images in uploading state and one of them is being
|
|
218
|
+
// placed in the graveyard (e.g. using undo). The other one should not be aborted.
|
|
219
|
+
const allImagesThatShareUploaderInGraveyard = Array
|
|
220
|
+
.from(this._uploadImageElements.get(uploadId))
|
|
221
|
+
.every(element => element.root.rootName == '$graveyard');
|
|
222
|
+
if (allImagesThatShareUploaderInGraveyard) {
|
|
223
|
+
loader.abort();
|
|
224
|
+
}
|
|
170
225
|
}
|
|
171
226
|
}
|
|
172
227
|
else {
|
|
@@ -178,7 +233,12 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
178
233
|
// can later resolve in the context of the correct model element. The model element could
|
|
179
234
|
// change for the same upload if one image was replaced by another (e.g. image type was changed),
|
|
180
235
|
// so this may also replace an existing mapping.
|
|
181
|
-
this._uploadImageElements.
|
|
236
|
+
if (!this._uploadImageElements.has(uploadId)) {
|
|
237
|
+
this._uploadImageElements.set(uploadId, new Set([imageElement]));
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
this._uploadImageElements.get(uploadId).add(imageElement);
|
|
241
|
+
}
|
|
182
242
|
if (loader.status == 'idle') {
|
|
183
243
|
// If the image was inserted into content and has not been loaded yet, start loading it.
|
|
184
244
|
this._readAndUpload(loader);
|
|
@@ -211,11 +271,13 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
211
271
|
schema.extend('imageBlock', {
|
|
212
272
|
allowAttributes: ['uploadId', 'uploadStatus']
|
|
213
273
|
});
|
|
274
|
+
this._registerConverters('imageBlock');
|
|
214
275
|
}
|
|
215
276
|
if (this.editor.plugins.has('ImageInlineEditing')) {
|
|
216
277
|
schema.extend('imageInline', {
|
|
217
278
|
allowAttributes: ['uploadId', 'uploadStatus']
|
|
218
279
|
});
|
|
280
|
+
this._registerConverters('imageInline');
|
|
219
281
|
}
|
|
220
282
|
}
|
|
221
283
|
/**
|
|
@@ -234,51 +296,57 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
234
296
|
const imageUtils = editor.plugins.get('ImageUtils');
|
|
235
297
|
const imageUploadElements = this._uploadImageElements;
|
|
236
298
|
model.enqueueChange({ isUndoable: false }, writer => {
|
|
237
|
-
|
|
299
|
+
const elements = imageUploadElements.get(loader.id);
|
|
300
|
+
for (const element of elements) {
|
|
301
|
+
writer.setAttribute('uploadStatus', 'reading', element);
|
|
302
|
+
}
|
|
238
303
|
});
|
|
239
304
|
return loader.read()
|
|
240
305
|
.then(() => {
|
|
241
306
|
const promise = loader.upload();
|
|
242
|
-
const imageElement = imageUploadElements.get(loader.id);
|
|
243
|
-
// Force re–paint in Safari. Without it, the image will display with a wrong size.
|
|
244
|
-
// https://github.com/ckeditor/ckeditor5/issues/1975
|
|
245
|
-
/* istanbul ignore next -- @preserve */
|
|
246
|
-
if (env.isSafari) {
|
|
247
|
-
const viewFigure = editor.editing.mapper.toViewElement(imageElement);
|
|
248
|
-
const viewImg = imageUtils.findViewImgElement(viewFigure);
|
|
249
|
-
editor.editing.view.once('render', () => {
|
|
250
|
-
// Early returns just to be safe. There might be some code ran
|
|
251
|
-
// in between the outer scope and this callback.
|
|
252
|
-
if (!viewImg.parent) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const domFigure = editor.editing.view.domConverter.mapViewToDom(viewImg.parent);
|
|
256
|
-
if (!domFigure) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
const originalDisplay = domFigure.style.display;
|
|
260
|
-
domFigure.style.display = 'none';
|
|
261
|
-
// Make sure this line will never be removed during minification for having "no effect".
|
|
262
|
-
domFigure._ckHack = domFigure.offsetHeight;
|
|
263
|
-
domFigure.style.display = originalDisplay;
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
307
|
if (editor.ui) {
|
|
267
308
|
editor.ui.ariaLiveAnnouncer.announce(t('Uploading image'));
|
|
268
309
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
310
|
+
for (const imageElement of imageUploadElements.get(loader.id)) {
|
|
311
|
+
// Force re–paint in Safari. Without it, the image will display with a wrong size.
|
|
312
|
+
// https://github.com/ckeditor/ckeditor5/issues/1975
|
|
313
|
+
/* istanbul ignore next -- @preserve */
|
|
314
|
+
if (env.isSafari) {
|
|
315
|
+
const viewFigure = editor.editing.mapper.toViewElement(imageElement);
|
|
316
|
+
const viewImg = imageUtils.findViewImgElement(viewFigure);
|
|
317
|
+
editor.editing.view.once('render', () => {
|
|
318
|
+
// Early returns just to be safe. There might be some code ran
|
|
319
|
+
// in between the outer scope and this callback.
|
|
320
|
+
if (!viewImg.parent) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const domFigure = editor.editing.view.domConverter.mapViewToDom(viewImg.parent);
|
|
324
|
+
if (!domFigure) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const originalDisplay = domFigure.style.display;
|
|
328
|
+
domFigure.style.display = 'none';
|
|
329
|
+
// Make sure this line will never be removed during minification for having "no effect".
|
|
330
|
+
domFigure._ckHack = domFigure.offsetHeight;
|
|
331
|
+
domFigure.style.display = originalDisplay;
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
model.enqueueChange({ isUndoable: false }, writer => {
|
|
335
|
+
writer.setAttribute('uploadStatus', 'uploading', imageElement);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
272
338
|
return promise;
|
|
273
339
|
})
|
|
274
340
|
.then(data => {
|
|
275
341
|
model.enqueueChange({ isUndoable: false }, writer => {
|
|
276
|
-
const imageElement
|
|
277
|
-
|
|
342
|
+
for (const imageElement of imageUploadElements.get(loader.id)) {
|
|
343
|
+
writer.setAttribute('uploadStatus', 'complete', imageElement);
|
|
344
|
+
this.fire('uploadComplete', { data, imageElement });
|
|
345
|
+
}
|
|
278
346
|
if (editor.ui) {
|
|
279
347
|
editor.ui.ariaLiveAnnouncer.announce(t('Image upload complete'));
|
|
280
348
|
}
|
|
281
|
-
this.
|
|
349
|
+
this._uploadedImages.set(loader.id, data);
|
|
282
350
|
});
|
|
283
351
|
clean();
|
|
284
352
|
})
|
|
@@ -300,20 +368,22 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
300
368
|
}
|
|
301
369
|
// Permanently remove image from insertion batch.
|
|
302
370
|
model.enqueueChange({ isUndoable: false }, writer => {
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
371
|
+
for (const imageElement of imageUploadElements.get(loader.id)) {
|
|
372
|
+
// Handle situation when the image has been removed and then `abort` exception was thrown.
|
|
373
|
+
// See: https://github.com/cksource/ckeditor5-commercial/issues/6817
|
|
374
|
+
if (imageElement.root.rootName !== '$graveyard') {
|
|
375
|
+
writer.remove(imageElement);
|
|
376
|
+
}
|
|
308
377
|
}
|
|
309
378
|
});
|
|
310
379
|
clean();
|
|
311
380
|
});
|
|
312
381
|
function clean() {
|
|
313
382
|
model.enqueueChange({ isUndoable: false }, writer => {
|
|
314
|
-
const imageElement
|
|
315
|
-
|
|
316
|
-
|
|
383
|
+
for (const imageElement of imageUploadElements.get(loader.id)) {
|
|
384
|
+
writer.removeAttribute('uploadId', imageElement);
|
|
385
|
+
writer.removeAttribute('uploadStatus', imageElement);
|
|
386
|
+
}
|
|
317
387
|
imageUploadElements.delete(loader.id);
|
|
318
388
|
});
|
|
319
389
|
fileRepository.destroyLoader(loader);
|
|
@@ -351,6 +421,36 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
351
421
|
writer.setAttributes(attributes, image);
|
|
352
422
|
}
|
|
353
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Registers image upload converters.
|
|
426
|
+
*
|
|
427
|
+
* @param imageType The type of the image.
|
|
428
|
+
*/
|
|
429
|
+
_registerConverters(imageType) {
|
|
430
|
+
const { conversion, plugins } = this.editor;
|
|
431
|
+
const fileRepository = plugins.get(FileRepository);
|
|
432
|
+
const imageUtils = plugins.get(ImageUtils);
|
|
433
|
+
// It sets `data-ck-upload-id` attribute on the view image elements that are not fully uploaded.
|
|
434
|
+
// It avoids the situation when image disappears when it's being moved and upload is not finished yet.
|
|
435
|
+
// See more: https://github.com/ckeditor/ckeditor5/issues/16967
|
|
436
|
+
conversion.for('dataDowncast').add(dispatcher => {
|
|
437
|
+
dispatcher.on(`attribute:uploadId:${imageType}`, (evt, data, conversionApi) => {
|
|
438
|
+
if (!conversionApi.consumable.test(data.item, evt.name)) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const loader = fileRepository.loaders.get(data.attributeNewValue);
|
|
442
|
+
if (!loader || !loader.data) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
const viewElement = conversionApi.mapper.toViewElement(data.item);
|
|
446
|
+
const img = imageUtils.findViewImgElement(viewElement);
|
|
447
|
+
if (img) {
|
|
448
|
+
conversionApi.consumable.consume(data.item, evt.name);
|
|
449
|
+
conversionApi.writer.setAttribute('data-ck-upload-id', loader.id, img);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
}
|
|
354
454
|
}
|
|
355
455
|
/**
|
|
356
456
|
* Returns `true` if non-empty `text/html` is included in the data transfer.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload/imageuploadprogress
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload/imageuploadprogress
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload/imageuploadui
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload/imageuploadui
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
6
6
|
import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { FileRepository } from 'ckeditor5/src/upload.js';
|
|
6
6
|
import { Command } from 'ckeditor5/src/core.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload/utils
|
package/src/imageupload/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { global } from 'ckeditor5/src/utils.js';
|
|
6
6
|
/**
|
package/src/imageupload.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload
|
package/src/imageupload.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageupload
|
package/src/imageutils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageutils
|
package/src/imageutils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
6
|
import { findOptimalInsertionRange, isWidget, toWidget } from 'ckeditor5/src/widget.js';
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image
|
package/src/pictureediting.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/pictureediting
|
package/src/pictureediting.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module image/pictureediting
|
package/theme/image.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
.ck-content {
|
package/theme/imagecaption.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
@import "@ckeditor/ckeditor5-ui/theme/mixins/_mediacolors.css";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
package/theme/imageinsert.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
.ck.ck-image-insert-url {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
.ck.ck-editor__editable {
|
package/theme/imageresize.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/* Preserve aspect ratio of the resized image after introducing image height attribute. */
|
package/theme/imagestyle.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
:root {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
.ck-image-upload-complete-icon {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
.ck .ck-upload-placeholder-loader {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
.ck.ck-editor__editable {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|