UNPKG

2.38 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 */
5import { Command } from 'ckeditor5/src/core.js';
6/**
7 * The toggle image caption command.
8 *
9 * This command is registered by {@link module:image/imagecaption/imagecaptionediting~ImageCaptionEditing} as the
10 * `'toggleImageCaption'` editor command.
11 *
12 * Executing this command:
13 *
14 * * either adds or removes the image caption of a selected image (depending on whether the caption is present or not),
15 * * removes the image caption if the selection is anchored in one.
16 *
17 * ```ts
18 * // Toggle the presence of the caption.
19 * editor.execute( 'toggleImageCaption' );
20 * ```
21 *
22 * **Note**: Upon executing this command, the selection will be set on the image if previously anchored in the caption element.
23 *
24 * **Note**: You can move the selection to the caption right away as it shows up upon executing this command by using
25 * the `focusCaptionOnShow` option:
26 *
27 * ```ts
28 * editor.execute( 'toggleImageCaption', { focusCaptionOnShow: true } );
29 * ```
30 */
31export default class ToggleImageCaptionCommand extends Command {
32 value: boolean;
33 /**
34 * @inheritDoc
35 */
36 refresh(): void;
37 /**
38 * Executes the command.
39 *
40 * ```ts
41 * editor.execute( 'toggleImageCaption' );
42 * ```
43 *
44 * @param options Options for the executed command.
45 * @param options.focusCaptionOnShow When true and the caption shows up, the selection will be moved into it straight away.
46 * @fires execute
47 */
48 execute(options?: {
49 focusCaptionOnShow?: boolean;
50 }): void;
51 /**
52 * Shows the caption of the `<imageBlock>` or `<imageInline>`. Also:
53 *
54 * * it converts `<imageInline>` to `<imageBlock>` to show the caption,
55 * * it attempts to restore the caption content from the `ImageCaptionEditing` caption registry,
56 * * it moves the selection to the caption right away, it the `focusCaptionOnShow` option was set.
57 */
58 private _showImageCaption;
59 /**
60 * Hides the caption of a selected image (or an image caption the selection is anchored to).
61 *
62 * The content of the caption is stored in the `ImageCaptionEditing` caption registry to make this
63 * a reversible action.
64 */
65 private _hideImageCaption;
66}