UNPKG

1.53 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2023, 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/imagetypecommand
7 */
8import type { Element } from 'ckeditor5/src/engine';
9import { Command, type Editor } from 'ckeditor5/src/core';
10/**
11 * The image type command. It changes the type of a selected image, depending on the configuration.
12 */
13export default class ImageTypeCommand extends Command {
14 /**
15 * Model element name the command converts to.
16 */
17 private readonly _modelElementName;
18 /**
19 * @inheritDoc
20 *
21 * @param modelElementName Model element name the command converts to.
22 */
23 constructor(editor: Editor, modelElementName: 'imageBlock' | 'imageInline');
24 /**
25 * @inheritDoc
26 */
27 refresh(): void;
28 /**
29 * Executes the command and changes the type of a selected image.
30 *
31 * @fires execute
32 * @param options.setImageSizes Specifies whether the image `width` and `height` attributes should be set automatically.
33 * The default is `true`.
34 * @returns An object containing references to old and new model image elements
35 * (for before and after the change) so external integrations can hook into the decorated
36 * `execute` event and handle this change. `null` if the type change failed.
37 */
38 execute(options?: {
39 setImageSizes?: boolean;
40 }): {
41 oldElement: Element;
42 newElement: Element;
43 } | null;
44}