UNPKG

2.33 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/listproperties/liststylecommand
7 */
8import { Command, type Editor } from 'ckeditor5/src/core.js';
9/**
10 * The list style command. It changes `listStyle` attribute of the selected list items,
11 * letting the user choose styles for the list item markers.
12 * It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
13 */
14export default class ListStyleCommand extends Command {
15 /**
16 * @inheritDoc
17 */
18 value: string | null;
19 /**
20 * The default type of the list style.
21 */
22 readonly defaultType: string;
23 /**
24 * The list of supported style types by this command.
25 */
26 private _supportedTypes;
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 * @param supportedTypes The list of supported style types by this command.
34 */
35 constructor(editor: Editor, defaultType: string, supportedTypes?: Array<string>);
36 /**
37 * @inheritDoc
38 */
39 refresh(): void;
40 /**
41 * Executes the command.
42 *
43 * @fires execute
44 * @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default
45 * style will be applied.
46 */
47 execute(options?: {
48 type?: string | null;
49 }): void;
50 /**
51 * Checks if the given style type is supported by this plugin.
52 */
53 isStyleTypeSupported(value: string): boolean;
54 /**
55 * Checks the command's {@link #value}.
56 *
57 * @returns The current value.
58 */
59 private _getValue;
60 /**
61 * Checks whether the command can be enabled in the current context.
62 *
63 * @returns Whether the command should be enabled.
64 */
65 private _checkEnabled;
66 /**
67 * Check if the provided list style is valid. Also change the selection to a list if it's not set yet.
68 *
69 * @param options.type The type of the list style. If `null` is specified, the function does nothing.
70 */
71 private _tryToConvertItemsToList;
72}