UNPKG

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