@ckeditor/ckeditor5-table 35.0.1 → 35.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/build/table.js +1 -1
- package/build/table.js.map +1 -0
- package/build/translations/ko.js +1 -1
- package/build/translations/tt.js +1 -0
- package/build/translations/ur.js +1 -1
- package/lang/translations/ko.po +1 -1
- package/lang/translations/tt.po +261 -0
- package/lang/translations/ur.po +9 -9
- package/package.json +26 -26
- package/src/index.js +1 -0
- package/src/tablecaption/tablecaptionui.js +2 -0
- package/src/tablecellproperties/tablecellpropertiesediting.js +4 -30
- package/src/tablecellproperties/tablecellpropertiesui.js +1 -1
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +2 -0
- package/src/{tablecellproperties → tablecellwidth}/commands/tablecellwidthcommand.js +2 -3
- package/src/tablecellwidth/tablecellwidthediting.js +58 -0
- package/src/tablecolumnresize/constants.js +0 -2
- package/src/tablecolumnresize/converters.js +29 -28
- package/src/tablecolumnresize/tablecolumnresizeediting.js +399 -425
- package/src/tablecolumnresize/tablecolumnwidthscommand.js +55 -0
- package/src/tablecolumnresize/tablewidthresizecommand.js +60 -0
- package/src/tablecolumnresize/utils.js +131 -167
- package/src/tablecolumnresize.js +4 -3
- package/src/tableproperties/ui/tablepropertiesview.js +2 -0
- package/src/tableui.js +0 -6
- package/src/ui/colorinputview.js +88 -51
- package/src/ui/inserttableview.js +86 -50
- package/src/utils/common.js +24 -0
- package/src/utils/ui/table-properties.js +7 -7
- package/theme/tablecolumnresize.css +13 -10
|
@@ -7,35 +7,34 @@
|
|
|
7
7
|
* @module table/tablecolumnresize/converters
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { getNumberOfColumn } from './utils';
|
|
10
|
+
import { normalizeColumnWidths } from './utils';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Returns a helper for converting a view `<colgroup>` and `<col>` elements to the model table `columnWidths` attribute.
|
|
16
14
|
*
|
|
17
15
|
* Only the inline width, provided as a percentage value, in the `<col>` element is taken into account. If there are not enough `<col>`
|
|
18
|
-
* elements matching this condition, the special value
|
|
16
|
+
* elements matching this condition, the special value `auto` is returned. It indicates that the width of a column will be automatically
|
|
19
17
|
* calculated in the
|
|
20
|
-
* {@link module:table/tablecolumnresize/tablecolumnresizeediting~TableColumnResizeEditing#
|
|
18
|
+
* {@link module:table/tablecolumnresize/tablecolumnresizeediting~TableColumnResizeEditing#_registerPostFixer post-fixer}, depending
|
|
21
19
|
* on the available table space.
|
|
22
20
|
*
|
|
23
|
-
* @param {module:core/
|
|
21
|
+
* @param {module:core/plugin~Plugin} tableUtilsPlugin The {@link module:table/tableutils~TableUtils} plugin instance.
|
|
24
22
|
* @returns {Function} Conversion helper.
|
|
25
23
|
*/
|
|
26
|
-
export function upcastColgroupElement(
|
|
24
|
+
export function upcastColgroupElement( tableUtilsPlugin ) {
|
|
27
25
|
return dispatcher => dispatcher.on( 'element:colgroup', ( evt, data, conversionApi ) => {
|
|
28
|
-
const
|
|
26
|
+
const viewColgroupElement = data.viewItem;
|
|
29
27
|
|
|
30
|
-
if ( !
|
|
28
|
+
if ( !conversionApi.consumable.test( viewColgroupElement, { name: true } ) ) {
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
const viewColgroupElement = data.viewItem;
|
|
36
|
-
const numberOfColumns = getNumberOfColumn( modelTable, editor );
|
|
32
|
+
conversionApi.consumable.consume( viewColgroupElement, { name: true } );
|
|
37
33
|
|
|
38
|
-
const
|
|
34
|
+
const modelTable = data.modelCursor.findAncestor( 'table' );
|
|
35
|
+
const numberOfColumns = tableUtilsPlugin.getColumns( modelTable );
|
|
36
|
+
|
|
37
|
+
let columnWidths = [ ...Array( numberOfColumns ).keys() ]
|
|
39
38
|
.map( columnIndex => {
|
|
40
39
|
const viewChild = viewColgroupElement.getChild( columnIndex );
|
|
41
40
|
|
|
@@ -50,10 +49,13 @@ export function upcastColgroupElement( editor ) {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
return viewColWidth;
|
|
53
|
-
} )
|
|
54
|
-
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
if ( columnWidths.includes( 'auto' ) ) {
|
|
55
|
+
columnWidths = normalizeColumnWidths( columnWidths ).map( width => width + '%' );
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
conversionApi.writer.setAttribute( 'columnWidths', columnWidths.join( ',' ), modelTable );
|
|
57
59
|
} );
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -71,11 +73,14 @@ export function downcastTableColumnWidthsAttribute() {
|
|
|
71
73
|
.find( viewChild => viewChild.is( 'element', 'table' ) );
|
|
72
74
|
|
|
73
75
|
if ( data.attributeNewValue ) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
// If new value is the same as the old, the operation is not applied (see the `writer.setAttributeOnItem()`).
|
|
77
|
+
// OTOH the model element has the attribute already applied, so we can't compare the values.
|
|
78
|
+
// Hence we need to just recreate the <colgroup> element every time.
|
|
79
|
+
insertColgroupElement( viewWriter, viewTable, data.attributeNewValue );
|
|
80
|
+
viewWriter.addClass( 'ck-table-resized', viewTable );
|
|
77
81
|
} else {
|
|
78
82
|
removeColgroupElement( viewWriter, viewTable );
|
|
83
|
+
viewWriter.removeClass( 'ck-table-resized', viewTable );
|
|
79
84
|
}
|
|
80
85
|
} );
|
|
81
86
|
}
|
|
@@ -86,7 +91,7 @@ export function downcastTableColumnWidthsAttribute() {
|
|
|
86
91
|
// @private
|
|
87
92
|
// @param {module:engine/view/downcastwriter~DowncastWriter} viewWriter View writer instance.
|
|
88
93
|
// @param {module:engine/view/element~Element} viewTable View table.
|
|
89
|
-
// @param {String} columnWidthsAttribute Column
|
|
94
|
+
// @param {String} columnWidthsAttribute Column widths attribute from model table.
|
|
90
95
|
function insertColgroupElement( viewWriter, viewTable, columnWidthsAttribute ) {
|
|
91
96
|
const columnWidths = columnWidthsAttribute.split( ',' );
|
|
92
97
|
|
|
@@ -94,10 +99,10 @@ function insertColgroupElement( viewWriter, viewTable, columnWidthsAttribute ) {
|
|
|
94
99
|
|
|
95
100
|
if ( !viewColgroupElement ) {
|
|
96
101
|
viewColgroupElement = viewWriter.createContainerElement( 'colgroup' );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
} else {
|
|
103
|
+
for ( const viewChild of [ ...viewColgroupElement.getChildren() ] ) {
|
|
104
|
+
viewWriter.remove( viewChild );
|
|
105
|
+
}
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
for ( const columnIndex of Array( columnWidths.length ).keys() ) {
|
|
@@ -118,9 +123,5 @@ function insertColgroupElement( viewWriter, viewTable, columnWidthsAttribute ) {
|
|
|
118
123
|
function removeColgroupElement( viewWriter, viewTable ) {
|
|
119
124
|
const viewColgroupElement = [ ...viewTable.getChildren() ].find( viewElement => viewElement.is( 'element', 'colgroup' ) );
|
|
120
125
|
|
|
121
|
-
if ( !viewColgroupElement ) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
126
|
viewWriter.remove( viewColgroupElement );
|
|
126
127
|
}
|