UNPKG

2.17 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 list/documentlist/documentlistsplitcommand
7 */
8import type { Element } from 'ckeditor5/src/engine';
9import { Command, type Editor } from 'ckeditor5/src/core';
10/**
11 * The document list split command that splits the list item at the selection.
12 *
13 * It is used by the {@link module:list/documentlist~DocumentList document list feature}.
14 */
15export default class DocumentListSplitCommand extends Command {
16 /**
17 * Whether list item should be split before or after the selected block.
18 */
19 private readonly _direction;
20 /**
21 * Creates an instance of the command.
22 *
23 * @param editor The editor instance.
24 * @param direction Whether list item should be split before or after the selected block.
25 */
26 constructor(editor: Editor, direction: 'before' | 'after');
27 /**
28 * @inheritDoc
29 */
30 refresh(): void;
31 /**
32 * Splits the list item at the selection.
33 *
34 * @fires execute
35 * @fires afterExecute
36 */
37 execute(): void;
38 /**
39 * Fires the `afterExecute` event.
40 *
41 * @param changedBlocks The changed list elements.
42 */
43 private _fireAfterExecute;
44 /**
45 * Checks whether the command can be enabled in the current context.
46 *
47 * @returns Whether the command should be enabled.
48 */
49 private _checkEnabled;
50 /**
51 * Returns the model element that is the main focus of the command (according to the current selection and command direction).
52 */
53 private _getStartBlock;
54}
55/**
56 * Event fired by the {@link ~DocumentListSplitCommand#execute} method.
57 *
58 * It allows to execute an action after executing the {@link module:list/documentlist/documentlistcommand~DocumentListCommand#execute}
59 * method, for example adjusting attributes of changed list items.
60 *
61 * @internal
62 * @eventName ~DocumentListSplitCommand#afterExecute
63 */
64export type DocumentListSplitCommandAfterExecuteEvent = {
65 name: 'afterExecute';
66 args: [changedBlocks: Array<Element>];
67};