UNPKG

1.66 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 heading/headingcommand
7 */
8import { Command, type Editor } from 'ckeditor5/src/core';
9/**
10 * The heading command. It is used by the {@link module:heading/heading~Heading heading feature} to apply headings.
11 */
12export default class HeadingCommand extends Command {
13 /**
14 * If the selection starts in a heading (which {@link #modelElements is supported by this command})
15 * the value is set to the name of that heading model element.
16 * It is set to `false` otherwise.
17 *
18 * @observable
19 * @readonly
20 */
21 value: false | string;
22 /**
23 * Set of defined model's elements names that this command support.
24 * See {@link module:heading/headingconfig~HeadingOption}.
25 */
26 readonly modelElements: Array<string>;
27 /**
28 * Creates an instance of the command.
29 *
30 * @param editor Editor instance.
31 * @param modelElements Names of the element which this command can apply in the model.
32 */
33 constructor(editor: Editor, modelElements: Array<string>);
34 /**
35 * @inheritDoc
36 */
37 refresh(): void;
38 /**
39 * Executes the command. Applies the heading to the selected blocks or, if the first selected
40 * block is a heading already, turns selected headings (of this level only) to paragraphs.
41 *
42 * @param options.value Name of the element which this command will apply in the model.
43 * @fires execute
44 */
45 execute(options: {
46 value: string;
47 }): void;
48}