UNPKG

1.42 kBJavaScriptView 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 */
5import TableCellPropertyCommand from './tablecellpropertycommand.js';
6import { getSingleValue } from '../../utils/table-properties.js';
7/**
8 * The table cell border color command.
9 *
10 * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as
11 * the `'tableCellBorderColor'` editor command.
12 *
13 * To change the border color of selected cells, execute the command:
14 *
15 * ```ts
16 * editor.execute( 'tableCellBorderColor', {
17 * value: '#f00'
18 * } );
19 * ```
20 */
21export default class TableCellBorderColorCommand extends TableCellPropertyCommand {
22 /**
23 * Creates a new `TableCellBorderColorCommand` instance.
24 *
25 * @param editor An editor in which this command will be used.
26 * @param defaultValue The default value of the attribute.
27 */
28 constructor(editor, defaultValue) {
29 super(editor, 'tableCellBorderColor', defaultValue);
30 }
31 /**
32 * @inheritDoc
33 */
34 _getAttribute(tableCell) {
35 if (!tableCell) {
36 return;
37 }
38 const value = getSingleValue(tableCell.getAttribute(this.attributeName));
39 if (value === this._defaultValue) {
40 return;
41 }
42 return value;
43 }
44}