-
Notifications
You must be signed in to change notification settings - Fork 37
Updated the UI after an image has been loaded in the DOM #210
Conversation
src/image/imageloadobserver.js
Outdated
*/ | ||
onDomEvent( domEvent ) { | ||
this.view.render(); | ||
this.fire( 'imageLoad', domEvent ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imageLoaded
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I forgot that the native image is called load
. Still... imageLoad
sounds soooo bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought was just load
the same as Image#load
but load
is too general, not only an image fires this event. So I added image prefix. But imageLoaded
sounds ok.
* @private | ||
* @type {Set.<HTMLElement>} | ||
*/ | ||
this._observedElements = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better if this is WeakSet
. Or that you clear it up in the destroy()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, both :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we can do both. You can not iterate over WeakSet
.
src/image/imageloadobserver.js
Outdated
} | ||
|
||
/** | ||
* Fired when img element has been loaded in one of the editable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very unclear when it's fired. Also an image element
or an <img> element
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fired when an
<img/>
DOM element has been loaded in the DOM root.
WDYT?
I've got serious doubts about this change. How is it going to work on initial data load? Imagine a content with 100 images. Are we going to call Also, we had a rule to not call render at random moments (outside Finally, why do we call |
I can fire |
I used |
I'm afraid that firing |
Maybe this is the right moment for introducing |
That would be a cross-layer call. But frankly speaking, we've got a problem here. We want to update the UI on something related closely to the engine. Therefore, IMO, this observer shouldn't do anything besides firing an event on the engine's "thing". And this event needs to be generic – we want to say that something has changed. Not that we render anything (hence Now, the problem is that this isn't the only reason why the layout may have changed. Resizing the editable is another one. How can someone who allowed resizing the editable let us know that it's changed? Are we back to Another problem is – do we need two events? One in |
tl;dr – we need a call for this |
Call result: |
R- because it's blocked by https://github.com/ckeditor/ckeditor5-core/issues/130. |
Introducing ImageLoadObserver has been moved to the separate ticket to split the engine and the UI part of this fix. #214 |
Suggested merge commit message (convention)
Fix: Rendered the view after an
<img/>
DOM element has been loaded in the DOM root. Closes ckeditor/ckeditor5#5118.