UNPKG

1.35 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/imageupload/utils
7 */
8import type { ViewElement } from 'ckeditor5/src/engine.js';
9import type ImageUtils from '../imageutils.js';
10/**
11 * Creates a regular expression used to test for image files.
12 *
13 * ```ts
14 * const imageType = createImageTypeRegExp( [ 'png', 'jpeg', 'svg+xml', 'vnd.microsoft.icon' ] );
15 *
16 * console.log( 'is supported image', imageType.test( file.type ) );
17 * ```
18 */
19export declare function createImageTypeRegExp(types: Array<string>): RegExp;
20/**
21 * Creates a promise that fetches the image local source (Base64 or blob) and resolves with a `File` object.
22 *
23 * @param image Image whose source to fetch.
24 * @returns A promise which resolves when an image source is fetched and converted to a `File` instance.
25 * It resolves with a `File` object. If there were any errors during file processing, the promise will be rejected.
26 */
27export declare function fetchLocalImage(image: ViewElement): Promise<File>;
28/**
29 * Checks whether a given node is an image element with a local source (Base64 or blob).
30 *
31 * @param node The node to check.
32 */
33export declare function isLocalImage(imageUtils: ImageUtils, node: ViewElement): boolean;