@ckeditor/ckeditor5-table 29.1.0 → 31.1.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/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/uz.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/lang/translations/es.po +11 -11
- package/lang/translations/id.po +10 -10
- package/lang/translations/nl.po +2 -2
- package/lang/translations/pl.po +3 -3
- package/lang/translations/pt-br.po +3 -3
- package/lang/translations/ru.po +3 -3
- package/lang/translations/sr-latn.po +3 -3
- package/lang/translations/sr.po +3 -3
- package/lang/translations/uz.po +261 -0
- package/lang/translations/zh.po +3 -3
- package/package.json +21 -21
- package/src/commands/selectcolumncommand.js +10 -0
- package/src/commands/selectrowcommand.js +10 -0
- package/src/converters/downcast.js +1 -18
- package/src/converters/table-heading-rows-refresh-post-fixer.js +23 -6
- package/src/converters/tableproperties.js +5 -4
- package/src/converters/upcasttable.js +6 -0
- package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellborderstylecommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellheightcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellpaddingcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellwidthcommand.js +1 -1
- package/src/tablecellproperties/tablecellpropertiesediting.js +41 -34
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +10 -1
- package/src/tablekeyboard.js +19 -4
- package/src/tableproperties/commands/tablealignmentcommand.js +1 -1
- package/src/tableproperties/commands/tablebackgroundcolorcommand.js +1 -1
- package/src/tableproperties/commands/tablebordercolorcommand.js +1 -1
- package/src/tableproperties/commands/tableborderstylecommand.js +1 -1
- package/src/tableproperties/commands/tableborderwidthcommand.js +1 -1
- package/src/tableproperties/commands/tableheightcommand.js +1 -1
- package/src/tableproperties/commands/tablewidthcommand.js +1 -1
- package/src/tableproperties/tablepropertiesediting.js +28 -20
- package/src/tableproperties/ui/tablepropertiesview.js +10 -1
- package/src/ui/colorinputview.js +2 -2
- package/src/utils/ui/contextualballoon.js +3 -8
- package/theme/colorinput.css +3 -0
- package/CHANGELOG.md +0 -261
|
@@ -29,14 +29,31 @@ function tableHeadingRowsRefreshPostFixer( model ) {
|
|
|
29
29
|
const tablesToRefresh = new Set();
|
|
30
30
|
|
|
31
31
|
for ( const change of differ.getChanges() ) {
|
|
32
|
-
if ( change.type
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if ( change.type === 'attribute' ) {
|
|
33
|
+
const element = change.range.start.nodeAfter;
|
|
34
|
+
|
|
35
|
+
if ( element && element.is( 'element', 'table' ) && change.attributeKey === 'headingRows' ) {
|
|
36
|
+
tablesToRefresh.add( element );
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
/* istanbul ignore else */
|
|
40
|
+
if ( change.type === 'insert' || change.type === 'remove' ) {
|
|
41
|
+
if ( change.name === 'tableRow' ) {
|
|
42
|
+
const table = change.position.findAncestor( 'table' );
|
|
43
|
+
const headingRows = table.getAttribute( 'headingRows' ) || 0;
|
|
35
44
|
|
|
36
|
-
|
|
45
|
+
if ( change.position.offset < headingRows ) {
|
|
46
|
+
tablesToRefresh.add( table );
|
|
47
|
+
}
|
|
48
|
+
} else if ( change.name === 'tableCell' ) {
|
|
49
|
+
const table = change.position.findAncestor( 'table' );
|
|
50
|
+
const headingColumns = table.getAttribute( 'headingColumns' ) || 0;
|
|
37
51
|
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
if ( change.position.offset < headingColumns ) {
|
|
53
|
+
tablesToRefresh.add( table );
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
40
57
|
}
|
|
41
58
|
}
|
|
42
59
|
|
|
@@ -47,12 +47,13 @@ export function upcastStyleToAttribute( conversion, options ) {
|
|
|
47
47
|
*
|
|
48
48
|
* @param {module:engine/conversion/conversion~Conversion} conversion
|
|
49
49
|
* @param {String} viewElementName
|
|
50
|
+
* @param {Object} modelAttributes
|
|
50
51
|
* @param {Object} defaultBorder The default border values.
|
|
51
52
|
* @param {String} defaultBorder.color The default `borderColor` value.
|
|
52
53
|
* @param {String} defaultBorder.style The default `borderStyle` value.
|
|
53
54
|
* @param {String} defaultBorder.width The default `borderWidth` value.
|
|
54
55
|
*/
|
|
55
|
-
export function upcastBorderStyles( conversion, viewElementName, defaultBorder ) {
|
|
56
|
+
export function upcastBorderStyles( conversion, viewElementName, modelAttributes, defaultBorder ) {
|
|
56
57
|
conversion.for( 'upcast' ).add( dispatcher => dispatcher.on( 'element:' + viewElementName, ( evt, data, conversionApi ) => {
|
|
57
58
|
// If the element was not converted by element-to-element converter,
|
|
58
59
|
// we should not try to convert the style. See #8393.
|
|
@@ -107,15 +108,15 @@ export function upcastBorderStyles( conversion, viewElementName, defaultBorder )
|
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
if ( reducedBorder.style !== defaultBorder.style ) {
|
|
110
|
-
conversionApi.writer.setAttribute(
|
|
111
|
+
conversionApi.writer.setAttribute( modelAttributes.style, reducedBorder.style, modelElement );
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
if ( reducedBorder.color !== defaultBorder.color ) {
|
|
114
|
-
conversionApi.writer.setAttribute(
|
|
115
|
+
conversionApi.writer.setAttribute( modelAttributes.color, reducedBorder.color, modelElement );
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
if ( reducedBorder.width !== defaultBorder.width ) {
|
|
118
|
-
conversionApi.writer.setAttribute(
|
|
119
|
+
conversionApi.writer.setAttribute( modelAttributes.width, reducedBorder.width, modelElement );
|
|
119
120
|
}
|
|
120
121
|
} ) );
|
|
121
122
|
}
|
|
@@ -37,6 +37,9 @@ export function upcastTableFigure() {
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// Consume the figure to prevent other converters from processing it again.
|
|
41
|
+
conversionApi.consumable.consume( data.viewItem, { name: true, classes: 'table' } );
|
|
42
|
+
|
|
40
43
|
// Convert view table to model table.
|
|
41
44
|
const conversionResult = conversionApi.convertItem( viewTable, data.modelCursor );
|
|
42
45
|
|
|
@@ -45,6 +48,9 @@ export function upcastTableFigure() {
|
|
|
45
48
|
|
|
46
49
|
// When table wasn't successfully converted then finish conversion.
|
|
47
50
|
if ( !modelTable ) {
|
|
51
|
+
// Revert consumed figure so other features can convert it.
|
|
52
|
+
conversionApi.consumable.revert( data.viewItem, { name: true, classes: 'table' } );
|
|
53
|
+
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
50
56
|
|
|
@@ -31,6 +31,6 @@ export default class TableCellBackgroundColorCommand extends TableCellPropertyCo
|
|
|
31
31
|
* @param {String} defaultValue The default value of the attribute.
|
|
32
32
|
*/
|
|
33
33
|
constructor( editor, defaultValue ) {
|
|
34
|
-
super( editor, '
|
|
34
|
+
super( editor, 'tableCellBackgroundColor', defaultValue );
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -32,7 +32,7 @@ export default class TableCellBorderColorCommand extends TableCellPropertyComman
|
|
|
32
32
|
* @param {String} defaultValue The default value of the attribute.
|
|
33
33
|
*/
|
|
34
34
|
constructor( editor, defaultValue ) {
|
|
35
|
-
super( editor, '
|
|
35
|
+
super( editor, 'tableCellBorderColor', defaultValue );
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -32,7 +32,7 @@ export default class TableCellBorderStyleCommand extends TableCellPropertyComman
|
|
|
32
32
|
* @param {String} defaultValue The default value of the attribute.
|
|
33
33
|
*/
|
|
34
34
|
constructor( editor, defaultValue ) {
|
|
35
|
-
super( editor, '
|
|
35
|
+
super( editor, 'tableCellBorderStyle', defaultValue );
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -40,7 +40,7 @@ export default class TableCellBorderWidthCommand extends TableCellPropertyComman
|
|
|
40
40
|
* @param {String} defaultValue The default value of the attribute.
|
|
41
41
|
*/
|
|
42
42
|
constructor( editor, defaultValue ) {
|
|
43
|
-
super( editor, '
|
|
43
|
+
super( editor, 'tableCellBorderWidth', defaultValue );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -40,7 +40,7 @@ export default class TableCellHeightCommand extends TableCellPropertyCommand {
|
|
|
40
40
|
* @param {String} defaultValue The default value of the attribute.
|
|
41
41
|
*/
|
|
42
42
|
constructor( editor, defaultValue ) {
|
|
43
|
-
super( editor, '
|
|
43
|
+
super( editor, 'tableCellHeight', defaultValue );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -31,6 +31,6 @@ export default class TableCellHorizontalAlignmentCommand extends TableCellProper
|
|
|
31
31
|
* @param {String} defaultValue The default value for the "alignment" attribute.
|
|
32
32
|
*/
|
|
33
33
|
constructor( editor, defaultValue ) {
|
|
34
|
-
super( editor, '
|
|
34
|
+
super( editor, 'tableCellHorizontalAlignment', defaultValue );
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -40,7 +40,7 @@ export default class TableCellPaddingCommand extends TableCellPropertyCommand {
|
|
|
40
40
|
* @param {String} defaultValue The default value of the attribute.
|
|
41
41
|
*/
|
|
42
42
|
constructor( editor, defaultValue ) {
|
|
43
|
-
super( editor, '
|
|
43
|
+
super( editor, 'tableCellPadding', defaultValue );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -39,6 +39,6 @@ export default class TableCellVerticalAlignmentCommand extends TableCellProperty
|
|
|
39
39
|
* @param {String} defaultValue The default value for the "alignment" attribute.
|
|
40
40
|
*/
|
|
41
41
|
constructor( editor, defaultValue ) {
|
|
42
|
-
super( editor, '
|
|
42
|
+
super( editor, 'tableCellVerticalAlignment', defaultValue );
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -40,7 +40,7 @@ export default class TableCellWidthCommand extends TableCellPropertyCommand {
|
|
|
40
40
|
* @param {String} defaultValue The default value of the attribute.
|
|
41
41
|
*/
|
|
42
42
|
constructor( editor, defaultValue ) {
|
|
43
|
-
super( editor, '
|
|
43
|
+
super( editor, 'tableCellWidth', defaultValue );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -31,11 +31,11 @@ const ALIGN_VALUES_REG_EXP = /^(left|center|right|justify)$/;
|
|
|
31
31
|
*
|
|
32
32
|
* Introduces table cell model attributes and their conversion:
|
|
33
33
|
*
|
|
34
|
-
* - border: `
|
|
35
|
-
* - background color: `
|
|
36
|
-
* - cell padding: `
|
|
37
|
-
* - horizontal and vertical alignment: `
|
|
38
|
-
* - cell width and height: `
|
|
34
|
+
* - border: `tableCellBorderStyle`, `tableCellBorderColor` and `tableCellBorderWidth`
|
|
35
|
+
* - background color: `tableCellBackgroundColor`
|
|
36
|
+
* - cell padding: `tableCellPadding`
|
|
37
|
+
* - horizontal and vertical alignment: `tableCellHorizontalAlignment`, `tableCellVerticalAlignment`
|
|
38
|
+
* - cell width and height: `tableCellWidth`, `tableCellHeight`
|
|
39
39
|
*
|
|
40
40
|
* It also registers commands used to manipulate the above attributes:
|
|
41
41
|
*
|
|
@@ -92,21 +92,15 @@ export default class TableCellPropertiesEditing extends Plugin {
|
|
|
92
92
|
editor.commands.add( 'tableCellBorderColor', new TableCellBorderColorCommand( editor, defaultTableCellProperties.borderColor ) );
|
|
93
93
|
editor.commands.add( 'tableCellBorderWidth', new TableCellBorderWidthCommand( editor, defaultTableCellProperties.borderWidth ) );
|
|
94
94
|
|
|
95
|
-
enableHorizontalAlignmentProperty( schema, conversion, defaultTableCellProperties.horizontalAlignment );
|
|
96
|
-
editor.commands.add(
|
|
97
|
-
'tableCellHorizontalAlignment',
|
|
98
|
-
new TableCellHorizontalAlignmentCommand( editor, defaultTableCellProperties.horizontalAlignment )
|
|
99
|
-
);
|
|
100
|
-
|
|
101
95
|
enableProperty( schema, conversion, {
|
|
102
|
-
modelAttribute: '
|
|
96
|
+
modelAttribute: 'tableCellWidth',
|
|
103
97
|
styleName: 'width',
|
|
104
98
|
defaultValue: defaultTableCellProperties.width
|
|
105
99
|
} );
|
|
106
100
|
editor.commands.add( 'tableCellWidth', new TableCellWidthCommand( editor, defaultTableCellProperties.width ) );
|
|
107
101
|
|
|
108
102
|
enableProperty( schema, conversion, {
|
|
109
|
-
modelAttribute: '
|
|
103
|
+
modelAttribute: 'tableCellHeight',
|
|
110
104
|
styleName: 'height',
|
|
111
105
|
defaultValue: defaultTableCellProperties.height
|
|
112
106
|
} );
|
|
@@ -114,7 +108,7 @@ export default class TableCellPropertiesEditing extends Plugin {
|
|
|
114
108
|
|
|
115
109
|
editor.data.addStyleProcessorRules( addPaddingRules );
|
|
116
110
|
enableProperty( schema, conversion, {
|
|
117
|
-
modelAttribute: '
|
|
111
|
+
modelAttribute: 'tableCellPadding',
|
|
118
112
|
styleName: 'padding',
|
|
119
113
|
reduceBoxSides: true,
|
|
120
114
|
defaultValue: defaultTableCellProperties.padding
|
|
@@ -123,7 +117,7 @@ export default class TableCellPropertiesEditing extends Plugin {
|
|
|
123
117
|
|
|
124
118
|
editor.data.addStyleProcessorRules( addBackgroundRules );
|
|
125
119
|
enableProperty( schema, conversion, {
|
|
126
|
-
modelAttribute: '
|
|
120
|
+
modelAttribute: 'tableCellBackgroundColor',
|
|
127
121
|
styleName: 'background-color',
|
|
128
122
|
defaultValue: defaultTableCellProperties.backgroundColor
|
|
129
123
|
} );
|
|
@@ -132,6 +126,12 @@ export default class TableCellPropertiesEditing extends Plugin {
|
|
|
132
126
|
new TableCellBackgroundColorCommand( editor, defaultTableCellProperties.backgroundColor )
|
|
133
127
|
);
|
|
134
128
|
|
|
129
|
+
enableHorizontalAlignmentProperty( schema, conversion, defaultTableCellProperties.horizontalAlignment );
|
|
130
|
+
editor.commands.add(
|
|
131
|
+
'tableCellHorizontalAlignment',
|
|
132
|
+
new TableCellHorizontalAlignmentCommand( editor, defaultTableCellProperties.horizontalAlignment )
|
|
133
|
+
);
|
|
134
|
+
|
|
135
135
|
enableVerticalAlignmentProperty( schema, conversion, defaultTableCellProperties.verticalAlignment );
|
|
136
136
|
editor.commands.add(
|
|
137
137
|
'tableCellVerticalAlignment',
|
|
@@ -140,26 +140,33 @@ export default class TableCellPropertiesEditing extends Plugin {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
// Enables the `'
|
|
143
|
+
// Enables the `'tableCellBorderStyle'`, `'tableCellBorderColor'` and `'tableCellBorderWidth'` attributes for table cells.
|
|
144
144
|
//
|
|
145
145
|
// @param {module:engine/model/schema~Schema} schema
|
|
146
146
|
// @param {module:engine/conversion/conversion~Conversion} conversion
|
|
147
147
|
// @param {Object} defaultBorder The default border values.
|
|
148
|
-
// @param {String} defaultBorder.color The default `
|
|
149
|
-
// @param {String} defaultBorder.style The default `
|
|
150
|
-
// @param {String} defaultBorder.width The default `
|
|
148
|
+
// @param {String} defaultBorder.color The default `tableCellBorderColor` value.
|
|
149
|
+
// @param {String} defaultBorder.style The default `tableCellBorderStyle` value.
|
|
150
|
+
// @param {String} defaultBorder.width The default `tableCellBorderWidth` value.
|
|
151
151
|
function enableBorderProperties( schema, conversion, defaultBorder ) {
|
|
152
|
+
const modelAttributes = {
|
|
153
|
+
width: 'tableCellBorderWidth',
|
|
154
|
+
color: 'tableCellBorderColor',
|
|
155
|
+
style: 'tableCellBorderStyle'
|
|
156
|
+
};
|
|
157
|
+
|
|
152
158
|
schema.extend( 'tableCell', {
|
|
153
|
-
allowAttributes:
|
|
159
|
+
allowAttributes: Object.values( modelAttributes )
|
|
154
160
|
} );
|
|
155
|
-
|
|
156
|
-
upcastBorderStyles( conversion, '
|
|
157
|
-
|
|
158
|
-
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute:
|
|
159
|
-
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute:
|
|
161
|
+
|
|
162
|
+
upcastBorderStyles( conversion, 'td', modelAttributes, defaultBorder );
|
|
163
|
+
upcastBorderStyles( conversion, 'th', modelAttributes, defaultBorder );
|
|
164
|
+
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.style, styleName: 'border-style' } );
|
|
165
|
+
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.color, styleName: 'border-color' } );
|
|
166
|
+
downcastAttributeToStyle( conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.width, styleName: 'border-width' } );
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
// Enables the `'
|
|
169
|
+
// Enables the `'tableCellHorizontalAlignment'` attribute for table cells.
|
|
163
170
|
//
|
|
164
171
|
// @param {module:engine/model/schema~Schema} schema
|
|
165
172
|
// @param {module:engine/conversion/conversion~Conversion} conversion
|
|
@@ -167,14 +174,14 @@ function enableBorderProperties( schema, conversion, defaultBorder ) {
|
|
|
167
174
|
// @param {String} defaultValue The default horizontal alignment value.
|
|
168
175
|
function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
169
176
|
schema.extend( 'tableCell', {
|
|
170
|
-
allowAttributes: [ '
|
|
177
|
+
allowAttributes: [ 'tableCellHorizontalAlignment' ]
|
|
171
178
|
} );
|
|
172
179
|
|
|
173
180
|
conversion.for( 'downcast' )
|
|
174
181
|
.attributeToAttribute( {
|
|
175
182
|
model: {
|
|
176
183
|
name: 'tableCell',
|
|
177
|
-
key: '
|
|
184
|
+
key: 'tableCellHorizontalAlignment'
|
|
178
185
|
},
|
|
179
186
|
view: alignment => ( {
|
|
180
187
|
key: 'style',
|
|
@@ -194,7 +201,7 @@ function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
|
194
201
|
}
|
|
195
202
|
},
|
|
196
203
|
model: {
|
|
197
|
-
key: '
|
|
204
|
+
key: 'tableCellHorizontalAlignment',
|
|
198
205
|
value: viewElement => {
|
|
199
206
|
const align = viewElement.getStyle( 'text-align' );
|
|
200
207
|
|
|
@@ -211,7 +218,7 @@ function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
|
211
218
|
}
|
|
212
219
|
},
|
|
213
220
|
model: {
|
|
214
|
-
key: '
|
|
221
|
+
key: 'tableCellHorizontalAlignment',
|
|
215
222
|
value: viewElement => {
|
|
216
223
|
const align = viewElement.getAttribute( 'align' );
|
|
217
224
|
|
|
@@ -228,14 +235,14 @@ function enableHorizontalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
|
228
235
|
// @param {String} defaultValue The default vertical alignment value.
|
|
229
236
|
function enableVerticalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
230
237
|
schema.extend( 'tableCell', {
|
|
231
|
-
allowAttributes: [ '
|
|
238
|
+
allowAttributes: [ 'tableCellVerticalAlignment' ]
|
|
232
239
|
} );
|
|
233
240
|
|
|
234
241
|
conversion.for( 'downcast' )
|
|
235
242
|
.attributeToAttribute( {
|
|
236
243
|
model: {
|
|
237
244
|
name: 'tableCell',
|
|
238
|
-
key: '
|
|
245
|
+
key: 'tableCellVerticalAlignment'
|
|
239
246
|
},
|
|
240
247
|
view: alignment => ( {
|
|
241
248
|
key: 'style',
|
|
@@ -255,7 +262,7 @@ function enableVerticalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
|
255
262
|
}
|
|
256
263
|
},
|
|
257
264
|
model: {
|
|
258
|
-
key: '
|
|
265
|
+
key: 'tableCellVerticalAlignment',
|
|
259
266
|
value: viewElement => {
|
|
260
267
|
const align = viewElement.getStyle( 'vertical-align' );
|
|
261
268
|
|
|
@@ -272,7 +279,7 @@ function enableVerticalAlignmentProperty( schema, conversion, defaultValue ) {
|
|
|
272
279
|
}
|
|
273
280
|
},
|
|
274
281
|
model: {
|
|
275
|
-
key: '
|
|
282
|
+
key: 'tableCellVerticalAlignment',
|
|
276
283
|
value: viewElement => {
|
|
277
284
|
const valign = viewElement.getAttribute( 'valign' );
|
|
278
285
|
|
|
@@ -430,6 +430,16 @@ export default class TableCellPropertiesView extends View {
|
|
|
430
430
|
this.keystrokes.listenTo( this.element );
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
+
/**
|
|
434
|
+
* @inheritDoc
|
|
435
|
+
*/
|
|
436
|
+
destroy() {
|
|
437
|
+
super.destroy();
|
|
438
|
+
|
|
439
|
+
this.focusTracker.destroy();
|
|
440
|
+
this.keystrokes.destroy();
|
|
441
|
+
}
|
|
442
|
+
|
|
433
443
|
/**
|
|
434
444
|
* Focuses the fist focusable field in the form.
|
|
435
445
|
*/
|
|
@@ -799,7 +809,6 @@ export default class TableCellPropertiesView extends View {
|
|
|
799
809
|
label: t( 'Cancel' ),
|
|
800
810
|
icon: icons.cancel,
|
|
801
811
|
class: 'ck-button-cancel',
|
|
802
|
-
type: 'cancel',
|
|
803
812
|
withText: true
|
|
804
813
|
} );
|
|
805
814
|
|
package/src/tablekeyboard.js
CHANGED
|
@@ -218,10 +218,25 @@ export default class TableKeyboard extends Plugin {
|
|
|
218
218
|
return false;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
// When the selection is not collapsed.
|
|
222
|
+
if ( !selection.isCollapsed ) {
|
|
223
|
+
if ( expandSelection ) {
|
|
224
|
+
// Navigation is in the opposite direction than the selection direction so this is shrinking of the selection.
|
|
225
|
+
// Selection for sure will not approach cell edge.
|
|
226
|
+
//
|
|
227
|
+
// With a special case when all cell content is selected - then selection should expand to the other cell.
|
|
228
|
+
// Note: When the entire cell gets selected using CTRL+A, the selection is always forward.
|
|
229
|
+
if ( selection.isBackward == isForward && !selection.containsEntireContent( tableCell ) ) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
const selectedElement = selection.getSelectedElement();
|
|
234
|
+
|
|
235
|
+
// It will collapse for non-object selected so it's not going to move to other cell.
|
|
236
|
+
if ( !selectedElement || !model.schema.isObject( selectedElement ) ) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
225
240
|
}
|
|
226
241
|
|
|
227
242
|
// Let's check if the selection is at the beginning/end of the cell.
|
|
@@ -31,6 +31,6 @@ export default class TableAlignmentCommand extends TablePropertyCommand {
|
|
|
31
31
|
* @param {String} defaultValue The default value for the "alignment" attribute.
|
|
32
32
|
*/
|
|
33
33
|
constructor( editor, defaultValue ) {
|
|
34
|
-
super( editor, '
|
|
34
|
+
super( editor, 'tableAlignment', defaultValue );
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -31,6 +31,6 @@ export default class TableBackgroundColorCommand extends TablePropertyCommand {
|
|
|
31
31
|
* @param {String} defaultValue The default value of the attribute.
|
|
32
32
|
*/
|
|
33
33
|
constructor( editor, defaultValue ) {
|
|
34
|
-
super( editor, '
|
|
34
|
+
super( editor, 'tableBackgroundColor', defaultValue );
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -32,7 +32,7 @@ export default class TableBorderColorCommand extends TablePropertyCommand {
|
|
|
32
32
|
* @param {String} defaultValue The default value of the attribute.
|
|
33
33
|
*/
|
|
34
34
|
constructor( editor, defaultValue ) {
|
|
35
|
-
super( editor, '
|
|
35
|
+
super( editor, 'tableBorderColor', defaultValue );
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -32,7 +32,7 @@ export default class TableBorderStyleCommand extends TablePropertyCommand {
|
|
|
32
32
|
* @param {String} defaultValue The default value of the attribute.
|
|
33
33
|
*/
|
|
34
34
|
constructor( editor, defaultValue ) {
|
|
35
|
-
super( editor, '
|
|
35
|
+
super( editor, 'tableBorderStyle', defaultValue );
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -40,7 +40,7 @@ export default class TableBorderWidthCommand extends TablePropertyCommand {
|
|
|
40
40
|
* @param {String} defaultValue The default value of the attribute.
|
|
41
41
|
*/
|
|
42
42
|
constructor( editor, defaultValue ) {
|
|
43
|
-
super( editor, '
|
|
43
|
+
super( editor, 'tableBorderWidth', defaultValue );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -40,7 +40,7 @@ export default class TableHeightCommand extends TablePropertyCommand {
|
|
|
40
40
|
* @param {String} defaultValue The default value of the attribute.
|
|
41
41
|
*/
|
|
42
42
|
constructor( editor, defaultValue ) {
|
|
43
|
-
super( editor, '
|
|
43
|
+
super( editor, 'tableHeight', defaultValue );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -40,7 +40,7 @@ export default class TableWidthCommand extends TablePropertyCommand {
|
|
|
40
40
|
* @param {String} defaultValue The default value of the attribute.
|
|
41
41
|
*/
|
|
42
42
|
constructor( editor, defaultValue ) {
|
|
43
|
-
super( editor, '
|
|
43
|
+
super( editor, 'tableWidth', defaultValue );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -34,10 +34,10 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
|
|
|
34
34
|
*
|
|
35
35
|
* Introduces table's model attributes and their conversion:
|
|
36
36
|
*
|
|
37
|
-
* - border: `
|
|
38
|
-
* - background color: `
|
|
39
|
-
* - horizontal alignment: `
|
|
40
|
-
* - width & height: `
|
|
37
|
+
* - border: `tableBorderStyle`, `tableBorderColor` and `tableBorderWidth`
|
|
38
|
+
* - background color: `tableBackgroundColor`
|
|
39
|
+
* - horizontal alignment: `tableAlignment`
|
|
40
|
+
* - width & height: `tableWidth` & `tableHeight`
|
|
41
41
|
*
|
|
42
42
|
* It also registers commands used to manipulate the above attributes:
|
|
43
43
|
*
|
|
@@ -91,14 +91,14 @@ export default class TablePropertiesEditing extends Plugin {
|
|
|
91
91
|
editor.commands.add( 'tableAlignment', new TableAlignmentCommand( editor, defaultTableProperties.alignment ) );
|
|
92
92
|
|
|
93
93
|
enableTableToFigureProperty( schema, conversion, {
|
|
94
|
-
modelAttribute: '
|
|
94
|
+
modelAttribute: 'tableWidth',
|
|
95
95
|
styleName: 'width',
|
|
96
96
|
defaultValue: defaultTableProperties.width
|
|
97
97
|
} );
|
|
98
98
|
editor.commands.add( 'tableWidth', new TableWidthCommand( editor, defaultTableProperties.width ) );
|
|
99
99
|
|
|
100
100
|
enableTableToFigureProperty( schema, conversion, {
|
|
101
|
-
modelAttribute: '
|
|
101
|
+
modelAttribute: 'tableHeight',
|
|
102
102
|
styleName: 'height',
|
|
103
103
|
defaultValue: defaultTableProperties.height
|
|
104
104
|
} );
|
|
@@ -106,7 +106,7 @@ export default class TablePropertiesEditing extends Plugin {
|
|
|
106
106
|
|
|
107
107
|
editor.data.addStyleProcessorRules( addBackgroundRules );
|
|
108
108
|
enableProperty( schema, conversion, {
|
|
109
|
-
modelAttribute: '
|
|
109
|
+
modelAttribute: 'tableBackgroundColor',
|
|
110
110
|
styleName: 'background-color',
|
|
111
111
|
defaultValue: defaultTableProperties.backgroundColor
|
|
112
112
|
} );
|
|
@@ -117,22 +117,30 @@ export default class TablePropertiesEditing extends Plugin {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
// Enables `'
|
|
120
|
+
// Enables `tableBorderStyle'`, `tableBorderColor'` and `tableBorderWidth'` attributes for table.
|
|
121
121
|
//
|
|
122
122
|
// @param {module:engine/model/schema~Schema} schema
|
|
123
123
|
// @param {module:engine/conversion/conversion~Conversion} conversion
|
|
124
124
|
// @param {Object} defaultBorder The default border values.
|
|
125
|
-
// @param {String} defaultBorder.color The default `
|
|
126
|
-
// @param {String} defaultBorder.style The default `
|
|
127
|
-
// @param {String} defaultBorder.width The default `
|
|
125
|
+
// @param {String} defaultBorder.color The default `tableBorderColor` value.
|
|
126
|
+
// @param {String} defaultBorder.style The default `tableBorderStyle` value.
|
|
127
|
+
// @param {String} defaultBorder.width The default `tableBorderWidth` value.
|
|
128
128
|
function enableBorderProperties( schema, conversion, defaultBorder ) {
|
|
129
|
+
const modelAttributes = {
|
|
130
|
+
width: 'tableBorderWidth',
|
|
131
|
+
color: 'tableBorderColor',
|
|
132
|
+
style: 'tableBorderStyle'
|
|
133
|
+
};
|
|
134
|
+
|
|
129
135
|
schema.extend( 'table', {
|
|
130
|
-
allowAttributes:
|
|
136
|
+
allowAttributes: Object.values( modelAttributes )
|
|
131
137
|
} );
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
downcastTableAttribute( conversion, { modelAttribute:
|
|
138
|
+
|
|
139
|
+
upcastBorderStyles( conversion, 'table', modelAttributes, defaultBorder );
|
|
140
|
+
|
|
141
|
+
downcastTableAttribute( conversion, { modelAttribute: modelAttributes.color, styleName: 'border-color' } );
|
|
142
|
+
downcastTableAttribute( conversion, { modelAttribute: modelAttributes.style, styleName: 'border-style' } );
|
|
143
|
+
downcastTableAttribute( conversion, { modelAttribute: modelAttributes.width, styleName: 'border-width' } );
|
|
136
144
|
}
|
|
137
145
|
|
|
138
146
|
// Enables the `'alignment'` attribute for table.
|
|
@@ -142,14 +150,14 @@ function enableBorderProperties( schema, conversion, defaultBorder ) {
|
|
|
142
150
|
// @param {String} defaultValue The default alignment value.
|
|
143
151
|
function enableAlignmentProperty( schema, conversion, defaultValue ) {
|
|
144
152
|
schema.extend( 'table', {
|
|
145
|
-
allowAttributes: [ '
|
|
153
|
+
allowAttributes: [ 'tableAlignment' ]
|
|
146
154
|
} );
|
|
147
155
|
|
|
148
156
|
conversion.for( 'downcast' )
|
|
149
157
|
.attributeToAttribute( {
|
|
150
158
|
model: {
|
|
151
159
|
name: 'table',
|
|
152
|
-
key: '
|
|
160
|
+
key: 'tableAlignment'
|
|
153
161
|
},
|
|
154
162
|
view: alignment => ( {
|
|
155
163
|
key: 'style',
|
|
@@ -171,7 +179,7 @@ function enableAlignmentProperty( schema, conversion, defaultValue ) {
|
|
|
171
179
|
}
|
|
172
180
|
},
|
|
173
181
|
model: {
|
|
174
|
-
key: '
|
|
182
|
+
key: 'tableAlignment',
|
|
175
183
|
value: viewElement => {
|
|
176
184
|
let align = viewElement.getStyle( 'float' );
|
|
177
185
|
|
|
@@ -193,7 +201,7 @@ function enableAlignmentProperty( schema, conversion, defaultValue ) {
|
|
|
193
201
|
},
|
|
194
202
|
model: {
|
|
195
203
|
name: 'table',
|
|
196
|
-
key: '
|
|
204
|
+
key: 'tableAlignment',
|
|
197
205
|
value: viewElement => {
|
|
198
206
|
const align = viewElement.getAttribute( 'align' );
|
|
199
207
|
|
|
@@ -379,6 +379,16 @@ export default class TablePropertiesView extends View {
|
|
|
379
379
|
this.keystrokes.listenTo( this.element );
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
+
/**
|
|
383
|
+
* @inheritDoc
|
|
384
|
+
*/
|
|
385
|
+
destroy() {
|
|
386
|
+
super.destroy();
|
|
387
|
+
|
|
388
|
+
this.focusTracker.destroy();
|
|
389
|
+
this.keystrokes.destroy();
|
|
390
|
+
}
|
|
391
|
+
|
|
382
392
|
/**
|
|
383
393
|
* Focuses the fist focusable field in the form.
|
|
384
394
|
*/
|
|
@@ -690,7 +700,6 @@ export default class TablePropertiesView extends View {
|
|
|
690
700
|
label: t( 'Cancel' ),
|
|
691
701
|
icon: icons.cancel,
|
|
692
702
|
class: 'ck-button-cancel',
|
|
693
|
-
type: 'cancel',
|
|
694
703
|
withText: true
|
|
695
704
|
} );
|
|
696
705
|
|
package/src/ui/colorinputview.js
CHANGED
|
@@ -25,7 +25,7 @@ export default class ColorInputView extends View {
|
|
|
25
25
|
*
|
|
26
26
|
* @param {module:utils/locale~Locale} locale The locale instance.
|
|
27
27
|
* @param {Object} options The input options.
|
|
28
|
-
* @param {module:ui/colorgrid/colorgrid~ColorDefinition} options.colorDefinitions The colors to be displayed
|
|
28
|
+
* @param {Array.<module:ui/colorgrid/colorgrid~ColorDefinition>} options.colorDefinitions The colors to be displayed
|
|
29
29
|
* in the palette inside the input's dropdown.
|
|
30
30
|
* @param {Number} options.columns The number of columns in which the colors will be displayed.
|
|
31
31
|
* @param {String} [options.defaultColorValue] If specified, the color input view will replace the "Remove color" button with
|
|
@@ -98,7 +98,7 @@ export default class ColorInputView extends View {
|
|
|
98
98
|
* some error, it helps screen readers read the error text.
|
|
99
99
|
*
|
|
100
100
|
* @observable
|
|
101
|
-
* @member {
|
|
101
|
+
* @member {String} #ariaDescribedById
|
|
102
102
|
*/
|
|
103
103
|
this.set( 'ariaDescribedById' );
|
|
104
104
|
|