Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge 0672e49 into 9bf4b35
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Aug 20, 2019
2 parents 9bf4b35 + 0672e49 commit ed7302e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/imageupload/imageuploadediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -192,6 +193,32 @@ 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
if ( env.isSafari ) {
editor.ui.once( 'update', () => {
// 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.viewToDom( viewImg.parent );

if ( !domFigure ) {
return;
}

const originalDisplay = domFigure.style.display;

domFigure.style.display = 'none';

const offsetHeightBefore = domFigure.offsetHeight; // eslint-disable-line no-unused-vars

domFigure.style.display = originalDisplay;
} );
}

editor.editing.view.change( writer => {
writer.setAttribute( 'src', data, viewImg );
} );
Expand Down

0 comments on commit ed7302e

Please sign in to comment.