@atlaskit/editor-plugin-table 7.7.0 → 7.7.2
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 +15 -0
- package/dist/cjs/nodeviews/TableContainer.js +4 -7
- package/dist/cjs/nodeviews/TableResizer.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +3 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +32 -5
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +19 -0
- package/dist/es2019/nodeviews/TableContainer.js +5 -8
- package/dist/es2019/nodeviews/TableResizer.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +3 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +31 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +20 -0
- package/dist/esm/nodeviews/TableContainer.js +4 -7
- package/dist/esm/nodeviews/TableResizer.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +3 -0
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +33 -5
- package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +18 -0
- package/dist/types/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/package.json +7 -7
- package/src/nodeviews/TableContainer.tsx +5 -8
- package/src/nodeviews/TableResizer.tsx +2 -8
- package/src/pm-plugins/table-resizing/event-handlers.ts +4 -0
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +57 -10
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.7.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92335](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92335) [`8bdb6ebbad6c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8bdb6ebbad6c) - fix column resize issue when table preserve width enabled.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 7.7.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#90896](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90896) [`ee5dc6f04816`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ee5dc6f04816) - Add new column resize functionality behind LD ff platform.editor.table.colum-resizing-improvements
|
|
15
|
+
- [#91106](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91106) [`b6ffa30186b9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b6ffa30186b9) - Bump ADF-schema package to version 35.0.0
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 7.7.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -13,7 +13,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
14
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
15
15
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
16
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
18
17
|
var _types = require("../types");
|
|
19
18
|
var _TableResizer = require("./TableResizer");
|
|
@@ -133,12 +132,10 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
133
132
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
134
133
|
pluginInjectionApi: pluginInjectionApi
|
|
135
134
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
141
|
-
}
|
|
135
|
+
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
136
|
+
onResizeStart: onResizeStart,
|
|
137
|
+
onResizeStop: onResizeStop
|
|
138
|
+
});
|
|
142
139
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
143
140
|
style: {
|
|
144
141
|
display: 'flex',
|
|
@@ -170,7 +170,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
170
170
|
dispatch(tr);
|
|
171
171
|
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, containerWidth);
|
|
172
172
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
173
|
-
if (
|
|
173
|
+
if (onResizeStart) {
|
|
174
174
|
onResizeStart();
|
|
175
175
|
}
|
|
176
176
|
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
@@ -274,7 +274,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
274
274
|
displayGuideline([]);
|
|
275
275
|
updateWidth(newWidth);
|
|
276
276
|
scheduleResize.cancel();
|
|
277
|
-
if (
|
|
277
|
+
if (onResizeStop) {
|
|
278
278
|
onResizeStop();
|
|
279
279
|
}
|
|
280
280
|
return newWidth;
|
|
@@ -141,6 +141,9 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
141
141
|
var newResizeState = (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
142
142
|
var resizedDelta = clientX - startX;
|
|
143
143
|
tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
|
|
144
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
145
|
+
tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
|
|
146
|
+
}
|
|
144
147
|
if (colIndex === map.width - 1) {
|
|
145
148
|
var mouseUpTime = event.timeStamp;
|
|
146
149
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -1,23 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.resizeColumn = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _types = require("../../../types");
|
|
7
11
|
var _misc = require("./misc");
|
|
8
12
|
var _resizeLogic = require("./resize-logic");
|
|
9
13
|
var _resizeState = require("./resize-state");
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
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; }
|
|
15
|
+
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
|
|
12
16
|
var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
|
|
13
17
|
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
14
18
|
var scalePercent = 1;
|
|
15
|
-
var resizeAmount = amount;
|
|
16
|
-
|
|
19
|
+
var resizeAmount = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements') ? amount * 2 : amount;
|
|
20
|
+
|
|
21
|
+
// 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
|
|
22
|
+
if (isTableScalingEnabled && !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
17
23
|
scalePercent = (0, _misc.getTableScalingPercent)(tableNode, tableRef);
|
|
18
24
|
resizeAmount = amount / scalePercent;
|
|
19
25
|
}
|
|
20
|
-
var newState = resizeAmount > 0 ? (0, _resizeLogic.growColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? (0, _resizeLogic.shrinkColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
26
|
+
var newState = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements') ? (0, _resizeLogic.updateAffectedColumn)(resizeState, colIndex, resizeAmount) : resizeAmount > 0 ? (0, _resizeLogic.growColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? (0, _resizeLogic.shrinkColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
21
27
|
(0, _resizeState.updateColgroup)(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
28
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
|
|
29
|
+
// use the difference in width from affected column to update overall table width
|
|
30
|
+
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
31
|
+
updateTable(delta, tableRef, tableNode);
|
|
32
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
|
33
|
+
tableWidth: resizeState.tableWidth + delta
|
|
34
|
+
});
|
|
35
|
+
}
|
|
22
36
|
return newState;
|
|
37
|
+
};
|
|
38
|
+
var updateTable = function updateTable(resizeAmount, tableRef, tableNode
|
|
39
|
+
// isTableScalingEnabled: boolean,
|
|
40
|
+
) {
|
|
41
|
+
var currentWidth = (0, _misc.getTableContainerElementWidth)(tableNode);
|
|
42
|
+
var resizingContainer = tableRef.closest(".".concat(_types.TableCssClassName.TABLE_RESIZER_CONTAINER));
|
|
43
|
+
var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
44
|
+
if (resizingContainer && resizingItem) {
|
|
45
|
+
var newWidth = "".concat(currentWidth + resizeAmount, "px");
|
|
46
|
+
tableRef.style.width = newWidth;
|
|
47
|
+
resizingContainer.style.width = newWidth;
|
|
48
|
+
resizingItem.style.width = newWidth;
|
|
49
|
+
}
|
|
23
50
|
};
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.growColumn = void 0;
|
|
8
8
|
exports.reduceSpace = reduceSpace;
|
|
9
9
|
exports.shrinkColumn = void 0;
|
|
10
|
+
exports.updateAffectedColumn = updateAffectedColumn;
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
13
|
var _columnState = require("./column-state");
|
|
@@ -224,4 +225,22 @@ function getCandidates(state, destIdx, amount) {
|
|
|
224
225
|
|
|
225
226
|
// only consider rows after the selected column in the direction of resize
|
|
226
227
|
return amount < 0 ? candidates.slice(0, destIdx) : candidates.slice(destIdx + 1);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Update the given column based on resizeAmount, maintaining all other columns
|
|
232
|
+
*/
|
|
233
|
+
function updateAffectedColumn(resizeState, colIndex, resizeAmount) {
|
|
234
|
+
var updatedCols = resizeState.cols.map(function (col, index) {
|
|
235
|
+
if (index === colIndex) {
|
|
236
|
+
var newWidth = Math.max(col.width + resizeAmount, col.minWidth);
|
|
237
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
238
|
+
width: newWidth
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return col;
|
|
242
|
+
});
|
|
243
|
+
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
244
|
+
cols: updatedCols
|
|
245
|
+
});
|
|
227
246
|
}
|
|
@@ -3,7 +3,6 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
5
5
|
import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
8
7
|
import { TableCssClassName as ClassName } from '../types';
|
|
9
8
|
import { TableResizer } from './TableResizer';
|
|
@@ -119,13 +118,11 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
119
118
|
isWholeTableInDanger,
|
|
120
119
|
pluginInjectionApi
|
|
121
120
|
};
|
|
122
|
-
|
|
123
|
-
tableResizerProps
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
128
|
-
}
|
|
121
|
+
tableResizerProps = {
|
|
122
|
+
...tableResizerProps,
|
|
123
|
+
onResizeStart: onResizeStart,
|
|
124
|
+
onResizeStop: onResizeStop
|
|
125
|
+
};
|
|
129
126
|
return /*#__PURE__*/React.createElement("div", {
|
|
130
127
|
style: {
|
|
131
128
|
display: 'flex',
|
|
@@ -165,7 +165,7 @@ export const TableResizer = ({
|
|
|
165
165
|
dispatch(tr);
|
|
166
166
|
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
167
167
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
168
|
-
if (
|
|
168
|
+
if (onResizeStart) {
|
|
169
169
|
onResizeStart();
|
|
170
170
|
}
|
|
171
171
|
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
@@ -272,7 +272,7 @@ export const TableResizer = ({
|
|
|
272
272
|
displayGuideline([]);
|
|
273
273
|
updateWidth(newWidth);
|
|
274
274
|
scheduleResize.cancel();
|
|
275
|
-
if (
|
|
275
|
+
if (onResizeStop) {
|
|
276
276
|
onResizeStop();
|
|
277
277
|
}
|
|
278
278
|
return newWidth;
|
|
@@ -148,6 +148,9 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
148
148
|
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale);
|
|
149
149
|
const resizedDelta = clientX - startX;
|
|
150
150
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
151
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
152
|
+
tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
|
|
153
|
+
}
|
|
151
154
|
if (colIndex === map.width - 1) {
|
|
152
155
|
const mouseUpTime = event.timeStamp;
|
|
153
156
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -1,16 +1,42 @@
|
|
|
1
1
|
// Resize a given column by an amount from the current state
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { TableCssClassName as ClassName } from '../../../types';
|
|
5
|
+
import { getTableContainerElementWidth, getTableScalingPercent } from './misc';
|
|
6
|
+
import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
|
|
5
7
|
import { updateColgroup } from './resize-state';
|
|
6
8
|
export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false) => {
|
|
7
9
|
let scalePercent = 1;
|
|
8
|
-
let resizeAmount = amount;
|
|
9
|
-
|
|
10
|
+
let resizeAmount = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? amount * 2 : amount;
|
|
11
|
+
|
|
12
|
+
// 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
|
|
13
|
+
if (isTableScalingEnabled && !getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
10
14
|
scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
11
15
|
resizeAmount = amount / scalePercent;
|
|
12
16
|
}
|
|
13
|
-
const newState = resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
17
|
+
const newState = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? updateAffectedColumn(resizeState, colIndex, resizeAmount) : resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
14
18
|
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
19
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
20
|
+
// use the difference in width from affected column to update overall table width
|
|
21
|
+
const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
22
|
+
updateTable(delta, tableRef, tableNode);
|
|
23
|
+
return {
|
|
24
|
+
...newState,
|
|
25
|
+
tableWidth: resizeState.tableWidth + delta
|
|
26
|
+
};
|
|
27
|
+
}
|
|
15
28
|
return newState;
|
|
29
|
+
};
|
|
30
|
+
const updateTable = (resizeAmount, tableRef, tableNode
|
|
31
|
+
// isTableScalingEnabled: boolean,
|
|
32
|
+
) => {
|
|
33
|
+
const currentWidth = getTableContainerElementWidth(tableNode);
|
|
34
|
+
const resizingContainer = tableRef.closest(`.${ClassName.TABLE_RESIZER_CONTAINER}`);
|
|
35
|
+
const resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
36
|
+
if (resizingContainer && resizingItem) {
|
|
37
|
+
const newWidth = `${currentWidth + resizeAmount}px`;
|
|
38
|
+
tableRef.style.width = newWidth;
|
|
39
|
+
resizingContainer.style.width = newWidth;
|
|
40
|
+
resizingItem.style.width = newWidth;
|
|
41
|
+
}
|
|
16
42
|
};
|
|
@@ -193,4 +193,24 @@ function getCandidates(state, destIdx, amount) {
|
|
|
193
193
|
|
|
194
194
|
// only consider rows after the selected column in the direction of resize
|
|
195
195
|
return amount < 0 ? candidates.slice(0, destIdx) : candidates.slice(destIdx + 1);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Update the given column based on resizeAmount, maintaining all other columns
|
|
200
|
+
*/
|
|
201
|
+
export function updateAffectedColumn(resizeState, colIndex, resizeAmount) {
|
|
202
|
+
const updatedCols = resizeState.cols.map((col, index) => {
|
|
203
|
+
if (index === colIndex) {
|
|
204
|
+
const newWidth = Math.max(col.width + resizeAmount, col.minWidth);
|
|
205
|
+
return {
|
|
206
|
+
...col,
|
|
207
|
+
width: newWidth
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return col;
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
...resizeState,
|
|
214
|
+
cols: updatedCols
|
|
215
|
+
};
|
|
196
216
|
}
|
|
@@ -7,7 +7,6 @@ import classNames from 'classnames';
|
|
|
7
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
9
9
|
import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
10
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
12
11
|
import { TableCssClassName as ClassName } from '../types';
|
|
13
12
|
import { TableResizer } from './TableResizer';
|
|
@@ -123,12 +122,10 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
123
122
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
124
123
|
pluginInjectionApi: pluginInjectionApi
|
|
125
124
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
131
|
-
}
|
|
125
|
+
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
126
|
+
onResizeStart: onResizeStart,
|
|
127
|
+
onResizeStop: onResizeStop
|
|
128
|
+
});
|
|
132
129
|
return /*#__PURE__*/React.createElement("div", {
|
|
133
130
|
style: {
|
|
134
131
|
display: 'flex',
|
|
@@ -160,7 +160,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
160
160
|
dispatch(tr);
|
|
161
161
|
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
162
162
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
163
|
-
if (
|
|
163
|
+
if (onResizeStart) {
|
|
164
164
|
onResizeStart();
|
|
165
165
|
}
|
|
166
166
|
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
@@ -264,7 +264,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
264
264
|
displayGuideline([]);
|
|
265
265
|
updateWidth(newWidth);
|
|
266
266
|
scheduleResize.cancel();
|
|
267
|
-
if (
|
|
267
|
+
if (onResizeStop) {
|
|
268
268
|
onResizeStop();
|
|
269
269
|
}
|
|
270
270
|
return newWidth;
|
|
@@ -135,6 +135,9 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
135
135
|
var newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale);
|
|
136
136
|
var resizedDelta = clientX - startX;
|
|
137
137
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
138
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
139
|
+
tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
|
|
140
|
+
}
|
|
138
141
|
if (colIndex === map.width - 1) {
|
|
139
142
|
var mouseUpTime = event.timeStamp;
|
|
140
143
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -1,17 +1,45 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
1
4
|
// Resize a given column by an amount from the current state
|
|
2
5
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { TableCssClassName as ClassName } from '../../../types';
|
|
8
|
+
import { getTableContainerElementWidth, getTableScalingPercent } from './misc';
|
|
9
|
+
import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
|
|
5
10
|
import { updateColgroup } from './resize-state';
|
|
6
11
|
export var resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
|
|
7
12
|
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
8
13
|
var scalePercent = 1;
|
|
9
|
-
var resizeAmount = amount;
|
|
10
|
-
|
|
14
|
+
var resizeAmount = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? amount * 2 : amount;
|
|
15
|
+
|
|
16
|
+
// 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
|
|
17
|
+
if (isTableScalingEnabled && !getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
11
18
|
scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
12
19
|
resizeAmount = amount / scalePercent;
|
|
13
20
|
}
|
|
14
|
-
var newState = resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
21
|
+
var newState = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? updateAffectedColumn(resizeState, colIndex, resizeAmount) : resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
15
22
|
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
23
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
24
|
+
// use the difference in width from affected column to update overall table width
|
|
25
|
+
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
26
|
+
updateTable(delta, tableRef, tableNode);
|
|
27
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
|
28
|
+
tableWidth: resizeState.tableWidth + delta
|
|
29
|
+
});
|
|
30
|
+
}
|
|
16
31
|
return newState;
|
|
32
|
+
};
|
|
33
|
+
var updateTable = function updateTable(resizeAmount, tableRef, tableNode
|
|
34
|
+
// isTableScalingEnabled: boolean,
|
|
35
|
+
) {
|
|
36
|
+
var currentWidth = getTableContainerElementWidth(tableNode);
|
|
37
|
+
var resizingContainer = tableRef.closest(".".concat(ClassName.TABLE_RESIZER_CONTAINER));
|
|
38
|
+
var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
39
|
+
if (resizingContainer && resizingItem) {
|
|
40
|
+
var newWidth = "".concat(currentWidth + resizeAmount, "px");
|
|
41
|
+
tableRef.style.width = newWidth;
|
|
42
|
+
resizingContainer.style.width = newWidth;
|
|
43
|
+
resizingItem.style.width = newWidth;
|
|
44
|
+
}
|
|
17
45
|
};
|
|
@@ -215,4 +215,22 @@ function getCandidates(state, destIdx, amount) {
|
|
|
215
215
|
|
|
216
216
|
// only consider rows after the selected column in the direction of resize
|
|
217
217
|
return amount < 0 ? candidates.slice(0, destIdx) : candidates.slice(destIdx + 1);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Update the given column based on resizeAmount, maintaining all other columns
|
|
222
|
+
*/
|
|
223
|
+
export function updateAffectedColumn(resizeState, colIndex, resizeAmount) {
|
|
224
|
+
var updatedCols = resizeState.cols.map(function (col, index) {
|
|
225
|
+
if (index === colIndex) {
|
|
226
|
+
var newWidth = Math.max(col.width + resizeAmount, col.minWidth);
|
|
227
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
228
|
+
width: newWidth
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return col;
|
|
232
|
+
});
|
|
233
|
+
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
234
|
+
cols: updatedCols
|
|
235
|
+
});
|
|
218
236
|
}
|
|
@@ -2,3 +2,7 @@ import type { ResizeState } from './types';
|
|
|
2
2
|
export declare const growColumn: (state: ResizeState, colIndex: number, amount: number, selectedColumns?: number[]) => ResizeState;
|
|
3
3
|
export declare const shrinkColumn: (state: ResizeState, colIndex: number, amount: number, selectedColumns?: number[]) => ResizeState;
|
|
4
4
|
export declare function reduceSpace(state: ResizeState, amount: number, ignoreCols?: number[]): ResizeState;
|
|
5
|
+
/**
|
|
6
|
+
* Update the given column based on resizeAmount, maintaining all other columns
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateAffectedColumn(resizeState: ResizeState, colIndex: number, resizeAmount: number): ResizeState;
|
|
@@ -2,3 +2,7 @@ import type { ResizeState } from './types';
|
|
|
2
2
|
export declare const growColumn: (state: ResizeState, colIndex: number, amount: number, selectedColumns?: number[]) => ResizeState;
|
|
3
3
|
export declare const shrinkColumn: (state: ResizeState, colIndex: number, amount: number, selectedColumns?: number[]) => ResizeState;
|
|
4
4
|
export declare function reduceSpace(state: ResizeState, amount: number, ignoreCols?: number[]): ResizeState;
|
|
5
|
+
/**
|
|
6
|
+
* Update the given column based on resizeAmount, maintaining all other columns
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateAffectedColumn(resizeState: ResizeState, colIndex: number, resizeAmount: number): ResizeState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.7.
|
|
3
|
+
"version": "7.7.2",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"runReact18": false
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^35.
|
|
32
|
-
"@atlaskit/custom-steps": "^0.0.
|
|
33
|
-
"@atlaskit/editor-common": "^78.
|
|
31
|
+
"@atlaskit/adf-schema": "^35.9.0",
|
|
32
|
+
"@atlaskit/custom-steps": "^0.0.18",
|
|
33
|
+
"@atlaskit/editor-common": "^78.30.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.3",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
@@ -112,9 +112,6 @@
|
|
|
112
112
|
"platform.editor.table.drag-move-options-logic-update_fp7xw": {
|
|
113
113
|
"type": "boolean"
|
|
114
114
|
},
|
|
115
|
-
"platform.editor.resizing-table-height-improvement": {
|
|
116
|
-
"type": "boolean"
|
|
117
|
-
},
|
|
118
115
|
"platform.editor.table.shift-arrowup-fix": {
|
|
119
116
|
"type": "boolean"
|
|
120
117
|
},
|
|
@@ -144,6 +141,9 @@
|
|
|
144
141
|
},
|
|
145
142
|
"platform.editor.a11y-table-floating-toolbar-dropdown-menu_zkb33": {
|
|
146
143
|
"type": "boolean"
|
|
144
|
+
},
|
|
145
|
+
"platform.editor.table.colum-resizing-improvements": {
|
|
146
|
+
"type": "boolean"
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
akEditorMediaResizeHandlerPaddingWide,
|
|
17
17
|
akEditorMobileBreakoutPoint,
|
|
18
18
|
} from '@atlaskit/editor-shared-styles';
|
|
19
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
20
19
|
|
|
21
20
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
22
21
|
import type { PluginInjectionAPI } from '../types';
|
|
@@ -201,13 +200,11 @@ export const ResizableTableContainer = React.memo(
|
|
|
201
200
|
pluginInjectionApi,
|
|
202
201
|
};
|
|
203
202
|
|
|
204
|
-
|
|
205
|
-
tableResizerProps
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
};
|
|
210
|
-
}
|
|
203
|
+
tableResizerProps = {
|
|
204
|
+
...tableResizerProps,
|
|
205
|
+
onResizeStart: onResizeStart,
|
|
206
|
+
onResizeStop: onResizeStop,
|
|
207
|
+
};
|
|
211
208
|
|
|
212
209
|
return (
|
|
213
210
|
<div
|
|
@@ -270,10 +270,7 @@ export const TableResizer = ({
|
|
|
270
270
|
);
|
|
271
271
|
|
|
272
272
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
273
|
-
if (
|
|
274
|
-
getBooleanFF('platform.editor.resizing-table-height-improvement') &&
|
|
275
|
-
onResizeStart
|
|
276
|
-
) {
|
|
273
|
+
if (onResizeStart) {
|
|
277
274
|
onResizeStart();
|
|
278
275
|
}
|
|
279
276
|
}, [
|
|
@@ -443,10 +440,7 @@ export const TableResizer = ({
|
|
|
443
440
|
updateWidth(newWidth);
|
|
444
441
|
scheduleResize.cancel();
|
|
445
442
|
|
|
446
|
-
if (
|
|
447
|
-
getBooleanFF('platform.editor.resizing-table-height-improvement') &&
|
|
448
|
-
onResizeStop
|
|
449
|
-
) {
|
|
443
|
+
if (onResizeStop) {
|
|
450
444
|
onResizeStop();
|
|
451
445
|
}
|
|
452
446
|
|
|
@@ -195,6 +195,10 @@ export const handleMouseDown = (
|
|
|
195
195
|
const resizedDelta = clientX - startX;
|
|
196
196
|
|
|
197
197
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
198
|
+
|
|
199
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
200
|
+
tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
|
|
201
|
+
}
|
|
198
202
|
if (colIndex === map.width - 1) {
|
|
199
203
|
const mouseUpTime = event.timeStamp;
|
|
200
204
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// Resize a given column by an amount from the current state
|
|
2
2
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { TableCssClassName as ClassName } from '../../../types';
|
|
6
|
+
|
|
7
|
+
import { getTableContainerElementWidth, getTableScalingPercent } from './misc';
|
|
8
|
+
import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
|
|
6
9
|
import { updateColgroup } from './resize-state';
|
|
7
10
|
import type { ResizeState } from './types';
|
|
8
11
|
|
|
@@ -16,20 +19,64 @@ export const resizeColumn = (
|
|
|
16
19
|
isTableScalingEnabled = false,
|
|
17
20
|
): ResizeState => {
|
|
18
21
|
let scalePercent = 1;
|
|
19
|
-
let resizeAmount =
|
|
22
|
+
let resizeAmount = getBooleanFF(
|
|
23
|
+
'platform.editor.table.colum-resizing-improvements',
|
|
24
|
+
)
|
|
25
|
+
? amount * 2
|
|
26
|
+
: amount;
|
|
20
27
|
|
|
21
|
-
if
|
|
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 (
|
|
30
|
+
isTableScalingEnabled &&
|
|
31
|
+
!getBooleanFF('platform.editor.table.colum-resizing-improvements')
|
|
32
|
+
) {
|
|
22
33
|
scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
23
34
|
resizeAmount = amount / scalePercent;
|
|
24
35
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
|
|
37
|
+
const newState = getBooleanFF(
|
|
38
|
+
'platform.editor.table.colum-resizing-improvements',
|
|
39
|
+
)
|
|
40
|
+
? updateAffectedColumn(resizeState, colIndex, resizeAmount)
|
|
41
|
+
: resizeAmount > 0
|
|
42
|
+
? growColumn(resizeState, colIndex, resizeAmount, selectedColumns)
|
|
43
|
+
: resizeAmount < 0
|
|
44
|
+
? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns)
|
|
45
|
+
: resizeState;
|
|
31
46
|
|
|
32
47
|
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
|
|
33
48
|
|
|
49
|
+
if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
|
|
50
|
+
// use the difference in width from affected column to update overall table width
|
|
51
|
+
const delta =
|
|
52
|
+
newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
53
|
+
|
|
54
|
+
updateTable(delta, tableRef, tableNode);
|
|
55
|
+
return {
|
|
56
|
+
...newState,
|
|
57
|
+
tableWidth: resizeState.tableWidth + delta,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
34
61
|
return newState;
|
|
35
62
|
};
|
|
63
|
+
|
|
64
|
+
const updateTable = (
|
|
65
|
+
resizeAmount: number,
|
|
66
|
+
tableRef: HTMLElement,
|
|
67
|
+
tableNode: PmNode,
|
|
68
|
+
// isTableScalingEnabled: boolean,
|
|
69
|
+
) => {
|
|
70
|
+
const currentWidth = getTableContainerElementWidth(tableNode);
|
|
71
|
+
const resizingContainer = tableRef.closest(
|
|
72
|
+
`.${ClassName.TABLE_RESIZER_CONTAINER}`,
|
|
73
|
+
);
|
|
74
|
+
const resizingItem = resizingContainer?.querySelector('.resizer-item');
|
|
75
|
+
|
|
76
|
+
if (resizingContainer && resizingItem) {
|
|
77
|
+
const newWidth = `${currentWidth + resizeAmount}px`;
|
|
78
|
+
tableRef.style.width = newWidth;
|
|
79
|
+
(resizingContainer as HTMLElement).style.width = newWidth;
|
|
80
|
+
(resizingItem as HTMLElement).style.width = newWidth;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -278,3 +278,28 @@ function getCandidates(
|
|
|
278
278
|
? candidates.slice(0, destIdx)
|
|
279
279
|
: candidates.slice(destIdx + 1);
|
|
280
280
|
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Update the given column based on resizeAmount, maintaining all other columns
|
|
284
|
+
*/
|
|
285
|
+
export function updateAffectedColumn(
|
|
286
|
+
resizeState: ResizeState,
|
|
287
|
+
colIndex: number,
|
|
288
|
+
resizeAmount: number,
|
|
289
|
+
): ResizeState {
|
|
290
|
+
const updatedCols = resizeState.cols.map((col, index) => {
|
|
291
|
+
if (index === colIndex) {
|
|
292
|
+
const newWidth = Math.max(col.width + resizeAmount, col.minWidth);
|
|
293
|
+
return {
|
|
294
|
+
...col,
|
|
295
|
+
width: newWidth,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
return col;
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
...resizeState,
|
|
303
|
+
cols: updatedCols,
|
|
304
|
+
};
|
|
305
|
+
}
|