UNPKG

2.12 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 table/tableproperties/commands/tablepropertycommand
7 */
8import type { Batch, Element } from 'ckeditor5/src/engine';
9import { Command, type Editor } from 'ckeditor5/src/core';
10export interface TablePropertyCommandExecuteOptions {
11 batch?: Batch;
12 columnWidths?: string;
13 table?: Element;
14 tableWidth?: string;
15 value?: string;
16}
17/**
18 * The table cell attribute command.
19 *
20 * This command is a base command for other table property commands.
21 */
22export default class TablePropertyCommand extends Command {
23 /**
24 * The attribute that will be set by the command.
25 */
26 readonly attributeName: string;
27 /**
28 * The default value for the attribute.
29 */
30 protected readonly _defaultValue: string | undefined;
31 /**
32 * Creates a new `TablePropertyCommand` instance.
33 *
34 * @param editor An editor in which this command will be used.
35 * @param attributeName Table cell attribute name.
36 * @param defaultValue The default value of the attribute.
37 */
38 constructor(editor: Editor, attributeName: string, defaultValue?: string);
39 /**
40 * @inheritDoc
41 */
42 refresh(): void;
43 /**
44 * Executes the command.
45 *
46 * @fires execute
47 * @param options.value If set, the command will set the attribute on the selected table.
48 * If not set, the command will remove the attribute from the selected table.
49 * @param options.batch Pass the model batch instance to the command to aggregate changes,
50 * for example, to allow a single undo step for multiple executions.
51 */
52 execute(options?: TablePropertyCommandExecuteOptions): void;
53 /**
54 * Returns the attribute value for a table.
55 */
56 protected _getValue(table: Element): unknown;
57 /**
58 * Returns the proper model value. It can be used to add a default unit to numeric values.
59 */
60 protected _getValueToSet(value: string | number | undefined): unknown;
61}