/
tablecellwidthediting.ts
56 lines (47 loc) · 1.46 KB
/
tablecellwidthediting.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module table/tablecellwidth/tablecellwidthediting
*/
import { Plugin } from 'ckeditor5/src/core.js';
import TableEditing from './../tableediting.js';
import TableCellWidthCommand from './commands/tablecellwidthcommand.js';
import { getNormalizedDefaultProperties } from '../utils/table-properties.js';
import { enableProperty } from '../utils/common.js';
/**
* The table cell width editing feature.
*
* Introduces `tableCellWidth` table cell model attribute alongside with its converters
* and a command.
*/
export default class TableCellWidthEditing extends Plugin {
/**
* @inheritDoc
*/
public static get pluginName() {
return 'TableCellWidthEditing' as const;
}
/**
* @inheritDoc
*/
public static get requires() {
return [ TableEditing ] as const;
}
/**
* @inheritDoc
*/
public init(): void {
const editor = this.editor;
const defaultTableCellProperties = getNormalizedDefaultProperties(
editor.config.get( 'table.tableCellProperties.defaultProperties' )!
);
enableProperty( editor.model.schema, editor.conversion, {
modelAttribute: 'tableCellWidth',
styleName: 'width',
defaultValue: defaultTableCellProperties.width
} );
editor.commands.add( 'tableCellWidth', new TableCellWidthCommand( editor, defaultTableCellProperties.width ) );
}
}