UNPKG

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