UNPKG

2.17 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 list/legacylistproperties/legacyliststylecommand
7 */
8import { Command, type Editor } from 'ckeditor5/src/core.js';
9/**
10 * The list style command. It changes the `listStyle` attribute of the selected list items.
11 *
12 * If the list type (numbered or bulleted) can be inferred from the passed style type,
13 * the command tries to convert selected items to a list of that type.
14 * It is used by the {@link module:list/legacylistproperties~LegacyListProperties legacy list properties feature}.
15 */
16export default class LegacyListStyleCommand extends Command {
17 isStyleTypeSupported: undefined;
18 /**
19 * @inheritDoc
20 * @readonly
21 */
22 value: string | null;
23 /**
24 * The default type of the list style.
25 */
26 readonly defaultType: string;
27 /**
28 * Creates an instance of the command.
29 *
30 * @param editor The editor instance.
31 * @param defaultType The list type that will be used by default if the value was not specified during
32 * the command execution.
33 */
34 constructor(editor: Editor, defaultType: string);
35 /**
36 * @inheritDoc
37 */
38 refresh(): void;
39 /**
40 * Executes the command.
41 *
42 * @fires execute
43 * @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
44 * style will be applied.
45 */
46 execute(options?: {
47 type?: string | null;
48 }): void;
49 /**
50 * Checks the command's {@link #value}.
51 *
52 * @returns The current value.
53 */
54 private _getValue;
55 /**
56 * Checks whether the command can be enabled in the current context.
57 *
58 * @returns Whether the command should be enabled.
59 */
60 private _checkEnabled;
61 /**
62 * Checks if the provided list style is valid. Also changes the selection to a list if it's not set yet.
63 *
64 * @param The type of the list style. If `null` is specified, the function does nothing.
65 */
66 private _tryToConvertItemsToList;
67}