@atlaskit/editor-plugin-table 2.14.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +52 -9
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +11 -2
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +54 -13
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +11 -2
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +52 -9
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +11 -2
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +5 -1
- package/dist/types/plugins/table/types.d.ts +0 -6
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +0 -6
- package/package.json +7 -4
- package/report.api.md +0 -12
- package/src/plugins/table/nodeviews/TableContainer.tsx +73 -13
- package/src/plugins/table/nodeviews/TableResizer.tsx +24 -1
- package/src/plugins/table/types.ts +0 -7
- package/tmp/api-report-tmp.d.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`18e8e6cc9c8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/18e8e6cc9c8) - ED-19782: Clean up feature flag types from table optimisation related feature flags.
|
|
8
|
+
|
|
9
|
+
## 2.14.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`b6525ba4703`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b6525ba4703) - [ux] Reimplement inline height for table when resizing
|
|
14
|
+
|
|
3
15
|
## 2.14.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -6,16 +6,20 @@ 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"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
12
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
12
13
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
16
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
15
17
|
var _types = require("../types");
|
|
16
18
|
var _TableResizer = require("./TableResizer");
|
|
17
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
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; }
|
|
19
23
|
var getMarginLeft = function getMarginLeft(lineLength, tableWidth) {
|
|
20
24
|
var marginLeft;
|
|
21
25
|
if (tableWidth !== 'inherit' && lineLength) {
|
|
@@ -55,6 +59,38 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
55
59
|
var containerRef = (0, _react.useRef)(null);
|
|
56
60
|
var marginLeftRef = (0, _react.useRef)(0);
|
|
57
61
|
var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
|
|
62
|
+
var updateContainerHeight = (0, _react.useCallback)(function (height) {
|
|
63
|
+
var _containerRef$current;
|
|
64
|
+
// current StickyHeader State is not stable to be fetch.
|
|
65
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
66
|
+
// consistently fetch and refactor below
|
|
67
|
+
var stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
68
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
69
|
+
var _containerRef$current2;
|
|
70
|
+
// when starting to drag, we need to keep the original space,
|
|
71
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
72
|
+
// 1px is border width but collapse make it 0.5.
|
|
73
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
74
|
+
// collapsed border
|
|
75
|
+
(_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.setProperty('height', typeof height === 'number' ? "".concat(height + 40.5, "px") : 'auto');
|
|
76
|
+
} else {
|
|
77
|
+
var _containerRef$current3, _containerRef$current4;
|
|
78
|
+
var stickyHeaderHeight = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
79
|
+
(_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.style.setProperty('height', typeof height === 'number' ? "".concat(height + stickyHeaderHeight + 39.5, "px") : 'auto');
|
|
80
|
+
}
|
|
81
|
+
}, []);
|
|
82
|
+
var resizeObserverRef = (0, _react.useRef)(new ResizeObserver(function (entries) {
|
|
83
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
84
|
+
}));
|
|
85
|
+
var onResizeStart = (0, _react.useCallback)(function () {
|
|
86
|
+
if (tableRef) {
|
|
87
|
+
resizeObserverRef.current.observe(tableRef);
|
|
88
|
+
}
|
|
89
|
+
}, [tableRef]);
|
|
90
|
+
var onResizeStop = (0, _react.useCallback)(function () {
|
|
91
|
+
updateContainerHeight('auto');
|
|
92
|
+
resizeObserverRef.current.disconnect();
|
|
93
|
+
}, [updateContainerHeight]);
|
|
58
94
|
var updateWidth = (0, _react.useCallback)(function (width) {
|
|
59
95
|
if (!containerRef.current) {
|
|
60
96
|
return;
|
|
@@ -98,14 +134,7 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
98
134
|
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
99
135
|
}
|
|
100
136
|
var maxResizerWidth = Math.min(responsiveContainerWidth, _utils.TABLE_MAX_WIDTH);
|
|
101
|
-
|
|
102
|
-
style: {
|
|
103
|
-
marginLeft: marginLeftRef.current,
|
|
104
|
-
width: tableWidthRef.current
|
|
105
|
-
},
|
|
106
|
-
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
107
|
-
ref: containerRef
|
|
108
|
-
}, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, {
|
|
137
|
+
var tableResizerProps = {
|
|
109
138
|
width: width,
|
|
110
139
|
maxWidth: maxResizerWidth,
|
|
111
140
|
containerWidth: containerWidth,
|
|
@@ -117,7 +146,21 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
117
146
|
displayGuideline: displayGuideline,
|
|
118
147
|
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
119
148
|
displayGapCursor: displayGapCursor
|
|
120
|
-
}
|
|
149
|
+
};
|
|
150
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement')) {
|
|
151
|
+
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
152
|
+
onResizeStart: onResizeStart,
|
|
153
|
+
onResizeStop: onResizeStop
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
157
|
+
style: {
|
|
158
|
+
marginLeft: marginLeftRef.current,
|
|
159
|
+
width: tableWidthRef.current
|
|
160
|
+
},
|
|
161
|
+
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
162
|
+
ref: containerRef
|
|
163
|
+
}, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, tableResizerProps, /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
121
164
|
className: className,
|
|
122
165
|
node: node
|
|
123
166
|
}, children)));
|
|
@@ -14,6 +14,7 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
14
14
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
15
15
|
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
16
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
18
19
|
var _utils2 = require("../pm-plugins/table-resizing/utils");
|
|
19
20
|
var _tableWidth = require("../pm-plugins/table-width");
|
|
@@ -85,6 +86,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
85
86
|
maxWidth = _ref.maxWidth,
|
|
86
87
|
containerWidth = _ref.containerWidth,
|
|
87
88
|
updateWidth = _ref.updateWidth,
|
|
89
|
+
onResizeStop = _ref.onResizeStop,
|
|
90
|
+
onResizeStart = _ref.onResizeStart,
|
|
88
91
|
editorView = _ref.editorView,
|
|
89
92
|
getPos = _ref.getPos,
|
|
90
93
|
node = _ref.node,
|
|
@@ -145,7 +148,10 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
145
148
|
dispatch(tr);
|
|
146
149
|
var visibleGuidelines = getVisibleGuidelines(_guidelines.defaultGuidelines, containerWidth);
|
|
147
150
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
148
|
-
|
|
151
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
152
|
+
onResizeStart();
|
|
153
|
+
}
|
|
154
|
+
}, [displayGapCursor, displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
149
155
|
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
150
156
|
countFrames();
|
|
151
157
|
var newWidth = originalState.width + delta.width;
|
|
@@ -217,8 +223,11 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
217
223
|
displayGuideline([]);
|
|
218
224
|
updateWidth(newWidth);
|
|
219
225
|
scheduleResize.cancel();
|
|
226
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.resizing-table-height-improvement') && onResizeStop) {
|
|
227
|
+
onResizeStop();
|
|
228
|
+
}
|
|
220
229
|
return newWidth;
|
|
221
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
230
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
222
231
|
var isTableSelected = ((_findTable = (0, _utils.findTable)((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos();
|
|
223
232
|
return /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
|
|
224
233
|
enable: handles,
|
|
@@ -3,6 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
4
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
7
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
8
9
|
import { TableResizer } from './TableResizer';
|
|
@@ -46,6 +47,38 @@ export const ResizableTableContainer = ({
|
|
|
46
47
|
const containerRef = useRef(null);
|
|
47
48
|
const marginLeftRef = useRef(0);
|
|
48
49
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
50
|
+
const updateContainerHeight = useCallback(height => {
|
|
51
|
+
var _containerRef$current;
|
|
52
|
+
// current StickyHeader State is not stable to be fetch.
|
|
53
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
54
|
+
// consistently fetch and refactor below
|
|
55
|
+
const stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
56
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
57
|
+
var _containerRef$current2;
|
|
58
|
+
// when starting to drag, we need to keep the original space,
|
|
59
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
60
|
+
// 1px is border width but collapse make it 0.5.
|
|
61
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
62
|
+
// collapsed border
|
|
63
|
+
(_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.setProperty('height', typeof height === 'number' ? `${height + 40.5}px` : 'auto');
|
|
64
|
+
} else {
|
|
65
|
+
var _containerRef$current3, _containerRef$current4;
|
|
66
|
+
const stickyHeaderHeight = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
67
|
+
(_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.style.setProperty('height', typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto');
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
const resizeObserverRef = useRef(new ResizeObserver(entries => {
|
|
71
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
72
|
+
}));
|
|
73
|
+
const onResizeStart = useCallback(() => {
|
|
74
|
+
if (tableRef) {
|
|
75
|
+
resizeObserverRef.current.observe(tableRef);
|
|
76
|
+
}
|
|
77
|
+
}, [tableRef]);
|
|
78
|
+
const onResizeStop = useCallback(() => {
|
|
79
|
+
updateContainerHeight('auto');
|
|
80
|
+
resizeObserverRef.current.disconnect();
|
|
81
|
+
}, [updateContainerHeight]);
|
|
49
82
|
const updateWidth = useCallback(width => {
|
|
50
83
|
if (!containerRef.current) {
|
|
51
84
|
return;
|
|
@@ -89,6 +122,26 @@ export const ResizableTableContainer = ({
|
|
|
89
122
|
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
90
123
|
}
|
|
91
124
|
const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
125
|
+
let tableResizerProps = {
|
|
126
|
+
width,
|
|
127
|
+
maxWidth: maxResizerWidth,
|
|
128
|
+
containerWidth,
|
|
129
|
+
updateWidth,
|
|
130
|
+
editorView,
|
|
131
|
+
getPos,
|
|
132
|
+
node,
|
|
133
|
+
tableRef,
|
|
134
|
+
displayGuideline,
|
|
135
|
+
attachAnalyticsEvent,
|
|
136
|
+
displayGapCursor
|
|
137
|
+
};
|
|
138
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
139
|
+
tableResizerProps = {
|
|
140
|
+
...tableResizerProps,
|
|
141
|
+
onResizeStart: onResizeStart,
|
|
142
|
+
onResizeStop: onResizeStop
|
|
143
|
+
};
|
|
144
|
+
}
|
|
92
145
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
146
|
style: {
|
|
94
147
|
marginLeft: marginLeftRef.current,
|
|
@@ -96,19 +149,7 @@ export const ResizableTableContainer = ({
|
|
|
96
149
|
},
|
|
97
150
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
98
151
|
ref: containerRef
|
|
99
|
-
}, /*#__PURE__*/React.createElement(TableResizer, {
|
|
100
|
-
width: width,
|
|
101
|
-
maxWidth: maxResizerWidth,
|
|
102
|
-
containerWidth: containerWidth,
|
|
103
|
-
updateWidth: updateWidth,
|
|
104
|
-
editorView: editorView,
|
|
105
|
-
getPos: getPos,
|
|
106
|
-
node: node,
|
|
107
|
-
tableRef: tableRef,
|
|
108
|
-
displayGuideline: displayGuideline,
|
|
109
|
-
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
110
|
-
displayGapCursor: displayGapCursor
|
|
111
|
-
}, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
152
|
+
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
112
153
|
className: className,
|
|
113
154
|
node: node
|
|
114
155
|
}, children)));
|
|
@@ -4,6 +4,7 @@ import { defineMessages, useIntl } from 'react-intl-next';
|
|
|
4
4
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
5
5
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
6
6
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
8
9
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
9
10
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
@@ -70,6 +71,8 @@ export const TableResizer = ({
|
|
|
70
71
|
maxWidth,
|
|
71
72
|
containerWidth,
|
|
72
73
|
updateWidth,
|
|
74
|
+
onResizeStop,
|
|
75
|
+
onResizeStart,
|
|
73
76
|
editorView,
|
|
74
77
|
getPos,
|
|
75
78
|
node,
|
|
@@ -135,7 +138,10 @@ export const TableResizer = ({
|
|
|
135
138
|
dispatch(tr);
|
|
136
139
|
const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
137
140
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
138
|
-
|
|
141
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
142
|
+
onResizeStart();
|
|
143
|
+
}
|
|
144
|
+
}, [displayGapCursor, displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
139
145
|
const handleResize = useCallback((originalState, delta) => {
|
|
140
146
|
countFrames();
|
|
141
147
|
const newWidth = originalState.width + delta.width;
|
|
@@ -208,8 +214,11 @@ export const TableResizer = ({
|
|
|
208
214
|
displayGuideline([]);
|
|
209
215
|
updateWidth(newWidth);
|
|
210
216
|
scheduleResize.cancel();
|
|
217
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStop) {
|
|
218
|
+
onResizeStop();
|
|
219
|
+
}
|
|
211
220
|
return newWidth;
|
|
212
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
221
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
213
222
|
const isTableSelected = ((_findTable = findTable((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos();
|
|
214
223
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
215
224
|
enable: handles,
|
|
@@ -1,8 +1,12 @@
|
|
|
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
|
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
2
5
|
import classNames from 'classnames';
|
|
3
6
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
7
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
5
8
|
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
9
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
10
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
7
11
|
import { TableCssClassName as ClassName } from '../types';
|
|
8
12
|
import { TableResizer } from './TableResizer';
|
|
@@ -44,6 +48,38 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
44
48
|
var containerRef = useRef(null);
|
|
45
49
|
var marginLeftRef = useRef(0);
|
|
46
50
|
var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
51
|
+
var updateContainerHeight = useCallback(function (height) {
|
|
52
|
+
var _containerRef$current;
|
|
53
|
+
// current StickyHeader State is not stable to be fetch.
|
|
54
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
55
|
+
// consistently fetch and refactor below
|
|
56
|
+
var stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
57
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
58
|
+
var _containerRef$current2;
|
|
59
|
+
// when starting to drag, we need to keep the original space,
|
|
60
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
61
|
+
// 1px is border width but collapse make it 0.5.
|
|
62
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
63
|
+
// collapsed border
|
|
64
|
+
(_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.setProperty('height', typeof height === 'number' ? "".concat(height + 40.5, "px") : 'auto');
|
|
65
|
+
} else {
|
|
66
|
+
var _containerRef$current3, _containerRef$current4;
|
|
67
|
+
var stickyHeaderHeight = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
68
|
+
(_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.style.setProperty('height', typeof height === 'number' ? "".concat(height + stickyHeaderHeight + 39.5, "px") : 'auto');
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
var resizeObserverRef = useRef(new ResizeObserver(function (entries) {
|
|
72
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
73
|
+
}));
|
|
74
|
+
var onResizeStart = useCallback(function () {
|
|
75
|
+
if (tableRef) {
|
|
76
|
+
resizeObserverRef.current.observe(tableRef);
|
|
77
|
+
}
|
|
78
|
+
}, [tableRef]);
|
|
79
|
+
var onResizeStop = useCallback(function () {
|
|
80
|
+
updateContainerHeight('auto');
|
|
81
|
+
resizeObserverRef.current.disconnect();
|
|
82
|
+
}, [updateContainerHeight]);
|
|
47
83
|
var updateWidth = useCallback(function (width) {
|
|
48
84
|
if (!containerRef.current) {
|
|
49
85
|
return;
|
|
@@ -87,14 +123,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
87
123
|
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
88
124
|
}
|
|
89
125
|
var maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
90
|
-
|
|
91
|
-
style: {
|
|
92
|
-
marginLeft: marginLeftRef.current,
|
|
93
|
-
width: tableWidthRef.current
|
|
94
|
-
},
|
|
95
|
-
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
96
|
-
ref: containerRef
|
|
97
|
-
}, /*#__PURE__*/React.createElement(TableResizer, {
|
|
126
|
+
var tableResizerProps = {
|
|
98
127
|
width: width,
|
|
99
128
|
maxWidth: maxResizerWidth,
|
|
100
129
|
containerWidth: containerWidth,
|
|
@@ -106,7 +135,21 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
106
135
|
displayGuideline: displayGuideline,
|
|
107
136
|
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
108
137
|
displayGapCursor: displayGapCursor
|
|
109
|
-
}
|
|
138
|
+
};
|
|
139
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
140
|
+
tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
|
|
141
|
+
onResizeStart: onResizeStart,
|
|
142
|
+
onResizeStop: onResizeStop
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
style: {
|
|
147
|
+
marginLeft: marginLeftRef.current,
|
|
148
|
+
width: tableWidthRef.current
|
|
149
|
+
},
|
|
150
|
+
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
151
|
+
ref: containerRef
|
|
152
|
+
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
110
153
|
className: className,
|
|
111
154
|
node: node
|
|
112
155
|
}, children)));
|
|
@@ -8,6 +8,7 @@ import { defineMessages, useIntl } from 'react-intl-next';
|
|
|
8
8
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
9
9
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
12
13
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
13
14
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
@@ -75,6 +76,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
75
76
|
maxWidth = _ref.maxWidth,
|
|
76
77
|
containerWidth = _ref.containerWidth,
|
|
77
78
|
updateWidth = _ref.updateWidth,
|
|
79
|
+
onResizeStop = _ref.onResizeStop,
|
|
80
|
+
onResizeStart = _ref.onResizeStart,
|
|
78
81
|
editorView = _ref.editorView,
|
|
79
82
|
getPos = _ref.getPos,
|
|
80
83
|
node = _ref.node,
|
|
@@ -135,7 +138,10 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
135
138
|
dispatch(tr);
|
|
136
139
|
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
137
140
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
138
|
-
|
|
141
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
142
|
+
onResizeStart();
|
|
143
|
+
}
|
|
144
|
+
}, [displayGapCursor, displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
139
145
|
var handleResize = useCallback(function (originalState, delta) {
|
|
140
146
|
countFrames();
|
|
141
147
|
var newWidth = originalState.width + delta.width;
|
|
@@ -207,8 +213,11 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
207
213
|
displayGuideline([]);
|
|
208
214
|
updateWidth(newWidth);
|
|
209
215
|
scheduleResize.cancel();
|
|
216
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStop) {
|
|
217
|
+
onResizeStop();
|
|
218
|
+
}
|
|
210
219
|
return newWidth;
|
|
211
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
220
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
212
221
|
var isTableSelected = ((_findTable = findTable((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos();
|
|
213
222
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
214
223
|
enable: handles,
|
|
@@ -17,5 +17,9 @@ interface TableResizerProps {
|
|
|
17
17
|
attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
|
|
18
18
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
21
|
+
onResizeStop?: () => void;
|
|
22
|
+
onResizeStart?: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
|
|
21
25
|
export {};
|
|
@@ -40,12 +40,6 @@ export interface PluginConfig {
|
|
|
40
40
|
stickyHeaders?: boolean;
|
|
41
41
|
allowCellOptionsInFloatingToolbar?: boolean;
|
|
42
42
|
allowDistributeColumns?: boolean;
|
|
43
|
-
tableCellOptimization?: boolean;
|
|
44
|
-
tableRenderOptimization?: boolean;
|
|
45
|
-
stickyHeadersOptimization?: boolean;
|
|
46
|
-
initialRenderOptimization?: boolean;
|
|
47
|
-
mouseMoveOptimization?: boolean;
|
|
48
|
-
tableOverflowShadowsOptimization?: boolean;
|
|
49
43
|
}
|
|
50
44
|
export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
|
|
51
45
|
export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
|
|
@@ -17,5 +17,9 @@ interface TableResizerProps {
|
|
|
17
17
|
attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
|
|
18
18
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
21
|
+
onResizeStop?: () => void;
|
|
22
|
+
onResizeStart?: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
|
|
21
25
|
export {};
|
|
@@ -40,12 +40,6 @@ export interface PluginConfig {
|
|
|
40
40
|
stickyHeaders?: boolean;
|
|
41
41
|
allowCellOptionsInFloatingToolbar?: boolean;
|
|
42
42
|
allowDistributeColumns?: boolean;
|
|
43
|
-
tableCellOptimization?: boolean;
|
|
44
|
-
tableRenderOptimization?: boolean;
|
|
45
|
-
stickyHeadersOptimization?: boolean;
|
|
46
|
-
initialRenderOptimization?: boolean;
|
|
47
|
-
mouseMoveOptimization?: boolean;
|
|
48
|
-
tableOverflowShadowsOptimization?: boolean;
|
|
49
43
|
}
|
|
50
44
|
export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
|
|
51
45
|
export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^29.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^74.
|
|
31
|
+
"@atlaskit/editor-common": "^74.59.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/icon": "^21.12.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
40
40
|
"@atlaskit/theme": "^12.6.0",
|
|
41
|
-
"@atlaskit/tokens": "^1.
|
|
41
|
+
"@atlaskit/tokens": "^1.22.0",
|
|
42
42
|
"@atlaskit/tooltip": "^17.8.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
|
44
44
|
"@emotion/react": "^11.7.1",
|
|
@@ -105,8 +105,11 @@
|
|
|
105
105
|
"platform.editor.update-table-cell-width-via-step": {
|
|
106
106
|
"type": "boolean"
|
|
107
107
|
},
|
|
108
|
+
"platform.editor.resizing-table-height-improvement": {
|
|
109
|
+
"type": "boolean"
|
|
110
|
+
},
|
|
108
111
|
"platform.editor.table-remove-update-resize-handles_djvab": {
|
|
109
112
|
"type": "boolean"
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
|
-
}
|
|
115
|
+
}
|
package/report.api.md
CHANGED
|
@@ -63,23 +63,11 @@ interface PluginConfig {
|
|
|
63
63
|
// (undocumented)
|
|
64
64
|
allowNumberColumn?: boolean;
|
|
65
65
|
// (undocumented)
|
|
66
|
-
initialRenderOptimization?: boolean;
|
|
67
|
-
// (undocumented)
|
|
68
66
|
isHeaderRowRequired?: boolean;
|
|
69
67
|
// (undocumented)
|
|
70
|
-
mouseMoveOptimization?: boolean;
|
|
71
|
-
// (undocumented)
|
|
72
68
|
permittedLayouts?: PermittedLayoutsDescriptor;
|
|
73
69
|
// (undocumented)
|
|
74
70
|
stickyHeaders?: boolean;
|
|
75
|
-
// (undocumented)
|
|
76
|
-
stickyHeadersOptimization?: boolean;
|
|
77
|
-
// (undocumented)
|
|
78
|
-
tableCellOptimization?: boolean;
|
|
79
|
-
// (undocumented)
|
|
80
|
-
tableOverflowShadowsOptimization?: boolean;
|
|
81
|
-
// (undocumented)
|
|
82
|
-
tableRenderOptimization?: boolean;
|
|
83
71
|
}
|
|
84
72
|
|
|
85
73
|
// @public (undocumented)
|
|
@@ -14,12 +14,14 @@ import {
|
|
|
14
14
|
akEditorDefaultLayoutWidth,
|
|
15
15
|
akEditorMobileBreakoutPoint,
|
|
16
16
|
} from '@atlaskit/editor-shared-styles';
|
|
17
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
|
|
18
19
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
19
20
|
import type { PluginInjectionAPI } from '../types';
|
|
20
21
|
import { TableCssClassName as ClassName } from '../types';
|
|
21
22
|
|
|
22
23
|
import { TableResizer } from './TableResizer';
|
|
24
|
+
import type { TableResizerImprovementProps } from './TableResizer';
|
|
23
25
|
|
|
24
26
|
const getMarginLeft = (lineLength: number, tableWidth: number | 'inherit') => {
|
|
25
27
|
let marginLeft;
|
|
@@ -89,6 +91,54 @@ export const ResizableTableContainer = ({
|
|
|
89
91
|
const marginLeftRef = useRef<number | undefined>(0);
|
|
90
92
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
91
93
|
|
|
94
|
+
const updateContainerHeight = useCallback((height: number | 'auto') => {
|
|
95
|
+
// current StickyHeader State is not stable to be fetch.
|
|
96
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
97
|
+
// consistently fetch and refactor below
|
|
98
|
+
const stickyHeaders =
|
|
99
|
+
containerRef.current?.getElementsByClassName('pm-table-sticky');
|
|
100
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
101
|
+
// when starting to drag, we need to keep the original space,
|
|
102
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
103
|
+
// 1px is border width but collapse make it 0.5.
|
|
104
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
105
|
+
// collapsed border
|
|
106
|
+
containerRef.current?.style.setProperty(
|
|
107
|
+
'height',
|
|
108
|
+
typeof height === 'number' ? `${height + 40.5}px` : 'auto',
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
const stickyHeaderHeight =
|
|
112
|
+
containerRef.current
|
|
113
|
+
?.getElementsByTagName('th')[0]
|
|
114
|
+
.getBoundingClientRect().height || 0;
|
|
115
|
+
containerRef.current?.style.setProperty(
|
|
116
|
+
'height',
|
|
117
|
+
typeof height === 'number'
|
|
118
|
+
? `${height + stickyHeaderHeight + 39.5}px`
|
|
119
|
+
: 'auto',
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
const resizeObserverRef = useRef(
|
|
125
|
+
new ResizeObserver((entries) => {
|
|
126
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const onResizeStart = useCallback(() => {
|
|
131
|
+
if (tableRef) {
|
|
132
|
+
resizeObserverRef.current.observe(tableRef);
|
|
133
|
+
}
|
|
134
|
+
}, [tableRef]);
|
|
135
|
+
|
|
136
|
+
const onResizeStop = useCallback(() => {
|
|
137
|
+
updateContainerHeight('auto');
|
|
138
|
+
|
|
139
|
+
resizeObserverRef.current.disconnect();
|
|
140
|
+
}, [updateContainerHeight]);
|
|
141
|
+
|
|
92
142
|
const updateWidth = useCallback(
|
|
93
143
|
(width: number) => {
|
|
94
144
|
if (!containerRef.current) {
|
|
@@ -158,6 +208,28 @@ export const ResizableTableContainer = ({
|
|
|
158
208
|
}
|
|
159
209
|
const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
160
210
|
|
|
211
|
+
let tableResizerProps: TableResizerImprovementProps = {
|
|
212
|
+
width,
|
|
213
|
+
maxWidth: maxResizerWidth,
|
|
214
|
+
containerWidth,
|
|
215
|
+
updateWidth,
|
|
216
|
+
editorView,
|
|
217
|
+
getPos,
|
|
218
|
+
node,
|
|
219
|
+
tableRef,
|
|
220
|
+
displayGuideline,
|
|
221
|
+
attachAnalyticsEvent,
|
|
222
|
+
displayGapCursor,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
226
|
+
tableResizerProps = {
|
|
227
|
+
...tableResizerProps,
|
|
228
|
+
onResizeStart: onResizeStart,
|
|
229
|
+
onResizeStop: onResizeStop,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
161
233
|
return (
|
|
162
234
|
<div
|
|
163
235
|
style={{
|
|
@@ -167,19 +239,7 @@ export const ResizableTableContainer = ({
|
|
|
167
239
|
className={ClassName.TABLE_RESIZER_CONTAINER}
|
|
168
240
|
ref={containerRef}
|
|
169
241
|
>
|
|
170
|
-
<TableResizer
|
|
171
|
-
width={width}
|
|
172
|
-
maxWidth={maxResizerWidth}
|
|
173
|
-
containerWidth={containerWidth}
|
|
174
|
-
updateWidth={updateWidth}
|
|
175
|
-
editorView={editorView}
|
|
176
|
-
getPos={getPos}
|
|
177
|
-
node={node}
|
|
178
|
-
tableRef={tableRef}
|
|
179
|
-
displayGuideline={displayGuideline}
|
|
180
|
-
attachAnalyticsEvent={attachAnalyticsEvent}
|
|
181
|
-
displayGapCursor={displayGapCursor}
|
|
182
|
-
>
|
|
242
|
+
<TableResizer {...tableResizerProps}>
|
|
183
243
|
<InnerContainer className={className} node={node}>
|
|
184
244
|
{children}
|
|
185
245
|
</InnerContainer>
|
|
@@ -22,6 +22,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
22
22
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
23
23
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
24
24
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
25
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
25
26
|
|
|
26
27
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
27
28
|
import {
|
|
@@ -60,6 +61,11 @@ interface TableResizerProps {
|
|
|
60
61
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
65
|
+
onResizeStop?: () => void;
|
|
66
|
+
onResizeStart?: () => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
const messages = defineMessages({
|
|
64
70
|
resizeTable: {
|
|
65
71
|
id: 'fabric.editor.tables.resizeTable',
|
|
@@ -135,6 +141,8 @@ export const TableResizer = ({
|
|
|
135
141
|
maxWidth,
|
|
136
142
|
containerWidth,
|
|
137
143
|
updateWidth,
|
|
144
|
+
onResizeStop,
|
|
145
|
+
onResizeStart,
|
|
138
146
|
editorView,
|
|
139
147
|
getPos,
|
|
140
148
|
node,
|
|
@@ -142,7 +150,7 @@ export const TableResizer = ({
|
|
|
142
150
|
displayGuideline,
|
|
143
151
|
attachAnalyticsEvent,
|
|
144
152
|
displayGapCursor,
|
|
145
|
-
}: PropsWithChildren<
|
|
153
|
+
}: PropsWithChildren<TableResizerImprovementProps>) => {
|
|
146
154
|
const currentGap = useRef(0);
|
|
147
155
|
// track resizing state - use ref over state to avoid re-render
|
|
148
156
|
const isResizing = useRef(false);
|
|
@@ -214,11 +222,18 @@ export const TableResizer = ({
|
|
|
214
222
|
containerWidth,
|
|
215
223
|
);
|
|
216
224
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
225
|
+
if (
|
|
226
|
+
getBooleanFF('platform.editor.resizing-table-height-improvement') &&
|
|
227
|
+
onResizeStart
|
|
228
|
+
) {
|
|
229
|
+
onResizeStart();
|
|
230
|
+
}
|
|
217
231
|
}, [
|
|
218
232
|
displayGapCursor,
|
|
219
233
|
displayGuideline,
|
|
220
234
|
editorView,
|
|
221
235
|
startMeasure,
|
|
236
|
+
onResizeStart,
|
|
222
237
|
containerWidth,
|
|
223
238
|
]);
|
|
224
239
|
|
|
@@ -330,6 +345,13 @@ export const TableResizer = ({
|
|
|
330
345
|
updateWidth(newWidth);
|
|
331
346
|
scheduleResize.cancel();
|
|
332
347
|
|
|
348
|
+
if (
|
|
349
|
+
getBooleanFF('platform.editor.resizing-table-height-improvement') &&
|
|
350
|
+
onResizeStop
|
|
351
|
+
) {
|
|
352
|
+
onResizeStop();
|
|
353
|
+
}
|
|
354
|
+
|
|
333
355
|
return newWidth;
|
|
334
356
|
},
|
|
335
357
|
[
|
|
@@ -343,6 +365,7 @@ export const TableResizer = ({
|
|
|
343
365
|
displayGuideline,
|
|
344
366
|
attachAnalyticsEvent,
|
|
345
367
|
endMeasure,
|
|
368
|
+
onResizeStop,
|
|
346
369
|
],
|
|
347
370
|
);
|
|
348
371
|
|
|
@@ -55,13 +55,6 @@ export interface PluginConfig {
|
|
|
55
55
|
stickyHeaders?: boolean;
|
|
56
56
|
allowCellOptionsInFloatingToolbar?: boolean;
|
|
57
57
|
allowDistributeColumns?: boolean;
|
|
58
|
-
// to be cleaned up in ED-19477 after confluence no longer consumes table optimisation flags
|
|
59
|
-
tableCellOptimization?: boolean;
|
|
60
|
-
tableRenderOptimization?: boolean;
|
|
61
|
-
stickyHeadersOptimization?: boolean;
|
|
62
|
-
initialRenderOptimization?: boolean;
|
|
63
|
-
mouseMoveOptimization?: boolean;
|
|
64
|
-
tableOverflowShadowsOptimization?: boolean;
|
|
65
58
|
}
|
|
66
59
|
|
|
67
60
|
export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -52,23 +52,11 @@ interface PluginConfig {
|
|
|
52
52
|
// (undocumented)
|
|
53
53
|
allowNumberColumn?: boolean;
|
|
54
54
|
// (undocumented)
|
|
55
|
-
initialRenderOptimization?: boolean;
|
|
56
|
-
// (undocumented)
|
|
57
55
|
isHeaderRowRequired?: boolean;
|
|
58
56
|
// (undocumented)
|
|
59
|
-
mouseMoveOptimization?: boolean;
|
|
60
|
-
// (undocumented)
|
|
61
57
|
permittedLayouts?: PermittedLayoutsDescriptor;
|
|
62
58
|
// (undocumented)
|
|
63
59
|
stickyHeaders?: boolean;
|
|
64
|
-
// (undocumented)
|
|
65
|
-
stickyHeadersOptimization?: boolean;
|
|
66
|
-
// (undocumented)
|
|
67
|
-
tableCellOptimization?: boolean;
|
|
68
|
-
// (undocumented)
|
|
69
|
-
tableOverflowShadowsOptimization?: boolean;
|
|
70
|
-
// (undocumented)
|
|
71
|
-
tableRenderOptimization?: boolean;
|
|
72
60
|
}
|
|
73
61
|
|
|
74
62
|
// @public (undocumented)
|