UNPKG

1.61 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5/**
6 * @module image/image/imageloadobserver
7 */
8import { Observer } from 'ckeditor5/src/engine.js';
9/**
10 * Observes all new images added to the {@link module:engine/view/document~Document},
11 * fires {@link module:engine/view/document~Document#event:imageLoaded} and
12 * {@link module:engine/view/document~Document#event:layoutChanged} event every time when the new image
13 * has been loaded.
14 *
15 * **Note:** This event is not fired for images that has been added to the document and rendered as `complete` (already loaded).
16 */
17export default class ImageLoadObserver extends Observer {
18 /**
19 * @inheritDoc
20 */
21 observe(domRoot: HTMLElement): void;
22 /**
23 * @inheritDoc
24 */
25 stopObserving(domRoot: HTMLElement): void;
26 /**
27 * Fires {@link module:engine/view/document~Document#event:layoutChanged} and
28 * {@link module:engine/view/document~Document#event:imageLoaded}
29 * if observer {@link #isEnabled is enabled}.
30 *
31 * @param domEvent The DOM event.
32 */
33 private _fireEvents;
34}
35/**
36 * Fired when an <img/> DOM element has been loaded in the DOM root.
37 *
38 * Introduced by {@link module:image/image/imageloadobserver~ImageLoadObserver}.
39 *
40 * @see module:image/image/imageloadobserver~ImageLoadObserver
41 *
42 * @eventName module:engine/view/document~Document#imageLoaded
43 * @param data Event data.
44 */
45export type ImageLoadedEvent = {
46 name: 'imageLoaded';
47 args: [Event];
48};