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 | import TableCellPropertyCommand from './tablecellpropertycommand.js';
|
6 | import { getSingleValue } from '../../utils/table-properties.js';
|
7 | /**
|
8 | * The table cell border style command.
|
9 | *
|
10 | * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as
|
11 | * the `'tableCellBorderStyle'` editor command.
|
12 | *
|
13 | * To change the border style of selected cells, execute the command:
|
14 | *
|
15 | * ```ts
|
16 | * editor.execute( 'tableCellBorderStyle', {
|
17 | * value: 'dashed'
|
18 | * } );
|
19 | * ```
|
20 | */
|
21 | export default class TableCellBorderStyleCommand extends TableCellPropertyCommand {
|
22 | /**
|
23 | * Creates a new `TableCellBorderStyleCommand` 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, 'tableCellBorderStyle', 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 | }
|