@@ -11,6 +11,7 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11
11
import FileRepository from '@ckeditor/ckeditor5-upload/src/filerepository' ;
12
12
import Notification from '@ckeditor/ckeditor5-ui/src/notification/notification' ;
13
13
import UpcastWriter from '@ckeditor/ckeditor5-engine/src/view/upcastwriter' ;
14
+ import env from '@ckeditor/ckeditor5-utils/src/env' ;
14
15
15
16
import ImageUploadCommand from '../../src/imageupload/imageuploadcommand' ;
16
17
import { isImageType , isLocalImage , fetchLocalImage } from '../../src/imageupload/utils' ;
@@ -192,6 +193,34 @@ export default class ImageUploadEditing extends Plugin {
192
193
const viewImg = viewFigure . getChild ( 0 ) ;
193
194
const promise = loader . upload ( ) ;
194
195
196
+ // Force re–paint in Safari. Without it, the image will display with a wrong size.
197
+ // https://github.com/ckeditor/ckeditor5/issues/1975
198
+ /* istanbul ignore next */
199
+ if ( env . isSafari ) {
200
+ editor . editing . view . once ( 'render' , ( ) => {
201
+ // Early returns just to be safe. There might be some code ran
202
+ // in between the outer scope and this callback.
203
+ if ( ! viewImg . parent ) {
204
+ return ;
205
+ }
206
+
207
+ const domFigure = editor . editing . view . domConverter . mapViewToDom ( viewImg . parent ) ;
208
+
209
+ if ( ! domFigure ) {
210
+ return ;
211
+ }
212
+
213
+ const originalDisplay = domFigure . style . display ;
214
+
215
+ domFigure . style . display = 'none' ;
216
+
217
+ // Make sure this line will never be removed during minification for having "no effect".
218
+ domFigure . _ckHack = domFigure . offsetHeight ;
219
+
220
+ domFigure . style . display = originalDisplay ;
221
+ } ) ;
222
+ }
223
+
195
224
editor . editing . view . change ( writer => {
196
225
writer . setAttribute ( 'src' , data , viewImg ) ;
197
226
} ) ;
0 commit comments