@ckeditor/ckeditor5-table 27.1.0 → 29.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +3 -3
- package/build/table.js +1 -1
- package/build/translations/ar.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/nb.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +174 -0
- package/lang/contexts.json +4 -1
- package/lang/translations/ar.po +12 -0
- package/lang/translations/az.po +12 -0
- package/lang/translations/bg.po +12 -0
- package/lang/translations/cs.po +12 -0
- package/lang/translations/da.po +12 -0
- package/lang/translations/de-ch.po +12 -0
- package/lang/translations/de.po +12 -0
- package/lang/translations/en-au.po +12 -0
- package/lang/translations/en-gb.po +12 -0
- package/lang/translations/en.po +12 -0
- package/lang/translations/es.po +12 -0
- package/lang/translations/et.po +12 -0
- package/lang/translations/fa.po +12 -0
- package/lang/translations/fi.po +12 -0
- package/lang/translations/fr.po +12 -0
- package/lang/translations/gl.po +12 -0
- package/lang/translations/hi.po +12 -0
- package/lang/translations/hr.po +12 -0
- package/lang/translations/hu.po +23 -11
- package/lang/translations/id.po +23 -11
- package/lang/translations/it.po +12 -0
- package/lang/translations/ja.po +12 -0
- package/lang/translations/ko.po +12 -0
- package/lang/translations/ku.po +12 -0
- package/lang/translations/lt.po +12 -0
- package/lang/translations/lv.po +12 -0
- package/lang/translations/nb.po +12 -0
- package/lang/translations/ne.po +12 -0
- package/lang/translations/nl.po +12 -0
- package/lang/translations/no.po +12 -0
- package/lang/translations/pl.po +12 -0
- package/lang/translations/pt-br.po +12 -0
- package/lang/translations/ro.po +51 -39
- package/lang/translations/ru.po +12 -0
- package/lang/translations/sk.po +12 -0
- package/lang/translations/sq.po +12 -0
- package/lang/translations/sr-latn.po +12 -0
- package/lang/translations/sr.po +12 -0
- package/lang/translations/sv.po +12 -0
- package/lang/translations/th.po +12 -0
- package/lang/translations/tk.po +12 -0
- package/lang/translations/tr.po +12 -0
- package/lang/translations/ug.po +12 -0
- package/lang/translations/uk.po +12 -0
- package/lang/translations/vi.po +12 -0
- package/lang/translations/zh-cn.po +12 -0
- package/lang/translations/zh.po +12 -0
- package/package.json +25 -23
- package/src/commands/insertcolumncommand.js +2 -3
- package/src/commands/insertrowcommand.js +2 -3
- package/src/commands/inserttablecommand.js +22 -7
- package/src/commands/mergecellcommand.js +5 -3
- package/src/commands/removerowcommand.js +8 -5
- package/src/converters/downcast.js +4 -5
- package/src/converters/table-caption-post-fixer.js +69 -0
- package/src/converters/table-cell-paragraph-post-fixer.js +3 -1
- package/src/converters/table-layout-post-fixer.js +13 -8
- package/src/converters/tableproperties.js +82 -23
- package/src/converters/upcasttable.js +63 -0
- package/src/index.js +18 -33
- package/src/table.js +17 -0
- package/src/tablecaption/tablecaptionediting.js +153 -0
- package/src/tablecaption/tablecaptionui.js +71 -0
- package/src/tablecaption/toggletablecaptioncommand.js +120 -0
- package/src/tablecaption/utils.js +93 -0
- package/src/tablecaption.js +35 -0
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +3 -2
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +10 -3
- package/src/tablecellproperties/commands/tablecellborderstylecommand.js +10 -3
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +17 -4
- package/src/tablecellproperties/commands/tablecellheightcommand.js +10 -3
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +3 -2
- package/src/tablecellproperties/commands/tablecellpaddingcommand.js +17 -4
- package/src/tablecellproperties/commands/tablecellpropertycommand.js +28 -2
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +3 -2
- package/src/tablecellproperties/commands/tablecellwidthcommand.js +10 -3
- package/src/tablecellproperties/tablecellpropertiesediting.js +164 -65
- package/src/tablecellproperties/tablecellpropertiesui.js +76 -16
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +39 -13
- package/src/tablecellproperties.js +42 -2
- package/src/tableediting.js +76 -6
- package/src/tablekeyboard.js +3 -2
- package/src/tableproperties/commands/tablealignmentcommand.js +3 -2
- package/src/tableproperties/commands/tablebackgroundcolorcommand.js +3 -2
- package/src/tableproperties/commands/tablebordercolorcommand.js +10 -3
- package/src/tableproperties/commands/tableborderstylecommand.js +10 -3
- package/src/tableproperties/commands/tableborderwidthcommand.js +17 -4
- package/src/tableproperties/commands/tableheightcommand.js +10 -3
- package/src/tableproperties/commands/tablepropertycommand.js +28 -2
- package/src/tableproperties/commands/tablewidthcommand.js +10 -3
- package/src/tableproperties/tablepropertiesediting.js +104 -47
- package/src/tableproperties/tablepropertiesui.js +68 -15
- package/src/tableproperties/ui/tablepropertiesview.js +26 -11
- package/src/tableproperties.js +38 -2
- package/src/tableui.js +10 -1
- package/src/tableutils.js +41 -5
- package/src/tablewalker.js +36 -1
- package/src/ui/colorinputview.js +11 -7
- package/src/utils/structure.js +4 -3
- package/src/utils/table-properties.js +41 -0
- package/src/utils/ui/table-properties.js +29 -7
- package/src/utils/ui/widget.js +7 -15
- package/theme/table.css +17 -1
- package/theme/tablecaption.css +53 -0
- package/build/table.js.map +0 -1
|
@@ -29,9 +29,10 @@ export default class TableCellBorderStyleCommand extends TableCellPropertyComman
|
|
|
29
29
|
* Creates a new `TableCellBorderStyleCommand` instance.
|
|
30
30
|
*
|
|
31
31
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
32
|
+
* @param {String} defaultValue The default value of the attribute.
|
|
32
33
|
*/
|
|
33
|
-
constructor( editor ) {
|
|
34
|
-
super( editor, 'borderStyle' );
|
|
34
|
+
constructor( editor, defaultValue ) {
|
|
35
|
+
super( editor, 'borderStyle', defaultValue );
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -42,6 +43,12 @@ export default class TableCellBorderStyleCommand extends TableCellPropertyComman
|
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
const value = getSingleValue( tableCell.getAttribute( this.attributeName ) );
|
|
47
|
+
|
|
48
|
+
if ( value === this._defaultValue ) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return value;
|
|
46
53
|
}
|
|
47
54
|
}
|
|
@@ -37,9 +37,10 @@ export default class TableCellBorderWidthCommand extends TableCellPropertyComman
|
|
|
37
37
|
* Creates a new `TableCellBorderWidthCommand` instance.
|
|
38
38
|
*
|
|
39
39
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
40
|
+
* @param {String} defaultValue The default value of the attribute.
|
|
40
41
|
*/
|
|
41
|
-
constructor( editor ) {
|
|
42
|
-
super( editor, 'borderWidth' );
|
|
42
|
+
constructor( editor, defaultValue ) {
|
|
43
|
+
super( editor, 'borderWidth', defaultValue );
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -50,13 +51,25 @@ export default class TableCellBorderWidthCommand extends TableCellPropertyComman
|
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
const value = getSingleValue( tableCell.getAttribute( this.attributeName ) );
|
|
55
|
+
|
|
56
|
+
if ( value === this._defaultValue ) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return value;
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
64
|
* @inheritDoc
|
|
58
65
|
*/
|
|
59
66
|
_getValueToSet( value ) {
|
|
60
|
-
|
|
67
|
+
value = addDefaultUnitToNumericValue( value, 'px' );
|
|
68
|
+
|
|
69
|
+
if ( value === this._defaultValue ) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return value;
|
|
61
74
|
}
|
|
62
75
|
}
|
|
@@ -37,15 +37,22 @@ export default class TableCellHeightCommand extends TableCellPropertyCommand {
|
|
|
37
37
|
* Creates a new `TableCellHeightCommand` instance.
|
|
38
38
|
*
|
|
39
39
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
40
|
+
* @param {String} defaultValue The default value of the attribute.
|
|
40
41
|
*/
|
|
41
|
-
constructor( editor ) {
|
|
42
|
-
super( editor, 'height' );
|
|
42
|
+
constructor( editor, defaultValue ) {
|
|
43
|
+
super( editor, 'height', defaultValue );
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* @inheritDoc
|
|
47
48
|
*/
|
|
48
49
|
_getValueToSet( value ) {
|
|
49
|
-
|
|
50
|
+
value = addDefaultUnitToNumericValue( value, 'px' );
|
|
51
|
+
|
|
52
|
+
if ( value === this._defaultValue ) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return value;
|
|
50
57
|
}
|
|
51
58
|
}
|
|
@@ -28,8 +28,9 @@ export default class TableCellHorizontalAlignmentCommand extends TableCellProper
|
|
|
28
28
|
* Creates a new `TableCellHorizontalAlignmentCommand` instance.
|
|
29
29
|
*
|
|
30
30
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
31
|
+
* @param {String} defaultValue The default value for the "alignment" attribute.
|
|
31
32
|
*/
|
|
32
|
-
constructor( editor ) {
|
|
33
|
-
super( editor, 'horizontalAlignment' );
|
|
33
|
+
constructor( editor, defaultValue ) {
|
|
34
|
+
super( editor, 'horizontalAlignment', defaultValue );
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -37,9 +37,10 @@ export default class TableCellPaddingCommand extends TableCellPropertyCommand {
|
|
|
37
37
|
* Creates a new `TableCellPaddingCommand` instance.
|
|
38
38
|
*
|
|
39
39
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
40
|
+
* @param {String} defaultValue The default value of the attribute.
|
|
40
41
|
*/
|
|
41
|
-
constructor( editor ) {
|
|
42
|
-
super( editor, 'padding' );
|
|
42
|
+
constructor( editor, defaultValue ) {
|
|
43
|
+
super( editor, 'padding', defaultValue );
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -50,13 +51,25 @@ export default class TableCellPaddingCommand extends TableCellPropertyCommand {
|
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
const value = getSingleValue( tableCell.getAttribute( this.attributeName ) );
|
|
55
|
+
|
|
56
|
+
if ( value === this._defaultValue ) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return value;
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
64
|
* @inheritDoc
|
|
58
65
|
*/
|
|
59
66
|
_getValueToSet( value ) {
|
|
60
|
-
|
|
67
|
+
value = addDefaultUnitToNumericValue( value, 'px' );
|
|
68
|
+
|
|
69
|
+
if ( value === this._defaultValue ) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return value;
|
|
61
74
|
}
|
|
62
75
|
}
|
|
@@ -23,11 +23,27 @@ export default class TableCellPropertyCommand extends Command {
|
|
|
23
23
|
*
|
|
24
24
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
25
25
|
* @param {String} attributeName Table cell attribute name.
|
|
26
|
+
* @param {String} defaultValue The default value of the attribute.
|
|
26
27
|
*/
|
|
27
|
-
constructor( editor, attributeName ) {
|
|
28
|
+
constructor( editor, attributeName, defaultValue ) {
|
|
28
29
|
super( editor );
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* The attribute that will be set by the command.
|
|
33
|
+
*
|
|
34
|
+
* @readonly
|
|
35
|
+
* @member {String}
|
|
36
|
+
*/
|
|
30
37
|
this.attributeName = attributeName;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The default value for the attribute.
|
|
41
|
+
*
|
|
42
|
+
* @readonly
|
|
43
|
+
* @protected
|
|
44
|
+
* @member {String}
|
|
45
|
+
*/
|
|
46
|
+
this._defaultValue = defaultValue;
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
/**
|
|
@@ -78,7 +94,13 @@ export default class TableCellPropertyCommand extends Command {
|
|
|
78
94
|
return;
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
const value = tableCell.getAttribute( this.attributeName );
|
|
98
|
+
|
|
99
|
+
if ( value === this._defaultValue ) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return value;
|
|
82
104
|
}
|
|
83
105
|
|
|
84
106
|
/**
|
|
@@ -89,6 +111,10 @@ export default class TableCellPropertyCommand extends Command {
|
|
|
89
111
|
* @returns {*}
|
|
90
112
|
*/
|
|
91
113
|
_getValueToSet( value ) {
|
|
114
|
+
if ( value === this._defaultValue ) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
92
118
|
return value;
|
|
93
119
|
}
|
|
94
120
|
|
|
@@ -36,8 +36,9 @@ export default class TableCellVerticalAlignmentCommand extends TableCellProperty
|
|
|
36
36
|
* Creates a new `TableCellVerticalAlignmentCommand` instance.
|
|
37
37
|
*
|
|
38
38
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
39
|
+
* @param {String} defaultValue The default value for the "alignment" attribute.
|
|
39
40
|
*/
|
|
40
|
-
constructor( editor ) {
|
|
41
|
-
super( editor, 'verticalAlignment' );
|
|
41
|
+
constructor( editor, defaultValue ) {
|
|
42
|
+
super( editor, 'verticalAlignment', defaultValue );
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -37,15 +37,22 @@ export default class TableCellWidthCommand extends TableCellPropertyCommand {
|
|
|
37
37
|
* Creates a new `TableCellWidthCommand` instance.
|
|
38
38
|
*
|
|
39
39
|
* @param {module:core/editor/editor~Editor} editor An editor in which this command will be used.
|
|
40
|
+
* @param {String} defaultValue The default value of the attribute.
|
|
40
41
|
*/
|
|
41
|
-
constructor( editor ) {
|
|
42
|
-
super( editor, 'width' );
|
|
42
|
+
constructor( editor, defaultValue ) {
|
|
43
|
+
super( editor, 'width', defaultValue );
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* @inheritDoc
|
|
47
48
|
*/
|
|
48
49
|
_getValueToSet( value ) {
|
|
49
|
-
|
|
50
|
+
value = addDefaultUnitToNumericValue( value, 'px' );
|
|
51
|
+
|
|
52
|
+
if ( value === this._defaultValue ) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return value;
|
|
50
57
|
}
|
|
51
58
|
}
|
|
@@ -21,8 +21,10 @@ import TableCellHorizontalAlignmentCommand from './commands/tablecellhorizontala
|
|
|
21
21
|
import TableCellBorderStyleCommand from './commands/tablecellborderstylecommand';
|
|
22
22
|
import TableCellBorderColorCommand from './commands/tablecellbordercolorcommand';
|
|
23
23
|
import TableCellBorderWidthCommand from './commands/tablecellborderwidthcommand';
|
|
24
|
+
import { getNormalizedDefaultProperties } from '../utils/table-properties';
|
|
24
25
|
|
|
25
|
-
const VALIGN_VALUES_REG_EXP = /^(top|bottom)$/;
|
|
26
|
+
const VALIGN_VALUES_REG_EXP = /^(top|middle|bottom)$/;
|
|
27
|
+
const ALIGN_VALUES_REG_EXP = /^(left|center|right|justify)$/;
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* The table cell properties editing feature.
|
|
@@ -67,33 +69,74 @@ export default class TableCellPropertiesEditing extends Plugin {
|
|
|
67
69
|
const editor = this.editor;
|
|
68
70
|
const schema = editor.model.schema;
|
|
69
71
|
const conversion = editor.conversion;
|
|
70
|
-
|
|
72
|
+
|
|
73
|
+
editor.config.define( 'table.tableCellProperties.defaultProperties', {} );
|
|
74
|
+
|
|
75
|
+
const defaultTableCellProperties = getNormalizedDefaultProperties(
|
|
76
|
+
editor.config.get( 'table.tableCellProperties.defaultProperties' ),
|
|
77
|
+
{
|
|
78
|
+
includeVerticalAlignmentProperty: true,
|
|
79
|
+
includeHorizontalAlignmentProperty: true,
|
|
80
|
+
includePaddingProperty: true,
|
|
81
|
+
isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'
|
|
82
|
+
}
|
|
83
|
+
);
|
|
71
84
|
|
|
72
85
|
editor.data.addStyleProcessorRules( addBorderRules );
|
|
73
|
-
enableBorderProperties( schema, conversion
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
enableBorderProperties( schema, conversion, {
|
|
87
|
+
color: defaultTableCellProperties.borderColor,
|
|
88
|
+
style: defaultTableCellProperties.borderStyle,
|
|
89
|
+
width: defaultTableCellProperties.borderWidth
|
|
90
|
+
} );
|
|
91
|
+
editor.commands.add( 'tableCellBorderStyle', new TableCellBorderStyleCommand( editor, defaultTableCellProperties.borderStyle ) );
|
|
92
|
+
editor.commands.add( 'tableCellBorderColor', new TableCellBorderColorCommand( editor, defaultTableCellProperties.borderColor ) );
|
|
93
|
+
editor.commands.add( 'tableCellBorderWidth', new TableCellBorderWidthCommand( editor, defaultTableCellProperties.borderWidth ) );
|
|
77
94
|
|
|
78
|
-
enableHorizontalAlignmentProperty( schema, conversion,
|
|
79
|
-
editor.commands.add(
|
|
95
|
+
enableHorizontalAlignmentProperty( schema, conversion, defaultTableCellProperties.horizontalAlignment );
|
|
96
|
+
editor.commands.add(
|
|
97
|
+
'tableCellHorizontalAlignment',
|
|
98
|
+
new TableCellHorizontalAlignmentCommand( editor, defaultTableCellProperties.horizontalAlignment )
|
|
99
|
+
);
|
|
80
100
|
|
|
81
|
-
enableProperty( schema, conversion,
|
|
82
|
-
|
|
101
|
+
enableProperty( schema, conversion, {
|
|
102
|
+
modelAttribute: 'width',
|
|
103
|
+
styleName: 'width',
|
|
104
|
+
defaultValue: defaultTableCellProperties.width
|
|
105
|
+
} );
|
|
106
|
+
editor.commands.add( 'tableCellWidth', new TableCellWidthCommand( editor, defaultTableCellProperties.width ) );
|
|
83
107
|
|
|
84
|
-
enableProperty( schema, conversion,
|
|
85
|
-
|
|
108
|
+
enableProperty( schema, conversion, {
|
|
109
|
+
modelAttribute: 'height',
|
|
110
|
+
styleName: 'height',
|
|
111
|
+
defaultValue: defaultTableCellProperties.height
|
|
112
|
+
} );
|
|
113
|
+
editor.commands.add( 'tableCellHeight', new TableCellHeightCommand( editor, defaultTableCellProperties.height ) );
|
|
86
114
|
|
|
87
115
|
editor.data.addStyleProcessorRules( addPaddingRules );
|
|
88
|
-
enableProperty( schema, conversion,
|
|
89
|
-
|
|
116
|
+
enableProperty( schema, conversion, {
|
|
117
|
+
modelAttribute: 'padding',
|
|
118
|
+
styleName: 'padding',
|
|
119
|
+
reduceBoxSides: true,
|
|
120
|
+
defaultValue: defaultTableCellProperties.padding
|
|
121
|
+
} );
|
|
122
|
+
editor.commands.add( 'tableCellPadding', new TableCellPaddingCommand( editor, defaultTableCellProperties.padding ) );
|
|
90
123
|
|
|
91
124
|
editor.data.addStyleProcessorRules( addBackgroundRules );
|
|
92
|
-
enableProperty( schema, conversion,
|
|
93
|
-
|
|
125
|
+
enableProperty( schema, conversion, {
|
|
126
|
+
modelAttribute: 'backgroundColor',
|
|
127
|
+
styleName: 'background-color',
|
|
128
|
+
defaultValue: defaultTableCellProperties.backgroundColor
|
|
129
|
+
} );
|
|
130
|
+
editor.commands.add(
|
|
131
|
+
'tableCellBackgroundColor',
|
|
132
|
+
new TableCellBackgroundColorCommand( editor, defaultTableCellProperties.backgroundColor )
|
|
133
|
+
);
|
|
94
134
|
|
|
95
|
-
enableVerticalAlignmentProperty( schema, conversion );
|
|
96
|
-
editor.commands.add(
|
|
135
|
+
enableVerticalAlignmentProperty( schema, conversion, defaultTableCellProperties.verticalAlignment );
|
|
136
|
+
editor.commands.add(
|
|
137
|
+
'tableCellVerticalAlignment',
|
|
138
|
+
new TableCellVerticalAlignmentCommand( editor, defaultTableCellProperties.verticalAlignment )
|
|
139
|
+
);
|
|
97
140
|
}
|
|
98
141
|
}
|
|
99
142
|
|
|
@@ -101,15 +144,19 @@ export default class TableCellPropertiesEditing extends Plugin {
|
|
|
101
144
|
//
|
|
102
145
|
// @param {module:engine/model/schema~Schema} schema
|
|
103
146
|
// @param {module:engine/conversion/conversion~Conversion} conversion
|
|
104
|
-
|
|
147
|
+
// @param {Object} defaultBorder The default border values.
|
|
148
|
+
// @param {String} defaultBorder.color The default `borderColor` value.
|
|
149
|
+
// @param {String} defaultBorder.style The default `borderStyle` value.
|
|
150
|
+
// @param {String} defaultBorder.width The default `borderWidth` value.
|
|
151
|
+
function enableBorderProperties( schema, conversion, defaultBorder ) {
|
|
105
152
|
schema.extend( 'tableCell', {
|
|
106
153
|
allowAttributes: [ 'borderWidth', 'borderColor', 'borderStyle' ]
|
|
107
154
|
} );
|
|
108
|
-
upcastBorderStyles( conversion, 'td' );
|
|
109
|
-
upcastBorderStyles( conversion, 'th' );
|
|
110
|
-
downcastAttributeToStyle( conversion, 'tableCell', 'borderStyle', 'border-style' );
|
|
111
|
-
downcastAttributeToStyle( conversion, 'tableCell', 'borderColor', 'border-color' );
|
|
112
|
-
downcastAttributeToStyle( conversion, 'tableCell', 'borderWidth', 'border-width' );
|
|
155
|
+
upcastBorderStyles( conversion, 'td', defaultBorder );
|
|
156
|
+
upcastBorderStyles( conversion, 'th', defaultBorder );
|
|
157
|
+
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: 'borderStyle', styleName: 'border-style' } );
|
|
158
|
+
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: 'borderColor', styleName: 'border-color' } );
|
|
159
|
+
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: 'borderWidth', styleName: 'border-width' } );
|
|
113
160
|
}
|
|
114
161
|
|
|
115
162
|
// Enables the `'horizontalAlignment'` attribute for table cells.
|
|
@@ -117,88 +164,140 @@ function enableBorderProperties( schema, conversion ) {
|
|
|
117
164
|
// @param {module:engine/model/schema~Schema} schema
|
|
118
165
|
// @param {module:engine/conversion/conversion~Conversion} conversion
|
|
119
166
|
// @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
120
|
-
|
|
167
|
+
// @param {String} defaultValue The default horizontal alignment value.
|
|
168
|
+
function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
121
169
|
schema.extend( 'tableCell', {
|
|
122
170
|
allowAttributes: [ 'horizontalAlignment' ]
|
|
123
171
|
} );
|
|
124
172
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
view: options.reduce( ( result, option ) => ( {
|
|
134
|
-
...result,
|
|
135
|
-
[ option ]: {
|
|
173
|
+
conversion.for( 'downcast' )
|
|
174
|
+
.attributeToAttribute( {
|
|
175
|
+
model: {
|
|
176
|
+
name: 'tableCell',
|
|
177
|
+
key: 'horizontalAlignment'
|
|
178
|
+
},
|
|
179
|
+
view: alignment => ( {
|
|
136
180
|
key: 'style',
|
|
137
181
|
value: {
|
|
138
|
-
'text-align':
|
|
182
|
+
'text-align': alignment
|
|
183
|
+
}
|
|
184
|
+
} )
|
|
185
|
+
} );
|
|
186
|
+
|
|
187
|
+
conversion.for( 'upcast' )
|
|
188
|
+
// Support for the `text-align:*;` CSS definition for the table cell alignment.
|
|
189
|
+
.attributeToAttribute( {
|
|
190
|
+
view: {
|
|
191
|
+
name: /^(td|th)$/,
|
|
192
|
+
styles: {
|
|
193
|
+
'text-align': ALIGN_VALUES_REG_EXP
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
model: {
|
|
197
|
+
key: 'horizontalAlignment',
|
|
198
|
+
value: viewElement => {
|
|
199
|
+
const align = viewElement.getStyle( 'text-align' );
|
|
200
|
+
|
|
201
|
+
return align === defaultValue ? null : align;
|
|
139
202
|
}
|
|
140
203
|
}
|
|
141
|
-
} )
|
|
142
|
-
|
|
204
|
+
} )
|
|
205
|
+
// Support for the `align` attribute as the backward compatibility while pasting from other sources.
|
|
206
|
+
.attributeToAttribute( {
|
|
207
|
+
view: {
|
|
208
|
+
name: /^(td|th)$/,
|
|
209
|
+
attributes: {
|
|
210
|
+
align: ALIGN_VALUES_REG_EXP
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
model: {
|
|
214
|
+
key: 'horizontalAlignment',
|
|
215
|
+
value: viewElement => {
|
|
216
|
+
const align = viewElement.getAttribute( 'align' );
|
|
217
|
+
|
|
218
|
+
return align === defaultValue ? null : align;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} );
|
|
143
222
|
}
|
|
144
223
|
|
|
145
224
|
// Enables the `'verticalAlignment'` attribute for table cells.
|
|
146
225
|
//
|
|
147
226
|
// @param {module:engine/model/schema~Schema} schema
|
|
148
227
|
// @param {module:engine/conversion/conversion~Conversion} conversion
|
|
149
|
-
|
|
228
|
+
// @param {String} defaultValue The default vertical alignment value.
|
|
229
|
+
function enableVerticalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
150
230
|
schema.extend( 'tableCell', {
|
|
151
231
|
allowAttributes: [ 'verticalAlignment' ]
|
|
152
232
|
} );
|
|
153
233
|
|
|
154
|
-
conversion.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
view: {
|
|
161
|
-
top: {
|
|
162
|
-
key: 'style',
|
|
163
|
-
value: {
|
|
164
|
-
'vertical-align': 'top'
|
|
165
|
-
}
|
|
234
|
+
conversion.for( 'downcast' )
|
|
235
|
+
.attributeToAttribute( {
|
|
236
|
+
model: {
|
|
237
|
+
name: 'tableCell',
|
|
238
|
+
key: 'verticalAlignment'
|
|
166
239
|
},
|
|
167
|
-
|
|
240
|
+
view: alignment => ( {
|
|
168
241
|
key: 'style',
|
|
169
242
|
value: {
|
|
170
|
-
'vertical-align':
|
|
243
|
+
'vertical-align': alignment
|
|
171
244
|
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
} );
|
|
245
|
+
} )
|
|
246
|
+
} );
|
|
175
247
|
|
|
176
248
|
conversion.for( 'upcast' )
|
|
177
|
-
// Support for
|
|
249
|
+
// Support for the `vertical-align:*;` CSS definition for the table cell alignment.
|
|
178
250
|
.attributeToAttribute( {
|
|
179
251
|
view: {
|
|
252
|
+
name: /^(td|th)$/,
|
|
253
|
+
styles: {
|
|
254
|
+
'vertical-align': VALIGN_VALUES_REG_EXP
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
model: {
|
|
258
|
+
key: 'verticalAlignment',
|
|
259
|
+
value: viewElement => {
|
|
260
|
+
const align = viewElement.getStyle( 'vertical-align' );
|
|
261
|
+
|
|
262
|
+
return align === defaultValue ? null : align;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} )
|
|
266
|
+
// Support for the `align` attribute as the backward compatibility while pasting from other sources.
|
|
267
|
+
.attributeToAttribute( {
|
|
268
|
+
view: {
|
|
269
|
+
name: /^(td|th)$/,
|
|
180
270
|
attributes: {
|
|
181
271
|
valign: VALIGN_VALUES_REG_EXP
|
|
182
272
|
}
|
|
183
273
|
},
|
|
184
274
|
model: {
|
|
185
|
-
name: 'tableCell',
|
|
186
275
|
key: 'verticalAlignment',
|
|
187
|
-
value: viewElement =>
|
|
276
|
+
value: viewElement => {
|
|
277
|
+
const valign = viewElement.getAttribute( 'valign' );
|
|
278
|
+
|
|
279
|
+
return valign === defaultValue ? null : valign;
|
|
280
|
+
}
|
|
188
281
|
}
|
|
189
282
|
} );
|
|
190
283
|
}
|
|
191
284
|
|
|
192
285
|
// Enables conversion for an attribute for simple view-model mappings.
|
|
193
286
|
//
|
|
194
|
-
// @param {String} modelAttribute
|
|
195
|
-
// @param {String} styleName
|
|
196
287
|
// @param {module:engine/model/schema~Schema} schema
|
|
197
288
|
// @param {module:engine/conversion/conversion~Conversion} conversion
|
|
198
|
-
|
|
289
|
+
// @param {Object} options
|
|
290
|
+
// @param {String} options.modelAttribute
|
|
291
|
+
// @param {String} options.styleName
|
|
292
|
+
// @param {String} options.defaultValue The default value for the specified `modelAttribute`.
|
|
293
|
+
// @param {Boolean} [options.reduceBoxSides=false]
|
|
294
|
+
function enableProperty( schema, conversion, options ) {
|
|
295
|
+
const { modelAttribute } = options;
|
|
296
|
+
|
|
199
297
|
schema.extend( 'tableCell', {
|
|
200
298
|
allowAttributes: [ modelAttribute ]
|
|
201
299
|
} );
|
|
202
|
-
|
|
203
|
-
|
|
300
|
+
|
|
301
|
+
upcastStyleToAttribute( conversion, { viewElement: /^(td|th)$/, ...options } );
|
|
302
|
+
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', ...options } );
|
|
204
303
|
}
|