UNPKG

1.36 kBJavaScriptView 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 */
5import TablePropertyCommand from './tablepropertycommand';
6import { getSingleValue } from '../../utils/table-properties';
7/**
8 * The table border color command.
9 *
10 * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as
11 * the `'tableBorderColor'` editor command.
12 *
13 * To change the border color of the selected table, execute the command:
14 *
15 * ```ts
16 * editor.execute( 'tableBorderColor', {
17 * value: '#f00'
18 * } );
19 * ```
20 */
21export default class TableBorderColorCommand extends TablePropertyCommand {
22 /**
23 * Creates a new `TableBorderColorCommand` 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, 'tableBorderColor', defaultValue);
30 }
31 /**
32 * @inheritDoc
33 */
34 _getValue(table) {
35 if (!table) {
36 return;
37 }
38 const value = getSingleValue(table.getAttribute(this.attributeName));
39 if (value === this._defaultValue) {
40 return;
41 }
42 return value;
43 }
44}