@ckeditor/ckeditor5-table 34.0.0 → 35.0.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +261 -0
  2. package/LICENSE.md +6 -2
  3. package/build/table.js +1 -1
  4. package/build/translations/ar.js +1 -1
  5. package/build/translations/bg.js +1 -1
  6. package/build/translations/bn.js +1 -0
  7. package/build/translations/ca.js +1 -0
  8. package/build/translations/da.js +1 -1
  9. package/build/translations/et.js +1 -1
  10. package/build/translations/fi.js +1 -1
  11. package/build/translations/fr.js +1 -1
  12. package/build/translations/he.js +1 -0
  13. package/build/translations/hi.js +1 -1
  14. package/build/translations/id.js +1 -1
  15. package/build/translations/ja.js +1 -1
  16. package/build/translations/ko.js +1 -1
  17. package/build/translations/lt.js +1 -1
  18. package/build/translations/lv.js +1 -1
  19. package/build/translations/ms.js +1 -0
  20. package/build/translations/nl.js +1 -1
  21. package/build/translations/no.js +1 -1
  22. package/build/translations/pt.js +1 -0
  23. package/build/translations/sv.js +1 -1
  24. package/build/translations/th.js +1 -1
  25. package/build/translations/tr.js +1 -1
  26. package/build/translations/uk.js +1 -1
  27. package/build/translations/ur.js +1 -0
  28. package/build/translations/vi.js +1 -1
  29. package/build/translations/zh-cn.js +1 -1
  30. package/ckeditor5-metadata.json +19 -0
  31. package/lang/translations/ar.po +11 -11
  32. package/lang/translations/bg.po +43 -43
  33. package/lang/translations/bn.po +263 -0
  34. package/lang/translations/ca.po +261 -0
  35. package/lang/translations/da.po +6 -6
  36. package/lang/translations/es.po +1 -1
  37. package/lang/translations/et.po +3 -3
  38. package/lang/translations/fi.po +41 -41
  39. package/lang/translations/fr.po +4 -4
  40. package/lang/translations/he.po +261 -0
  41. package/lang/translations/hi.po +3 -3
  42. package/lang/translations/id.po +21 -21
  43. package/lang/translations/it.po +1 -1
  44. package/lang/translations/ja.po +45 -45
  45. package/lang/translations/ko.po +60 -60
  46. package/lang/translations/lt.po +43 -43
  47. package/lang/translations/lv.po +42 -42
  48. package/lang/translations/ms.po +261 -0
  49. package/lang/translations/nl.po +25 -25
  50. package/lang/translations/no.po +3 -3
  51. package/lang/translations/pt-br.po +1 -1
  52. package/lang/translations/pt.po +261 -0
  53. package/lang/translations/sv.po +56 -56
  54. package/lang/translations/th.po +42 -42
  55. package/lang/translations/tr.po +3 -3
  56. package/lang/translations/uk.po +3 -3
  57. package/lang/translations/ur.po +261 -0
  58. package/lang/translations/vi.po +28 -28
  59. package/lang/translations/zh-cn.po +3 -3
  60. package/package.json +27 -23
  61. package/src/index.js +2 -0
  62. package/src/tablecellproperties/ui/tablecellpropertiesview.js +2 -2
  63. package/src/tablecolumnresize/constants.js +32 -0
  64. package/src/tablecolumnresize/converters.js +126 -0
  65. package/src/tablecolumnresize/tablecolumnresizeediting.js +758 -0
  66. package/src/tablecolumnresize/utils.js +367 -0
  67. package/src/tablecolumnresize.js +36 -0
  68. package/src/tableproperties/ui/tablepropertiesview.js +1 -1
  69. package/src/tableui.js +6 -2
  70. package/src/ui/colorinputview.js +2 -1
  71. package/src/utils/ui/contextualballoon.js +3 -3
  72. package/src/utils/ui/widget.js +7 -1
  73. package/theme/tablecolumnresize.css +59 -0
  74. package/build/table.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-table",
3
- "version": "34.0.0",
3
+ "version": "35.0.0",
4
4
  "description": "Table feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,31 +12,34 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "^34.0.0",
15
+ "ckeditor5": "^35.0.0",
16
16
  "lodash-es": "^4.17.15"
17
17
  },
18
18
  "devDependencies": {
19
- "@ckeditor/ckeditor5-alignment": "^34.0.0",
20
- "@ckeditor/ckeditor5-block-quote": "^34.0.0",
21
- "@ckeditor/ckeditor5-clipboard": "^34.0.0",
22
- "@ckeditor/ckeditor5-core": "^34.0.0",
19
+ "@ckeditor/ckeditor5-alignment": "^35.0.0",
20
+ "@ckeditor/ckeditor5-basic-styles": "^35.0.0",
21
+ "@ckeditor/ckeditor5-block-quote": "^35.0.0",
22
+ "@ckeditor/ckeditor5-clipboard": "^35.0.0",
23
+ "@ckeditor/ckeditor5-core": "^35.0.0",
23
24
  "@ckeditor/ckeditor5-dev-utils": "^30.0.0",
24
- "@ckeditor/ckeditor5-editor-classic": "^34.0.0",
25
- "@ckeditor/ckeditor5-engine": "^34.0.0",
26
- "@ckeditor/ckeditor5-horizontal-line": "^34.0.0",
27
- "@ckeditor/ckeditor5-html-support": "^34.0.0",
28
- "@ckeditor/ckeditor5-image": "^34.0.0",
29
- "@ckeditor/ckeditor5-indent": "^34.0.0",
30
- "@ckeditor/ckeditor5-list": "^34.0.0",
31
- "@ckeditor/ckeditor5-media-embed": "^34.0.0",
32
- "@ckeditor/ckeditor5-paragraph": "^34.0.0",
33
- "@ckeditor/ckeditor5-theme-lark": "^34.0.0",
34
- "@ckeditor/ckeditor5-typing": "^34.0.0",
35
- "@ckeditor/ckeditor5-ui": "^34.0.0",
36
- "@ckeditor/ckeditor5-undo": "^34.0.0",
37
- "@ckeditor/ckeditor5-utils": "^34.0.0",
38
- "@ckeditor/ckeditor5-widget": "^34.0.0",
39
- "@ckeditor/ckeditor5-source-editing": "^34.0.0",
25
+ "@ckeditor/ckeditor5-editor-classic": "^35.0.0",
26
+ "@ckeditor/ckeditor5-engine": "^35.0.0",
27
+ "@ckeditor/ckeditor5-highlight": "^35.0.0",
28
+ "@ckeditor/ckeditor5-horizontal-line": "^35.0.0",
29
+ "@ckeditor/ckeditor5-html-support": "^35.0.0",
30
+ "@ckeditor/ckeditor5-image": "^35.0.0",
31
+ "@ckeditor/ckeditor5-indent": "^35.0.0",
32
+ "@ckeditor/ckeditor5-link": "^35.0.0",
33
+ "@ckeditor/ckeditor5-list": "^35.0.0",
34
+ "@ckeditor/ckeditor5-media-embed": "^35.0.0",
35
+ "@ckeditor/ckeditor5-paragraph": "^35.0.0",
36
+ "@ckeditor/ckeditor5-theme-lark": "^35.0.0",
37
+ "@ckeditor/ckeditor5-typing": "^35.0.0",
38
+ "@ckeditor/ckeditor5-ui": "^35.0.0",
39
+ "@ckeditor/ckeditor5-undo": "^35.0.0",
40
+ "@ckeditor/ckeditor5-utils": "^35.0.0",
41
+ "@ckeditor/ckeditor5-widget": "^35.0.0",
42
+ "@ckeditor/ckeditor5-source-editing": "^35.0.0",
40
43
  "json-diff": "^0.5.4",
41
44
  "webpack": "^5.58.1",
42
45
  "webpack-cli": "^4.9.0"
@@ -59,7 +62,8 @@
59
62
  "src",
60
63
  "theme",
61
64
  "build",
62
- "ckeditor5-metadata.json"
65
+ "ckeditor5-metadata.json",
66
+ "CHANGELOG.md"
63
67
  ],
64
68
  "scripts": {
65
69
  "dll:build": "webpack"
package/src/index.js CHANGED
@@ -26,3 +26,5 @@ export { default as TableMouse } from './tablemouse';
26
26
  export { default as TableKeyboard } from './tablekeyboard';
27
27
  export { default as TableSelection } from './tableselection';
28
28
  export { default as TableUtils } from './tableutils';
29
+ export { default as TableColumnResize } from './tablecolumnresize';
30
+ export { default as TableColumnResizeEditing } from './tablecolumnresize/tablecolumnresizeediting';
@@ -247,7 +247,7 @@ export default class TableCellPropertiesView extends View {
247
247
  * A toolbar with buttons that allow changing the horizontal text alignment in a table cell.
248
248
  *
249
249
  * @readonly
250
- * @member {module:ui/toolbar/toolbar~ToolbarView}
250
+ * @member {module:ui/toolbar/toolbarview~ToolbarView}
251
251
  */
252
252
  this.horizontalAlignmentToolbar = horizontalAlignmentToolbar;
253
253
 
@@ -255,7 +255,7 @@ export default class TableCellPropertiesView extends View {
255
255
  * A toolbar with buttons that allow changing the vertical text alignment in a table cell.
256
256
  *
257
257
  * @readonly
258
- * @member {module:ui/toolbar/toolbar~ToolbarView}
258
+ * @member {module:ui/toolbar/toolbarview~ToolbarView}
259
259
  */
260
260
  this.verticalAlignmentToolbar = verticalAlignmentToolbar;
261
261
 
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+
6
+ /**
7
+ * @module table/tablecolumnresize/constants
8
+ */
9
+
10
+ /* istanbul ignore file */
11
+
12
+ /**
13
+ * The minimum column width given as a percentage value. Used in situations when the table is not yet rendered, so it is impossible to
14
+ * calculate how many percentage of the table width would be {@link ~COLUMN_MIN_WIDTH_IN_PIXELS minimum column width in pixels}.
15
+ *
16
+ * @const {Number}
17
+ */
18
+ export const COLUMN_MIN_WIDTH_AS_PERCENTAGE = 5;
19
+
20
+ /**
21
+ * The minimum column width in pixels when the maximum table width is known.
22
+ *
23
+ * @const {Number}
24
+ */
25
+ export const COLUMN_MIN_WIDTH_IN_PIXELS = 40;
26
+
27
+ /**
28
+ * Determines how many digits after the decimal point are used to store the column width as a percentage value.
29
+ *
30
+ * @const {Number}
31
+ */
32
+ export const COLUMN_WIDTH_PRECISION = 2;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+
6
+ /**
7
+ * @module table/tablecolumnresize/converters
8
+ */
9
+
10
+ /* istanbul ignore file */
11
+
12
+ import { getNumberOfColumn } from './utils';
13
+
14
+ /**
15
+ * Returns a helper for converting a view `<colgroup>` and `<col>` elements to the model table `columnWidths` attribute.
16
+ *
17
+ * 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 'auto' is returned. It indicates that the width of a column will be automatically
19
+ * calculated in the
20
+ * {@link module:table/tablecolumnresize/tablecolumnresizeediting~TableColumnResizeEditing#_setupPostFixer post-fixer}, depending
21
+ * on the available table space.
22
+ *
23
+ * @param {module:core/editor/editor~Editor} editor The editor instance.
24
+ * @returns {Function} Conversion helper.
25
+ */
26
+ export function upcastColgroupElement( editor ) {
27
+ return dispatcher => dispatcher.on( 'element:colgroup', ( evt, data, conversionApi ) => {
28
+ const modelTable = data.modelCursor.findAncestor( 'table' );
29
+
30
+ if ( !modelTable ) {
31
+ return;
32
+ }
33
+
34
+ const modelWriter = conversionApi.writer;
35
+ const viewColgroupElement = data.viewItem;
36
+ const numberOfColumns = getNumberOfColumn( modelTable, editor );
37
+
38
+ const columnWidthsAttribute = [ ...Array( numberOfColumns ).keys() ]
39
+ .map( columnIndex => {
40
+ const viewChild = viewColgroupElement.getChild( columnIndex );
41
+
42
+ if ( !viewChild || !viewChild.is( 'element', 'col' ) ) {
43
+ return 'auto';
44
+ }
45
+
46
+ const viewColWidth = viewChild.getStyle( 'width' );
47
+
48
+ if ( !viewColWidth || !viewColWidth.endsWith( '%' ) ) {
49
+ return 'auto';
50
+ }
51
+
52
+ return viewColWidth;
53
+ } )
54
+ .join( ',' );
55
+
56
+ modelWriter.setAttribute( 'columnWidths', columnWidthsAttribute, modelTable );
57
+ } );
58
+ }
59
+
60
+ /**
61
+ * Returns a helper for converting a model table `columnWidths` attribute to view `<colgroup>` and `<col>` elements.
62
+ *
63
+ * @returns {Function} Conversion helper.
64
+ */
65
+ export function downcastTableColumnWidthsAttribute() {
66
+ return dispatcher => dispatcher.on( 'attribute:columnWidths:table', ( evt, data, conversionApi ) => {
67
+ const viewWriter = conversionApi.writer;
68
+ const modelTable = data.item;
69
+
70
+ const viewTable = [ ...conversionApi.mapper.toViewElement( modelTable ).getChildren() ]
71
+ .find( viewChild => viewChild.is( 'element', 'table' ) );
72
+
73
+ if ( data.attributeNewValue ) {
74
+ if ( data.attributeNewValue !== data.attributeOldValue ) {
75
+ insertColgroupElement( viewWriter, viewTable, data.attributeNewValue );
76
+ }
77
+ } else {
78
+ removeColgroupElement( viewWriter, viewTable );
79
+ }
80
+ } );
81
+ }
82
+
83
+ // Inserts the `<colgroup>` with `<col>` elements as the first child in the view table. Each `<col>` element represents a single column
84
+ // and it has the inline width style set, taken from the appropriate slot from the `columnWidths` table attribute.
85
+ //
86
+ // @private
87
+ // @param {module:engine/view/downcastwriter~DowncastWriter} viewWriter View writer instance.
88
+ // @param {module:engine/view/element~Element} viewTable View table.
89
+ // @param {String} columnWidthsAttribute Column width attribute from model table.
90
+ function insertColgroupElement( viewWriter, viewTable, columnWidthsAttribute ) {
91
+ const columnWidths = columnWidthsAttribute.split( ',' );
92
+
93
+ let viewColgroupElement = [ ...viewTable.getChildren() ].find( viewElement => viewElement.is( 'element', 'colgroup' ) );
94
+
95
+ if ( !viewColgroupElement ) {
96
+ viewColgroupElement = viewWriter.createContainerElement( 'colgroup' );
97
+ }
98
+
99
+ for ( const viewChild of [ ...viewColgroupElement.getChildren() ] ) {
100
+ viewWriter.remove( viewChild );
101
+ }
102
+
103
+ for ( const columnIndex of Array( columnWidths.length ).keys() ) {
104
+ const viewColElement = viewWriter.createEmptyElement( 'col' );
105
+
106
+ viewWriter.setStyle( 'width', columnWidths[ columnIndex ], viewColElement );
107
+ viewWriter.insert( viewWriter.createPositionAt( viewColgroupElement, 'end' ), viewColElement );
108
+ }
109
+
110
+ viewWriter.insert( viewWriter.createPositionAt( viewTable, 'start' ), viewColgroupElement );
111
+ }
112
+
113
+ // Removes the `<colgroup>` with `<col>` elements from the view table.
114
+ //
115
+ // @private
116
+ // @param {module:engine/view/downcastwriter~DowncastWriter} viewWriter View writer instance.
117
+ // @param {module:engine/view/element~Element} viewTable View table.
118
+ function removeColgroupElement( viewWriter, viewTable ) {
119
+ const viewColgroupElement = [ ...viewTable.getChildren() ].find( viewElement => viewElement.is( 'element', 'colgroup' ) );
120
+
121
+ if ( !viewColgroupElement ) {
122
+ return;
123
+ }
124
+
125
+ viewWriter.remove( viewColgroupElement );
126
+ }