@atlaskit/editor-plugin-table 5.6.0 → 5.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +3 -28
- package/dist/cjs/plugins/table/nodeviews/TableStickyScrollbar.js +2 -5
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +3 -28
- package/dist/es2019/plugins/table/nodeviews/TableStickyScrollbar.js +2 -5
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +3 -28
- package/dist/esm/plugins/table/nodeviews/TableStickyScrollbar.js +2 -5
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types/plugins/table/nodeviews/TableStickyScrollbar.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableStickyScrollbar.d.ts +0 -1
- package/package.json +1 -4
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +3 -7
- package/src/plugins/table/nodeviews/TableContainer.tsx +13 -50
- package/src/plugins/table/nodeviews/TableStickyScrollbar.ts +2 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#61138](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/61138) [`d3a57afcd62b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d3a57afcd62b) - Cleaned references for feature flag: platform.editor.table.update-table-resizer-styles
|
|
8
|
+
|
|
9
|
+
## 5.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#61294](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/61294) [`70b236bfd951`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/70b236bfd951) - remove raf from sticky scrollbar handler to fix jittery behaviour
|
|
14
|
+
|
|
3
15
|
## 5.6.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -48,7 +48,6 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
48
48
|
var children = _ref2.children,
|
|
49
49
|
className = _ref2.className,
|
|
50
50
|
node = _ref2.node,
|
|
51
|
-
lineLength = _ref2.lineLength,
|
|
52
51
|
containerWidth = _ref2.containerWidth,
|
|
53
52
|
editorView = _ref2.editorView,
|
|
54
53
|
getPos = _ref2.getPos,
|
|
@@ -56,7 +55,6 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
56
55
|
isResizing = _ref2.isResizing,
|
|
57
56
|
pluginInjectionApi = _ref2.pluginInjectionApi;
|
|
58
57
|
var containerRef = (0, _react.useRef)(null);
|
|
59
|
-
var marginLeftRef = (0, _react.useRef)(0);
|
|
60
58
|
var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
|
|
61
59
|
var updateContainerHeight = (0, _react.useCallback)(function (height) {
|
|
62
60
|
var _containerRef$current;
|
|
@@ -102,16 +100,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
102
100
|
if (containerRef.current.style.width !== "".concat(width, "px")) {
|
|
103
101
|
containerRef.current.style.width = "".concat(width, "px");
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
var marginLeft = getMarginLeft(lineLength, width);
|
|
107
|
-
if (marginLeftRef.current !== marginLeft) {
|
|
108
|
-
marginLeftRef.current = marginLeft;
|
|
109
|
-
if (Number.isFinite(marginLeft)) {
|
|
110
|
-
containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}, [lineLength]);
|
|
103
|
+
}, []);
|
|
115
104
|
var displayGuideline = (0, _react.useCallback)(function (guidelines) {
|
|
116
105
|
var _pluginInjectionApi$g, _pluginInjectionApi$g2;
|
|
117
106
|
return (_pluginInjectionApi$g = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$g2 = pluginInjectionApi.guideline) === null || _pluginInjectionApi$g2 === void 0 || (_pluginInjectionApi$g2 = _pluginInjectionApi$g2.actions) === null || _pluginInjectionApi$g2 === void 0 ? void 0 : _pluginInjectionApi$g2.displayGuideline(editorView)({
|
|
@@ -132,9 +121,6 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
132
121
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
133
122
|
if (!isResizing) {
|
|
134
123
|
tableWidthRef.current = width;
|
|
135
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.update-table-resizer-styles')) {
|
|
136
|
-
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
137
|
-
}
|
|
138
124
|
}
|
|
139
125
|
var maxResizerWidth = Math.min(responsiveContainerWidth, _utils.TABLE_MAX_WIDTH);
|
|
140
126
|
var tableResizerProps = {
|
|
@@ -156,7 +142,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
156
142
|
onResizeStop: onResizeStop
|
|
157
143
|
});
|
|
158
144
|
}
|
|
159
|
-
return
|
|
145
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
160
146
|
style: {
|
|
161
147
|
display: 'flex',
|
|
162
148
|
justifyContent: 'center'
|
|
@@ -170,17 +156,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
170
156
|
}, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, tableResizerProps, /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
171
157
|
className: className,
|
|
172
158
|
node: node
|
|
173
|
-
}, children))))
|
|
174
|
-
style: {
|
|
175
|
-
marginLeft: marginLeftRef.current,
|
|
176
|
-
width: tableWidthRef.current
|
|
177
|
-
},
|
|
178
|
-
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
179
|
-
ref: containerRef
|
|
180
|
-
}, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, tableResizerProps, /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
181
|
-
className: className,
|
|
182
|
-
node: node
|
|
183
|
-
}, children)));
|
|
159
|
+
}, children))));
|
|
184
160
|
});
|
|
185
161
|
var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
|
|
186
162
|
var children = _ref3.children,
|
|
@@ -201,7 +177,6 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
|
|
|
201
177
|
return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
|
|
202
178
|
className: className,
|
|
203
179
|
node: node,
|
|
204
|
-
lineLength: lineLength,
|
|
205
180
|
containerWidth: editorWidth,
|
|
206
181
|
editorView: editorView,
|
|
207
182
|
getPos: getPos,
|
|
@@ -8,7 +8,6 @@ exports.TableStickyScrollbar = void 0;
|
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
11
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
13
12
|
var _types = require("../types");
|
|
14
13
|
var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function () {
|
|
@@ -22,7 +21,6 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
|
|
|
22
21
|
}
|
|
23
22
|
_this.wrapper.scrollLeft = _this.stickyScrollbarContainerElement.scrollLeft;
|
|
24
23
|
});
|
|
25
|
-
(0, _defineProperty2.default)(this, "handleScrollDebounced", (0, _rafSchd.default)(this.handleScroll));
|
|
26
24
|
this.wrapper = wrapper;
|
|
27
25
|
this.view = view;
|
|
28
26
|
this.init();
|
|
@@ -31,8 +29,7 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
|
|
|
31
29
|
key: "dispose",
|
|
32
30
|
value: function dispose() {
|
|
33
31
|
if (this.stickyScrollbarContainerElement) {
|
|
34
|
-
this.stickyScrollbarContainerElement.removeEventListener('scroll', this.
|
|
35
|
-
this.handleScrollDebounced.cancel();
|
|
32
|
+
this.stickyScrollbarContainerElement.removeEventListener('scroll', this.handleScroll);
|
|
36
33
|
}
|
|
37
34
|
this.deleteIntersectionObserver();
|
|
38
35
|
}
|
|
@@ -52,7 +49,7 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
|
|
|
52
49
|
}
|
|
53
50
|
this.stickyScrollbarContainerElement = (_this$wrapper$parentE = this.wrapper.parentElement) === null || _this$wrapper$parentE === void 0 ? void 0 : _this$wrapper$parentE.querySelector(".".concat(_types.TableCssClassName.TABLE_STICKY_SCROLLBAR_CONTAINER));
|
|
54
51
|
if (this.stickyScrollbarContainerElement) {
|
|
55
|
-
this.stickyScrollbarContainerElement.addEventListener('scroll', this.
|
|
52
|
+
this.stickyScrollbarContainerElement.addEventListener('scroll', this.handleScroll, {
|
|
56
53
|
passive: true
|
|
57
54
|
});
|
|
58
55
|
}
|
|
@@ -36,7 +36,6 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
36
36
|
children,
|
|
37
37
|
className,
|
|
38
38
|
node,
|
|
39
|
-
lineLength,
|
|
40
39
|
containerWidth,
|
|
41
40
|
editorView,
|
|
42
41
|
getPos,
|
|
@@ -45,7 +44,6 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
45
44
|
pluginInjectionApi
|
|
46
45
|
}) => {
|
|
47
46
|
const containerRef = useRef(null);
|
|
48
|
-
const marginLeftRef = useRef(0);
|
|
49
47
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
50
48
|
const updateContainerHeight = useCallback(height => {
|
|
51
49
|
var _containerRef$current;
|
|
@@ -91,16 +89,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
91
89
|
if (containerRef.current.style.width !== `${width}px`) {
|
|
92
90
|
containerRef.current.style.width = `${width}px`;
|
|
93
91
|
}
|
|
94
|
-
|
|
95
|
-
const marginLeft = getMarginLeft(lineLength, width);
|
|
96
|
-
if (marginLeftRef.current !== marginLeft) {
|
|
97
|
-
marginLeftRef.current = marginLeft;
|
|
98
|
-
if (Number.isFinite(marginLeft)) {
|
|
99
|
-
containerRef.current.style.marginLeft = `${marginLeft}px`;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}, [lineLength]);
|
|
92
|
+
}, []);
|
|
104
93
|
const displayGuideline = useCallback(guidelines => {
|
|
105
94
|
var _pluginInjectionApi$g, _pluginInjectionApi$g2, _pluginInjectionApi$g3;
|
|
106
95
|
return (_pluginInjectionApi$g = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$g2 = pluginInjectionApi.guideline) === null || _pluginInjectionApi$g2 === void 0 ? void 0 : (_pluginInjectionApi$g3 = _pluginInjectionApi$g2.actions) === null || _pluginInjectionApi$g3 === void 0 ? void 0 : _pluginInjectionApi$g3.displayGuideline(editorView)({
|
|
@@ -121,9 +110,6 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
121
110
|
const width = Math.min(tableWidth, responsiveContainerWidth);
|
|
122
111
|
if (!isResizing) {
|
|
123
112
|
tableWidthRef.current = width;
|
|
124
|
-
if (!getBooleanFF('platform.editor.table.update-table-resizer-styles')) {
|
|
125
|
-
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
126
|
-
}
|
|
127
113
|
}
|
|
128
114
|
const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
129
115
|
let tableResizerProps = {
|
|
@@ -146,7 +132,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
146
132
|
onResizeStop: onResizeStop
|
|
147
133
|
};
|
|
148
134
|
}
|
|
149
|
-
return
|
|
135
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
150
136
|
style: {
|
|
151
137
|
display: 'flex',
|
|
152
138
|
justifyContent: 'center'
|
|
@@ -160,17 +146,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
160
146
|
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
161
147
|
className: className,
|
|
162
148
|
node: node
|
|
163
|
-
}, children))))
|
|
164
|
-
style: {
|
|
165
|
-
marginLeft: marginLeftRef.current,
|
|
166
|
-
width: tableWidthRef.current
|
|
167
|
-
},
|
|
168
|
-
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
169
|
-
ref: containerRef
|
|
170
|
-
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
171
|
-
className: className,
|
|
172
|
-
node: node
|
|
173
|
-
}, children)));
|
|
149
|
+
}, children))));
|
|
174
150
|
});
|
|
175
151
|
export const TableContainer = ({
|
|
176
152
|
children,
|
|
@@ -193,7 +169,6 @@ export const TableContainer = ({
|
|
|
193
169
|
return /*#__PURE__*/React.createElement(ResizableTableContainer, {
|
|
194
170
|
className: className,
|
|
195
171
|
node: node,
|
|
196
|
-
lineLength: lineLength,
|
|
197
172
|
containerWidth: editorWidth,
|
|
198
173
|
editorView: editorView,
|
|
199
174
|
getPos: getPos,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import rafSchedule from 'raf-schd';
|
|
3
2
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
4
3
|
import { TableCssClassName as ClassName } from '../types';
|
|
5
4
|
export class TableStickyScrollbar {
|
|
@@ -11,15 +10,13 @@ export class TableStickyScrollbar {
|
|
|
11
10
|
}
|
|
12
11
|
this.wrapper.scrollLeft = this.stickyScrollbarContainerElement.scrollLeft;
|
|
13
12
|
});
|
|
14
|
-
_defineProperty(this, "handleScrollDebounced", rafSchedule(this.handleScroll));
|
|
15
13
|
this.wrapper = wrapper;
|
|
16
14
|
this.view = view;
|
|
17
15
|
this.init();
|
|
18
16
|
}
|
|
19
17
|
dispose() {
|
|
20
18
|
if (this.stickyScrollbarContainerElement) {
|
|
21
|
-
this.stickyScrollbarContainerElement.removeEventListener('scroll', this.
|
|
22
|
-
this.handleScrollDebounced.cancel();
|
|
19
|
+
this.stickyScrollbarContainerElement.removeEventListener('scroll', this.handleScroll);
|
|
23
20
|
}
|
|
24
21
|
this.deleteIntersectionObserver();
|
|
25
22
|
}
|
|
@@ -35,7 +32,7 @@ export class TableStickyScrollbar {
|
|
|
35
32
|
}
|
|
36
33
|
this.stickyScrollbarContainerElement = (_this$wrapper$parentE = this.wrapper.parentElement) === null || _this$wrapper$parentE === void 0 ? void 0 : _this$wrapper$parentE.querySelector(`.${ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER}`);
|
|
37
34
|
if (this.stickyScrollbarContainerElement) {
|
|
38
|
-
this.stickyScrollbarContainerElement.addEventListener('scroll', this.
|
|
35
|
+
this.stickyScrollbarContainerElement.addEventListener('scroll', this.handleScroll, {
|
|
39
36
|
passive: true
|
|
40
37
|
});
|
|
41
38
|
}
|
|
@@ -38,7 +38,6 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
38
38
|
var children = _ref2.children,
|
|
39
39
|
className = _ref2.className,
|
|
40
40
|
node = _ref2.node,
|
|
41
|
-
lineLength = _ref2.lineLength,
|
|
42
41
|
containerWidth = _ref2.containerWidth,
|
|
43
42
|
editorView = _ref2.editorView,
|
|
44
43
|
getPos = _ref2.getPos,
|
|
@@ -46,7 +45,6 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
46
45
|
isResizing = _ref2.isResizing,
|
|
47
46
|
pluginInjectionApi = _ref2.pluginInjectionApi;
|
|
48
47
|
var containerRef = useRef(null);
|
|
49
|
-
var marginLeftRef = useRef(0);
|
|
50
48
|
var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
51
49
|
var updateContainerHeight = useCallback(function (height) {
|
|
52
50
|
var _containerRef$current;
|
|
@@ -92,16 +90,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
92
90
|
if (containerRef.current.style.width !== "".concat(width, "px")) {
|
|
93
91
|
containerRef.current.style.width = "".concat(width, "px");
|
|
94
92
|
}
|
|
95
|
-
|
|
96
|
-
var marginLeft = getMarginLeft(lineLength, width);
|
|
97
|
-
if (marginLeftRef.current !== marginLeft) {
|
|
98
|
-
marginLeftRef.current = marginLeft;
|
|
99
|
-
if (Number.isFinite(marginLeft)) {
|
|
100
|
-
containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, [lineLength]);
|
|
93
|
+
}, []);
|
|
105
94
|
var displayGuideline = useCallback(function (guidelines) {
|
|
106
95
|
var _pluginInjectionApi$g, _pluginInjectionApi$g2;
|
|
107
96
|
return (_pluginInjectionApi$g = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$g2 = pluginInjectionApi.guideline) === null || _pluginInjectionApi$g2 === void 0 || (_pluginInjectionApi$g2 = _pluginInjectionApi$g2.actions) === null || _pluginInjectionApi$g2 === void 0 ? void 0 : _pluginInjectionApi$g2.displayGuideline(editorView)({
|
|
@@ -122,9 +111,6 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
122
111
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
123
112
|
if (!isResizing) {
|
|
124
113
|
tableWidthRef.current = width;
|
|
125
|
-
if (!getBooleanFF('platform.editor.table.update-table-resizer-styles')) {
|
|
126
|
-
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
127
|
-
}
|
|
128
114
|
}
|
|
129
115
|
var maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
130
116
|
var tableResizerProps = {
|
|
@@ -146,7 +132,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
146
132
|
onResizeStop: onResizeStop
|
|
147
133
|
});
|
|
148
134
|
}
|
|
149
|
-
return
|
|
135
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
150
136
|
style: {
|
|
151
137
|
display: 'flex',
|
|
152
138
|
justifyContent: 'center'
|
|
@@ -160,17 +146,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
160
146
|
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
161
147
|
className: className,
|
|
162
148
|
node: node
|
|
163
|
-
}, children))))
|
|
164
|
-
style: {
|
|
165
|
-
marginLeft: marginLeftRef.current,
|
|
166
|
-
width: tableWidthRef.current
|
|
167
|
-
},
|
|
168
|
-
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
169
|
-
ref: containerRef
|
|
170
|
-
}, /*#__PURE__*/React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
171
|
-
className: className,
|
|
172
|
-
node: node
|
|
173
|
-
}, children)));
|
|
149
|
+
}, children))));
|
|
174
150
|
});
|
|
175
151
|
export var TableContainer = function TableContainer(_ref3) {
|
|
176
152
|
var children = _ref3.children,
|
|
@@ -191,7 +167,6 @@ export var TableContainer = function TableContainer(_ref3) {
|
|
|
191
167
|
return /*#__PURE__*/React.createElement(ResizableTableContainer, {
|
|
192
168
|
className: className,
|
|
193
169
|
node: node,
|
|
194
|
-
lineLength: lineLength,
|
|
195
170
|
containerWidth: editorWidth,
|
|
196
171
|
editorView: editorView,
|
|
197
172
|
getPos: getPos,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import rafSchedule from 'raf-schd';
|
|
5
4
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
6
5
|
import { TableCssClassName as ClassName } from '../types';
|
|
7
6
|
export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
@@ -15,7 +14,6 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
|
15
14
|
}
|
|
16
15
|
_this.wrapper.scrollLeft = _this.stickyScrollbarContainerElement.scrollLeft;
|
|
17
16
|
});
|
|
18
|
-
_defineProperty(this, "handleScrollDebounced", rafSchedule(this.handleScroll));
|
|
19
17
|
this.wrapper = wrapper;
|
|
20
18
|
this.view = view;
|
|
21
19
|
this.init();
|
|
@@ -24,8 +22,7 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
|
24
22
|
key: "dispose",
|
|
25
23
|
value: function dispose() {
|
|
26
24
|
if (this.stickyScrollbarContainerElement) {
|
|
27
|
-
this.stickyScrollbarContainerElement.removeEventListener('scroll', this.
|
|
28
|
-
this.handleScrollDebounced.cancel();
|
|
25
|
+
this.stickyScrollbarContainerElement.removeEventListener('scroll', this.handleScroll);
|
|
29
26
|
}
|
|
30
27
|
this.deleteIntersectionObserver();
|
|
31
28
|
}
|
|
@@ -45,7 +42,7 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
|
|
|
45
42
|
}
|
|
46
43
|
this.stickyScrollbarContainerElement = (_this$wrapper$parentE = this.wrapper.parentElement) === null || _this$wrapper$parentE === void 0 ? void 0 : _this$wrapper$parentE.querySelector(".".concat(ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER));
|
|
47
44
|
if (this.stickyScrollbarContainerElement) {
|
|
48
|
-
this.stickyScrollbarContainerElement.addEventListener('scroll', this.
|
|
45
|
+
this.stickyScrollbarContainerElement.addEventListener('scroll', this.handleScroll, {
|
|
49
46
|
passive: true
|
|
50
47
|
});
|
|
51
48
|
}
|
|
@@ -17,7 +17,6 @@ export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContai
|
|
|
17
17
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
18
18
|
type ResizableTableContainerProps = {
|
|
19
19
|
containerWidth: number;
|
|
20
|
-
lineLength?: number;
|
|
21
20
|
node: PMNode;
|
|
22
21
|
className: string;
|
|
23
22
|
editorView: EditorView;
|
|
@@ -26,7 +25,7 @@ type ResizableTableContainerProps = {
|
|
|
26
25
|
isResizing?: boolean;
|
|
27
26
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
28
27
|
};
|
|
29
|
-
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node,
|
|
28
|
+
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
|
|
30
29
|
type TableContainerProps = {
|
|
31
30
|
node: PMNode;
|
|
32
31
|
className: string;
|
|
@@ -17,7 +17,6 @@ export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContai
|
|
|
17
17
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
18
18
|
type ResizableTableContainerProps = {
|
|
19
19
|
containerWidth: number;
|
|
20
|
-
lineLength?: number;
|
|
21
20
|
node: PMNode;
|
|
22
21
|
className: string;
|
|
23
22
|
editorView: EditorView;
|
|
@@ -26,7 +25,7 @@ type ResizableTableContainerProps = {
|
|
|
26
25
|
isResizing?: boolean;
|
|
27
26
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
28
27
|
};
|
|
29
|
-
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node,
|
|
28
|
+
export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
|
|
30
29
|
type TableContainerProps = {
|
|
31
30
|
node: PMNode;
|
|
32
31
|
className: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.2",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -127,9 +127,6 @@
|
|
|
127
127
|
"platform.editor.table.shift-arrowup-fix": {
|
|
128
128
|
"type": "boolean"
|
|
129
129
|
},
|
|
130
|
-
"platform.editor.table.update-table-resizer-styles": {
|
|
131
|
-
"type": "boolean"
|
|
132
|
-
},
|
|
133
130
|
"platform.editor.table-update-colwidths-after-column-is-deleted": {
|
|
134
131
|
"type": "boolean"
|
|
135
132
|
},
|
|
@@ -258,7 +258,6 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
258
258
|
const { container } = render(
|
|
259
259
|
<ResizableTableContainer
|
|
260
260
|
containerWidth={1800}
|
|
261
|
-
lineLength={720}
|
|
262
261
|
node={table}
|
|
263
262
|
className={''}
|
|
264
263
|
editorView={editorView}
|
|
@@ -272,10 +271,10 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
272
271
|
|
|
273
272
|
test('when width attribute is not set', () => {
|
|
274
273
|
const container = buildContainer({ layout: 'wide' });
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
const style = window.getComputedStyle(
|
|
275
|
+
container.firstChild?.firstChild as Element,
|
|
276
|
+
);
|
|
277
277
|
expect(style.width).toBe(`${akEditorWideLayoutWidth}px`);
|
|
278
|
-
expect(style.marginLeft).toBe('-120px');
|
|
279
278
|
});
|
|
280
279
|
});
|
|
281
280
|
|
|
@@ -287,7 +286,6 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
287
286
|
const { container } = render(
|
|
288
287
|
<ResizableTableContainer
|
|
289
288
|
containerWidth={1800}
|
|
290
|
-
lineLength={720}
|
|
291
289
|
node={table}
|
|
292
290
|
className={''}
|
|
293
291
|
editorView={editorView}
|
|
@@ -383,7 +381,6 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
383
381
|
const { container } = render(
|
|
384
382
|
<ResizableTableContainer
|
|
385
383
|
containerWidth={1800}
|
|
386
|
-
lineLength={720}
|
|
387
384
|
node={table}
|
|
388
385
|
className={''}
|
|
389
386
|
editorView={editorView}
|
|
@@ -442,7 +439,6 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
442
439
|
const { container, unmount } = render(
|
|
443
440
|
<ResizableTableContainer
|
|
444
441
|
containerWidth={1800}
|
|
445
|
-
lineLength={720}
|
|
446
442
|
node={table}
|
|
447
443
|
className={''}
|
|
448
444
|
editorView={editorView}
|
|
@@ -68,7 +68,6 @@ export const InnerContainer = forwardRef<
|
|
|
68
68
|
|
|
69
69
|
type ResizableTableContainerProps = {
|
|
70
70
|
containerWidth: number;
|
|
71
|
-
lineLength?: number;
|
|
72
71
|
node: PMNode;
|
|
73
72
|
className: string;
|
|
74
73
|
editorView: EditorView;
|
|
@@ -83,7 +82,6 @@ export const ResizableTableContainer = React.memo(
|
|
|
83
82
|
children,
|
|
84
83
|
className,
|
|
85
84
|
node,
|
|
86
|
-
lineLength,
|
|
87
85
|
containerWidth,
|
|
88
86
|
editorView,
|
|
89
87
|
getPos,
|
|
@@ -92,7 +90,6 @@ export const ResizableTableContainer = React.memo(
|
|
|
92
90
|
pluginInjectionApi,
|
|
93
91
|
}: PropsWithChildren<ResizableTableContainerProps>) => {
|
|
94
92
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
95
|
-
const marginLeftRef = useRef<number | undefined>(0);
|
|
96
93
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
97
94
|
|
|
98
95
|
const updateContainerHeight = useCallback((height: number | 'auto') => {
|
|
@@ -143,34 +140,19 @@ export const ResizableTableContainer = React.memo(
|
|
|
143
140
|
resizeObserverRef.current.disconnect();
|
|
144
141
|
}, [updateContainerHeight]);
|
|
145
142
|
|
|
146
|
-
const updateWidth = useCallback(
|
|
147
|
-
(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// make sure during resizing
|
|
153
|
-
// the pm-table-resizer-container width is the same as its child div resizer-item
|
|
154
|
-
// otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
|
|
155
|
-
// and cause the fabric-editor-popup-scroll-parent to overflow
|
|
156
|
-
if (containerRef.current.style.width !== `${width}px`) {
|
|
157
|
-
containerRef.current.style.width = `${width}px`;
|
|
158
|
-
}
|
|
143
|
+
const updateWidth = useCallback((width: number) => {
|
|
144
|
+
if (!containerRef.current) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
159
147
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
[lineLength],
|
|
173
|
-
);
|
|
148
|
+
// make sure during resizing
|
|
149
|
+
// the pm-table-resizer-container width is the same as its child div resizer-item
|
|
150
|
+
// otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
|
|
151
|
+
// and cause the fabric-editor-popup-scroll-parent to overflow
|
|
152
|
+
if (containerRef.current.style.width !== `${width}px`) {
|
|
153
|
+
containerRef.current.style.width = `${width}px`;
|
|
154
|
+
}
|
|
155
|
+
}, []);
|
|
174
156
|
|
|
175
157
|
const displayGuideline = useCallback(
|
|
176
158
|
(guidelines: GuidelineConfig[]) => {
|
|
@@ -210,9 +192,6 @@ export const ResizableTableContainer = React.memo(
|
|
|
210
192
|
|
|
211
193
|
if (!isResizing) {
|
|
212
194
|
tableWidthRef.current = width;
|
|
213
|
-
if (!getBooleanFF('platform.editor.table.update-table-resizer-styles')) {
|
|
214
|
-
marginLeftRef.current = getMarginLeft(lineLength, width);
|
|
215
|
-
}
|
|
216
195
|
}
|
|
217
196
|
const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
218
197
|
|
|
@@ -238,7 +217,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
238
217
|
};
|
|
239
218
|
}
|
|
240
219
|
|
|
241
|
-
return
|
|
220
|
+
return (
|
|
242
221
|
<div
|
|
243
222
|
style={{
|
|
244
223
|
display: 'flex',
|
|
@@ -259,21 +238,6 @@ export const ResizableTableContainer = React.memo(
|
|
|
259
238
|
</TableResizer>
|
|
260
239
|
</div>
|
|
261
240
|
</div>
|
|
262
|
-
) : (
|
|
263
|
-
<div
|
|
264
|
-
style={{
|
|
265
|
-
marginLeft: marginLeftRef.current,
|
|
266
|
-
width: tableWidthRef.current,
|
|
267
|
-
}}
|
|
268
|
-
className={ClassName.TABLE_RESIZER_CONTAINER}
|
|
269
|
-
ref={containerRef}
|
|
270
|
-
>
|
|
271
|
-
<TableResizer {...tableResizerProps}>
|
|
272
|
-
<InnerContainer className={className} node={node}>
|
|
273
|
-
{children}
|
|
274
|
-
</InnerContainer>
|
|
275
|
-
</TableResizer>
|
|
276
|
-
</div>
|
|
277
241
|
);
|
|
278
242
|
},
|
|
279
243
|
);
|
|
@@ -311,7 +275,6 @@ export const TableContainer = ({
|
|
|
311
275
|
<ResizableTableContainer
|
|
312
276
|
className={className}
|
|
313
277
|
node={node}
|
|
314
|
-
lineLength={lineLength!}
|
|
315
278
|
containerWidth={editorWidth!}
|
|
316
279
|
editorView={editorView}
|
|
317
280
|
getPos={getPos}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import rafSchedule from 'raf-schd';
|
|
2
|
-
|
|
3
1
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
4
2
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
3
|
|
|
@@ -33,9 +31,8 @@ export class TableStickyScrollbar {
|
|
|
33
31
|
if (this.stickyScrollbarContainerElement) {
|
|
34
32
|
this.stickyScrollbarContainerElement.removeEventListener(
|
|
35
33
|
'scroll',
|
|
36
|
-
this.
|
|
34
|
+
this.handleScroll,
|
|
37
35
|
);
|
|
38
|
-
this.handleScrollDebounced.cancel();
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
this.deleteIntersectionObserver();
|
|
@@ -60,7 +57,7 @@ export class TableStickyScrollbar {
|
|
|
60
57
|
if (this.stickyScrollbarContainerElement) {
|
|
61
58
|
this.stickyScrollbarContainerElement.addEventListener(
|
|
62
59
|
'scroll',
|
|
63
|
-
this.
|
|
60
|
+
this.handleScroll,
|
|
64
61
|
{ passive: true },
|
|
65
62
|
);
|
|
66
63
|
}
|
|
@@ -199,6 +196,4 @@ export class TableStickyScrollbar {
|
|
|
199
196
|
|
|
200
197
|
this.wrapper.scrollLeft = this.stickyScrollbarContainerElement.scrollLeft;
|
|
201
198
|
};
|
|
202
|
-
|
|
203
|
-
private handleScrollDebounced = rafSchedule(this.handleScroll);
|
|
204
199
|
}
|