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 paragraph/insertparagraphcommand
|
7 | */
|
8 | import { Command, type Editor } from '@ckeditor/ckeditor5-core';
|
9 | import type { Position } from '@ckeditor/ckeditor5-engine';
|
10 | /**
|
11 | * The insert paragraph command. It inserts a new paragraph at a specific
|
12 | * {@link module:engine/model/position~Position document position}.
|
13 | *
|
14 | * ```ts
|
15 | * // Insert a new paragraph before an element in the document.
|
16 | * editor.execute( 'insertParagraph', {
|
17 | * position: editor.model.createPositionBefore( element )
|
18 | * } );
|
19 | * ```
|
20 | *
|
21 | * If a paragraph is disallowed in the context of the specific position, the command
|
22 | * will attempt to split position ancestors to find a place where it is possible
|
23 | * to insert a paragraph.
|
24 | *
|
25 | * **Note**: This command moves the selection to the inserted paragraph.
|
26 | */
|
27 | export default class InsertParagraphCommand extends Command {
|
28 | constructor(editor: Editor);
|
29 | /**
|
30 | * Executes the command.
|
31 | *
|
32 | * @param options Options for the executed command.
|
33 | * @param options.position The model position at which the new paragraph will be inserted.
|
34 | * @param options.attributes Attributes keys and values to set on a inserted paragraph.
|
35 | * @fires execute
|
36 | */
|
37 | execute(options: {
|
38 | position: Position;
|
39 | attributes?: Record<string, unknown>;
|
40 | }): void;
|
41 | /**
|
42 | * Returns the best position to insert a new paragraph.
|
43 | */
|
44 | private _findPositionToInsertParagraph;
|
45 | }
|