@atlaskit/editor-plugin-table 2.10.2 → 2.10.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 +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +19 -0
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +12 -4
- package/dist/cjs/plugins/table/pm-plugins/main.js +7 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/cjs/plugins/table/types.js +1 -0
- package/dist/cjs/plugins/table/utils/dom.js +4 -1
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +19 -0
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +12 -4
- package/dist/es2019/plugins/table/pm-plugins/main.js +7 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/es2019/plugins/table/types.js +1 -0
- package/dist/es2019/plugins/table/utils/dom.js +4 -1
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +19 -0
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +12 -4
- package/dist/esm/plugins/table/pm-plugins/main.js +7 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/esm/plugins/table/types.js +1 -0
- package/dist/esm/plugins/table/utils/dom.js +4 -1
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/table/ui/common-styles.d.ts +1 -1
- package/dist/types/plugins/table/utils/dom.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/ui/common-styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +1 -1
- package/package.json +5 -2
- package/src/plugins/table/nodeviews/TableContainer.tsx +29 -0
- package/src/plugins/table/nodeviews/TableResizer.tsx +24 -4
- package/src/plugins/table/pm-plugins/main.ts +16 -7
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +7 -1
- package/src/plugins/table/types.ts +1 -0
- package/src/plugins/table/ui/common-styles.ts +1 -1
- package/src/plugins/table/utils/dom.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.10.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`eefbc3c6065`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eefbc3c6065) - [ED-19510] Applies performance tweaks for table
|
|
8
|
+
|
|
9
|
+
## 2.10.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`d6e4badd8c4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d6e4badd8c4) - Add explicit height to table when resizing width to increase performance
|
|
14
|
+
|
|
3
15
|
## 2.10.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -55,6 +55,23 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
55
55
|
var containerRef = (0, _react.useRef)(null);
|
|
56
56
|
var marginLeftRef = (0, _react.useRef)(0);
|
|
57
57
|
var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
|
|
58
|
+
var updateContainerHeight = (0, _react.useCallback)(function (height) {
|
|
59
|
+
var _containerRef$current;
|
|
60
|
+
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.style.setProperty('height', typeof height === 'number' ? "".concat(height + 29, "px") : 'auto');
|
|
61
|
+
}, []);
|
|
62
|
+
var resizeObserverRef = (0, _react.useRef)(new ResizeObserver(function (entries) {
|
|
63
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
64
|
+
}));
|
|
65
|
+
var onResizeStart = (0, _react.useCallback)(function () {
|
|
66
|
+
updateContainerHeight(tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight);
|
|
67
|
+
if (tableRef) {
|
|
68
|
+
resizeObserverRef.current.observe(tableRef);
|
|
69
|
+
}
|
|
70
|
+
}, [tableRef, updateContainerHeight]);
|
|
71
|
+
var onResizeStop = (0, _react.useCallback)(function () {
|
|
72
|
+
updateContainerHeight('auto');
|
|
73
|
+
resizeObserverRef.current.disconnect();
|
|
74
|
+
}, [updateContainerHeight]);
|
|
58
75
|
var updateWidth = (0, _react.useCallback)(function (width) {
|
|
59
76
|
if (!containerRef.current) {
|
|
60
77
|
return;
|
|
@@ -102,6 +119,8 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
102
119
|
className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
|
|
103
120
|
ref: containerRef
|
|
104
121
|
}, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, {
|
|
122
|
+
onResizeStart: onResizeStart,
|
|
123
|
+
onResizeStop: onResizeStop,
|
|
105
124
|
width: width,
|
|
106
125
|
maxWidth: maxResizerWidth,
|
|
107
126
|
containerWidth: containerWidth,
|
|
@@ -33,6 +33,10 @@ var tableHandlePosition = 14;
|
|
|
33
33
|
var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
34
34
|
var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
|
|
35
35
|
var handleHeightSize = 'small';
|
|
36
|
+
if (!tableHeight) {
|
|
37
|
+
return handleHeightSize;
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
/*
|
|
37
41
|
- One row table height (minimum possible table height) ~ 45px
|
|
38
42
|
- Two row table height ~ 90px
|
|
@@ -41,9 +45,9 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
41
45
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
42
46
|
- < 96 is the height of large resize handle.
|
|
43
47
|
*/
|
|
44
|
-
if (tableHeight
|
|
48
|
+
if (tableHeight > 46 && tableHeight < 96) {
|
|
45
49
|
handleHeightSize = 'medium';
|
|
46
|
-
} else if (tableHeight
|
|
50
|
+
} else if (tableHeight >= 96) {
|
|
47
51
|
handleHeightSize = 'large';
|
|
48
52
|
}
|
|
49
53
|
return handleHeightSize;
|
|
@@ -74,6 +78,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
74
78
|
maxWidth = _ref.maxWidth,
|
|
75
79
|
containerWidth = _ref.containerWidth,
|
|
76
80
|
updateWidth = _ref.updateWidth,
|
|
81
|
+
onResizeStop = _ref.onResizeStop,
|
|
82
|
+
onResizeStart = _ref.onResizeStart,
|
|
77
83
|
editorView = _ref.editorView,
|
|
78
84
|
getPos = _ref.getPos,
|
|
79
85
|
node = _ref.node,
|
|
@@ -116,7 +122,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
116
122
|
}));
|
|
117
123
|
var visibleGuidelines = getVisibleGuidelines(_guidelines.defaultGuidelines, containerWidth);
|
|
118
124
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
119
|
-
|
|
125
|
+
onResizeStart();
|
|
126
|
+
}, [displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
120
127
|
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
121
128
|
countFrames();
|
|
122
129
|
var newWidth = originalState.width + delta.width;
|
|
@@ -181,8 +188,9 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
181
188
|
displayGuideline([]);
|
|
182
189
|
updateWidth(newWidth);
|
|
183
190
|
scheduleResize.cancel();
|
|
191
|
+
onResizeStop();
|
|
184
192
|
return newWidth;
|
|
185
|
-
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
193
|
+
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
186
194
|
var handleComponent = (0, _react.useMemo)(function () {
|
|
187
195
|
return {
|
|
188
196
|
left: /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -13,6 +13,7 @@ var _transforms = require("@atlaskit/editor-common/transforms");
|
|
|
13
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
15
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _commands = require("../commands");
|
|
17
18
|
var _misc = require("../commands/misc");
|
|
18
19
|
var _eventHandlers = require("../event-handlers");
|
|
@@ -132,8 +133,12 @@ var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, porta
|
|
|
132
133
|
if (pluginState.tableRef !== tableRef) {
|
|
133
134
|
(0, _commands.setTableRef)(tableRef)(state, dispatch);
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
|
|
137
|
+
// Removes updateResizeHandles
|
|
138
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
139
|
+
if (pluginState.tableNode !== tableNode) {
|
|
140
|
+
(0, _utils4.updateResizeHandles)(tableRef);
|
|
141
|
+
}
|
|
137
142
|
}
|
|
138
143
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
139
144
|
var _ref = state.selection,
|
|
@@ -140,7 +140,10 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
140
140
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
141
141
|
(0, _utils3.resizeColumn)(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
142
142
|
(0, _utils3.updateControls)()(state);
|
|
143
|
-
|
|
143
|
+
// Remove updateResizeHandles
|
|
144
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
145
|
+
(0, _utils2.updateResizeHandles)(dom);
|
|
146
|
+
}
|
|
144
147
|
}
|
|
145
148
|
window.addEventListener('mouseup', finish);
|
|
146
149
|
window.addEventListener('mousemove', move);
|
|
@@ -93,6 +93,7 @@ var TableCssClassName = _objectSpread(_objectSpread({}, _styles.TableSharedCssCl
|
|
|
93
93
|
RESIZING_PLUGIN: "".concat(_adfSchema.tablePrefixSelector, "-resizing-plugin"),
|
|
94
94
|
RESIZE_CURSOR: "".concat(_adfSchema.tablePrefixSelector, "-resize-cursor"),
|
|
95
95
|
IS_RESIZING: "".concat(_adfSchema.tablePrefixSelector, "-is-resizing"),
|
|
96
|
+
// Resize handle is going to be removed together with updateResizeHandles - table's utility function
|
|
96
97
|
RESIZE_HANDLE: "".concat(_adfSchema.tablePrefixSelector, "-resize-handle"),
|
|
97
98
|
RESIZE_HANDLE_DECORATION: "".concat(_adfSchema.tablePrefixSelector, "-resize-decoration"),
|
|
98
99
|
CONTEXTUAL_SUBMENU: "".concat(_adfSchema.tablePrefixSelector, "-contextual-submenu"),
|
|
@@ -135,17 +135,20 @@ var getMousePositionVerticalRelativeByElement = function getMousePositionVertica
|
|
|
135
135
|
}
|
|
136
136
|
return null;
|
|
137
137
|
};
|
|
138
|
+
|
|
139
|
+
// This function is deprecated
|
|
138
140
|
exports.getMousePositionVerticalRelativeByElement = getMousePositionVerticalRelativeByElement;
|
|
139
141
|
var updateResizeHandles = function updateResizeHandles(tableRef) {
|
|
140
142
|
if (!tableRef) {
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
|
|
144
146
|
// see ED-7600
|
|
145
147
|
var nodes = Array.from(tableRef.querySelectorAll(".".concat(_types.TableCssClassName.RESIZE_HANDLE)));
|
|
146
148
|
if (!nodes || !nodes.length) {
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
151
|
+
var height = tableRef.offsetHeight + _consts.tableToolbarSize;
|
|
149
152
|
nodes.forEach(function (node) {
|
|
150
153
|
node.style.height = "".concat(height, "px");
|
|
151
154
|
});
|
|
@@ -46,6 +46,23 @@ export const ResizableTableContainer = ({
|
|
|
46
46
|
const containerRef = useRef(null);
|
|
47
47
|
const marginLeftRef = useRef(0);
|
|
48
48
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
49
|
+
const updateContainerHeight = useCallback(height => {
|
|
50
|
+
var _containerRef$current;
|
|
51
|
+
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.style.setProperty('height', typeof height === 'number' ? `${height + 29}px` : 'auto');
|
|
52
|
+
}, []);
|
|
53
|
+
const resizeObserverRef = useRef(new ResizeObserver(entries => {
|
|
54
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
55
|
+
}));
|
|
56
|
+
const onResizeStart = useCallback(() => {
|
|
57
|
+
updateContainerHeight(tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight);
|
|
58
|
+
if (tableRef) {
|
|
59
|
+
resizeObserverRef.current.observe(tableRef);
|
|
60
|
+
}
|
|
61
|
+
}, [tableRef, updateContainerHeight]);
|
|
62
|
+
const onResizeStop = useCallback(() => {
|
|
63
|
+
updateContainerHeight('auto');
|
|
64
|
+
resizeObserverRef.current.disconnect();
|
|
65
|
+
}, [updateContainerHeight]);
|
|
49
66
|
const updateWidth = useCallback(width => {
|
|
50
67
|
if (!containerRef.current) {
|
|
51
68
|
return;
|
|
@@ -93,6 +110,8 @@ export const ResizableTableContainer = ({
|
|
|
93
110
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
94
111
|
ref: containerRef
|
|
95
112
|
}, /*#__PURE__*/React.createElement(TableResizer, {
|
|
113
|
+
onResizeStart: onResizeStart,
|
|
114
|
+
onResizeStop: onResizeStop,
|
|
96
115
|
width: width,
|
|
97
116
|
maxWidth: maxResizerWidth,
|
|
98
117
|
containerWidth: containerWidth,
|
|
@@ -19,6 +19,10 @@ const tableHandlePosition = 14;
|
|
|
19
19
|
const getResizerHandleHeight = tableRef => {
|
|
20
20
|
const tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
|
|
21
21
|
let handleHeightSize = 'small';
|
|
22
|
+
if (!tableHeight) {
|
|
23
|
+
return handleHeightSize;
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
/*
|
|
23
27
|
- One row table height (minimum possible table height) ~ 45px
|
|
24
28
|
- Two row table height ~ 90px
|
|
@@ -27,9 +31,9 @@ const getResizerHandleHeight = tableRef => {
|
|
|
27
31
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
28
32
|
- < 96 is the height of large resize handle.
|
|
29
33
|
*/
|
|
30
|
-
if (tableHeight
|
|
34
|
+
if (tableHeight > 46 && tableHeight < 96) {
|
|
31
35
|
handleHeightSize = 'medium';
|
|
32
|
-
} else if (tableHeight
|
|
36
|
+
} else if (tableHeight >= 96) {
|
|
33
37
|
handleHeightSize = 'large';
|
|
34
38
|
}
|
|
35
39
|
return handleHeightSize;
|
|
@@ -59,6 +63,8 @@ export const TableResizer = ({
|
|
|
59
63
|
maxWidth,
|
|
60
64
|
containerWidth,
|
|
61
65
|
updateWidth,
|
|
66
|
+
onResizeStop,
|
|
67
|
+
onResizeStart,
|
|
62
68
|
editorView,
|
|
63
69
|
getPos,
|
|
64
70
|
node,
|
|
@@ -105,7 +111,8 @@ export const TableResizer = ({
|
|
|
105
111
|
}));
|
|
106
112
|
const visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
107
113
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
108
|
-
|
|
114
|
+
onResizeStart();
|
|
115
|
+
}, [displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
109
116
|
const handleResize = useCallback((originalState, delta) => {
|
|
110
117
|
countFrames();
|
|
111
118
|
const newWidth = originalState.width + delta.width;
|
|
@@ -171,8 +178,9 @@ export const TableResizer = ({
|
|
|
171
178
|
displayGuideline([]);
|
|
172
179
|
updateWidth(newWidth);
|
|
173
180
|
scheduleResize.cancel();
|
|
181
|
+
onResizeStop();
|
|
174
182
|
return newWidth;
|
|
175
|
-
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
183
|
+
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
176
184
|
const handleComponent = useMemo(() => ({
|
|
177
185
|
left: /*#__PURE__*/React.createElement("div", {
|
|
178
186
|
className: resizerHandleShadowClassName,
|
|
@@ -5,6 +5,7 @@ import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenEx
|
|
|
5
5
|
import { browser, closestElement } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
9
10
|
import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
10
11
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
|
|
@@ -117,8 +118,12 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
117
118
|
if (pluginState.tableRef !== tableRef) {
|
|
118
119
|
setTableRef(tableRef)(state, dispatch);
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
|
|
122
|
+
// Removes updateResizeHandles
|
|
123
|
+
if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
124
|
+
if (pluginState.tableNode !== tableNode) {
|
|
125
|
+
updateResizeHandles(tableRef);
|
|
126
|
+
}
|
|
122
127
|
}
|
|
123
128
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
124
129
|
const {
|
|
@@ -150,7 +150,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
150
150
|
const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
151
151
|
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
152
152
|
updateControls()(state);
|
|
153
|
-
updateResizeHandles
|
|
153
|
+
// Remove updateResizeHandles
|
|
154
|
+
if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
155
|
+
updateResizeHandles(dom);
|
|
156
|
+
}
|
|
154
157
|
}
|
|
155
158
|
window.addEventListener('mouseup', finish);
|
|
156
159
|
window.addEventListener('mousemove', move);
|
|
@@ -83,6 +83,7 @@ export const TableCssClassName = {
|
|
|
83
83
|
RESIZING_PLUGIN: `${tablePrefixSelector}-resizing-plugin`,
|
|
84
84
|
RESIZE_CURSOR: `${tablePrefixSelector}-resize-cursor`,
|
|
85
85
|
IS_RESIZING: `${tablePrefixSelector}-is-resizing`,
|
|
86
|
+
// Resize handle is going to be removed together with updateResizeHandles - table's utility function
|
|
86
87
|
RESIZE_HANDLE: `${tablePrefixSelector}-resize-handle`,
|
|
87
88
|
RESIZE_HANDLE_DECORATION: `${tablePrefixSelector}-resize-decoration`,
|
|
88
89
|
CONTEXTUAL_SUBMENU: `${tablePrefixSelector}-contextual-submenu`,
|
|
@@ -104,16 +104,19 @@ export const getMousePositionVerticalRelativeByElement = mouseEvent => {
|
|
|
104
104
|
}
|
|
105
105
|
return null;
|
|
106
106
|
};
|
|
107
|
+
|
|
108
|
+
// This function is deprecated
|
|
107
109
|
export const updateResizeHandles = tableRef => {
|
|
108
110
|
if (!tableRef) {
|
|
109
111
|
return;
|
|
110
112
|
}
|
|
111
|
-
|
|
113
|
+
|
|
112
114
|
// see ED-7600
|
|
113
115
|
const nodes = Array.from(tableRef.querySelectorAll(`.${ClassName.RESIZE_HANDLE}`));
|
|
114
116
|
if (!nodes || !nodes.length) {
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
119
|
+
const height = tableRef.offsetHeight + tableToolbarSize;
|
|
117
120
|
nodes.forEach(node => {
|
|
118
121
|
node.style.height = `${height}px`;
|
|
119
122
|
});
|
|
@@ -44,6 +44,23 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
44
44
|
var containerRef = useRef(null);
|
|
45
45
|
var marginLeftRef = useRef(0);
|
|
46
46
|
var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
47
|
+
var updateContainerHeight = useCallback(function (height) {
|
|
48
|
+
var _containerRef$current;
|
|
49
|
+
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.style.setProperty('height', typeof height === 'number' ? "".concat(height + 29, "px") : 'auto');
|
|
50
|
+
}, []);
|
|
51
|
+
var resizeObserverRef = useRef(new ResizeObserver(function (entries) {
|
|
52
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
53
|
+
}));
|
|
54
|
+
var onResizeStart = useCallback(function () {
|
|
55
|
+
updateContainerHeight(tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight);
|
|
56
|
+
if (tableRef) {
|
|
57
|
+
resizeObserverRef.current.observe(tableRef);
|
|
58
|
+
}
|
|
59
|
+
}, [tableRef, updateContainerHeight]);
|
|
60
|
+
var onResizeStop = useCallback(function () {
|
|
61
|
+
updateContainerHeight('auto');
|
|
62
|
+
resizeObserverRef.current.disconnect();
|
|
63
|
+
}, [updateContainerHeight]);
|
|
47
64
|
var updateWidth = useCallback(function (width) {
|
|
48
65
|
if (!containerRef.current) {
|
|
49
66
|
return;
|
|
@@ -91,6 +108,8 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
91
108
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
92
109
|
ref: containerRef
|
|
93
110
|
}, /*#__PURE__*/React.createElement(TableResizer, {
|
|
111
|
+
onResizeStart: onResizeStart,
|
|
112
|
+
onResizeStop: onResizeStop,
|
|
94
113
|
width: width,
|
|
95
114
|
maxWidth: maxResizerWidth,
|
|
96
115
|
containerWidth: containerWidth,
|
|
@@ -23,6 +23,10 @@ var tableHandlePosition = 14;
|
|
|
23
23
|
var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
24
24
|
var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
|
|
25
25
|
var handleHeightSize = 'small';
|
|
26
|
+
if (!tableHeight) {
|
|
27
|
+
return handleHeightSize;
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
/*
|
|
27
31
|
- One row table height (minimum possible table height) ~ 45px
|
|
28
32
|
- Two row table height ~ 90px
|
|
@@ -31,9 +35,9 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
31
35
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
32
36
|
- < 96 is the height of large resize handle.
|
|
33
37
|
*/
|
|
34
|
-
if (tableHeight
|
|
38
|
+
if (tableHeight > 46 && tableHeight < 96) {
|
|
35
39
|
handleHeightSize = 'medium';
|
|
36
|
-
} else if (tableHeight
|
|
40
|
+
} else if (tableHeight >= 96) {
|
|
37
41
|
handleHeightSize = 'large';
|
|
38
42
|
}
|
|
39
43
|
return handleHeightSize;
|
|
@@ -64,6 +68,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
64
68
|
maxWidth = _ref.maxWidth,
|
|
65
69
|
containerWidth = _ref.containerWidth,
|
|
66
70
|
updateWidth = _ref.updateWidth,
|
|
71
|
+
onResizeStop = _ref.onResizeStop,
|
|
72
|
+
onResizeStart = _ref.onResizeStart,
|
|
67
73
|
editorView = _ref.editorView,
|
|
68
74
|
getPos = _ref.getPos,
|
|
69
75
|
node = _ref.node,
|
|
@@ -106,7 +112,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
106
112
|
}));
|
|
107
113
|
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
108
114
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
109
|
-
|
|
115
|
+
onResizeStart();
|
|
116
|
+
}, [displayGuideline, editorView, startMeasure, onResizeStart, containerWidth]);
|
|
110
117
|
var handleResize = useCallback(function (originalState, delta) {
|
|
111
118
|
countFrames();
|
|
112
119
|
var newWidth = originalState.width + delta.width;
|
|
@@ -171,8 +178,9 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
171
178
|
displayGuideline([]);
|
|
172
179
|
updateWidth(newWidth);
|
|
173
180
|
scheduleResize.cancel();
|
|
181
|
+
onResizeStop();
|
|
174
182
|
return newWidth;
|
|
175
|
-
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
183
|
+
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
|
|
176
184
|
var handleComponent = useMemo(function () {
|
|
177
185
|
return {
|
|
178
186
|
left: /*#__PURE__*/React.createElement("div", {
|
|
@@ -8,6 +8,7 @@ import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenEx
|
|
|
8
8
|
import { browser, closestElement } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
12
13
|
import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
13
14
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
|
|
@@ -125,8 +126,12 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
125
126
|
if (pluginState.tableRef !== tableRef) {
|
|
126
127
|
setTableRef(tableRef)(state, dispatch);
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
|
|
130
|
+
// Removes updateResizeHandles
|
|
131
|
+
if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
132
|
+
if (pluginState.tableNode !== tableNode) {
|
|
133
|
+
updateResizeHandles(tableRef);
|
|
134
|
+
}
|
|
130
135
|
}
|
|
131
136
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
132
137
|
var _ref = state.selection,
|
|
@@ -134,7 +134,10 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
134
134
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
135
135
|
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
136
136
|
updateControls()(state);
|
|
137
|
-
updateResizeHandles
|
|
137
|
+
// Remove updateResizeHandles
|
|
138
|
+
if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
139
|
+
updateResizeHandles(dom);
|
|
140
|
+
}
|
|
138
141
|
}
|
|
139
142
|
window.addEventListener('mouseup', finish);
|
|
140
143
|
window.addEventListener('mousemove', move);
|
|
@@ -85,6 +85,7 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
85
85
|
RESIZING_PLUGIN: "".concat(tablePrefixSelector, "-resizing-plugin"),
|
|
86
86
|
RESIZE_CURSOR: "".concat(tablePrefixSelector, "-resize-cursor"),
|
|
87
87
|
IS_RESIZING: "".concat(tablePrefixSelector, "-is-resizing"),
|
|
88
|
+
// Resize handle is going to be removed together with updateResizeHandles - table's utility function
|
|
88
89
|
RESIZE_HANDLE: "".concat(tablePrefixSelector, "-resize-handle"),
|
|
89
90
|
RESIZE_HANDLE_DECORATION: "".concat(tablePrefixSelector, "-resize-decoration"),
|
|
90
91
|
CONTEXTUAL_SUBMENU: "".concat(tablePrefixSelector, "-contextual-submenu"),
|
|
@@ -120,16 +120,19 @@ export var getMousePositionVerticalRelativeByElement = function getMousePosition
|
|
|
120
120
|
}
|
|
121
121
|
return null;
|
|
122
122
|
};
|
|
123
|
+
|
|
124
|
+
// This function is deprecated
|
|
123
125
|
export var updateResizeHandles = function updateResizeHandles(tableRef) {
|
|
124
126
|
if (!tableRef) {
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
|
-
|
|
129
|
+
|
|
128
130
|
// see ED-7600
|
|
129
131
|
var nodes = Array.from(tableRef.querySelectorAll(".".concat(ClassName.RESIZE_HANDLE)));
|
|
130
132
|
if (!nodes || !nodes.length) {
|
|
131
133
|
return;
|
|
132
134
|
}
|
|
135
|
+
var height = tableRef.offsetHeight + tableToolbarSize;
|
|
133
136
|
nodes.forEach(function (node) {
|
|
134
137
|
node.style.height = "".concat(height, "px");
|
|
135
138
|
});
|
|
@@ -9,6 +9,8 @@ interface TableResizerProps {
|
|
|
9
9
|
maxWidth: number;
|
|
10
10
|
containerWidth: number;
|
|
11
11
|
updateWidth: (width: number) => void;
|
|
12
|
+
onResizeStop: () => void;
|
|
13
|
+
onResizeStart: () => void;
|
|
12
14
|
editorView: EditorView;
|
|
13
15
|
getPos: () => number | undefined;
|
|
14
16
|
node: PMNode;
|
|
@@ -16,5 +18,5 @@ interface TableResizerProps {
|
|
|
16
18
|
displayGuideline: (guideline: GuidelineConfig[]) => boolean;
|
|
17
19
|
attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
|
|
18
20
|
}
|
|
19
|
-
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
21
|
+
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
20
22
|
export {};
|
|
@@ -3,5 +3,5 @@ import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-di
|
|
|
3
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
6
|
-
import { PluginConfig, PluginInjectionAPI } from '../types';
|
|
6
|
+
import type { PluginConfig, PluginInjectionAPI } from '../types';
|
|
7
7
|
export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { ThemeProps } from '@atlaskit/theme/types';
|
|
2
|
+
import type { ThemeProps } from '@atlaskit/theme/types';
|
|
3
3
|
export declare const insertColumnButtonOffset: number;
|
|
4
4
|
export declare const tableStyles: (props: ThemeProps & {
|
|
5
5
|
featureFlags?: FeatureFlags;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementContentRects } from '../types';
|
|
1
|
+
import type { ElementContentRects } from '../types';
|
|
2
2
|
export declare const isCell: (node: HTMLElement | null) => boolean;
|
|
3
3
|
export declare const isCornerButton: (node: HTMLElement | null) => boolean;
|
|
4
4
|
export declare const isInsertRowButton: (node: HTMLElement | null) => boolean | HTMLElement | null;
|
|
@@ -9,6 +9,8 @@ interface TableResizerProps {
|
|
|
9
9
|
maxWidth: number;
|
|
10
10
|
containerWidth: number;
|
|
11
11
|
updateWidth: (width: number) => void;
|
|
12
|
+
onResizeStop: () => void;
|
|
13
|
+
onResizeStart: () => void;
|
|
12
14
|
editorView: EditorView;
|
|
13
15
|
getPos: () => number | undefined;
|
|
14
16
|
node: PMNode;
|
|
@@ -16,5 +18,5 @@ interface TableResizerProps {
|
|
|
16
18
|
displayGuideline: (guideline: GuidelineConfig[]) => boolean;
|
|
17
19
|
attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
|
|
18
20
|
}
|
|
19
|
-
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
21
|
+
export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
20
22
|
export {};
|
|
@@ -3,5 +3,5 @@ import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-di
|
|
|
3
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
6
|
-
import { PluginConfig, PluginInjectionAPI } from '../types';
|
|
6
|
+
import type { PluginConfig, PluginInjectionAPI } from '../types';
|
|
7
7
|
export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { ThemeProps } from '@atlaskit/theme/types';
|
|
2
|
+
import type { ThemeProps } from '@atlaskit/theme/types';
|
|
3
3
|
export declare const insertColumnButtonOffset: number;
|
|
4
4
|
export declare const tableStyles: (props: ThemeProps & {
|
|
5
5
|
featureFlags?: FeatureFlags;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementContentRects } from '../types';
|
|
1
|
+
import type { ElementContentRects } from '../types';
|
|
2
2
|
export declare const isCell: (node: HTMLElement | null) => boolean;
|
|
3
3
|
export declare const isCornerButton: (node: HTMLElement | null) => boolean;
|
|
4
4
|
export declare const isInsertRowButton: (node: HTMLElement | null) => boolean | HTMLElement | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.4",
|
|
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": "^28.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^74.
|
|
31
|
+
"@atlaskit/editor-common": "^74.50.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.0.8",
|
|
@@ -105,6 +105,9 @@
|
|
|
105
105
|
},
|
|
106
106
|
"platform.editor.update-table-cell-width-via-step": {
|
|
107
107
|
"type": "boolean"
|
|
108
|
+
},
|
|
109
|
+
"platform.editor.table-remove-update-resize-handles_djvab": {
|
|
110
|
+
"type": "boolean"
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
}
|
|
@@ -89,6 +89,33 @@ export const ResizableTableContainer = ({
|
|
|
89
89
|
const marginLeftRef = useRef<number | undefined>(0);
|
|
90
90
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
91
91
|
|
|
92
|
+
const updateContainerHeight = useCallback((height: number | 'auto') => {
|
|
93
|
+
containerRef.current?.style.setProperty(
|
|
94
|
+
'height',
|
|
95
|
+
typeof height === 'number' ? `${height + 29}px` : 'auto',
|
|
96
|
+
);
|
|
97
|
+
}, []);
|
|
98
|
+
|
|
99
|
+
const resizeObserverRef = useRef(
|
|
100
|
+
new ResizeObserver((entries) => {
|
|
101
|
+
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const onResizeStart = useCallback(() => {
|
|
106
|
+
updateContainerHeight(tableRef?.clientHeight);
|
|
107
|
+
|
|
108
|
+
if (tableRef) {
|
|
109
|
+
resizeObserverRef.current.observe(tableRef);
|
|
110
|
+
}
|
|
111
|
+
}, [tableRef, updateContainerHeight]);
|
|
112
|
+
|
|
113
|
+
const onResizeStop = useCallback(() => {
|
|
114
|
+
updateContainerHeight('auto');
|
|
115
|
+
|
|
116
|
+
resizeObserverRef.current.disconnect();
|
|
117
|
+
}, [updateContainerHeight]);
|
|
118
|
+
|
|
92
119
|
const updateWidth = useCallback(
|
|
93
120
|
(width: number) => {
|
|
94
121
|
if (!containerRef.current) {
|
|
@@ -157,6 +184,8 @@ export const ResizableTableContainer = ({
|
|
|
157
184
|
ref={containerRef}
|
|
158
185
|
>
|
|
159
186
|
<TableResizer
|
|
187
|
+
onResizeStart={onResizeStart}
|
|
188
|
+
onResizeStop={onResizeStop}
|
|
160
189
|
width={width}
|
|
161
190
|
maxWidth={maxResizerWidth}
|
|
162
191
|
containerWidth={containerWidth}
|
|
@@ -43,6 +43,8 @@ interface TableResizerProps {
|
|
|
43
43
|
maxWidth: number;
|
|
44
44
|
containerWidth: number;
|
|
45
45
|
updateWidth: (width: number) => void;
|
|
46
|
+
onResizeStop: () => void;
|
|
47
|
+
onResizeStart: () => void;
|
|
46
48
|
editorView: EditorView;
|
|
47
49
|
getPos: () => number | undefined;
|
|
48
50
|
node: PMNode;
|
|
@@ -57,9 +59,14 @@ const handles = { right: true };
|
|
|
57
59
|
const tableHandleMarginTop = 12;
|
|
58
60
|
const tableHandlePosition = 14;
|
|
59
61
|
|
|
60
|
-
const getResizerHandleHeight = (tableRef: HTMLTableElement) => {
|
|
62
|
+
const getResizerHandleHeight = (tableRef: HTMLTableElement | undefined) => {
|
|
61
63
|
const tableHeight = tableRef?.clientHeight;
|
|
62
64
|
let handleHeightSize: HandleHeightSizeType | undefined = 'small';
|
|
65
|
+
|
|
66
|
+
if (!tableHeight) {
|
|
67
|
+
return handleHeightSize;
|
|
68
|
+
}
|
|
69
|
+
|
|
63
70
|
/*
|
|
64
71
|
- One row table height (minimum possible table height) ~ 45px
|
|
65
72
|
- Two row table height ~ 90px
|
|
@@ -69,9 +76,9 @@ const getResizerHandleHeight = (tableRef: HTMLTableElement) => {
|
|
|
69
76
|
- > 46 because the height of the table can be a float number like 45.44.
|
|
70
77
|
- < 96 is the height of large resize handle.
|
|
71
78
|
*/
|
|
72
|
-
if (tableHeight
|
|
79
|
+
if (tableHeight > 46 && tableHeight < 96) {
|
|
73
80
|
handleHeightSize = 'medium';
|
|
74
|
-
} else if (tableHeight
|
|
81
|
+
} else if (tableHeight >= 96) {
|
|
75
82
|
handleHeightSize = 'large';
|
|
76
83
|
}
|
|
77
84
|
|
|
@@ -115,6 +122,8 @@ export const TableResizer = ({
|
|
|
115
122
|
maxWidth,
|
|
116
123
|
containerWidth,
|
|
117
124
|
updateWidth,
|
|
125
|
+
onResizeStop,
|
|
126
|
+
onResizeStart,
|
|
118
127
|
editorView,
|
|
119
128
|
getPos,
|
|
120
129
|
node,
|
|
@@ -177,7 +186,15 @@ export const TableResizer = ({
|
|
|
177
186
|
containerWidth,
|
|
178
187
|
);
|
|
179
188
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
180
|
-
|
|
189
|
+
|
|
190
|
+
onResizeStart();
|
|
191
|
+
}, [
|
|
192
|
+
displayGuideline,
|
|
193
|
+
editorView,
|
|
194
|
+
startMeasure,
|
|
195
|
+
onResizeStart,
|
|
196
|
+
containerWidth,
|
|
197
|
+
]);
|
|
181
198
|
|
|
182
199
|
const handleResize = useCallback(
|
|
183
200
|
(originalState, delta) => {
|
|
@@ -281,6 +298,8 @@ export const TableResizer = ({
|
|
|
281
298
|
updateWidth(newWidth);
|
|
282
299
|
scheduleResize.cancel();
|
|
283
300
|
|
|
301
|
+
onResizeStop();
|
|
302
|
+
|
|
284
303
|
return newWidth;
|
|
285
304
|
},
|
|
286
305
|
[
|
|
@@ -293,6 +312,7 @@ export const TableResizer = ({
|
|
|
293
312
|
displayGuideline,
|
|
294
313
|
attachAnalyticsEvent,
|
|
295
314
|
endMeasure,
|
|
315
|
+
onResizeStop,
|
|
296
316
|
],
|
|
297
317
|
);
|
|
298
318
|
|
|
@@ -26,8 +26,8 @@ import type {
|
|
|
26
26
|
getPosHandler,
|
|
27
27
|
} from '@atlaskit/editor-common/types';
|
|
28
28
|
import { browser, closestElement } from '@atlaskit/editor-common/utils';
|
|
29
|
-
import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
30
|
-
import {
|
|
29
|
+
import type { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
30
|
+
import type {
|
|
31
31
|
EditorState,
|
|
32
32
|
TextSelection,
|
|
33
33
|
Transaction,
|
|
@@ -36,8 +36,9 @@ import {
|
|
|
36
36
|
findParentDomRefOfType,
|
|
37
37
|
findParentNodeOfType,
|
|
38
38
|
} from '@atlaskit/editor-prosemirror/utils';
|
|
39
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
39
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
40
40
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
41
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
41
42
|
|
|
42
43
|
import {
|
|
43
44
|
addBoldInEmptyHeaderCells,
|
|
@@ -66,13 +67,13 @@ import { createTableView } from '../nodeviews/table';
|
|
|
66
67
|
import TableCellNodeView from '../nodeviews/tableCell';
|
|
67
68
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
68
69
|
import { fixTables, replaceSelectedTable } from '../transforms';
|
|
69
|
-
import {
|
|
70
|
-
TableCssClassName as ClassName,
|
|
70
|
+
import type {
|
|
71
71
|
ElementContentRects,
|
|
72
72
|
InvalidNodeAttr,
|
|
73
73
|
PluginConfig,
|
|
74
74
|
PluginInjectionAPI,
|
|
75
75
|
} from '../types';
|
|
76
|
+
import { TableCssClassName as ClassName } from '../types';
|
|
76
77
|
import {
|
|
77
78
|
findControlsHoverDecoration,
|
|
78
79
|
transformSliceToCorrectEmptyTableCells,
|
|
@@ -230,8 +231,16 @@ export const createPlugin = (
|
|
|
230
231
|
setTableRef(tableRef)(state, dispatch);
|
|
231
232
|
}
|
|
232
233
|
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
// Removes updateResizeHandles
|
|
235
|
+
if (
|
|
236
|
+
getBooleanFF(
|
|
237
|
+
'platform.editor.table-remove-update-resize-handles_djvab',
|
|
238
|
+
)
|
|
239
|
+
) {
|
|
240
|
+
} else {
|
|
241
|
+
if (pluginState.tableNode !== tableNode) {
|
|
242
|
+
updateResizeHandles(tableRef);
|
|
243
|
+
}
|
|
235
244
|
}
|
|
236
245
|
|
|
237
246
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
@@ -215,7 +215,13 @@ export const handleMouseDown = (
|
|
|
215
215
|
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
216
216
|
|
|
217
217
|
updateControls()(state);
|
|
218
|
-
updateResizeHandles
|
|
218
|
+
// Remove updateResizeHandles
|
|
219
|
+
if (
|
|
220
|
+
getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')
|
|
221
|
+
) {
|
|
222
|
+
} else {
|
|
223
|
+
updateResizeHandles(dom);
|
|
224
|
+
}
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
window.addEventListener('mouseup', finish);
|
|
@@ -282,6 +282,7 @@ export const TableCssClassName = {
|
|
|
282
282
|
RESIZE_CURSOR: `${tablePrefixSelector}-resize-cursor`,
|
|
283
283
|
IS_RESIZING: `${tablePrefixSelector}-is-resizing`,
|
|
284
284
|
|
|
285
|
+
// Resize handle is going to be removed together with updateResizeHandles - table's utility function
|
|
285
286
|
RESIZE_HANDLE: `${tablePrefixSelector}-resize-handle`,
|
|
286
287
|
RESIZE_HANDLE_DECORATION: `${tablePrefixSelector}-resize-decoration`,
|
|
287
288
|
|
|
@@ -21,7 +21,7 @@ import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
|
21
21
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
22
22
|
import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
|
|
23
23
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
24
|
-
import { ThemeProps } from '@atlaskit/theme/types';
|
|
24
|
+
import type { ThemeProps } from '@atlaskit/theme/types';
|
|
25
25
|
import { token } from '@atlaskit/tokens';
|
|
26
26
|
|
|
27
27
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
containsClassName,
|
|
4
4
|
} from '@atlaskit/editor-common/utils';
|
|
5
5
|
|
|
6
|
-
import { TableCssClassName as ClassName
|
|
6
|
+
import { TableCssClassName as ClassName } from '../types';
|
|
7
|
+
import type { ElementContentRects } from '../types';
|
|
7
8
|
import { tableToolbarSize } from '../ui/consts';
|
|
8
9
|
|
|
9
10
|
const SELECTOR_TABLE_LEAFS = `.${ClassName.TABLE_CELL}, .${ClassName.TABLE_HEADER_CELL}`;
|
|
@@ -154,11 +155,12 @@ export const getMousePositionVerticalRelativeByElement = (
|
|
|
154
155
|
return null;
|
|
155
156
|
};
|
|
156
157
|
|
|
158
|
+
// This function is deprecated
|
|
157
159
|
export const updateResizeHandles = (tableRef?: HTMLElement) => {
|
|
158
160
|
if (!tableRef) {
|
|
159
161
|
return;
|
|
160
162
|
}
|
|
161
|
-
|
|
163
|
+
|
|
162
164
|
// see ED-7600
|
|
163
165
|
const nodes = Array.from(
|
|
164
166
|
tableRef.querySelectorAll(
|
|
@@ -169,6 +171,7 @@ export const updateResizeHandles = (tableRef?: HTMLElement) => {
|
|
|
169
171
|
return;
|
|
170
172
|
}
|
|
171
173
|
|
|
174
|
+
const height = tableRef.offsetHeight + tableToolbarSize;
|
|
172
175
|
nodes.forEach((node) => {
|
|
173
176
|
node.style.height = `${height}px`;
|
|
174
177
|
});
|