@atlaskit/editor-plugin-table 15.4.19 → 15.4.21
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 +14 -0
- package/dist/cjs/nodeviews/TableComponentLegacy.js +8 -21
- package/dist/cjs/nodeviews/TableComponentNext.js +6 -18
- package/dist/cjs/ui/DragHandle/index.js +5 -71
- package/dist/es2019/nodeviews/TableComponentLegacy.js +6 -19
- package/dist/es2019/nodeviews/TableComponentNext.js +4 -16
- package/dist/es2019/ui/DragHandle/index.js +5 -74
- package/dist/esm/nodeviews/TableComponentLegacy.js +9 -22
- package/dist/esm/nodeviews/TableComponentNext.js +7 -19
- package/dist/esm/ui/DragHandle/index.js +5 -71
- package/dist/types/ui/DragHandle/index.d.ts +2 -10
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +2 -10
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 15.4.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`5935652291a5f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5935652291a5f) -
|
|
8
|
+
Remove platform_editor_table_drag_handle_hover experiment and enable hover behavior permanently
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 15.4.20
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 15.4.19
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -572,10 +572,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
572
572
|
this.handleWindowResizeDebounced.cancel();
|
|
573
573
|
}
|
|
574
574
|
this.handleWindowResizeNewDebounced.cancel();
|
|
575
|
-
if (
|
|
576
|
-
|
|
577
|
-
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
578
|
-
}
|
|
575
|
+
if (isInDanger) {
|
|
576
|
+
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
579
577
|
}
|
|
580
578
|
if (!allowTableResizing && allowColumnResizing) {
|
|
581
579
|
// Ignored via go/ees005
|
|
@@ -766,7 +764,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
766
764
|
_this$wrapper,
|
|
767
765
|
_this5 = this;
|
|
768
766
|
var _this$props1 = this.props,
|
|
769
|
-
view = _this$props1.view,
|
|
770
767
|
getNode = _this$props1.getNode,
|
|
771
768
|
isMediaFullscreen = _this$props1.isMediaFullscreen,
|
|
772
769
|
allowColumnResizing = _this$props1.allowColumnResizing,
|
|
@@ -775,9 +772,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
775
772
|
options = _this$props1.options,
|
|
776
773
|
isTableScalingEnabled = _this$props1.isTableScalingEnabled,
|
|
777
774
|
getPos = _this$props1.getPos,
|
|
778
|
-
getEditorFeatureFlags = _this$props1.getEditorFeatureFlags
|
|
779
|
-
isInDanger = _this$props1.isInDanger;
|
|
780
|
-
var table = (0, _utils2.findTable)(view.state.selection);
|
|
775
|
+
getEditorFeatureFlags = _this$props1.getEditorFeatureFlags;
|
|
781
776
|
var shouldScale = false;
|
|
782
777
|
var shouldHandleColgroupUpdates = false;
|
|
783
778
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
@@ -801,21 +796,13 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
801
796
|
if (shouldHandleColgroupUpdates) {
|
|
802
797
|
this.handleColgroupUpdates();
|
|
803
798
|
}
|
|
804
|
-
|
|
805
|
-
// table is always defined so this never runs
|
|
806
|
-
if (!(0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
807
|
-
if (isInDanger && !table) {
|
|
808
|
-
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
799
|
if ((_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
812
800
|
this.removeInlineTableWidth();
|
|
813
801
|
}
|
|
814
802
|
if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
815
803
|
// isDragAndDropEnabled will be false when the editorViewMode is 'live' and so the fix below is never triggered
|
|
816
804
|
// but the shadow observer must run async so its initial state is correct.
|
|
817
|
-
|
|
818
|
-
if (this.props.isDragAndDropEnabled || (0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
805
|
+
if (this.props.isDragAndDropEnabled) {
|
|
819
806
|
// requestAnimationFrame is used here to fix a race condition issue
|
|
820
807
|
// that happens when a table is nested in expand and expand's width is
|
|
821
808
|
// changed via breakout button
|
|
@@ -853,15 +840,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
853
840
|
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
854
841
|
// re-draw colgroup.
|
|
855
842
|
if ((0, _nodes.tablesHaveDifferentColumnWidths)(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
856
|
-
var
|
|
843
|
+
var view = this.props.view;
|
|
857
844
|
var shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
|
|
858
845
|
if (shouldRecreateResizeCols) {
|
|
859
846
|
var start = getPos() || 0;
|
|
860
|
-
var depth =
|
|
847
|
+
var depth = view.state.doc.resolve(start).depth;
|
|
861
848
|
shouldScale = depth === 0 && shouldScale;
|
|
862
849
|
(0, _colgroup.insertColgroupFromNode)(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
863
850
|
}
|
|
864
|
-
(0, _dom.updateControls)()(
|
|
851
|
+
(0, _dom.updateControls)()(view.state);
|
|
865
852
|
}
|
|
866
853
|
this.handleTableResizingDebounced();
|
|
867
854
|
}
|
|
@@ -1003,7 +990,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1003
990
|
var tablePos;
|
|
1004
991
|
try {
|
|
1005
992
|
tablePos = getPos ? getPos() : undefined;
|
|
1006
|
-
} catch (
|
|
993
|
+
} catch (_unused) {
|
|
1007
994
|
tablePos = undefined;
|
|
1008
995
|
}
|
|
1009
996
|
var isNested = (0, _nodes.isTableNested)(view.state, tablePos);
|
|
@@ -509,10 +509,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
509
509
|
this.handleWindowResizeDebounced.cancel();
|
|
510
510
|
}
|
|
511
511
|
this.handleWindowResizeNewDebounced.cancel();
|
|
512
|
-
if (
|
|
513
|
-
|
|
514
|
-
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
515
|
-
}
|
|
512
|
+
if (isInDanger) {
|
|
513
|
+
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
516
514
|
}
|
|
517
515
|
if (!allowTableResizing && allowColumnResizing) {
|
|
518
516
|
// Ignored via go/ees005
|
|
@@ -697,7 +695,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
697
695
|
value: function componentDidUpdate(_, prevState) {
|
|
698
696
|
var _this$props$options0, _this$props$options1;
|
|
699
697
|
var _this$props0 = this.props,
|
|
700
|
-
view = _this$props0.view,
|
|
701
698
|
getNode = _this$props0.getNode,
|
|
702
699
|
isMediaFullscreen = _this$props0.isMediaFullscreen,
|
|
703
700
|
allowColumnResizing = _this$props0.allowColumnResizing,
|
|
@@ -706,9 +703,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
706
703
|
options = _this$props0.options,
|
|
707
704
|
isTableScalingEnabled = _this$props0.isTableScalingEnabled,
|
|
708
705
|
getPos = _this$props0.getPos,
|
|
709
|
-
getEditorFeatureFlags = _this$props0.getEditorFeatureFlags
|
|
710
|
-
isInDanger = _this$props0.isInDanger;
|
|
711
|
-
var table = (0, _utils2.findTable)(view.state.selection);
|
|
706
|
+
getEditorFeatureFlags = _this$props0.getEditorFeatureFlags;
|
|
712
707
|
var shouldScale = false;
|
|
713
708
|
var shouldHandleColgroupUpdates = false;
|
|
714
709
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
@@ -732,13 +727,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
732
727
|
if (shouldHandleColgroupUpdates) {
|
|
733
728
|
this.handleColgroupUpdates();
|
|
734
729
|
}
|
|
735
|
-
|
|
736
|
-
// table is always defined so this never runs
|
|
737
|
-
if (!(0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
738
|
-
if (isInDanger && !table) {
|
|
739
|
-
(0, _commands.clearHoverSelection)()(view.state, view.dispatch);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
730
|
if ((_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
743
731
|
this.removeInlineTableWidth();
|
|
744
732
|
}
|
|
@@ -762,15 +750,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
762
750
|
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
763
751
|
// re-draw colgroup.
|
|
764
752
|
if ((0, _nodes.tablesHaveDifferentColumnWidths)(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
765
|
-
var
|
|
753
|
+
var view = this.props.view;
|
|
766
754
|
var shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
|
|
767
755
|
if (shouldRecreateResizeCols) {
|
|
768
756
|
var start = getPos() || 0;
|
|
769
|
-
var depth =
|
|
757
|
+
var depth = view.state.doc.resolve(start).depth;
|
|
770
758
|
shouldScale = depth === 0 && shouldScale;
|
|
771
759
|
(0, _colgroup.insertColgroupFromNode)(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
772
760
|
}
|
|
773
|
-
(0, _dom.updateControls)()(
|
|
761
|
+
(0, _dom.updateControls)()(view.state);
|
|
774
762
|
}
|
|
775
763
|
this.handleTableResizingDebounced();
|
|
776
764
|
}
|
|
@@ -13,7 +13,6 @@ var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
14
14
|
var _reactIntlNext = require("react-intl-next");
|
|
15
15
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
16
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
17
16
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
18
17
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
18
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
@@ -21,7 +20,6 @@ var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
|
21
20
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
22
21
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
22
|
var _pluginFactory = require("../../pm-plugins/drag-and-drop/plugin-factory");
|
|
24
|
-
var _pluginFactory2 = require("../../pm-plugins/plugin-factory");
|
|
25
23
|
var _mergedCells = require("../../pm-plugins/utils/merged-cells");
|
|
26
24
|
var _types = require("../../types");
|
|
27
25
|
var _consts = require("../consts");
|
|
@@ -48,9 +46,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
48
46
|
hoveredCell = _ref.hoveredCell,
|
|
49
47
|
onClick = _ref.onClick,
|
|
50
48
|
editorView = _ref.editorView,
|
|
51
|
-
formatMessage = _ref.intl.formatMessage
|
|
52
|
-
hoveredColumns = _ref.hoveredColumns,
|
|
53
|
-
hoveredRows = _ref.hoveredRows;
|
|
49
|
+
formatMessage = _ref.intl.formatMessage;
|
|
54
50
|
var dragHandleDivRef = (0, _react.useRef)(null);
|
|
55
51
|
var _useState = (0, _react.useState)(null),
|
|
56
52
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -58,13 +54,6 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
58
54
|
setPreviewContainer = _useState2[1];
|
|
59
55
|
var state = editorView.state,
|
|
60
56
|
selection = editorView.state.selection;
|
|
61
|
-
if (hoveredColumns === undefined || hoveredRows === undefined) {
|
|
62
|
-
var _getPluginState = (0, _pluginFactory2.getPluginState)(state),
|
|
63
|
-
hoveredColumnsState = _getPluginState.hoveredColumns,
|
|
64
|
-
hoveredRowsState = _getPluginState.hoveredRows;
|
|
65
|
-
hoveredColumns = hoveredColumnsState;
|
|
66
|
-
hoveredRows = hoveredRowsState;
|
|
67
|
-
}
|
|
68
57
|
var _getDnDPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
69
58
|
_getDnDPluginState$is = _getDnDPluginState.isDragMenuOpen,
|
|
70
59
|
isDragMenuOpen = _getDnDPluginState$is === void 0 ? false : _getDnDPluginState$is;
|
|
@@ -74,11 +63,6 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
74
63
|
setIsHovered = _useState4[1];
|
|
75
64
|
var isRow = direction === 'row';
|
|
76
65
|
var isColumn = direction === 'column';
|
|
77
|
-
|
|
78
|
-
// Added !isDragMenuOpen check so when hover 'Delete column/row' from drag menu
|
|
79
|
-
// the handle of the next column/row does not show the 'hovered' state icon
|
|
80
|
-
var isRowHandleHovered = isRow && hoveredRows.length > 0 && !isDragMenuOpen;
|
|
81
|
-
var isColumnHandleHovered = isColumn && hoveredColumns.length > 0 && !isDragMenuOpen;
|
|
82
66
|
var hasMergedCells = (0, _react.useMemo)(function () {
|
|
83
67
|
var table = (0, _editorTables.findTable)(selection);
|
|
84
68
|
if (!table) {
|
|
@@ -113,7 +97,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
113
97
|
}, [indexes, selection, direction, hoveredCell]);
|
|
114
98
|
var handleIconProps = {
|
|
115
99
|
forceDefaultHandle: forceDefaultHandle,
|
|
116
|
-
isHandleHovered:
|
|
100
|
+
isHandleHovered: isHovered,
|
|
117
101
|
hasMergedCells: hasMergedCells
|
|
118
102
|
};
|
|
119
103
|
(0, _react.useEffect)(function () {
|
|
@@ -223,17 +207,13 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
223
207
|
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
224
208
|
,
|
|
225
209
|
onMouseOver: function onMouseOver(e) {
|
|
226
|
-
|
|
227
|
-
setIsHovered(true);
|
|
228
|
-
}
|
|
210
|
+
setIsHovered(true);
|
|
229
211
|
_onMouseOver && _onMouseOver(e);
|
|
230
212
|
}
|
|
231
213
|
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
232
214
|
,
|
|
233
215
|
onMouseOut: function onMouseOut(e) {
|
|
234
|
-
|
|
235
|
-
setIsHovered(false);
|
|
236
|
-
}
|
|
216
|
+
setIsHovered(false);
|
|
237
217
|
_onMouseOut && _onMouseOut(e);
|
|
238
218
|
},
|
|
239
219
|
onMouseUp: function onMouseUp(e) {
|
|
@@ -270,50 +250,4 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
270
250
|
height: previewHeight
|
|
271
251
|
}), previewContainer));
|
|
272
252
|
};
|
|
273
|
-
var
|
|
274
|
-
var isDragMenuTarget = _ref5.isDragMenuTarget,
|
|
275
|
-
tableLocalId = _ref5.tableLocalId,
|
|
276
|
-
direction = _ref5.direction,
|
|
277
|
-
appearance = _ref5.appearance,
|
|
278
|
-
indexes = _ref5.indexes,
|
|
279
|
-
forceDefaultHandle = _ref5.forceDefaultHandle,
|
|
280
|
-
previewHeight = _ref5.previewHeight,
|
|
281
|
-
previewWidth = _ref5.previewWidth,
|
|
282
|
-
onMouseOver = _ref5.onMouseOver,
|
|
283
|
-
onMouseOut = _ref5.onMouseOut,
|
|
284
|
-
toggleDragMenu = _ref5.toggleDragMenu,
|
|
285
|
-
hoveredCell = _ref5.hoveredCell,
|
|
286
|
-
onClick = _ref5.onClick,
|
|
287
|
-
editorView = _ref5.editorView,
|
|
288
|
-
intl = _ref5.intl,
|
|
289
|
-
api = _ref5.api;
|
|
290
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['table'], function (states) {
|
|
291
|
-
var _states$tableState, _states$tableState2;
|
|
292
|
-
return {
|
|
293
|
-
hoveredColumns: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.hoveredColumns,
|
|
294
|
-
hoveredRows: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.hoveredRows
|
|
295
|
-
};
|
|
296
|
-
}),
|
|
297
|
-
hoveredColumns = _useSharedPluginState.hoveredColumns,
|
|
298
|
-
hoveredRows = _useSharedPluginState.hoveredRows;
|
|
299
|
-
return /*#__PURE__*/_react.default.createElement(DragHandleComponent, {
|
|
300
|
-
isDragMenuTarget: isDragMenuTarget,
|
|
301
|
-
tableLocalId: tableLocalId,
|
|
302
|
-
direction: direction,
|
|
303
|
-
appearance: appearance,
|
|
304
|
-
indexes: indexes,
|
|
305
|
-
forceDefaultHandle: forceDefaultHandle,
|
|
306
|
-
previewWidth: previewWidth,
|
|
307
|
-
previewHeight: previewHeight,
|
|
308
|
-
onMouseOver: onMouseOver,
|
|
309
|
-
onMouseOut: onMouseOut,
|
|
310
|
-
toggleDragMenu: toggleDragMenu,
|
|
311
|
-
hoveredCell: hoveredCell,
|
|
312
|
-
onClick: onClick,
|
|
313
|
-
editorView: editorView,
|
|
314
|
-
intl: intl,
|
|
315
|
-
hoveredColumns: hoveredColumns,
|
|
316
|
-
hoveredRows: hoveredRows
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleComponentWithSharedState);
|
|
253
|
+
var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleComponent);
|
|
@@ -13,7 +13,7 @@ import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-com
|
|
|
13
13
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
14
14
|
import { isValidPosition } from '@atlaskit/editor-common/utils';
|
|
15
15
|
import { akEditorTableNumberColumnWidth, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
16
|
-
import {
|
|
16
|
+
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
18
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
19
19
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -546,10 +546,8 @@ class TableComponent extends React.Component {
|
|
|
546
546
|
this.handleWindowResizeDebounced.cancel();
|
|
547
547
|
}
|
|
548
548
|
this.handleWindowResizeNewDebounced.cancel();
|
|
549
|
-
if (
|
|
550
|
-
|
|
551
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
552
|
-
}
|
|
549
|
+
if (isInDanger) {
|
|
550
|
+
clearHoverSelection()(view.state, view.dispatch);
|
|
553
551
|
}
|
|
554
552
|
if (!allowTableResizing && allowColumnResizing) {
|
|
555
553
|
// Ignored via go/ees005
|
|
@@ -732,7 +730,6 @@ class TableComponent extends React.Component {
|
|
|
732
730
|
componentDidUpdate(_, prevState) {
|
|
733
731
|
var _this$props$options10, _this$props$options11, _this$wrapper2;
|
|
734
732
|
const {
|
|
735
|
-
view,
|
|
736
733
|
getNode,
|
|
737
734
|
isMediaFullscreen,
|
|
738
735
|
allowColumnResizing,
|
|
@@ -742,10 +739,8 @@ class TableComponent extends React.Component {
|
|
|
742
739
|
isTableScalingEnabled,
|
|
743
740
|
// we could use options.isTableScalingEnabled here
|
|
744
741
|
getPos,
|
|
745
|
-
getEditorFeatureFlags
|
|
746
|
-
isInDanger
|
|
742
|
+
getEditorFeatureFlags
|
|
747
743
|
} = this.props;
|
|
748
|
-
const table = findTable(view.state.selection);
|
|
749
744
|
let shouldScale = false;
|
|
750
745
|
let shouldHandleColgroupUpdates = false;
|
|
751
746
|
const {
|
|
@@ -769,21 +764,13 @@ class TableComponent extends React.Component {
|
|
|
769
764
|
if (shouldHandleColgroupUpdates) {
|
|
770
765
|
this.handleColgroupUpdates();
|
|
771
766
|
}
|
|
772
|
-
|
|
773
|
-
// table is always defined so this never runs
|
|
774
|
-
if (!expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
775
|
-
if (isInDanger && !table) {
|
|
776
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
767
|
if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
780
768
|
this.removeInlineTableWidth();
|
|
781
769
|
}
|
|
782
770
|
if ((_this$wrapper2 = this.wrapper) !== null && _this$wrapper2 !== void 0 && _this$wrapper2.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
783
771
|
// isDragAndDropEnabled will be false when the editorViewMode is 'live' and so the fix below is never triggered
|
|
784
772
|
// but the shadow observer must run async so its initial state is correct.
|
|
785
|
-
|
|
786
|
-
if (this.props.isDragAndDropEnabled || expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
773
|
+
if (this.props.isDragAndDropEnabled) {
|
|
787
774
|
// requestAnimationFrame is used here to fix a race condition issue
|
|
788
775
|
// that happens when a table is nested in expand and expand's width is
|
|
789
776
|
// changed via breakout button
|
|
@@ -971,7 +958,7 @@ class TableComponent extends React.Component {
|
|
|
971
958
|
let tablePos;
|
|
972
959
|
try {
|
|
973
960
|
tablePos = getPos ? getPos() : undefined;
|
|
974
|
-
} catch
|
|
961
|
+
} catch {
|
|
975
962
|
tablePos = undefined;
|
|
976
963
|
}
|
|
977
964
|
const isNested = isTableNested(view.state, tablePos);
|
|
@@ -10,7 +10,7 @@ import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
|
10
10
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
11
11
|
import { isValidPosition } from '@atlaskit/editor-common/utils';
|
|
12
12
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
13
|
-
import {
|
|
13
|
+
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
16
16
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -473,10 +473,8 @@ class TableComponent extends React.Component {
|
|
|
473
473
|
this.handleWindowResizeDebounced.cancel();
|
|
474
474
|
}
|
|
475
475
|
this.handleWindowResizeNewDebounced.cancel();
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
479
|
-
}
|
|
476
|
+
if (isInDanger) {
|
|
477
|
+
clearHoverSelection()(view.state, view.dispatch);
|
|
480
478
|
}
|
|
481
479
|
if (!allowTableResizing && allowColumnResizing) {
|
|
482
480
|
// Ignored via go/ees005
|
|
@@ -656,7 +654,6 @@ class TableComponent extends React.Component {
|
|
|
656
654
|
componentDidUpdate(_, prevState) {
|
|
657
655
|
var _this$props$options10, _this$props$options11;
|
|
658
656
|
const {
|
|
659
|
-
view,
|
|
660
657
|
getNode,
|
|
661
658
|
isMediaFullscreen,
|
|
662
659
|
allowColumnResizing,
|
|
@@ -666,10 +663,8 @@ class TableComponent extends React.Component {
|
|
|
666
663
|
isTableScalingEnabled,
|
|
667
664
|
// we could use options.isTableScalingEnabled here
|
|
668
665
|
getPos,
|
|
669
|
-
getEditorFeatureFlags
|
|
670
|
-
isInDanger
|
|
666
|
+
getEditorFeatureFlags
|
|
671
667
|
} = this.props;
|
|
672
|
-
const table = findTable(view.state.selection);
|
|
673
668
|
let shouldScale = false;
|
|
674
669
|
let shouldHandleColgroupUpdates = false;
|
|
675
670
|
const {
|
|
@@ -693,13 +688,6 @@ class TableComponent extends React.Component {
|
|
|
693
688
|
if (shouldHandleColgroupUpdates) {
|
|
694
689
|
this.handleColgroupUpdates();
|
|
695
690
|
}
|
|
696
|
-
|
|
697
|
-
// table is always defined so this never runs
|
|
698
|
-
if (!expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
699
|
-
if (isInDanger && !table) {
|
|
700
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
691
|
if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
704
692
|
this.removeInlineTableWidth();
|
|
705
693
|
}
|
|
@@ -5,7 +5,6 @@ import classnames from 'classnames';
|
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
7
|
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
8
|
-
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
9
8
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
9
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
10
|
import { findTable, TableMap } from '@atlaskit/editor-tables';
|
|
@@ -13,7 +12,6 @@ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
|
13
12
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
14
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
14
|
import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
16
|
-
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
17
15
|
import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
|
|
18
16
|
import { TableCssClassName as ClassName } from '../../types';
|
|
19
17
|
import { dragTableInsertColumnButtonSize } from '../consts';
|
|
@@ -36,9 +34,7 @@ const DragHandleComponent = ({
|
|
|
36
34
|
editorView,
|
|
37
35
|
intl: {
|
|
38
36
|
formatMessage
|
|
39
|
-
}
|
|
40
|
-
hoveredColumns,
|
|
41
|
-
hoveredRows
|
|
37
|
+
}
|
|
42
38
|
}) => {
|
|
43
39
|
const dragHandleDivRef = useRef(null);
|
|
44
40
|
const [previewContainer, setPreviewContainer] = useState(null);
|
|
@@ -48,25 +44,12 @@ const DragHandleComponent = ({
|
|
|
48
44
|
selection
|
|
49
45
|
}
|
|
50
46
|
} = editorView;
|
|
51
|
-
if (hoveredColumns === undefined || hoveredRows === undefined) {
|
|
52
|
-
const {
|
|
53
|
-
hoveredColumns: hoveredColumnsState,
|
|
54
|
-
hoveredRows: hoveredRowsState
|
|
55
|
-
} = getPluginState(state);
|
|
56
|
-
hoveredColumns = hoveredColumnsState;
|
|
57
|
-
hoveredRows = hoveredRowsState;
|
|
58
|
-
}
|
|
59
47
|
const {
|
|
60
48
|
isDragMenuOpen = false
|
|
61
49
|
} = getDnDPluginState(state);
|
|
62
50
|
const [isHovered, setIsHovered] = useState(false);
|
|
63
51
|
const isRow = direction === 'row';
|
|
64
52
|
const isColumn = direction === 'column';
|
|
65
|
-
|
|
66
|
-
// Added !isDragMenuOpen check so when hover 'Delete column/row' from drag menu
|
|
67
|
-
// the handle of the next column/row does not show the 'hovered' state icon
|
|
68
|
-
const isRowHandleHovered = isRow && hoveredRows.length > 0 && !isDragMenuOpen;
|
|
69
|
-
const isColumnHandleHovered = isColumn && hoveredColumns.length > 0 && !isDragMenuOpen;
|
|
70
53
|
const hasMergedCells = useMemo(() => {
|
|
71
54
|
const table = findTable(selection);
|
|
72
55
|
if (!table) {
|
|
@@ -101,7 +84,7 @@ const DragHandleComponent = ({
|
|
|
101
84
|
}, [indexes, selection, direction, hoveredCell]);
|
|
102
85
|
const handleIconProps = {
|
|
103
86
|
forceDefaultHandle,
|
|
104
|
-
isHandleHovered:
|
|
87
|
+
isHandleHovered: isHovered,
|
|
105
88
|
hasMergedCells
|
|
106
89
|
};
|
|
107
90
|
useEffect(() => {
|
|
@@ -216,17 +199,13 @@ const DragHandleComponent = ({
|
|
|
216
199
|
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
217
200
|
,
|
|
218
201
|
onMouseOver: e => {
|
|
219
|
-
|
|
220
|
-
setIsHovered(true);
|
|
221
|
-
}
|
|
202
|
+
setIsHovered(true);
|
|
222
203
|
onMouseOver && onMouseOver(e);
|
|
223
204
|
}
|
|
224
205
|
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
225
206
|
,
|
|
226
207
|
onMouseOut: e => {
|
|
227
|
-
|
|
228
|
-
setIsHovered(false);
|
|
229
|
-
}
|
|
208
|
+
setIsHovered(false);
|
|
230
209
|
onMouseOut && onMouseOut(e);
|
|
231
210
|
},
|
|
232
211
|
onMouseUp: e => {
|
|
@@ -263,52 +242,4 @@ const DragHandleComponent = ({
|
|
|
263
242
|
height: previewHeight
|
|
264
243
|
}), previewContainer));
|
|
265
244
|
};
|
|
266
|
-
const
|
|
267
|
-
isDragMenuTarget,
|
|
268
|
-
tableLocalId,
|
|
269
|
-
direction,
|
|
270
|
-
appearance,
|
|
271
|
-
indexes,
|
|
272
|
-
forceDefaultHandle,
|
|
273
|
-
previewHeight,
|
|
274
|
-
previewWidth,
|
|
275
|
-
onMouseOver,
|
|
276
|
-
onMouseOut,
|
|
277
|
-
toggleDragMenu,
|
|
278
|
-
hoveredCell,
|
|
279
|
-
onClick,
|
|
280
|
-
editorView,
|
|
281
|
-
intl,
|
|
282
|
-
api
|
|
283
|
-
}) => {
|
|
284
|
-
const {
|
|
285
|
-
hoveredColumns,
|
|
286
|
-
hoveredRows
|
|
287
|
-
} = useSharedPluginStateWithSelector(api, ['table'], states => {
|
|
288
|
-
var _states$tableState, _states$tableState2;
|
|
289
|
-
return {
|
|
290
|
-
hoveredColumns: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.hoveredColumns,
|
|
291
|
-
hoveredRows: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.hoveredRows
|
|
292
|
-
};
|
|
293
|
-
});
|
|
294
|
-
return /*#__PURE__*/React.createElement(DragHandleComponent, {
|
|
295
|
-
isDragMenuTarget: isDragMenuTarget,
|
|
296
|
-
tableLocalId: tableLocalId,
|
|
297
|
-
direction: direction,
|
|
298
|
-
appearance: appearance,
|
|
299
|
-
indexes: indexes,
|
|
300
|
-
forceDefaultHandle: forceDefaultHandle,
|
|
301
|
-
previewWidth: previewWidth,
|
|
302
|
-
previewHeight: previewHeight,
|
|
303
|
-
onMouseOver: onMouseOver,
|
|
304
|
-
onMouseOut: onMouseOut,
|
|
305
|
-
toggleDragMenu: toggleDragMenu,
|
|
306
|
-
hoveredCell: hoveredCell,
|
|
307
|
-
onClick: onClick,
|
|
308
|
-
editorView: editorView,
|
|
309
|
-
intl: intl,
|
|
310
|
-
hoveredColumns: hoveredColumns,
|
|
311
|
-
hoveredRows: hoveredRows
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
export const DragHandle = injectIntl(DragHandleComponentWithSharedState);
|
|
245
|
+
export const DragHandle = injectIntl(DragHandleComponent);
|
|
@@ -26,7 +26,7 @@ import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-com
|
|
|
26
26
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
27
27
|
import { isValidPosition } from '@atlaskit/editor-common/utils';
|
|
28
28
|
import { akEditorTableNumberColumnWidth, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
29
|
-
import {
|
|
29
|
+
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
30
30
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
31
31
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
32
32
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -566,10 +566,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
566
566
|
this.handleWindowResizeDebounced.cancel();
|
|
567
567
|
}
|
|
568
568
|
this.handleWindowResizeNewDebounced.cancel();
|
|
569
|
-
if (
|
|
570
|
-
|
|
571
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
572
|
-
}
|
|
569
|
+
if (isInDanger) {
|
|
570
|
+
clearHoverSelection()(view.state, view.dispatch);
|
|
573
571
|
}
|
|
574
572
|
if (!allowTableResizing && allowColumnResizing) {
|
|
575
573
|
// Ignored via go/ees005
|
|
@@ -760,7 +758,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
760
758
|
_this$wrapper,
|
|
761
759
|
_this5 = this;
|
|
762
760
|
var _this$props1 = this.props,
|
|
763
|
-
view = _this$props1.view,
|
|
764
761
|
getNode = _this$props1.getNode,
|
|
765
762
|
isMediaFullscreen = _this$props1.isMediaFullscreen,
|
|
766
763
|
allowColumnResizing = _this$props1.allowColumnResizing,
|
|
@@ -769,9 +766,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
769
766
|
options = _this$props1.options,
|
|
770
767
|
isTableScalingEnabled = _this$props1.isTableScalingEnabled,
|
|
771
768
|
getPos = _this$props1.getPos,
|
|
772
|
-
getEditorFeatureFlags = _this$props1.getEditorFeatureFlags
|
|
773
|
-
isInDanger = _this$props1.isInDanger;
|
|
774
|
-
var table = findTable(view.state.selection);
|
|
769
|
+
getEditorFeatureFlags = _this$props1.getEditorFeatureFlags;
|
|
775
770
|
var shouldScale = false;
|
|
776
771
|
var shouldHandleColgroupUpdates = false;
|
|
777
772
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
@@ -795,21 +790,13 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
795
790
|
if (shouldHandleColgroupUpdates) {
|
|
796
791
|
this.handleColgroupUpdates();
|
|
797
792
|
}
|
|
798
|
-
|
|
799
|
-
// table is always defined so this never runs
|
|
800
|
-
if (!expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
801
|
-
if (isInDanger && !table) {
|
|
802
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
793
|
if ((_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
806
794
|
this.removeInlineTableWidth();
|
|
807
795
|
}
|
|
808
796
|
if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
809
797
|
// isDragAndDropEnabled will be false when the editorViewMode is 'live' and so the fix below is never triggered
|
|
810
798
|
// but the shadow observer must run async so its initial state is correct.
|
|
811
|
-
|
|
812
|
-
if (this.props.isDragAndDropEnabled || expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
799
|
+
if (this.props.isDragAndDropEnabled) {
|
|
813
800
|
// requestAnimationFrame is used here to fix a race condition issue
|
|
814
801
|
// that happens when a table is nested in expand and expand's width is
|
|
815
802
|
// changed via breakout button
|
|
@@ -847,15 +834,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
847
834
|
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
848
835
|
// re-draw colgroup.
|
|
849
836
|
if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
850
|
-
var
|
|
837
|
+
var view = this.props.view;
|
|
851
838
|
var shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
|
|
852
839
|
if (shouldRecreateResizeCols) {
|
|
853
840
|
var start = getPos() || 0;
|
|
854
|
-
var depth =
|
|
841
|
+
var depth = view.state.doc.resolve(start).depth;
|
|
855
842
|
shouldScale = depth === 0 && shouldScale;
|
|
856
843
|
insertColgroupFromNode(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
857
844
|
}
|
|
858
|
-
updateControls()(
|
|
845
|
+
updateControls()(view.state);
|
|
859
846
|
}
|
|
860
847
|
this.handleTableResizingDebounced();
|
|
861
848
|
}
|
|
@@ -997,7 +984,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
997
984
|
var tablePos;
|
|
998
985
|
try {
|
|
999
986
|
tablePos = getPos ? getPos() : undefined;
|
|
1000
|
-
} catch (
|
|
987
|
+
} catch (_unused) {
|
|
1001
988
|
tablePos = undefined;
|
|
1002
989
|
}
|
|
1003
990
|
var isNested = isTableNested(view.state, tablePos);
|
|
@@ -23,7 +23,7 @@ import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
|
23
23
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
24
24
|
import { isValidPosition } from '@atlaskit/editor-common/utils';
|
|
25
25
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
26
|
-
import {
|
|
26
|
+
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
27
27
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
28
28
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
29
29
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -503,10 +503,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
503
503
|
this.handleWindowResizeDebounced.cancel();
|
|
504
504
|
}
|
|
505
505
|
this.handleWindowResizeNewDebounced.cancel();
|
|
506
|
-
if (
|
|
507
|
-
|
|
508
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
509
|
-
}
|
|
506
|
+
if (isInDanger) {
|
|
507
|
+
clearHoverSelection()(view.state, view.dispatch);
|
|
510
508
|
}
|
|
511
509
|
if (!allowTableResizing && allowColumnResizing) {
|
|
512
510
|
// Ignored via go/ees005
|
|
@@ -691,7 +689,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
691
689
|
value: function componentDidUpdate(_, prevState) {
|
|
692
690
|
var _this$props$options0, _this$props$options1;
|
|
693
691
|
var _this$props0 = this.props,
|
|
694
|
-
view = _this$props0.view,
|
|
695
692
|
getNode = _this$props0.getNode,
|
|
696
693
|
isMediaFullscreen = _this$props0.isMediaFullscreen,
|
|
697
694
|
allowColumnResizing = _this$props0.allowColumnResizing,
|
|
@@ -700,9 +697,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
700
697
|
options = _this$props0.options,
|
|
701
698
|
isTableScalingEnabled = _this$props0.isTableScalingEnabled,
|
|
702
699
|
getPos = _this$props0.getPos,
|
|
703
|
-
getEditorFeatureFlags = _this$props0.getEditorFeatureFlags
|
|
704
|
-
isInDanger = _this$props0.isInDanger;
|
|
705
|
-
var table = findTable(view.state.selection);
|
|
700
|
+
getEditorFeatureFlags = _this$props0.getEditorFeatureFlags;
|
|
706
701
|
var shouldScale = false;
|
|
707
702
|
var shouldHandleColgroupUpdates = false;
|
|
708
703
|
var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
|
|
@@ -726,13 +721,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
726
721
|
if (shouldHandleColgroupUpdates) {
|
|
727
722
|
this.handleColgroupUpdates();
|
|
728
723
|
}
|
|
729
|
-
|
|
730
|
-
// table is always defined so this never runs
|
|
731
|
-
if (!expValEquals('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
|
|
732
|
-
if (isInDanger && !table) {
|
|
733
|
-
clearHoverSelection()(view.state, view.dispatch);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
724
|
if ((_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
737
725
|
this.removeInlineTableWidth();
|
|
738
726
|
}
|
|
@@ -756,15 +744,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
756
744
|
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
757
745
|
// re-draw colgroup.
|
|
758
746
|
if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
759
|
-
var
|
|
747
|
+
var view = this.props.view;
|
|
760
748
|
var shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
|
|
761
749
|
if (shouldRecreateResizeCols) {
|
|
762
750
|
var start = getPos() || 0;
|
|
763
|
-
var depth =
|
|
751
|
+
var depth = view.state.doc.resolve(start).depth;
|
|
764
752
|
shouldScale = depth === 0 && shouldScale;
|
|
765
753
|
insertColgroupFromNode(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
766
754
|
}
|
|
767
|
-
updateControls()(
|
|
755
|
+
updateControls()(view.state);
|
|
768
756
|
}
|
|
769
757
|
this.handleTableResizingDebounced();
|
|
770
758
|
}
|
|
@@ -7,7 +7,6 @@ import classnames from 'classnames';
|
|
|
7
7
|
import ReactDOM from 'react-dom';
|
|
8
8
|
import { injectIntl } from 'react-intl-next';
|
|
9
9
|
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
10
|
-
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
11
10
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
12
11
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
12
|
import { findTable, TableMap } from '@atlaskit/editor-tables';
|
|
@@ -15,7 +14,6 @@ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
|
15
14
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
16
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
16
|
import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
18
|
-
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
19
17
|
import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugins/utils/merged-cells';
|
|
20
18
|
import { TableCssClassName as ClassName } from '../../types';
|
|
21
19
|
import { dragTableInsertColumnButtonSize } from '../consts';
|
|
@@ -39,9 +37,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
39
37
|
hoveredCell = _ref.hoveredCell,
|
|
40
38
|
onClick = _ref.onClick,
|
|
41
39
|
editorView = _ref.editorView,
|
|
42
|
-
formatMessage = _ref.intl.formatMessage
|
|
43
|
-
hoveredColumns = _ref.hoveredColumns,
|
|
44
|
-
hoveredRows = _ref.hoveredRows;
|
|
40
|
+
formatMessage = _ref.intl.formatMessage;
|
|
45
41
|
var dragHandleDivRef = useRef(null);
|
|
46
42
|
var _useState = useState(null),
|
|
47
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -49,13 +45,6 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
49
45
|
setPreviewContainer = _useState2[1];
|
|
50
46
|
var state = editorView.state,
|
|
51
47
|
selection = editorView.state.selection;
|
|
52
|
-
if (hoveredColumns === undefined || hoveredRows === undefined) {
|
|
53
|
-
var _getPluginState = getPluginState(state),
|
|
54
|
-
hoveredColumnsState = _getPluginState.hoveredColumns,
|
|
55
|
-
hoveredRowsState = _getPluginState.hoveredRows;
|
|
56
|
-
hoveredColumns = hoveredColumnsState;
|
|
57
|
-
hoveredRows = hoveredRowsState;
|
|
58
|
-
}
|
|
59
48
|
var _getDnDPluginState = getDnDPluginState(state),
|
|
60
49
|
_getDnDPluginState$is = _getDnDPluginState.isDragMenuOpen,
|
|
61
50
|
isDragMenuOpen = _getDnDPluginState$is === void 0 ? false : _getDnDPluginState$is;
|
|
@@ -65,11 +54,6 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
65
54
|
setIsHovered = _useState4[1];
|
|
66
55
|
var isRow = direction === 'row';
|
|
67
56
|
var isColumn = direction === 'column';
|
|
68
|
-
|
|
69
|
-
// Added !isDragMenuOpen check so when hover 'Delete column/row' from drag menu
|
|
70
|
-
// the handle of the next column/row does not show the 'hovered' state icon
|
|
71
|
-
var isRowHandleHovered = isRow && hoveredRows.length > 0 && !isDragMenuOpen;
|
|
72
|
-
var isColumnHandleHovered = isColumn && hoveredColumns.length > 0 && !isDragMenuOpen;
|
|
73
57
|
var hasMergedCells = useMemo(function () {
|
|
74
58
|
var table = findTable(selection);
|
|
75
59
|
if (!table) {
|
|
@@ -104,7 +88,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
104
88
|
}, [indexes, selection, direction, hoveredCell]);
|
|
105
89
|
var handleIconProps = {
|
|
106
90
|
forceDefaultHandle: forceDefaultHandle,
|
|
107
|
-
isHandleHovered:
|
|
91
|
+
isHandleHovered: isHovered,
|
|
108
92
|
hasMergedCells: hasMergedCells
|
|
109
93
|
};
|
|
110
94
|
useEffect(function () {
|
|
@@ -214,17 +198,13 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
214
198
|
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
215
199
|
,
|
|
216
200
|
onMouseOver: function onMouseOver(e) {
|
|
217
|
-
|
|
218
|
-
setIsHovered(true);
|
|
219
|
-
}
|
|
201
|
+
setIsHovered(true);
|
|
220
202
|
_onMouseOver && _onMouseOver(e);
|
|
221
203
|
}
|
|
222
204
|
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
223
205
|
,
|
|
224
206
|
onMouseOut: function onMouseOut(e) {
|
|
225
|
-
|
|
226
|
-
setIsHovered(false);
|
|
227
|
-
}
|
|
207
|
+
setIsHovered(false);
|
|
228
208
|
_onMouseOut && _onMouseOut(e);
|
|
229
209
|
},
|
|
230
210
|
onMouseUp: function onMouseUp(e) {
|
|
@@ -261,50 +241,4 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
261
241
|
height: previewHeight
|
|
262
242
|
}), previewContainer));
|
|
263
243
|
};
|
|
264
|
-
var
|
|
265
|
-
var isDragMenuTarget = _ref5.isDragMenuTarget,
|
|
266
|
-
tableLocalId = _ref5.tableLocalId,
|
|
267
|
-
direction = _ref5.direction,
|
|
268
|
-
appearance = _ref5.appearance,
|
|
269
|
-
indexes = _ref5.indexes,
|
|
270
|
-
forceDefaultHandle = _ref5.forceDefaultHandle,
|
|
271
|
-
previewHeight = _ref5.previewHeight,
|
|
272
|
-
previewWidth = _ref5.previewWidth,
|
|
273
|
-
onMouseOver = _ref5.onMouseOver,
|
|
274
|
-
onMouseOut = _ref5.onMouseOut,
|
|
275
|
-
toggleDragMenu = _ref5.toggleDragMenu,
|
|
276
|
-
hoveredCell = _ref5.hoveredCell,
|
|
277
|
-
onClick = _ref5.onClick,
|
|
278
|
-
editorView = _ref5.editorView,
|
|
279
|
-
intl = _ref5.intl,
|
|
280
|
-
api = _ref5.api;
|
|
281
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['table'], function (states) {
|
|
282
|
-
var _states$tableState, _states$tableState2;
|
|
283
|
-
return {
|
|
284
|
-
hoveredColumns: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.hoveredColumns,
|
|
285
|
-
hoveredRows: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.hoveredRows
|
|
286
|
-
};
|
|
287
|
-
}),
|
|
288
|
-
hoveredColumns = _useSharedPluginState.hoveredColumns,
|
|
289
|
-
hoveredRows = _useSharedPluginState.hoveredRows;
|
|
290
|
-
return /*#__PURE__*/React.createElement(DragHandleComponent, {
|
|
291
|
-
isDragMenuTarget: isDragMenuTarget,
|
|
292
|
-
tableLocalId: tableLocalId,
|
|
293
|
-
direction: direction,
|
|
294
|
-
appearance: appearance,
|
|
295
|
-
indexes: indexes,
|
|
296
|
-
forceDefaultHandle: forceDefaultHandle,
|
|
297
|
-
previewWidth: previewWidth,
|
|
298
|
-
previewHeight: previewHeight,
|
|
299
|
-
onMouseOver: onMouseOver,
|
|
300
|
-
onMouseOut: onMouseOut,
|
|
301
|
-
toggleDragMenu: toggleDragMenu,
|
|
302
|
-
hoveredCell: hoveredCell,
|
|
303
|
-
onClick: onClick,
|
|
304
|
-
editorView: editorView,
|
|
305
|
-
intl: intl,
|
|
306
|
-
hoveredColumns: hoveredColumns,
|
|
307
|
-
hoveredRows: hoveredRows
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
export var DragHandle = injectIntl(DragHandleComponentWithSharedState);
|
|
244
|
+
export var DragHandle = injectIntl(DragHandleComponent);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { MouseEventHandler } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
5
|
import type { TriggerType } from '../../pm-plugins/drag-and-drop/types';
|
|
7
|
-
import type { TablePlugin } from '../../tablePluginType';
|
|
8
6
|
import type { CellHoverMeta, TableDirection } from '../../types';
|
|
9
7
|
export type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger' | 'placeholder';
|
|
10
8
|
type DragHandleProps = {
|
|
@@ -13,8 +11,6 @@ type DragHandleProps = {
|
|
|
13
11
|
editorView: EditorView;
|
|
14
12
|
forceDefaultHandle?: boolean;
|
|
15
13
|
hoveredCell?: CellHoverMeta;
|
|
16
|
-
hoveredColumns?: number[];
|
|
17
|
-
hoveredRows?: number[];
|
|
18
14
|
indexes: number[];
|
|
19
15
|
isDragMenuTarget: boolean;
|
|
20
16
|
onClick?: MouseEventHandler;
|
|
@@ -25,11 +21,7 @@ type DragHandleProps = {
|
|
|
25
21
|
tableLocalId: string;
|
|
26
22
|
toggleDragMenu?: (trigger: TriggerType, event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
27
23
|
};
|
|
28
|
-
export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & {
|
|
29
|
-
|
|
30
|
-
} & WrappedComponentProps>> & {
|
|
31
|
-
WrappedComponent: React.ComponentType<DragHandleProps & {
|
|
32
|
-
api?: ExtractInjectionAPI<TablePlugin>;
|
|
33
|
-
} & WrappedComponentProps>;
|
|
24
|
+
export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & WrappedComponentProps>> & {
|
|
25
|
+
WrappedComponent: React.ComponentType<DragHandleProps & WrappedComponentProps>;
|
|
34
26
|
};
|
|
35
27
|
export {};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { MouseEventHandler } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
5
|
import type { TriggerType } from '../../pm-plugins/drag-and-drop/types';
|
|
7
|
-
import type { TablePlugin } from '../../tablePluginType';
|
|
8
6
|
import type { CellHoverMeta, TableDirection } from '../../types';
|
|
9
7
|
export type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger' | 'placeholder';
|
|
10
8
|
type DragHandleProps = {
|
|
@@ -13,8 +11,6 @@ type DragHandleProps = {
|
|
|
13
11
|
editorView: EditorView;
|
|
14
12
|
forceDefaultHandle?: boolean;
|
|
15
13
|
hoveredCell?: CellHoverMeta;
|
|
16
|
-
hoveredColumns?: number[];
|
|
17
|
-
hoveredRows?: number[];
|
|
18
14
|
indexes: number[];
|
|
19
15
|
isDragMenuTarget: boolean;
|
|
20
16
|
onClick?: MouseEventHandler;
|
|
@@ -25,11 +21,7 @@ type DragHandleProps = {
|
|
|
25
21
|
tableLocalId: string;
|
|
26
22
|
toggleDragMenu?: (trigger: TriggerType, event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
27
23
|
};
|
|
28
|
-
export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & {
|
|
29
|
-
|
|
30
|
-
} & WrappedComponentProps>> & {
|
|
31
|
-
WrappedComponent: React.ComponentType<DragHandleProps & {
|
|
32
|
-
api?: ExtractInjectionAPI<TablePlugin>;
|
|
33
|
-
} & WrappedComponentProps>;
|
|
24
|
+
export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & WrappedComponentProps>> & {
|
|
25
|
+
WrappedComponent: React.ComponentType<DragHandleProps & WrappedComponentProps>;
|
|
34
26
|
};
|
|
35
27
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "15.4.
|
|
3
|
+
"version": "15.4.21",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^6.1.0",
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^6.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
|
|
40
|
-
"@atlaskit/editor-plugin-extension": "9.2.
|
|
40
|
+
"@atlaskit/editor-plugin-extension": "9.2.11",
|
|
41
41
|
"@atlaskit/editor-plugin-guideline": "^6.0.0",
|
|
42
42
|
"@atlaskit/editor-plugin-interaction": "^10.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-limited-mode": "^3.1.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
59
59
|
"@atlaskit/primitives": "^16.4.0",
|
|
60
60
|
"@atlaskit/theme": "^21.0.0",
|
|
61
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
61
|
+
"@atlaskit/tmp-editor-statsig": "^15.1.0",
|
|
62
62
|
"@atlaskit/toggle": "^15.1.0",
|
|
63
63
|
"@atlaskit/tokens": "^8.4.0",
|
|
64
64
|
"@atlaskit/tooltip": "^20.11.0",
|