@atlaskit/editor-plugin-table 7.5.14 → 7.5.15
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/CHANGELOG.md +7 -0
- package/dist/cjs/nodeviews/TableComponent.js +12 -5
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +4 -2
- package/dist/cjs/transforms/column-width.js +4 -0
- package/dist/es2019/nodeviews/TableComponent.js +12 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +4 -2
- package/dist/es2019/transforms/column-width.js +5 -1
- package/dist/esm/nodeviews/TableComponent.js +12 -5
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +4 -2
- package/dist/esm/transforms/column-width.js +4 -0
- package/dist/types/nodeviews/TableComponent.d.ts +2 -0
- package/dist/types/pm-plugins/table-resizing/utils/types.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/nodeviews/TableComponent.tsx +21 -7
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/types.ts +1 -0
- package/src/transforms/column-width.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.5.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#83567](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83567) [`755de34e0656`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/755de34e0656) - fix preserve table width copy paste and resizing to full width behaviour
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 7.5.14
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -457,15 +457,20 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
457
457
|
return;
|
|
458
458
|
}
|
|
459
459
|
var tableNodeWidth = (0, _nodeWidth.getTableContainerWidth)(tableNode);
|
|
460
|
-
var
|
|
461
|
-
|
|
460
|
+
var isTableResizedFullWidth = tableNodeWidth === 1800 && this.wasResizing && !isResizing;
|
|
461
|
+
// Needed for undo / redo
|
|
462
|
+
var isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
463
|
+
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
464
|
+
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth;
|
|
465
|
+
if (force || maybeScale) {
|
|
462
466
|
var _this$containerWidth;
|
|
463
467
|
var containerWidthValue = containerWidth.width;
|
|
464
468
|
var isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
465
469
|
var wasTableResized = (0, _colgroup.hasTableBeenResized)(this.node);
|
|
466
|
-
var
|
|
467
|
-
var isColumnsDistributed = wasTableResized && !
|
|
468
|
-
|
|
470
|
+
var isTableResized = (0, _colgroup.hasTableBeenResized)(tableNode);
|
|
471
|
+
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
472
|
+
var shouldScale = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged;
|
|
473
|
+
if (force || !isResizing && shouldScale) {
|
|
469
474
|
var resizeState = (0, _utils4.getResizeState)({
|
|
470
475
|
minWidth: _utils4.COLUMN_MIN_WIDTH,
|
|
471
476
|
maxSize: tableRenderWidth,
|
|
@@ -482,6 +487,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
482
487
|
});
|
|
483
488
|
}
|
|
484
489
|
}
|
|
490
|
+
this.tableNodeWidth = tableNodeWidth;
|
|
491
|
+
this.wasResizing = isResizing;
|
|
485
492
|
this.containerWidth = containerWidth;
|
|
486
493
|
}
|
|
487
494
|
}, {
|
|
@@ -51,7 +51,8 @@ var getResizeState = exports.getResizeState = function getResizeState(_ref) {
|
|
|
51
51
|
widths: _widths,
|
|
52
52
|
maxSize: maxSize,
|
|
53
53
|
tableWidth: _tableWidth,
|
|
54
|
-
overflow: _overflow
|
|
54
|
+
overflow: _overflow,
|
|
55
|
+
isScaled: isTableScalingEnabled
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
var shouldReinsertColgroup = !isTableScalingEnabled;
|
|
@@ -85,7 +86,8 @@ var getResizeState = exports.getResizeState = function getResizeState(_ref) {
|
|
|
85
86
|
widths: widths,
|
|
86
87
|
maxSize: maxSize,
|
|
87
88
|
tableWidth: tableWidth,
|
|
88
|
-
overflow: overflow
|
|
89
|
+
overflow: overflow,
|
|
90
|
+
isScaled: isTableScalingEnabled
|
|
89
91
|
};
|
|
90
92
|
};
|
|
91
93
|
|
|
@@ -33,6 +33,10 @@ var updateColumnWidths = exports.updateColumnWidths = function updateColumnWidth
|
|
|
33
33
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
34
34
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
35
35
|
var width = resizeState.cols[columnIndex].width;
|
|
36
|
+
if (resizeState.isScaled) {
|
|
37
|
+
// Ensure that the width is an integer if the table has been scaled
|
|
38
|
+
width = Math.floor(width);
|
|
39
|
+
}
|
|
36
40
|
var mapIndex = rowIndex * map.width + columnIndex;
|
|
37
41
|
var cellPos = map.map[mapIndex];
|
|
38
42
|
var attrs = updatedCellsAttrs[cellPos] || _objectSpread({}, table.nodeAt(cellPos).attrs);
|
|
@@ -439,17 +439,22 @@ class TableComponent extends React.Component {
|
|
|
439
439
|
return;
|
|
440
440
|
}
|
|
441
441
|
const tableNodeWidth = getTableContainerWidth(tableNode);
|
|
442
|
-
const
|
|
443
|
-
|
|
442
|
+
const isTableResizedFullWidth = tableNodeWidth === 1800 && this.wasResizing && !isResizing;
|
|
443
|
+
// Needed for undo / redo
|
|
444
|
+
const isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
445
|
+
const isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
446
|
+
const maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth;
|
|
447
|
+
if (force || maybeScale) {
|
|
444
448
|
var _this$containerWidth;
|
|
445
449
|
const {
|
|
446
450
|
width: containerWidthValue
|
|
447
451
|
} = containerWidth;
|
|
448
452
|
const isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
449
453
|
const wasTableResized = hasTableBeenResized(this.node);
|
|
450
|
-
const
|
|
451
|
-
const isColumnsDistributed = wasTableResized && !
|
|
452
|
-
|
|
454
|
+
const isTableResized = hasTableBeenResized(tableNode);
|
|
455
|
+
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
456
|
+
const shouldScale = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged;
|
|
457
|
+
if (force || !isResizing && shouldScale) {
|
|
453
458
|
const resizeState = getResizeState({
|
|
454
459
|
minWidth: COLUMN_MIN_WIDTH,
|
|
455
460
|
maxSize: tableRenderWidth,
|
|
@@ -466,6 +471,8 @@ class TableComponent extends React.Component {
|
|
|
466
471
|
});
|
|
467
472
|
}
|
|
468
473
|
}
|
|
474
|
+
this.tableNodeWidth = tableNodeWidth;
|
|
475
|
+
this.wasResizing = isResizing;
|
|
469
476
|
this.containerWidth = containerWidth;
|
|
470
477
|
}
|
|
471
478
|
componentDidUpdate(_, prevState) {
|
|
@@ -35,7 +35,8 @@ export const getResizeState = ({
|
|
|
35
35
|
widths,
|
|
36
36
|
maxSize,
|
|
37
37
|
tableWidth,
|
|
38
|
-
overflow
|
|
38
|
+
overflow,
|
|
39
|
+
isScaled: isTableScalingEnabled
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
const shouldReinsertColgroup = !isTableScalingEnabled;
|
|
@@ -65,7 +66,8 @@ export const getResizeState = ({
|
|
|
65
66
|
widths,
|
|
66
67
|
maxSize,
|
|
67
68
|
tableWidth,
|
|
68
|
-
overflow
|
|
69
|
+
overflow,
|
|
70
|
+
isScaled: isTableScalingEnabled
|
|
69
71
|
};
|
|
70
72
|
};
|
|
71
73
|
|
|
@@ -22,9 +22,13 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
22
22
|
// calculating new attributes for each cell
|
|
23
23
|
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
24
24
|
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
25
|
-
|
|
25
|
+
let {
|
|
26
26
|
width
|
|
27
27
|
} = resizeState.cols[columnIndex];
|
|
28
|
+
if (resizeState.isScaled) {
|
|
29
|
+
// Ensure that the width is an integer if the table has been scaled
|
|
30
|
+
width = Math.floor(width);
|
|
31
|
+
}
|
|
28
32
|
const mapIndex = rowIndex * map.width + columnIndex;
|
|
29
33
|
const cellPos = map.map[mapIndex];
|
|
30
34
|
const attrs = updatedCellsAttrs[cellPos] || {
|
|
@@ -450,15 +450,20 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
450
450
|
return;
|
|
451
451
|
}
|
|
452
452
|
var tableNodeWidth = getTableContainerWidth(tableNode);
|
|
453
|
-
var
|
|
454
|
-
|
|
453
|
+
var isTableResizedFullWidth = tableNodeWidth === 1800 && this.wasResizing && !isResizing;
|
|
454
|
+
// Needed for undo / redo
|
|
455
|
+
var isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
456
|
+
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
457
|
+
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth;
|
|
458
|
+
if (force || maybeScale) {
|
|
455
459
|
var _this$containerWidth;
|
|
456
460
|
var containerWidthValue = containerWidth.width;
|
|
457
461
|
var isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
458
462
|
var wasTableResized = hasTableBeenResized(this.node);
|
|
459
|
-
var
|
|
460
|
-
var isColumnsDistributed = wasTableResized && !
|
|
461
|
-
|
|
463
|
+
var isTableResized = hasTableBeenResized(tableNode);
|
|
464
|
+
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
465
|
+
var shouldScale = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged;
|
|
466
|
+
if (force || !isResizing && shouldScale) {
|
|
462
467
|
var resizeState = getResizeState({
|
|
463
468
|
minWidth: COLUMN_MIN_WIDTH,
|
|
464
469
|
maxSize: tableRenderWidth,
|
|
@@ -475,6 +480,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
475
480
|
});
|
|
476
481
|
}
|
|
477
482
|
}
|
|
483
|
+
this.tableNodeWidth = tableNodeWidth;
|
|
484
|
+
this.wasResizing = isResizing;
|
|
478
485
|
this.containerWidth = containerWidth;
|
|
479
486
|
}
|
|
480
487
|
}, {
|
|
@@ -44,7 +44,8 @@ export var getResizeState = function getResizeState(_ref) {
|
|
|
44
44
|
widths: _widths,
|
|
45
45
|
maxSize: maxSize,
|
|
46
46
|
tableWidth: _tableWidth,
|
|
47
|
-
overflow: _overflow
|
|
47
|
+
overflow: _overflow,
|
|
48
|
+
isScaled: isTableScalingEnabled
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
var shouldReinsertColgroup = !isTableScalingEnabled;
|
|
@@ -78,7 +79,8 @@ export var getResizeState = function getResizeState(_ref) {
|
|
|
78
79
|
widths: widths,
|
|
79
80
|
maxSize: maxSize,
|
|
80
81
|
tableWidth: tableWidth,
|
|
81
|
-
overflow: overflow
|
|
82
|
+
overflow: overflow,
|
|
83
|
+
isScaled: isTableScalingEnabled
|
|
82
84
|
};
|
|
83
85
|
};
|
|
84
86
|
|
|
@@ -27,6 +27,10 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
27
27
|
for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
28
28
|
for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
29
29
|
var width = resizeState.cols[columnIndex].width;
|
|
30
|
+
if (resizeState.isScaled) {
|
|
31
|
+
// Ensure that the width is an integer if the table has been scaled
|
|
32
|
+
width = Math.floor(width);
|
|
33
|
+
}
|
|
30
34
|
var mapIndex = rowIndex * map.width + columnIndex;
|
|
31
35
|
var cellPos = map.map[mapIndex];
|
|
32
36
|
var attrs = updatedCellsAttrs[cellPos] || _objectSpread({}, table.nodeAt(cellPos).attrs);
|
|
@@ -47,6 +47,8 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
|
|
|
47
47
|
private table?;
|
|
48
48
|
private node;
|
|
49
49
|
private containerWidth?;
|
|
50
|
+
private wasResizing?;
|
|
51
|
+
private tableNodeWidth?;
|
|
50
52
|
private layoutSize?;
|
|
51
53
|
private overflowShadowsObserver?;
|
|
52
54
|
private stickyScrollbar?;
|
|
@@ -47,6 +47,8 @@ declare class TableComponent extends React.Component<ComponentProps, TableState>
|
|
|
47
47
|
private table?;
|
|
48
48
|
private node;
|
|
49
49
|
private containerWidth?;
|
|
50
|
+
private wasResizing?;
|
|
51
|
+
private tableNodeWidth?;
|
|
50
52
|
private layoutSize?;
|
|
51
53
|
private overflowShadowsObserver?;
|
|
52
54
|
private stickyScrollbar?;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.15",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/icon": "^22.1.0",
|
|
44
44
|
"@atlaskit/menu": "^2.1.5",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
46
|
-
"@atlaskit/pragmatic-drag-and-drop": "^1.
|
|
46
|
+
"@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.0.0",
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
49
49
|
"@atlaskit/primitives": "^5.1.0",
|
|
@@ -140,6 +140,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
140
140
|
private table?: HTMLTableElement | null;
|
|
141
141
|
private node: PmNode;
|
|
142
142
|
private containerWidth?: EditorContainerWidth;
|
|
143
|
+
private wasResizing?: boolean;
|
|
144
|
+
private tableNodeWidth?: number;
|
|
143
145
|
private layoutSize?: number;
|
|
144
146
|
private overflowShadowsObserver?: OverflowShadowsObserver;
|
|
145
147
|
private stickyScrollbar?: TableStickyScrollbar;
|
|
@@ -338,16 +340,26 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
338
340
|
}
|
|
339
341
|
|
|
340
342
|
const tableNodeWidth = getTableContainerWidth(tableNode);
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
+
const isTableResizedFullWidth =
|
|
344
|
+
tableNodeWidth === 1800 && this.wasResizing && !isResizing;
|
|
345
|
+
// Needed for undo / redo
|
|
346
|
+
const isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
347
|
+
const isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
348
|
+
|
|
349
|
+
const maybeScale =
|
|
350
|
+
isTableSquashed || isTableWidthChanged || isTableResizedFullWidth;
|
|
351
|
+
if (force || maybeScale) {
|
|
343
352
|
const { width: containerWidthValue } = containerWidth;
|
|
344
353
|
const isWidthChanged = this.containerWidth?.width !== containerWidthValue;
|
|
345
|
-
|
|
346
354
|
const wasTableResized = hasTableBeenResized(this.node);
|
|
347
|
-
const
|
|
348
|
-
const isColumnsDistributed = wasTableResized && !
|
|
349
|
-
|
|
350
|
-
|
|
355
|
+
const isTableResized = hasTableBeenResized(tableNode);
|
|
356
|
+
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
357
|
+
const shouldScale =
|
|
358
|
+
isWidthChanged ||
|
|
359
|
+
isColumnsDistributed ||
|
|
360
|
+
isTableResizedFullWidth ||
|
|
361
|
+
isTableWidthChanged;
|
|
362
|
+
if (force || (!isResizing && shouldScale)) {
|
|
351
363
|
const resizeState = getResizeState({
|
|
352
364
|
minWidth: COLUMN_MIN_WIDTH,
|
|
353
365
|
maxSize: tableRenderWidth,
|
|
@@ -364,6 +376,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
364
376
|
});
|
|
365
377
|
}
|
|
366
378
|
}
|
|
379
|
+
this.tableNodeWidth = tableNodeWidth;
|
|
380
|
+
this.wasResizing = isResizing;
|
|
367
381
|
this.containerWidth = containerWidth;
|
|
368
382
|
}
|
|
369
383
|
|
|
@@ -63,6 +63,7 @@ export const getResizeState = ({
|
|
|
63
63
|
maxSize,
|
|
64
64
|
tableWidth,
|
|
65
65
|
overflow,
|
|
66
|
+
isScaled: isTableScalingEnabled,
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -101,6 +102,7 @@ export const getResizeState = ({
|
|
|
101
102
|
maxSize,
|
|
102
103
|
tableWidth,
|
|
103
104
|
overflow,
|
|
105
|
+
isScaled: isTableScalingEnabled,
|
|
104
106
|
};
|
|
105
107
|
};
|
|
106
108
|
|
|
@@ -35,7 +35,11 @@ export const updateColumnWidths =
|
|
|
35
35
|
// calculating new attributes for each cell
|
|
36
36
|
for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
|
|
37
37
|
for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
|
|
38
|
-
|
|
38
|
+
let { width } = resizeState.cols[columnIndex];
|
|
39
|
+
if (resizeState.isScaled) {
|
|
40
|
+
// Ensure that the width is an integer if the table has been scaled
|
|
41
|
+
width = Math.floor(width);
|
|
42
|
+
}
|
|
39
43
|
const mapIndex = rowIndex * map.width + columnIndex;
|
|
40
44
|
const cellPos = map.map[mapIndex];
|
|
41
45
|
const attrs = updatedCellsAttrs[cellPos] || {
|