-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8108 from ckeditor/i/7548
Fix (link): Fixed a quick image flicker of image resize frame when inserting an image. Closes #8088. Other (widget): `WidgetResize#visibleResizer` and `WidgetResize#getResizerByViewElement()` are now public. See #8088. Other (widget): `WidgetResize` will now automatically set `WidgetResize#visibleResizer` when calling `WidgetResize#attachTo()` if the corresponding resizer's element is focused during the call. See #8088.
- Loading branch information
Showing
8 changed files
with
214 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/ckeditor5-image/tests/imageresize/_utils/utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
import ImageLoadObserver from '../../../src/image/imageloadobserver'; | ||
|
||
// A 100x50 black png image | ||
export const IMAGE_SRC_FIXTURE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAQAAAAAPLY1AAAAQklEQVR42u3PQREAAAgDoK1/' + | ||
'aM3g14MGNJMXKiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiJysRFNMgH0RpujAAAAAElFTkSuQmCC'; | ||
|
||
export async function waitForAllImagesLoaded( editor ) { | ||
// Returns a promise that waits for all the images in editor to be loaded. | ||
// This is needed because resizers are created only after images are loaded. | ||
const root = editor.model.document.getRoot(); | ||
const editingView = editor.editing.view; | ||
const images = new Set(); | ||
|
||
for ( const curModel of root.getChildren() ) { | ||
if ( curModel.is( 'element', 'image' ) ) { | ||
const imageView = editor.editing.mapper.toViewElement( curModel ); | ||
images.add( editingView.domConverter.viewToDom( imageView ).querySelector( 'img' ) ); | ||
} | ||
} | ||
|
||
editingView.addObserver( ImageLoadObserver ); | ||
|
||
return new Promise( resolve => { | ||
editingView.document.on( 'imageLoaded', ( evt, domEvent ) => { | ||
images.delete( domEvent.target ); | ||
|
||
if ( images.size === 0 ) { | ||
resolve(); | ||
} | ||
} ); | ||
} ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.