|
|
@@ -11,6 +11,7 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
|
|
import FileRepository from '@ckeditor/ckeditor5-upload/src/filerepository';
|
|
|
import Notification from '@ckeditor/ckeditor5-ui/src/notification/notification';
|
|
|
import UpcastWriter from '@ckeditor/ckeditor5-engine/src/view/upcastwriter';
|
|
|
+import env from '@ckeditor/ckeditor5-utils/src/env';
|
|
|
|
|
|
import ImageUploadCommand from '../../src/imageupload/imageuploadcommand';
|
|
|
import { isImageType, isLocalImage, fetchLocalImage } from '../../src/imageupload/utils';
|
|
|
@@ -192,6 +193,34 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
const viewImg = viewFigure.getChild( 0 );
|
|
|
const promise = loader.upload();
|
|
|
|
|
|
+ // Force re–paint in Safari. Without it, the image will display with a wrong size.
|
|
|
+ // https://github.com/ckeditor/ckeditor5/issues/1975
|
|
|
+ /* istanbul ignore next */
|
|
|
+ if ( env.isSafari ) {
|
|
|
+ editor.editing.view.once( 'render', () => {
|
|
|
+ // Early returns just to be safe. There might be some code ran
|
|
|
+ // in between the outer scope and this callback.
|
|
|
+ if ( !viewImg.parent ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const domFigure = editor.editing.view.domConverter.mapViewToDom( viewImg.parent );
|
|
|
+
|
|
|
+ if ( !domFigure ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const originalDisplay = domFigure.style.display;
|
|
|
+
|
|
|
+ domFigure.style.display = 'none';
|
|
|
+
|
|
|
+ // Make sure this line will never be removed during minification for having "no effect".
|
|
|
+ domFigure._ckHack = domFigure.offsetHeight;
|
|
|
+
|
|
|
+ domFigure.style.display = originalDisplay;
|
|
|
+ } );
|
|
|
+ }
|
|
|
+
|
|
|
editor.editing.view.change( writer => {
|
|
|
writer.setAttribute( 'src', data, viewImg );
|
|
|
} );
|