UNPKG

1.99 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/list/listindentcommand
7 */
8import { Command, type Editor } from 'ckeditor5/src/core.js';
9import type { Element } from 'ckeditor5/src/engine.js';
10/**
11 * The document list indent command. It is used by the {@link module:list/list~List list feature}.
12 */
13export default class ListIndentCommand extends Command {
14 /**
15 * Determines by how much the command will change the list item's indent attribute.
16 */
17 private readonly _direction;
18 /**
19 * Creates an instance of the command.
20 *
21 * @param editor The editor instance.
22 * @param indentDirection The direction of indent. If it is equal to `backward`, the command
23 * will outdent a list item.
24 */
25 constructor(editor: Editor, indentDirection: 'forward' | 'backward');
26 /**
27 * @inheritDoc
28 */
29 refresh(): void;
30 /**
31 * Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
32 *
33 * @fires execute
34 * @fires afterExecute
35 */
36 execute(): void;
37 /**
38 * Fires the `afterExecute` event.
39 *
40 * @param changedBlocks The changed list elements.
41 */
42 private _fireAfterExecute;
43 /**
44 * Checks whether the command can be enabled in the current context.
45 *
46 * @returns Whether the command should be enabled.
47 */
48 private _checkEnabled;
49}
50/**
51 * Event fired by the {@link ~ListIndentCommand#execute} method.
52 *
53 * It allows to execute an action after executing the {@link module:list/list/listcommand~ListCommand#execute}
54 * method, for example adjusting attributes of changed list items.
55 *
56 * @internal
57 * @eventName ~ListIndentCommand#afterExecute
58 */
59export type ListIndentCommandAfterExecuteEvent = {
60 name: 'afterExecute';
61 args: [changedBlocks: Array<Element>];
62};