UNPKG

2.73 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/utils
7 */
8import type { DocumentSelection, MatcherPattern, Schema, Selection, ViewContainerElement, DowncastWriter, ViewElement } from 'ckeditor5/src/engine.js';
9import type { Editor } from 'ckeditor5/src/core.js';
10/**
11 * Creates a view element representing the inline image.
12 *
13 * ```html
14 * <span class="image-inline"><img></img></span>
15 * ```
16 *
17 * Note that `alt` and `src` attributes are converted separately, so they are not included.
18 *
19 * @internal
20 */
21export declare function createInlineImageViewElement(writer: DowncastWriter): ViewContainerElement;
22/**
23 * Creates a view element representing the block image.
24 *
25 * ```html
26 * <figure class="image"><img></img></figure>
27 * ```
28 *
29 * Note that `alt` and `src` attributes are converted separately, so they are not included.
30 *
31 * @internal
32 */
33export declare function createBlockImageViewElement(writer: DowncastWriter): ViewContainerElement;
34/**
35 * A function returning a `MatcherPattern` for a particular type of View images.
36 *
37 * @internal
38 * @param matchImageType The type of created image.
39 */
40export declare function getImgViewElementMatcher(editor: Editor, matchImageType: 'imageBlock' | 'imageInline'): MatcherPattern;
41/**
42 * Considering the current model selection, it returns the name of the model image element
43 * (`'imageBlock'` or `'imageInline'`) that will make most sense from the UX perspective if a new
44 * image was inserted (also: uploaded, dropped, pasted) at that selection.
45 *
46 * The assumption is that inserting images into empty blocks or on other block widgets should
47 * produce block images. Inline images should be inserted in other cases, e.g. in paragraphs
48 * that already contain some text.
49 *
50 * @internal
51 */
52export declare function determineImageTypeForInsertionAtSelection(schema: Schema, selection: Selection | DocumentSelection): 'imageBlock' | 'imageInline';
53/**
54 * Returns parsed value of the size, but only if it contains unit: px.
55 */
56export declare function getSizeValueIfInPx(size: string | undefined): number | null;
57/**
58 * Returns true if both styles (width and height) are set.
59 *
60 * If both image styles: width & height are set, they will override the image width & height attributes in the
61 * browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles.
62 * That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight.
63 */
64export declare function widthAndHeightStylesAreBothSet(viewElement: ViewElement): boolean;