@atlaskit/editor-plugin-table 7.13.1 → 7.13.3
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 +17 -0
- package/dist/cjs/nodeviews/TableContainer.js +10 -10
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +10 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +6 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +8 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +51 -34
- package/dist/es2019/nodeviews/TableContainer.js +12 -10
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +11 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +7 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +49 -34
- package/dist/esm/nodeviews/TableContainer.js +10 -10
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +11 -4
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +7 -0
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +50 -33
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -0
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -4
- package/dist/types/ui/TableFloatingControls/index.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -0
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -4
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/nodeviews/TableContainer.tsx +11 -9
- package/src/pm-plugins/table-resizing/event-handlers.ts +43 -21
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +11 -0
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +85 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.13.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#99050](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99050)
|
|
8
|
+
[`d280c1f18875`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d280c1f18875) -
|
|
9
|
+
Enforce table container width when live pages view mode is enabled
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 7.13.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#97570](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97570)
|
|
17
|
+
[`d53d6981c3ce`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d53d6981c3ce) -
|
|
18
|
+
Clean up resizing logic and stop growing table container when overflowed
|
|
19
|
+
|
|
3
20
|
## 7.13.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.TableContainer = exports.ResizableTableContainer = exports.InnerContainer = void 0;
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -18,8 +17,6 @@ var _types = require("../types");
|
|
|
18
17
|
var _TableResizer = require("./TableResizer");
|
|
19
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
20
|
var InnerContainer = exports.InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
24
21
|
var className = _ref.className,
|
|
25
22
|
style = _ref.style,
|
|
@@ -130,12 +127,11 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
130
127
|
displayGapCursor: displayGapCursor,
|
|
131
128
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
132
129
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
133
|
-
pluginInjectionApi: pluginInjectionApi
|
|
134
|
-
};
|
|
135
|
-
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
130
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
136
131
|
onResizeStart: onResizeStart,
|
|
137
132
|
onResizeStop: onResizeStop
|
|
138
|
-
}
|
|
133
|
+
};
|
|
134
|
+
var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
139
135
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
140
136
|
style: {
|
|
141
137
|
display: 'flex',
|
|
@@ -144,13 +140,17 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
144
140
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
145
141
|
style: {
|
|
146
142
|
width: tableWidthRef.current,
|
|
147
|
-
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto'
|
|
143
|
+
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto',
|
|
144
|
+
position: isLivePageViewMode ? 'relative' : 'unset'
|
|
148
145
|
},
|
|
149
146
|
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
150
147
|
ref: containerRef
|
|
151
|
-
},
|
|
148
|
+
}, isLivePageViewMode ? /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
152
149
|
className: className,
|
|
153
|
-
node: node
|
|
150
|
+
node: node,
|
|
151
|
+
style: {
|
|
152
|
+
width: 'inherit'
|
|
153
|
+
}
|
|
154
154
|
}, children) : /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, tableResizerProps, /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
155
155
|
className: className,
|
|
156
156
|
node: node
|
|
@@ -141,11 +141,14 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
141
141
|
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
142
142
|
_shouldScale = _shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
143
143
|
}
|
|
144
|
-
var newResizeState = (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
145
144
|
var resizedDelta = clientX - startX;
|
|
146
|
-
tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
|
|
147
145
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
146
|
+
var newResizeState = (0, _utils3.resizeColumnAndTable)(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
147
|
+
tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
|
|
148
148
|
tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
|
|
149
|
+
} else {
|
|
150
|
+
var _newResizeState = (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
151
|
+
tr = (0, _transforms.updateColumnWidths)(_newResizeState, table, start)(tr);
|
|
149
152
|
}
|
|
150
153
|
if (colIndex === map.width - 1) {
|
|
151
154
|
var mouseUpTime = event.timeStamp;
|
|
@@ -215,7 +218,11 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
215
218
|
if (isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
216
219
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
217
220
|
}
|
|
218
|
-
(0,
|
|
221
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
222
|
+
(0, _utils3.resizeColumnAndTable)(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
223
|
+
} else {
|
|
224
|
+
(0, _utils3.resizeColumn)(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
225
|
+
}
|
|
219
226
|
(0, _utils3.updateControls)()(state);
|
|
220
227
|
}
|
|
221
228
|
window.addEventListener('mouseup', finish);
|
|
@@ -207,6 +207,12 @@ Object.defineProperty(exports, "resizeColumn", {
|
|
|
207
207
|
return _resizeColumn.resizeColumn;
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
|
+
Object.defineProperty(exports, "resizeColumnAndTable", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
get: function get() {
|
|
213
|
+
return _resizeColumn.resizeColumnAndTable;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
210
216
|
Object.defineProperty(exports, "scale", {
|
|
211
217
|
enumerable: true,
|
|
212
218
|
get: function get() {
|
|
@@ -7,7 +7,7 @@ exports.currentColWidth = currentColWidth;
|
|
|
7
7
|
exports.domCellAround = domCellAround;
|
|
8
8
|
exports.getDefaultLayoutMaxWidth = getDefaultLayoutMaxWidth;
|
|
9
9
|
exports.getLayoutSize = getLayoutSize;
|
|
10
|
-
exports.getTableScalingPercent = exports.getTableMaxWidth = exports.getTableElementWidth = exports.getTableContainerElementWidth = void 0;
|
|
10
|
+
exports.getTableScalingPercent = exports.getTableMaxWidth = exports.getTableElementWidth = exports.getTableContainerElementWidth = exports.getStaticTableScalingPercent = void 0;
|
|
11
11
|
exports.pointsAtCell = pointsAtCell;
|
|
12
12
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
13
13
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
@@ -108,4 +108,11 @@ var getTableScalingPercent = exports.getTableScalingPercent = function getTableS
|
|
|
108
108
|
var scalePercent = (renderWidth - 1) / tableWidth;
|
|
109
109
|
scalePercent = Math.max(scalePercent, 1 - _consts.MAX_SCALING_PERCENT);
|
|
110
110
|
return Math.min(scalePercent, 1);
|
|
111
|
+
};
|
|
112
|
+
var getStaticTableScalingPercent = exports.getStaticTableScalingPercent = function getStaticTableScalingPercent(table, tableRenderWidth) {
|
|
113
|
+
var tableWidth = getTableContainerElementWidth(table);
|
|
114
|
+
// minus 1 here to avoid any 1px scroll in Firefox
|
|
115
|
+
var scalePercent = (tableRenderWidth - 1) / tableWidth;
|
|
116
|
+
scalePercent = Math.max(scalePercent, 1 - _consts.MAX_SCALING_PERCENT);
|
|
117
|
+
return Math.min(scalePercent, 1);
|
|
111
118
|
};
|
|
@@ -4,9 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.resizeColumn = void 0;
|
|
7
|
+
exports.resizeColumnAndTable = exports.resizeColumn = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
9
|
var _types = require("../../../types");
|
|
11
10
|
var _misc = require("./misc");
|
|
12
11
|
var _resizeLogic = require("./resize-logic");
|
|
@@ -15,47 +14,65 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
15
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // Resize a given column by an amount from the current state
|
|
16
15
|
var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
|
|
17
16
|
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
18
|
-
// If table resize to show overflowed content, we need to re calculate the resize amount because now offset = amount amount instead of amount * 2
|
|
19
17
|
var scalePercent = 1;
|
|
20
|
-
var resizeAmount;
|
|
21
|
-
if (
|
|
22
|
-
var _tableRef$closest;
|
|
23
|
-
// when table initially not overflow, but enter overflow, we need to calculate the resize amount by two part, before and after overflow, before overflow should be double, after should not be double.
|
|
24
|
-
var tableWidth = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth;
|
|
25
|
-
var tableContainerWidth = tableRef === null || tableRef === void 0 || (_tableRef$closest = tableRef.closest('.resizer-item')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
26
|
-
var isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
|
|
27
|
-
resizeAmount = amount * 2;
|
|
28
|
-
if (isOverflowed) {
|
|
29
|
-
resizeAmount = amount < 0 ? amount : resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2;
|
|
30
|
-
} else {
|
|
31
|
-
resizeAmount = amount > 0 && tableContainerWidth ? resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2 : resizeAmount;
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
resizeAmount = amount;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// This need to be clean up if clean up the FF, we will not need this scale logic because now full table width changed/updated in resizeColumn
|
|
38
|
-
if (isTableScalingEnabled && !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
18
|
+
var resizeAmount = amount;
|
|
19
|
+
if (isTableScalingEnabled) {
|
|
39
20
|
scalePercent = (0, _misc.getTableScalingPercent)(tableNode, tableRef);
|
|
40
21
|
resizeAmount = amount / scalePercent;
|
|
41
22
|
}
|
|
42
|
-
var newState =
|
|
43
|
-
(0,
|
|
44
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
45
|
-
// use the difference in width from affected column to update overall table width
|
|
46
|
-
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
47
|
-
updateTable(delta, tableRef, tableNode);
|
|
48
|
-
return _objectSpread(_objectSpread({}, newState), {}, {
|
|
49
|
-
tableWidth: resizeState.tableWidth + delta
|
|
50
|
-
});
|
|
51
|
-
}
|
|
23
|
+
var newState = resizeAmount > 0 ? (0, _resizeLogic.growColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? (0, _resizeLogic.shrinkColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
24
|
+
(0, _resizeState.updateColgroup)(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
52
25
|
return newState;
|
|
53
26
|
};
|
|
54
|
-
|
|
27
|
+
|
|
28
|
+
// try not scale table during resize
|
|
29
|
+
var resizeColumnAndTable = exports.resizeColumnAndTable = function resizeColumnAndTable(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
|
|
30
|
+
var _tableRef$closest;
|
|
31
|
+
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
32
|
+
var originalTableWidth = arguments.length > 7 ? arguments[7] : undefined;
|
|
33
|
+
// TODO: can we use document state, and apply scaling factor?
|
|
34
|
+
var tableWidth = tableRef.clientWidth;
|
|
35
|
+
var tableContainerWidth = (_tableRef$closest = tableRef.closest('.pm-table-container')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
36
|
+
var isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
|
|
37
|
+
var resizeAmount = amount * 2;
|
|
38
|
+
|
|
39
|
+
// todo: reimplement - use getTableScalingPercentFrozen to get scaled percent before table width changes dynamically
|
|
40
|
+
// let scalePercent = 1;
|
|
41
|
+
// if (isTableScalingEnabled) {
|
|
42
|
+
// import from ./misc
|
|
43
|
+
// scalePercent = getStaticTableScalingPercent(
|
|
44
|
+
// tableNode,
|
|
45
|
+
// originalTableWidth || resizeState.maxSize,
|
|
46
|
+
// );
|
|
47
|
+
// resizeAmount = amount / scalePercent;
|
|
48
|
+
// }
|
|
49
|
+
|
|
50
|
+
// need to look at the resize amount and try to adjust the colgroups
|
|
51
|
+
if (isOverflowed) {
|
|
52
|
+
resizeAmount = amount < 0 ? amount : resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2;
|
|
53
|
+
} else {
|
|
54
|
+
resizeAmount = amount > 0 && tableContainerWidth ? resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2 : resizeAmount;
|
|
55
|
+
}
|
|
56
|
+
var newState = (0, _resizeLogic.updateAffectedColumn)(resizeState, colIndex, resizeAmount);
|
|
57
|
+
|
|
58
|
+
// this function only updates the colgroup in DOM, it reverses the scalePercent
|
|
59
|
+
// todo: change isScalingEnabled to true when reimplementing scaling
|
|
60
|
+
(0, _resizeState.updateColgroup)(newState, tableRef, tableNode, false);
|
|
61
|
+
|
|
62
|
+
// use the difference in width from affected column to update overall table width
|
|
63
|
+
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
64
|
+
if (!isOverflowed) {
|
|
65
|
+
updateTablePreview(delta, tableRef, tableNode);
|
|
66
|
+
}
|
|
67
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
|
68
|
+
tableWidth: isOverflowed ? tableContainerWidth : resizeState.tableWidth + delta
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
var updateTablePreview = function updateTablePreview(resizeAmount, tableRef, tableNode) {
|
|
55
72
|
var currentWidth = (0, _misc.getTableContainerElementWidth)(tableNode);
|
|
56
73
|
var resizingContainer = tableRef === null || tableRef === void 0 ? void 0 : tableRef.closest(".".concat(_types.TableCssClassName.TABLE_RESIZER_CONTAINER));
|
|
57
74
|
var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
58
|
-
if (
|
|
75
|
+
if (resizingItem) {
|
|
59
76
|
var newWidth = "".concat(currentWidth + resizeAmount, "px");
|
|
60
77
|
if (tableRef) {
|
|
61
78
|
tableRef.style.width = newWidth;
|
|
@@ -102,7 +102,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
102
102
|
tableWidthRef.current = width;
|
|
103
103
|
}
|
|
104
104
|
const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
105
|
-
|
|
105
|
+
const tableResizerProps = {
|
|
106
106
|
width,
|
|
107
107
|
maxWidth: maxResizerWidth,
|
|
108
108
|
containerWidth,
|
|
@@ -116,13 +116,11 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
116
116
|
displayGapCursor,
|
|
117
117
|
isTableScalingEnabled,
|
|
118
118
|
isWholeTableInDanger,
|
|
119
|
-
pluginInjectionApi
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
...tableResizerProps,
|
|
123
|
-
onResizeStart: onResizeStart,
|
|
124
|
-
onResizeStop: onResizeStop
|
|
119
|
+
pluginInjectionApi,
|
|
120
|
+
onResizeStart,
|
|
121
|
+
onResizeStop
|
|
125
122
|
};
|
|
123
|
+
const isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
126
124
|
return /*#__PURE__*/React.createElement("div", {
|
|
127
125
|
style: {
|
|
128
126
|
display: 'flex',
|
|
@@ -131,13 +129,17 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
131
129
|
}, /*#__PURE__*/React.createElement("div", {
|
|
132
130
|
style: {
|
|
133
131
|
width: tableWidthRef.current,
|
|
134
|
-
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto'
|
|
132
|
+
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto',
|
|
133
|
+
position: isLivePageViewMode ? 'relative' : 'unset'
|
|
135
134
|
},
|
|
136
135
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
137
136
|
ref: containerRef
|
|
138
|
-
},
|
|
137
|
+
}, isLivePageViewMode ? /*#__PURE__*/React.createElement(InnerContainer, {
|
|
139
138
|
className: className,
|
|
140
|
-
node: node
|
|
139
|
+
node: node,
|
|
140
|
+
style: {
|
|
141
|
+
width: 'inherit'
|
|
142
|
+
}
|
|
141
143
|
}, children) : /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
142
144
|
className: className,
|
|
143
145
|
node: node
|
|
@@ -11,7 +11,7 @@ import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
|
11
11
|
import { META_KEYS } from '../table-analytics';
|
|
12
12
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
13
13
|
import { getPluginState } from './plugin-factory';
|
|
14
|
-
import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
14
|
+
import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, resizeColumnAndTable, updateControls } from './utils';
|
|
15
15
|
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, editorAnalyticsAPI) => {
|
|
16
16
|
const {
|
|
17
17
|
state,
|
|
@@ -148,11 +148,14 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
148
148
|
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
149
149
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
150
150
|
}
|
|
151
|
-
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale);
|
|
152
151
|
const resizedDelta = clientX - startX;
|
|
153
|
-
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
154
152
|
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
153
|
+
const newResizeState = resizeColumnAndTable(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale);
|
|
154
|
+
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
155
155
|
tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
|
|
156
|
+
} else {
|
|
157
|
+
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale);
|
|
158
|
+
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
156
159
|
}
|
|
157
160
|
if (colIndex === map.width - 1) {
|
|
158
161
|
const mouseUpTime = event.timeStamp;
|
|
@@ -228,7 +231,11 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
228
231
|
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
229
232
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
230
233
|
}
|
|
231
|
-
|
|
234
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
235
|
+
resizeColumnAndTable(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
236
|
+
} else {
|
|
237
|
+
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
238
|
+
}
|
|
232
239
|
updateControls()(state);
|
|
233
240
|
}
|
|
234
241
|
window.addEventListener('mouseup', finish);
|
|
@@ -6,5 +6,5 @@ export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bu
|
|
|
6
6
|
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth, getTableElementWidth, getTableContainerElementWidth } from './misc';
|
|
7
7
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
8
8
|
export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
|
|
9
|
-
export { resizeColumn } from './resize-column';
|
|
9
|
+
export { resizeColumn, resizeColumnAndTable } from './resize-column';
|
|
10
10
|
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH, TABLE_DEFAULT_WIDTH, MAX_SCALING_PERCENT } from './consts';
|
|
@@ -98,4 +98,11 @@ export const getTableScalingPercent = (table, tableRef) => {
|
|
|
98
98
|
let scalePercent = (renderWidth - 1) / tableWidth;
|
|
99
99
|
scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
|
|
100
100
|
return Math.min(scalePercent, 1);
|
|
101
|
+
};
|
|
102
|
+
export const getStaticTableScalingPercent = (table, tableRenderWidth) => {
|
|
103
|
+
const tableWidth = getTableContainerElementWidth(table);
|
|
104
|
+
// minus 1 here to avoid any 1px scroll in Firefox
|
|
105
|
+
let scalePercent = (tableRenderWidth - 1) / tableWidth;
|
|
106
|
+
scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
|
|
107
|
+
return Math.min(scalePercent, 1);
|
|
101
108
|
};
|
|
@@ -1,53 +1,68 @@
|
|
|
1
1
|
// Resize a given column by an amount from the current state
|
|
2
2
|
|
|
3
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
5
4
|
import { getTableContainerElementWidth, getTableScalingPercent } from './misc';
|
|
6
5
|
import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
|
|
7
6
|
import { updateColgroup } from './resize-state';
|
|
8
7
|
export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false) => {
|
|
9
|
-
// If table resize to show overflowed content, we need to re calculate the resize amount because now offset = amount amount instead of amount * 2
|
|
10
8
|
let scalePercent = 1;
|
|
11
|
-
let resizeAmount;
|
|
12
|
-
if (
|
|
13
|
-
var _tableRef$closest;
|
|
14
|
-
// when table initially not overflow, but enter overflow, we need to calculate the resize amount by two part, before and after overflow, before overflow should be double, after should not be double.
|
|
15
|
-
const tableWidth = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth;
|
|
16
|
-
const tableContainerWidth = tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$closest = tableRef.closest('.resizer-item')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
17
|
-
const isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
|
|
18
|
-
resizeAmount = amount * 2;
|
|
19
|
-
if (isOverflowed) {
|
|
20
|
-
resizeAmount = amount < 0 ? amount : resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2;
|
|
21
|
-
} else {
|
|
22
|
-
resizeAmount = amount > 0 && tableContainerWidth ? resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2 : resizeAmount;
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
resizeAmount = amount;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// This need to be clean up if clean up the FF, we will not need this scale logic because now full table width changed/updated in resizeColumn
|
|
29
|
-
if (isTableScalingEnabled && !getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
9
|
+
let resizeAmount = amount;
|
|
10
|
+
if (isTableScalingEnabled) {
|
|
30
11
|
scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
31
12
|
resizeAmount = amount / scalePercent;
|
|
32
13
|
}
|
|
33
|
-
const newState =
|
|
34
|
-
|
|
35
|
-
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
36
|
-
// use the difference in width from affected column to update overall table width
|
|
37
|
-
const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
38
|
-
updateTable(delta, tableRef, tableNode);
|
|
39
|
-
return {
|
|
40
|
-
...newState,
|
|
41
|
-
tableWidth: resizeState.tableWidth + delta
|
|
42
|
-
};
|
|
43
|
-
}
|
|
14
|
+
const newState = resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
15
|
+
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
44
16
|
return newState;
|
|
45
17
|
};
|
|
46
|
-
|
|
18
|
+
|
|
19
|
+
// try not scale table during resize
|
|
20
|
+
export const resizeColumnAndTable = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false, originalTableWidth) => {
|
|
21
|
+
var _tableRef$closest;
|
|
22
|
+
// TODO: can we use document state, and apply scaling factor?
|
|
23
|
+
const tableWidth = tableRef.clientWidth;
|
|
24
|
+
const tableContainerWidth = (_tableRef$closest = tableRef.closest('.pm-table-container')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
25
|
+
const isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
|
|
26
|
+
let resizeAmount = amount * 2;
|
|
27
|
+
|
|
28
|
+
// todo: reimplement - use getTableScalingPercentFrozen to get scaled percent before table width changes dynamically
|
|
29
|
+
// let scalePercent = 1;
|
|
30
|
+
// if (isTableScalingEnabled) {
|
|
31
|
+
// import from ./misc
|
|
32
|
+
// scalePercent = getStaticTableScalingPercent(
|
|
33
|
+
// tableNode,
|
|
34
|
+
// originalTableWidth || resizeState.maxSize,
|
|
35
|
+
// );
|
|
36
|
+
// resizeAmount = amount / scalePercent;
|
|
37
|
+
// }
|
|
38
|
+
|
|
39
|
+
// need to look at the resize amount and try to adjust the colgroups
|
|
40
|
+
if (isOverflowed) {
|
|
41
|
+
resizeAmount = amount < 0 ? amount : resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2;
|
|
42
|
+
} else {
|
|
43
|
+
resizeAmount = amount > 0 && tableContainerWidth ? resizeAmount - (tableNode.attrs.width + resizeAmount - tableContainerWidth) / 2 : resizeAmount;
|
|
44
|
+
}
|
|
45
|
+
const newState = updateAffectedColumn(resizeState, colIndex, resizeAmount);
|
|
46
|
+
|
|
47
|
+
// this function only updates the colgroup in DOM, it reverses the scalePercent
|
|
48
|
+
// todo: change isScalingEnabled to true when reimplementing scaling
|
|
49
|
+
updateColgroup(newState, tableRef, tableNode, false);
|
|
50
|
+
|
|
51
|
+
// use the difference in width from affected column to update overall table width
|
|
52
|
+
const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
53
|
+
if (!isOverflowed) {
|
|
54
|
+
updateTablePreview(delta, tableRef, tableNode);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
...newState,
|
|
58
|
+
tableWidth: isOverflowed ? tableContainerWidth : resizeState.tableWidth + delta
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const updateTablePreview = (resizeAmount, tableRef, tableNode) => {
|
|
47
62
|
const currentWidth = getTableContainerElementWidth(tableNode);
|
|
48
63
|
const resizingContainer = tableRef === null || tableRef === void 0 ? void 0 : tableRef.closest(`.${ClassName.TABLE_RESIZER_CONTAINER}`);
|
|
49
64
|
const resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
50
|
-
if (
|
|
65
|
+
if (resizingItem) {
|
|
51
66
|
const newWidth = `${currentWidth + resizeAmount}px`;
|
|
52
67
|
if (tableRef) {
|
|
53
68
|
tableRef.style.width = newWidth;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
2
|
import React, { forwardRef, useCallback, useRef, useState } from 'react';
|
|
6
3
|
import classNames from 'classnames';
|
|
7
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
@@ -120,12 +117,11 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
120
117
|
displayGapCursor: displayGapCursor,
|
|
121
118
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
122
119
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
123
|
-
pluginInjectionApi: pluginInjectionApi
|
|
124
|
-
};
|
|
125
|
-
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
120
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
126
121
|
onResizeStart: onResizeStart,
|
|
127
122
|
onResizeStop: onResizeStop
|
|
128
|
-
}
|
|
123
|
+
};
|
|
124
|
+
var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
129
125
|
return /*#__PURE__*/React.createElement("div", {
|
|
130
126
|
style: {
|
|
131
127
|
display: 'flex',
|
|
@@ -134,13 +130,17 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
134
130
|
}, /*#__PURE__*/React.createElement("div", {
|
|
135
131
|
style: {
|
|
136
132
|
width: tableWidthRef.current,
|
|
137
|
-
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto'
|
|
133
|
+
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto',
|
|
134
|
+
position: isLivePageViewMode ? 'relative' : 'unset'
|
|
138
135
|
},
|
|
139
136
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
140
137
|
ref: containerRef
|
|
141
|
-
},
|
|
138
|
+
}, isLivePageViewMode ? /*#__PURE__*/React.createElement(InnerContainer, {
|
|
142
139
|
className: className,
|
|
143
|
-
node: node
|
|
140
|
+
node: node,
|
|
141
|
+
style: {
|
|
142
|
+
width: 'inherit'
|
|
143
|
+
}
|
|
144
144
|
}, children) : /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
145
145
|
className: className,
|
|
146
146
|
node: node
|
|
@@ -11,7 +11,7 @@ import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
|
11
11
|
import { META_KEYS } from '../table-analytics';
|
|
12
12
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
13
13
|
import { getPluginState } from './plugin-factory';
|
|
14
|
-
import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
14
|
+
import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, resizeColumnAndTable, updateControls } from './utils';
|
|
15
15
|
export var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, editorAnalyticsAPI) {
|
|
16
16
|
var state = view.state,
|
|
17
17
|
dispatch = view.dispatch;
|
|
@@ -135,11 +135,14 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
135
135
|
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
136
136
|
_shouldScale = _shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
137
137
|
}
|
|
138
|
-
var newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
139
138
|
var resizedDelta = clientX - startX;
|
|
140
|
-
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
141
139
|
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
140
|
+
var newResizeState = resizeColumnAndTable(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
141
|
+
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
142
142
|
tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
|
|
143
|
+
} else {
|
|
144
|
+
var _newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
145
|
+
tr = updateColumnWidths(_newResizeState, table, start)(tr);
|
|
143
146
|
}
|
|
144
147
|
if (colIndex === map.width - 1) {
|
|
145
148
|
var mouseUpTime = event.timeStamp;
|
|
@@ -209,7 +212,11 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
209
212
|
if (isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
|
|
210
213
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
211
214
|
}
|
|
212
|
-
|
|
215
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
216
|
+
resizeColumnAndTable(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
217
|
+
} else {
|
|
218
|
+
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, shouldScale);
|
|
219
|
+
}
|
|
213
220
|
updateControls()(state);
|
|
214
221
|
}
|
|
215
222
|
window.addEventListener('mouseup', finish);
|
|
@@ -6,5 +6,5 @@ export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bu
|
|
|
6
6
|
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth, getTableElementWidth, getTableContainerElementWidth } from './misc';
|
|
7
7
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
8
8
|
export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
|
|
9
|
-
export { resizeColumn } from './resize-column';
|
|
9
|
+
export { resizeColumn, resizeColumnAndTable } from './resize-column';
|
|
10
10
|
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH, TABLE_DEFAULT_WIDTH, MAX_SCALING_PERCENT } from './consts';
|
|
@@ -98,4 +98,11 @@ export var getTableScalingPercent = function getTableScalingPercent(table, table
|
|
|
98
98
|
var scalePercent = (renderWidth - 1) / tableWidth;
|
|
99
99
|
scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
|
|
100
100
|
return Math.min(scalePercent, 1);
|
|
101
|
+
};
|
|
102
|
+
export var getStaticTableScalingPercent = function getStaticTableScalingPercent(table, tableRenderWidth) {
|
|
103
|
+
var tableWidth = getTableContainerElementWidth(table);
|
|
104
|
+
// minus 1 here to avoid any 1px scroll in Firefox
|
|
105
|
+
var scalePercent = (tableRenderWidth - 1) / tableWidth;
|
|
106
|
+
scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
|
|
107
|
+
return Math.min(scalePercent, 1);
|
|
101
108
|
};
|