@atlaskit/editor-plugin-table 7.5.3 → 7.5.4
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/TableContainer.js +1 -1
- package/dist/cjs/nodeviews/TableResizer.js +8 -8
- package/dist/cjs/ui/ColumnResizeWidget/index.js +4 -5
- package/dist/cjs/utils/guidelines.js +5 -2
- package/dist/cjs/utils/snapping.js +14 -1
- package/dist/es2019/nodeviews/TableContainer.js +2 -2
- package/dist/es2019/nodeviews/TableResizer.js +10 -10
- package/dist/es2019/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/es2019/utils/guidelines.js +3 -2
- package/dist/es2019/utils/snapping.js +12 -1
- package/dist/esm/nodeviews/TableContainer.js +2 -2
- package/dist/esm/nodeviews/TableResizer.js +10 -10
- package/dist/esm/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/esm/utils/guidelines.js +5 -2
- package/dist/esm/utils/snapping.js +14 -1
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types/utils/guidelines.d.ts +1 -0
- package/dist/types/utils/snapping.d.ts +2 -0
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/utils/guidelines.d.ts +1 -0
- package/dist/types-ts4.5/utils/snapping.d.ts +2 -0
- package/package.json +1 -1
- package/src/nodeviews/TableContainer.tsx +10 -1
- package/src/nodeviews/TableResizer.tsx +39 -19
- package/src/ui/ColumnResizeWidget/index.tsx +2 -4
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +2 -2
- package/src/utils/drag-menu.ts +1 -1
- package/src/utils/guidelines.ts +12 -1
- package/src/utils/snapping.ts +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.5.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#80391](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/80391) [`bf741c7ef44c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bf741c7ef44c) - Make @atlaskit/editor-plugin-table, @atlaskit/date, @atlaskit/editor-plugin-date React 18 compatible.
|
|
8
|
+
- [#79483](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/79483) [`b2a75ed4502b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b2a75ed4502b) - add dynamic widest guideline for table resize
|
|
9
|
+
|
|
3
10
|
## 7.5.3
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -118,7 +118,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
118
118
|
}, [pluginInjectionApi]);
|
|
119
119
|
var tableWidth = (0, _nodeWidth.getTableContainerWidth)(node);
|
|
120
120
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
121
|
-
var responsiveContainerWidth = containerWidth -
|
|
121
|
+
var responsiveContainerWidth = tablePreserveWidth ? containerWidth - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide;
|
|
122
122
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
123
123
|
if (!isResizing) {
|
|
124
124
|
tableWidthRef.current = width;
|
|
@@ -145,15 +145,15 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
145
145
|
keys = _ref2.keys;
|
|
146
146
|
if (gap !== currentGap.current) {
|
|
147
147
|
currentGap.current = gap;
|
|
148
|
-
var visibleGuidelines = getVisibleGuidelines(_guidelines.defaultGuidelines, containerWidth);
|
|
148
|
+
var visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, containerWidth);
|
|
149
149
|
displayGuideline((0, _guideline.getGuidelinesWithHighlights)(gap, _consts.TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
150
150
|
}
|
|
151
|
-
}, [
|
|
151
|
+
}, [tablePreserveWidth, containerWidth, displayGuideline]);
|
|
152
152
|
var guidelineSnaps = (0, _react.useMemo)(function () {
|
|
153
153
|
return snappingEnabled ? {
|
|
154
|
-
x: _snapping.defaultSnappingWidths
|
|
154
|
+
x: tablePreserveWidth ? (0, _snapping.defaultTablePreserveSnappingWidths)(containerWidth) : _snapping.defaultSnappingWidths
|
|
155
155
|
} : undefined;
|
|
156
|
-
}, [snappingEnabled]);
|
|
156
|
+
}, [snappingEnabled, tablePreserveWidth, containerWidth]);
|
|
157
157
|
(0, _react.useEffect)(function () {
|
|
158
158
|
return function () {
|
|
159
159
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -183,12 +183,12 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
183
183
|
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
184
184
|
});
|
|
185
185
|
dispatch(tr);
|
|
186
|
-
var visibleGuidelines = getVisibleGuidelines(_guidelines.defaultGuidelines, containerWidth);
|
|
186
|
+
var visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, containerWidth);
|
|
187
187
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
188
188
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
189
189
|
onResizeStart();
|
|
190
190
|
}
|
|
191
|
-
}, [displayGapCursor,
|
|
191
|
+
}, [startMeasure, editorView, displayGapCursor, tablePreserveWidth, containerWidth, displayGuideline, onResizeStart]);
|
|
192
192
|
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
193
193
|
countFrames();
|
|
194
194
|
var newWidth = originalState.width + delta.width;
|
|
@@ -207,10 +207,10 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
207
207
|
start: pos + 1,
|
|
208
208
|
parentWidth: newWidth
|
|
209
209
|
}, editorView.domAtPos.bind(editorView), tablePreserveWidth);
|
|
210
|
-
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth, _snapping.defaultSnappingWidths, _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP, _consts.TABLE_HIGHLIGHT_TOLERANCE));
|
|
210
|
+
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth, tablePreserveWidth ? (0, _snapping.defaultTablePreserveSnappingWidths)(containerWidth) : _snapping.defaultSnappingWidths, tablePreserveWidth ? (0, _guidelines.defaultGuidelinesForPreserveTable)(containerWidth) : _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP, _consts.TABLE_HIGHLIGHT_TOLERANCE));
|
|
211
211
|
updateWidth(newWidth);
|
|
212
212
|
return newWidth;
|
|
213
|
-
}, [
|
|
213
|
+
}, [countFrames, tablePreserveWidth, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
214
214
|
var scheduleResize = (0, _react.useMemo)(function () {
|
|
215
215
|
return (0, _rafSchd.default)(handleResize);
|
|
216
216
|
}, [handleResize]);
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.ColumnResizeWidget = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _react =
|
|
10
|
-
var _react2 = require("@emotion/react");
|
|
9
|
+
var _react = require("@emotion/react");
|
|
11
10
|
var _reactIntlNext = require("react-intl-next");
|
|
12
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
12
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
@@ -21,20 +20,20 @@ var ColumnResizeWidget = exports.ColumnResizeWidget = function ColumnResizeWidge
|
|
|
21
20
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
22
21
|
formatMessage = _useIntl.formatMessage;
|
|
23
22
|
if (!includeTooltip) {
|
|
24
|
-
return (0,
|
|
23
|
+
return (0, _react.jsx)("div", {
|
|
25
24
|
className: _types.TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
26
25
|
"data-start-index": startIndex,
|
|
27
26
|
"data-end-index": endIndex
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
return (0,
|
|
29
|
+
return (0, _react.jsx)(_tooltip.default, {
|
|
31
30
|
content: formatMessage(_messages.tableMessages.adjustColumns),
|
|
32
31
|
hideTooltipOnClick: true,
|
|
33
32
|
hideTooltipOnMouseDown: true,
|
|
34
33
|
position: "mouse",
|
|
35
34
|
mousePosition: "auto-start"
|
|
36
35
|
}, function (tooltipProps) {
|
|
37
|
-
return (0,
|
|
36
|
+
return (0, _react.jsx)("div", (0, _extends2.default)({
|
|
38
37
|
className: _types.TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
39
38
|
"data-start-index": startIndex,
|
|
40
39
|
"data-end-index": endIndex
|
|
@@ -4,10 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.defaultGuidelines = void 0;
|
|
7
|
+
exports.defaultGuidelinesForPreserveTable = exports.defaultGuidelines = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
10
10
|
var _snapping = require("./snapping");
|
|
11
11
|
// NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
|
|
12
12
|
// If we don't do this then the guidelines will not align correctly to the edge of the table
|
|
13
|
-
var defaultGuidelines = exports.defaultGuidelines = (0, _guideline.createFixedGuidelinesFromLengths)([0].concat((0, _toConsumableArray2.default)((0, _snapping.calculateDefaultSnappings)(-1))));
|
|
13
|
+
var defaultGuidelines = exports.defaultGuidelines = (0, _guideline.createFixedGuidelinesFromLengths)([0].concat((0, _toConsumableArray2.default)((0, _snapping.calculateDefaultSnappings)(-1))));
|
|
14
|
+
var defaultGuidelinesForPreserveTable = exports.defaultGuidelinesForPreserveTable = function defaultGuidelinesForPreserveTable(editorContainerWidth) {
|
|
15
|
+
return (0, _guideline.createFixedGuidelinesFromLengths)([0].concat((0, _toConsumableArray2.default)((0, _snapping.calculateDefaultTablePreserveSnappings)(-1, editorContainerWidth))));
|
|
16
|
+
};
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.findClosestSnap = exports.defaultSnappingWidths = exports.calculateDefaultSnappings = void 0;
|
|
7
|
+
exports.findClosestSnap = exports.defaultTablePreserveSnappingWidths = exports.defaultSnappingWidths = exports.calculateDefaultTablePreserveSnappings = exports.calculateDefaultSnappings = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -18,8 +18,21 @@ var calculateDefaultSnappings = exports.calculateDefaultSnappings = function cal
|
|
|
18
18
|
var lengthOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
19
19
|
return [].concat((0, _toConsumableArray2.default)(calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, _editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset)), [_editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset, _editorSharedStyles.akEditorCalculatedWideLayoutWidth + lengthOffset, _editorSharedStyles.akEditorFullWidthLayoutWidth + lengthOffset]);
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
// FF TablePreserve for calculateDefaultSnappings
|
|
23
|
+
var calculateDefaultTablePreserveSnappings = exports.calculateDefaultTablePreserveSnappings = function calculateDefaultTablePreserveSnappings() {
|
|
24
|
+
var lengthOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
25
|
+
var editorContainerWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
26
|
+
var dynamicFullWidthLine = editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 >= _editorSharedStyles.akEditorFullWidthLayoutWidth ? _editorSharedStyles.akEditorFullWidthLayoutWidth : editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 - _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide;
|
|
27
|
+
return [].concat((0, _toConsumableArray2.default)(calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, _editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset)), [_editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset, _editorSharedStyles.akEditorCalculatedWideLayoutWidth + lengthOffset, dynamicFullWidthLine - lengthOffset]);
|
|
28
|
+
};
|
|
21
29
|
var defaultSnappingWidths = exports.defaultSnappingWidths = calculateDefaultSnappings();
|
|
22
30
|
|
|
31
|
+
// FF TablePreserve for defaultSnappingWidths
|
|
32
|
+
var defaultTablePreserveSnappingWidths = exports.defaultTablePreserveSnappingWidths = function defaultTablePreserveSnappingWidths(editorContainerWidth) {
|
|
33
|
+
return editorContainerWidth - _editorSharedStyles.akEditorGutterPadding * 2 > _editorSharedStyles.akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(0, editorContainerWidth);
|
|
34
|
+
};
|
|
35
|
+
|
|
23
36
|
/**
|
|
24
37
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
25
38
|
*/
|
|
@@ -2,7 +2,7 @@ import React, { forwardRef, useCallback, useRef } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
4
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
5
|
-
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
8
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -107,7 +107,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
107
107
|
}, [pluginInjectionApi]);
|
|
108
108
|
const tableWidth = getTableContainerWidth(node);
|
|
109
109
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
110
|
-
const responsiveContainerWidth = containerWidth -
|
|
110
|
+
const responsiveContainerWidth = tablePreserveWidth ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
111
111
|
const width = Math.min(tableWidth, responsiveContainerWidth);
|
|
112
112
|
if (!isResizing) {
|
|
113
113
|
tableWidthRef.current = width;
|
|
@@ -16,8 +16,8 @@ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTa
|
|
|
16
16
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
17
17
|
import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
18
18
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
19
|
-
import { defaultGuidelines } from '../utils/guidelines';
|
|
20
|
-
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
19
|
+
import { defaultGuidelines, defaultGuidelinesForPreserveTable } from '../utils/guidelines';
|
|
20
|
+
import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
21
21
|
const DEBOUNCE_TIME_FOR_SCREEN_READER_ANNOUNCER = 1000;
|
|
22
22
|
const RESIZE_STEP_VALUE = 10;
|
|
23
23
|
const handles = {
|
|
@@ -130,13 +130,13 @@ export const TableResizer = ({
|
|
|
130
130
|
}) => {
|
|
131
131
|
if (gap !== currentGap.current) {
|
|
132
132
|
currentGap.current = gap;
|
|
133
|
-
const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
133
|
+
const visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
134
134
|
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
135
135
|
}
|
|
136
|
-
}, [
|
|
136
|
+
}, [tablePreserveWidth, containerWidth, displayGuideline]);
|
|
137
137
|
const guidelineSnaps = useMemo(() => snappingEnabled ? {
|
|
138
|
-
x: defaultSnappingWidths
|
|
139
|
-
} : undefined, [snappingEnabled]);
|
|
138
|
+
x: tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
|
|
139
|
+
} : undefined, [snappingEnabled, tablePreserveWidth, containerWidth]);
|
|
140
140
|
useEffect(() => {
|
|
141
141
|
return () => {
|
|
142
142
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -174,12 +174,12 @@ export const TableResizer = ({
|
|
|
174
174
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
175
175
|
});
|
|
176
176
|
dispatch(tr);
|
|
177
|
-
const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
177
|
+
const visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
178
178
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
179
179
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
180
180
|
onResizeStart();
|
|
181
181
|
}
|
|
182
|
-
}, [displayGapCursor,
|
|
182
|
+
}, [startMeasure, editorView, displayGapCursor, tablePreserveWidth, containerWidth, displayGuideline, onResizeStart]);
|
|
183
183
|
const handleResize = useCallback((originalState, delta) => {
|
|
184
184
|
countFrames();
|
|
185
185
|
const newWidth = originalState.width + delta.width;
|
|
@@ -198,10 +198,10 @@ export const TableResizer = ({
|
|
|
198
198
|
start: pos + 1,
|
|
199
199
|
parentWidth: newWidth
|
|
200
200
|
}, editorView.domAtPos.bind(editorView), tablePreserveWidth);
|
|
201
|
-
updateActiveGuidelines(findClosestSnap(newWidth, defaultSnappingWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
201
|
+
updateActiveGuidelines(findClosestSnap(newWidth, tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
202
202
|
updateWidth(newWidth);
|
|
203
203
|
return newWidth;
|
|
204
|
-
}, [
|
|
204
|
+
}, [countFrames, tablePreserveWidth, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
205
205
|
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
206
206
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
207
207
|
isResizing.current = false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
|
|
2
|
-
import { calculateDefaultSnappings } from './snapping';
|
|
2
|
+
import { calculateDefaultSnappings, calculateDefaultTablePreserveSnappings } from './snapping';
|
|
3
3
|
|
|
4
4
|
// NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
|
|
5
5
|
// If we don't do this then the guidelines will not align correctly to the edge of the table
|
|
6
|
-
export const defaultGuidelines = createFixedGuidelinesFromLengths([0, ...calculateDefaultSnappings(-1)]);
|
|
6
|
+
export const defaultGuidelines = createFixedGuidelinesFromLengths([0, ...calculateDefaultSnappings(-1)]);
|
|
7
|
+
export const defaultGuidelinesForPreserveTable = editorContainerWidth => createFixedGuidelinesFromLengths([0, ...calculateDefaultTablePreserveSnappings(-1, editorContainerWidth)]);
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { isVerticalPosition } from '@atlaskit/editor-common/guideline';
|
|
2
|
-
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
2
|
+
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide } from '@atlaskit/editor-shared-styles';
|
|
3
3
|
const numberOfLanesInDefaultLayoutWidth = 12;
|
|
4
4
|
const calculateSubSnappingWidths = (totalLanes, totalWidth) => new Array(Math.round(totalLanes / 2) - 1).fill(totalWidth / totalLanes).map((v, i) => v * (i + 1) * 2);
|
|
5
5
|
export const calculateDefaultSnappings = (lengthOffset = 0) => [...calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, akEditorDefaultLayoutWidth + lengthOffset), akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset, akEditorFullWidthLayoutWidth + lengthOffset];
|
|
6
|
+
|
|
7
|
+
// FF TablePreserve for calculateDefaultSnappings
|
|
8
|
+
export const calculateDefaultTablePreserveSnappings = (lengthOffset = 0, editorContainerWith = akEditorFullWidthLayoutWidth) => {
|
|
9
|
+
const dynamicFullWidthLine = editorContainerWith - akEditorGutterPadding * 2 >= akEditorFullWidthLayoutWidth ? akEditorFullWidthLayoutWidth : editorContainerWith - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
10
|
+
return [...calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, akEditorDefaultLayoutWidth + lengthOffset), akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset, dynamicFullWidthLine - lengthOffset];
|
|
11
|
+
};
|
|
6
12
|
export const defaultSnappingWidths = calculateDefaultSnappings();
|
|
7
13
|
|
|
14
|
+
// FF TablePreserve for defaultSnappingWidths
|
|
15
|
+
export const defaultTablePreserveSnappingWidths = editorContainerWidth => {
|
|
16
|
+
return editorContainerWidth - akEditorGutterPadding * 2 > akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(0, editorContainerWidth);
|
|
17
|
+
};
|
|
18
|
+
|
|
8
19
|
/**
|
|
9
20
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
10
21
|
*/
|
|
@@ -5,7 +5,7 @@ import React, { forwardRef, useCallback, useRef } from 'react';
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
7
7
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
8
|
-
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
9
9
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
11
11
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -108,7 +108,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
108
108
|
}, [pluginInjectionApi]);
|
|
109
109
|
var tableWidth = getTableContainerWidth(node);
|
|
110
110
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
111
|
-
var responsiveContainerWidth = containerWidth -
|
|
111
|
+
var responsiveContainerWidth = tablePreserveWidth ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
112
112
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
113
113
|
if (!isResizing) {
|
|
114
114
|
tableWidthRef.current = width;
|
|
@@ -20,8 +20,8 @@ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTa
|
|
|
20
20
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
21
21
|
import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
22
22
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
23
|
-
import { defaultGuidelines } from '../utils/guidelines';
|
|
24
|
-
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
23
|
+
import { defaultGuidelines, defaultGuidelinesForPreserveTable } from '../utils/guidelines';
|
|
24
|
+
import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
25
25
|
var DEBOUNCE_TIME_FOR_SCREEN_READER_ANNOUNCER = 1000;
|
|
26
26
|
var RESIZE_STEP_VALUE = 10;
|
|
27
27
|
var handles = {
|
|
@@ -135,15 +135,15 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
135
135
|
keys = _ref2.keys;
|
|
136
136
|
if (gap !== currentGap.current) {
|
|
137
137
|
currentGap.current = gap;
|
|
138
|
-
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
138
|
+
var visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
139
139
|
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
140
140
|
}
|
|
141
|
-
}, [
|
|
141
|
+
}, [tablePreserveWidth, containerWidth, displayGuideline]);
|
|
142
142
|
var guidelineSnaps = useMemo(function () {
|
|
143
143
|
return snappingEnabled ? {
|
|
144
|
-
x: defaultSnappingWidths
|
|
144
|
+
x: tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
|
|
145
145
|
} : undefined;
|
|
146
|
-
}, [snappingEnabled]);
|
|
146
|
+
}, [snappingEnabled, tablePreserveWidth, containerWidth]);
|
|
147
147
|
useEffect(function () {
|
|
148
148
|
return function () {
|
|
149
149
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -173,12 +173,12 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
173
173
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
174
174
|
});
|
|
175
175
|
dispatch(tr);
|
|
176
|
-
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
176
|
+
var visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
177
177
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
178
178
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
179
179
|
onResizeStart();
|
|
180
180
|
}
|
|
181
|
-
}, [displayGapCursor,
|
|
181
|
+
}, [startMeasure, editorView, displayGapCursor, tablePreserveWidth, containerWidth, displayGuideline, onResizeStart]);
|
|
182
182
|
var handleResize = useCallback(function (originalState, delta) {
|
|
183
183
|
countFrames();
|
|
184
184
|
var newWidth = originalState.width + delta.width;
|
|
@@ -197,10 +197,10 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
197
197
|
start: pos + 1,
|
|
198
198
|
parentWidth: newWidth
|
|
199
199
|
}, editorView.domAtPos.bind(editorView), tablePreserveWidth);
|
|
200
|
-
updateActiveGuidelines(findClosestSnap(newWidth, defaultSnappingWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
200
|
+
updateActiveGuidelines(findClosestSnap(newWidth, tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
201
201
|
updateWidth(newWidth);
|
|
202
202
|
return newWidth;
|
|
203
|
-
}, [
|
|
203
|
+
}, [countFrames, tablePreserveWidth, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
204
204
|
var scheduleResize = useMemo(function () {
|
|
205
205
|
return rafSchd(handleResize);
|
|
206
206
|
}, [handleResize]);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
|
|
3
|
-
import { calculateDefaultSnappings } from './snapping';
|
|
3
|
+
import { calculateDefaultSnappings, calculateDefaultTablePreserveSnappings } from './snapping';
|
|
4
4
|
|
|
5
5
|
// NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
|
|
6
6
|
// If we don't do this then the guidelines will not align correctly to the edge of the table
|
|
7
|
-
export var defaultGuidelines = createFixedGuidelinesFromLengths([0].concat(_toConsumableArray(calculateDefaultSnappings(-1))));
|
|
7
|
+
export var defaultGuidelines = createFixedGuidelinesFromLengths([0].concat(_toConsumableArray(calculateDefaultSnappings(-1))));
|
|
8
|
+
export var defaultGuidelinesForPreserveTable = function defaultGuidelinesForPreserveTable(editorContainerWidth) {
|
|
9
|
+
return createFixedGuidelinesFromLengths([0].concat(_toConsumableArray(calculateDefaultTablePreserveSnappings(-1, editorContainerWidth))));
|
|
10
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { isVerticalPosition } from '@atlaskit/editor-common/guideline';
|
|
3
|
-
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
var numberOfLanesInDefaultLayoutWidth = 12;
|
|
5
5
|
var calculateSubSnappingWidths = function calculateSubSnappingWidths(totalLanes, totalWidth) {
|
|
6
6
|
return new Array(Math.round(totalLanes / 2) - 1).fill(totalWidth / totalLanes).map(function (v, i) {
|
|
@@ -11,8 +11,21 @@ export var calculateDefaultSnappings = function calculateDefaultSnappings() {
|
|
|
11
11
|
var lengthOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
12
12
|
return [].concat(_toConsumableArray(calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, akEditorDefaultLayoutWidth + lengthOffset)), [akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset, akEditorFullWidthLayoutWidth + lengthOffset]);
|
|
13
13
|
};
|
|
14
|
+
|
|
15
|
+
// FF TablePreserve for calculateDefaultSnappings
|
|
16
|
+
export var calculateDefaultTablePreserveSnappings = function calculateDefaultTablePreserveSnappings() {
|
|
17
|
+
var lengthOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
18
|
+
var editorContainerWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : akEditorFullWidthLayoutWidth;
|
|
19
|
+
var dynamicFullWidthLine = editorContainerWith - akEditorGutterPadding * 2 >= akEditorFullWidthLayoutWidth ? akEditorFullWidthLayoutWidth : editorContainerWith - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
20
|
+
return [].concat(_toConsumableArray(calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, akEditorDefaultLayoutWidth + lengthOffset)), [akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset, dynamicFullWidthLine - lengthOffset]);
|
|
21
|
+
};
|
|
14
22
|
export var defaultSnappingWidths = calculateDefaultSnappings();
|
|
15
23
|
|
|
24
|
+
// FF TablePreserve for defaultSnappingWidths
|
|
25
|
+
export var defaultTablePreserveSnappingWidths = function defaultTablePreserveSnappingWidths(editorContainerWidth) {
|
|
26
|
+
return editorContainerWidth - akEditorGutterPadding * 2 > akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(0, editorContainerWidth);
|
|
27
|
+
};
|
|
28
|
+
|
|
16
29
|
/**
|
|
17
30
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
18
31
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
3
|
type Props = {
|
|
4
4
|
startIndex: number;
|
|
5
5
|
endIndex: number;
|
|
6
6
|
includeTooltip?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export declare const ColumnResizeWidget:
|
|
8
|
+
export declare const ColumnResizeWidget: ({ startIndex, endIndex, includeTooltip, }: Props) => jsx.JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export interface Props {
|
|
3
3
|
index: number;
|
|
4
4
|
localId?: string;
|
|
@@ -6,4 +6,4 @@ export interface Props {
|
|
|
6
6
|
height?: number;
|
|
7
7
|
marginTop?: number;
|
|
8
8
|
}
|
|
9
|
-
export declare const ColumnDropTarget:
|
|
9
|
+
export declare const ColumnDropTarget: ({ index, localId, width, height, marginTop, }: Props) => JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export interface Props {
|
|
3
3
|
tableRef: HTMLTableElement;
|
|
4
4
|
tableHeight?: number;
|
|
@@ -7,4 +7,4 @@ export interface Props {
|
|
|
7
7
|
isHeaderSticky?: boolean;
|
|
8
8
|
getScrollOffset?: () => number;
|
|
9
9
|
}
|
|
10
|
-
export declare const ColumnDropTargets:
|
|
10
|
+
export declare const ColumnDropTargets: ({ tableRef, tableHeight, localId, colWidths, isHeaderSticky, getScrollOffset, }: Props) => JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
3
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -26,5 +26,5 @@ export interface Props {
|
|
|
26
26
|
isNumberColumnEnabled?: boolean;
|
|
27
27
|
getScrollOffset?: () => number;
|
|
28
28
|
}
|
|
29
|
-
export declare const TableFloatingColumnControls:
|
|
29
|
+
export declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, }: Props) => JSX.Element | null;
|
|
30
30
|
export default TableFloatingColumnControls;
|
|
@@ -10,7 +10,7 @@ export declare const canMove: (sourceType: DraggableType, direction: DraggableDa
|
|
|
10
10
|
export type DragMenuOptionIdType = 'add_row_above' | 'add_row_below' | 'add_column_left' | 'add_column_right' | 'distribute_columns' | 'clear_cells' | 'delete_row' | 'delete_column' | 'move_column_left' | 'move_column_right' | 'move_row_up' | 'move_row_down' | 'sort_column_asc' | 'sort_column_desc';
|
|
11
11
|
export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
12
12
|
id: DragMenuOptionIdType;
|
|
13
|
-
icon?: React.ComponentType<IconProps
|
|
13
|
+
icon?: React.ComponentType<React.PropsWithChildren<IconProps>>;
|
|
14
14
|
keymap?: string;
|
|
15
15
|
}
|
|
16
16
|
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI, isHeaderRowRequired?: boolean, tablePreserveWidth?: boolean) => DragMenuConfig[];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
2
2
|
export declare const calculateDefaultSnappings: (lengthOffset?: number) => number[];
|
|
3
|
+
export declare const calculateDefaultTablePreserveSnappings: (lengthOffset?: number, editorContainerWith?: number) => number[];
|
|
3
4
|
export declare const defaultSnappingWidths: number[];
|
|
5
|
+
export declare const defaultTablePreserveSnappingWidths: (editorContainerWidth: number) => number[];
|
|
4
6
|
/**
|
|
5
7
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
6
8
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
3
|
type Props = {
|
|
4
4
|
startIndex: number;
|
|
5
5
|
endIndex: number;
|
|
6
6
|
includeTooltip?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export declare const ColumnResizeWidget:
|
|
8
|
+
export declare const ColumnResizeWidget: ({ startIndex, endIndex, includeTooltip, }: Props) => jsx.JSX.Element;
|
|
9
9
|
export {};
|
package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export interface Props {
|
|
3
3
|
index: number;
|
|
4
4
|
localId?: string;
|
|
@@ -6,4 +6,4 @@ export interface Props {
|
|
|
6
6
|
height?: number;
|
|
7
7
|
marginTop?: number;
|
|
8
8
|
}
|
|
9
|
-
export declare const ColumnDropTarget:
|
|
9
|
+
export declare const ColumnDropTarget: ({ index, localId, width, height, marginTop, }: Props) => JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export interface Props {
|
|
3
3
|
tableRef: HTMLTableElement;
|
|
4
4
|
tableHeight?: number;
|
|
@@ -7,4 +7,4 @@ export interface Props {
|
|
|
7
7
|
isHeaderSticky?: boolean;
|
|
8
8
|
getScrollOffset?: () => number;
|
|
9
9
|
}
|
|
10
|
-
export declare const ColumnDropTargets:
|
|
10
|
+
export declare const ColumnDropTargets: ({ tableRef, tableHeight, localId, colWidths, isHeaderSticky, getScrollOffset, }: Props) => JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
3
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -26,5 +26,5 @@ export interface Props {
|
|
|
26
26
|
isNumberColumnEnabled?: boolean;
|
|
27
27
|
getScrollOffset?: () => number;
|
|
28
28
|
}
|
|
29
|
-
export declare const TableFloatingColumnControls:
|
|
29
|
+
export declare const TableFloatingColumnControls: ({ editorView, tableRef, getNode, tableActive, hasHeaderRow, hoveredCell, isResizing, stickyHeader, selection, isInDanger, isTableHovered, tableContainerWidth, isNumberColumnEnabled, getScrollOffset, }: Props) => JSX.Element | null;
|
|
30
30
|
export default TableFloatingColumnControls;
|
|
@@ -10,7 +10,7 @@ export declare const canMove: (sourceType: DraggableType, direction: DraggableDa
|
|
|
10
10
|
export type DragMenuOptionIdType = 'add_row_above' | 'add_row_below' | 'add_column_left' | 'add_column_right' | 'distribute_columns' | 'clear_cells' | 'delete_row' | 'delete_column' | 'move_column_left' | 'move_column_right' | 'move_row_up' | 'move_row_down' | 'sort_column_asc' | 'sort_column_desc';
|
|
11
11
|
export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
12
12
|
id: DragMenuOptionIdType;
|
|
13
|
-
icon?: React.ComponentType<IconProps
|
|
13
|
+
icon?: React.ComponentType<React.PropsWithChildren<IconProps>>;
|
|
14
14
|
keymap?: string;
|
|
15
15
|
}
|
|
16
16
|
export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI, isHeaderRowRequired?: boolean, tablePreserveWidth?: boolean) => DragMenuConfig[];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
2
2
|
export declare const calculateDefaultSnappings: (lengthOffset?: number) => number[];
|
|
3
|
+
export declare const calculateDefaultTablePreserveSnappings: (lengthOffset?: number, editorContainerWith?: number) => number[];
|
|
3
4
|
export declare const defaultSnappingWidths: number[];
|
|
5
|
+
export declare const defaultTablePreserveSnappingWidths: (editorContainerWidth: number) => number[];
|
|
4
6
|
/**
|
|
5
7
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
6
8
|
*/
|
package/package.json
CHANGED
|
@@ -12,6 +12,8 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
12
12
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
13
13
|
import {
|
|
14
14
|
akEditorDefaultLayoutWidth,
|
|
15
|
+
akEditorGutterPadding,
|
|
16
|
+
akEditorMediaResizeHandlerPaddingWide,
|
|
15
17
|
akEditorMobileBreakoutPoint,
|
|
16
18
|
} from '@atlaskit/editor-shared-styles';
|
|
17
19
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -189,7 +191,14 @@ export const ResizableTableContainer = React.memo(
|
|
|
189
191
|
|
|
190
192
|
const tableWidth = getTableContainerWidth(node);
|
|
191
193
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
192
|
-
const responsiveContainerWidth =
|
|
194
|
+
const responsiveContainerWidth = tablePreserveWidth
|
|
195
|
+
? containerWidth -
|
|
196
|
+
akEditorGutterPadding * 2 -
|
|
197
|
+
akEditorMediaResizeHandlerPaddingWide / 2
|
|
198
|
+
: containerWidth -
|
|
199
|
+
akEditorGutterPadding * 2 -
|
|
200
|
+
akEditorMediaResizeHandlerPaddingWide;
|
|
201
|
+
|
|
193
202
|
const width = Math.min(tableWidth, responsiveContainerWidth);
|
|
194
203
|
|
|
195
204
|
if (!isResizing) {
|
|
@@ -51,8 +51,15 @@ import {
|
|
|
51
51
|
generateResizeFrameRatePayloads,
|
|
52
52
|
useMeasureFramerate,
|
|
53
53
|
} from '../utils/analytics';
|
|
54
|
-
import {
|
|
55
|
-
|
|
54
|
+
import {
|
|
55
|
+
defaultGuidelines,
|
|
56
|
+
defaultGuidelinesForPreserveTable,
|
|
57
|
+
} from '../utils/guidelines';
|
|
58
|
+
import {
|
|
59
|
+
defaultSnappingWidths,
|
|
60
|
+
defaultTablePreserveSnappingWidths,
|
|
61
|
+
findClosestSnap,
|
|
62
|
+
} from '../utils/snapping';
|
|
56
63
|
|
|
57
64
|
interface TableResizerProps {
|
|
58
65
|
width: number;
|
|
@@ -211,9 +218,12 @@ export const TableResizer = ({
|
|
|
211
218
|
if (gap !== currentGap.current) {
|
|
212
219
|
currentGap.current = gap;
|
|
213
220
|
const visibleGuidelines = getVisibleGuidelines(
|
|
214
|
-
|
|
221
|
+
tablePreserveWidth
|
|
222
|
+
? defaultGuidelinesForPreserveTable(containerWidth)
|
|
223
|
+
: defaultGuidelines,
|
|
215
224
|
containerWidth,
|
|
216
225
|
);
|
|
226
|
+
|
|
217
227
|
displayGuideline(
|
|
218
228
|
getGuidelinesWithHighlights(
|
|
219
229
|
gap,
|
|
@@ -224,17 +234,19 @@ export const TableResizer = ({
|
|
|
224
234
|
);
|
|
225
235
|
}
|
|
226
236
|
},
|
|
227
|
-
[
|
|
237
|
+
[tablePreserveWidth, containerWidth, displayGuideline],
|
|
228
238
|
);
|
|
229
239
|
|
|
230
240
|
const guidelineSnaps = useMemo(
|
|
231
241
|
() =>
|
|
232
242
|
snappingEnabled
|
|
233
243
|
? {
|
|
234
|
-
x:
|
|
244
|
+
x: tablePreserveWidth
|
|
245
|
+
? defaultTablePreserveSnappingWidths(containerWidth)
|
|
246
|
+
: defaultSnappingWidths,
|
|
235
247
|
}
|
|
236
248
|
: undefined,
|
|
237
|
-
[snappingEnabled],
|
|
249
|
+
[snappingEnabled, tablePreserveWidth, containerWidth],
|
|
238
250
|
);
|
|
239
251
|
|
|
240
252
|
useEffect(() => {
|
|
@@ -270,9 +282,12 @@ export const TableResizer = ({
|
|
|
270
282
|
dispatch(tr);
|
|
271
283
|
|
|
272
284
|
const visibleGuidelines = getVisibleGuidelines(
|
|
273
|
-
|
|
285
|
+
tablePreserveWidth
|
|
286
|
+
? defaultGuidelinesForPreserveTable(containerWidth)
|
|
287
|
+
: defaultGuidelines,
|
|
274
288
|
containerWidth,
|
|
275
289
|
);
|
|
290
|
+
|
|
276
291
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
277
292
|
if (
|
|
278
293
|
getBooleanFF('platform.editor.resizing-table-height-improvement') &&
|
|
@@ -281,12 +296,13 @@ export const TableResizer = ({
|
|
|
281
296
|
onResizeStart();
|
|
282
297
|
}
|
|
283
298
|
}, [
|
|
299
|
+
startMeasure,
|
|
300
|
+
editorView,
|
|
284
301
|
displayGapCursor,
|
|
302
|
+
tablePreserveWidth,
|
|
303
|
+
containerWidth,
|
|
285
304
|
displayGuideline,
|
|
286
|
-
editorView,
|
|
287
|
-
startMeasure,
|
|
288
305
|
onResizeStart,
|
|
289
|
-
containerWidth,
|
|
290
306
|
]);
|
|
291
307
|
|
|
292
308
|
const handleResize = useCallback(
|
|
@@ -318,26 +334,30 @@ export const TableResizer = ({
|
|
|
318
334
|
updateActiveGuidelines(
|
|
319
335
|
findClosestSnap(
|
|
320
336
|
newWidth,
|
|
321
|
-
|
|
322
|
-
|
|
337
|
+
tablePreserveWidth
|
|
338
|
+
? defaultTablePreserveSnappingWidths(containerWidth)
|
|
339
|
+
: defaultSnappingWidths,
|
|
340
|
+
tablePreserveWidth
|
|
341
|
+
? defaultGuidelinesForPreserveTable(containerWidth)
|
|
342
|
+
: defaultGuidelines,
|
|
323
343
|
TABLE_HIGHLIGHT_GAP,
|
|
324
344
|
TABLE_HIGHLIGHT_TOLERANCE,
|
|
325
345
|
),
|
|
326
346
|
);
|
|
327
|
-
|
|
328
347
|
updateWidth(newWidth);
|
|
329
348
|
|
|
330
349
|
return newWidth;
|
|
331
350
|
},
|
|
332
351
|
[
|
|
333
|
-
editorView,
|
|
334
|
-
getPos,
|
|
335
|
-
node,
|
|
336
|
-
tableRef,
|
|
337
|
-
updateWidth,
|
|
338
|
-
updateActiveGuidelines,
|
|
339
352
|
countFrames,
|
|
340
353
|
tablePreserveWidth,
|
|
354
|
+
tableRef,
|
|
355
|
+
node,
|
|
356
|
+
editorView,
|
|
357
|
+
updateActiveGuidelines,
|
|
358
|
+
containerWidth,
|
|
359
|
+
updateWidth,
|
|
360
|
+
getPos,
|
|
341
361
|
],
|
|
342
362
|
);
|
|
343
363
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
2
|
import { jsx } from '@emotion/react';
|
|
5
3
|
import { useIntl } from 'react-intl-next';
|
|
6
4
|
|
|
@@ -15,11 +13,11 @@ type Props = {
|
|
|
15
13
|
includeTooltip?: boolean;
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
export const ColumnResizeWidget
|
|
16
|
+
export const ColumnResizeWidget = ({
|
|
19
17
|
startIndex,
|
|
20
18
|
endIndex,
|
|
21
19
|
includeTooltip,
|
|
22
|
-
}) => {
|
|
20
|
+
}: Props) => {
|
|
23
21
|
const { formatMessage } = useIntl();
|
|
24
22
|
|
|
25
23
|
if (!includeTooltip) {
|
|
@@ -13,13 +13,13 @@ export interface Props {
|
|
|
13
13
|
marginTop?: number;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const ColumnDropTarget
|
|
16
|
+
export const ColumnDropTarget = ({
|
|
17
17
|
index,
|
|
18
18
|
localId,
|
|
19
19
|
width,
|
|
20
20
|
height,
|
|
21
21
|
marginTop,
|
|
22
|
-
}) => {
|
|
22
|
+
}: Props) => {
|
|
23
23
|
const dropTargetRef = useRef<HTMLDivElement | null>(null);
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
@@ -13,14 +13,14 @@ export interface Props {
|
|
|
13
13
|
getScrollOffset?: () => number;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const ColumnDropTargets
|
|
16
|
+
export const ColumnDropTargets = ({
|
|
17
17
|
tableRef,
|
|
18
18
|
tableHeight,
|
|
19
19
|
localId,
|
|
20
20
|
colWidths,
|
|
21
21
|
isHeaderSticky,
|
|
22
22
|
getScrollOffset,
|
|
23
|
-
}) => {
|
|
23
|
+
}: Props) => {
|
|
24
24
|
const dropTargetRef = useRef<HTMLDivElement>(null);
|
|
25
25
|
|
|
26
26
|
if (!tableRef) {
|
|
@@ -40,7 +40,7 @@ export interface Props {
|
|
|
40
40
|
getScrollOffset?: () => number;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export const TableFloatingColumnControls
|
|
43
|
+
export const TableFloatingColumnControls = ({
|
|
44
44
|
editorView,
|
|
45
45
|
tableRef,
|
|
46
46
|
getNode,
|
|
@@ -55,7 +55,7 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
55
55
|
tableContainerWidth,
|
|
56
56
|
isNumberColumnEnabled,
|
|
57
57
|
getScrollOffset,
|
|
58
|
-
}) => {
|
|
58
|
+
}: Props) => {
|
|
59
59
|
const [tableRect, setTableRect] = useState<{ width: number; height: number }>(
|
|
60
60
|
{ width: 0, height: 0 },
|
|
61
61
|
);
|
package/src/utils/drag-menu.ts
CHANGED
|
@@ -141,7 +141,7 @@ export type DragMenuOptionIdType =
|
|
|
141
141
|
|
|
142
142
|
export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
143
143
|
id: DragMenuOptionIdType;
|
|
144
|
-
icon?: React.ComponentType<IconProps
|
|
144
|
+
icon?: React.ComponentType<React.PropsWithChildren<IconProps>>;
|
|
145
145
|
keymap?: string;
|
|
146
146
|
}
|
|
147
147
|
|
package/src/utils/guidelines.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
|
|
2
2
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
calculateDefaultSnappings,
|
|
6
|
+
calculateDefaultTablePreserveSnappings,
|
|
7
|
+
} from './snapping';
|
|
5
8
|
|
|
6
9
|
// NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
|
|
7
10
|
// If we don't do this then the guidelines will not align correctly to the edge of the table
|
|
@@ -9,3 +12,11 @@ export const defaultGuidelines = createFixedGuidelinesFromLengths([
|
|
|
9
12
|
0,
|
|
10
13
|
...calculateDefaultSnappings(-1),
|
|
11
14
|
]) as GuidelineConfig[];
|
|
15
|
+
|
|
16
|
+
export const defaultGuidelinesForPreserveTable = (
|
|
17
|
+
editorContainerWidth: number,
|
|
18
|
+
) =>
|
|
19
|
+
createFixedGuidelinesFromLengths([
|
|
20
|
+
0,
|
|
21
|
+
...calculateDefaultTablePreserveSnappings(-1, editorContainerWidth),
|
|
22
|
+
]) as GuidelineConfig[];
|
package/src/utils/snapping.ts
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
akEditorCalculatedWideLayoutWidth,
|
|
5
5
|
akEditorDefaultLayoutWidth,
|
|
6
6
|
akEditorFullWidthLayoutWidth,
|
|
7
|
+
akEditorGutterPadding,
|
|
8
|
+
akEditorMediaResizeHandlerPaddingWide,
|
|
7
9
|
} from '@atlaskit/editor-shared-styles';
|
|
8
10
|
|
|
9
11
|
const numberOfLanesInDefaultLayoutWidth = 12;
|
|
@@ -23,8 +25,42 @@ export const calculateDefaultSnappings = (lengthOffset: number = 0) => [
|
|
|
23
25
|
akEditorFullWidthLayoutWidth + lengthOffset,
|
|
24
26
|
];
|
|
25
27
|
|
|
28
|
+
// FF TablePreserve for calculateDefaultSnappings
|
|
29
|
+
export const calculateDefaultTablePreserveSnappings = (
|
|
30
|
+
lengthOffset: number = 0,
|
|
31
|
+
editorContainerWith: number = akEditorFullWidthLayoutWidth,
|
|
32
|
+
) => {
|
|
33
|
+
const dynamicFullWidthLine =
|
|
34
|
+
editorContainerWith - akEditorGutterPadding * 2 >=
|
|
35
|
+
akEditorFullWidthLayoutWidth
|
|
36
|
+
? akEditorFullWidthLayoutWidth
|
|
37
|
+
: editorContainerWith -
|
|
38
|
+
akEditorGutterPadding * 2 -
|
|
39
|
+
akEditorMediaResizeHandlerPaddingWide;
|
|
40
|
+
|
|
41
|
+
return [
|
|
42
|
+
...calculateSubSnappingWidths(
|
|
43
|
+
numberOfLanesInDefaultLayoutWidth,
|
|
44
|
+
akEditorDefaultLayoutWidth + lengthOffset,
|
|
45
|
+
),
|
|
46
|
+
akEditorDefaultLayoutWidth + lengthOffset,
|
|
47
|
+
akEditorCalculatedWideLayoutWidth + lengthOffset,
|
|
48
|
+
dynamicFullWidthLine - lengthOffset,
|
|
49
|
+
];
|
|
50
|
+
};
|
|
51
|
+
|
|
26
52
|
export const defaultSnappingWidths = calculateDefaultSnappings();
|
|
27
53
|
|
|
54
|
+
// FF TablePreserve for defaultSnappingWidths
|
|
55
|
+
export const defaultTablePreserveSnappingWidths = (
|
|
56
|
+
editorContainerWidth: number,
|
|
57
|
+
) => {
|
|
58
|
+
return editorContainerWidth - akEditorGutterPadding * 2 >
|
|
59
|
+
akEditorFullWidthLayoutWidth
|
|
60
|
+
? calculateDefaultSnappings()
|
|
61
|
+
: calculateDefaultTablePreserveSnappings(0, editorContainerWidth);
|
|
62
|
+
};
|
|
63
|
+
|
|
28
64
|
/**
|
|
29
65
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
30
66
|
*/
|