@atlaskit/editor-plugin-table 9.1.3 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +5 -5
  3. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +6 -4
  4. package/dist/cjs/nodeviews/table.js +1 -2
  5. package/dist/cjs/tablePlugin.js +1 -0
  6. package/dist/cjs/ui/DragHandle/index.js +55 -6
  7. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +17 -2
  8. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  9. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +60 -7
  10. package/dist/cjs/ui/TableFloatingControls/index.js +24 -4
  11. package/dist/es2019/nodeviews/TableComponent.js +5 -5
  12. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +6 -4
  13. package/dist/es2019/nodeviews/table.js +1 -2
  14. package/dist/es2019/tablePlugin.js +1 -0
  15. package/dist/es2019/ui/DragHandle/index.js +57 -6
  16. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -3
  17. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  18. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +62 -7
  19. package/dist/es2019/ui/TableFloatingControls/index.js +25 -5
  20. package/dist/esm/nodeviews/TableComponent.js +5 -5
  21. package/dist/esm/nodeviews/TableComponentWithSharedState.js +6 -4
  22. package/dist/esm/nodeviews/table.js +1 -2
  23. package/dist/esm/tablePlugin.js +1 -0
  24. package/dist/esm/ui/DragHandle/index.js +54 -5
  25. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -3
  26. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  27. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +60 -7
  28. package/dist/esm/ui/TableFloatingControls/index.js +25 -5
  29. package/dist/types/nodeviews/TableComponent.d.ts +3 -1
  30. package/dist/types/types/index.d.ts +1 -1
  31. package/dist/types/ui/DragHandle/index.d.ts +21 -0
  32. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  33. package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  34. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -1
  35. package/dist/types-ts4.5/types/index.d.ts +1 -1
  36. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +21 -0
  37. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  38. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  39. package/package.json +8 -5
  40. package/src/nodeviews/TableComponent.tsx +9 -7
  41. package/src/nodeviews/TableComponentWithSharedState.tsx +4 -2
  42. package/src/nodeviews/table.tsx +1 -2
  43. package/src/tablePlugin.tsx +1 -0
  44. package/src/types/index.ts +1 -0
  45. package/src/ui/DragHandle/index.tsx +67 -2
  46. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +38 -19
  47. package/src/ui/TableFloatingColumnControls/index.tsx +2 -5
  48. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +86 -25
  49. package/src/ui/TableFloatingControls/index.tsx +54 -27
@@ -12,7 +12,7 @@ import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
12
12
  import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
13
13
  import { getSelectedColumnIndexes } from '../../../pm-plugins/utils/selection';
14
14
  import { TableCssClassName as ClassName } from '../../../types';
15
- import { DragHandle } from '../../DragHandle';
15
+ import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
16
16
  const getSelectedColumns = selection => {
17
17
  if (selection instanceof CellSelection && selection.isColSelection()) {
18
18
  const rect = getSelectionRect(selection);
@@ -33,7 +33,6 @@ export const ColumnControls = ({
33
33
  isInDanger,
34
34
  rowHeights,
35
35
  colWidths,
36
- hasHeaderColumn,
37
36
  isTableHovered,
38
37
  tableContainerWidth,
39
38
  isNumberColumnEnabled,
@@ -172,7 +171,23 @@ export const ColumnControls = ({
172
171
  position: 'relative'
173
172
  },
174
173
  "data-testid": `table-floating-column-${isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0]}-drag-handle`
175
- }, /*#__PURE__*/React.createElement(DragHandle, {
174
+ }, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(DragHandleWithSharedState, {
175
+ isDragMenuTarget: !isHover,
176
+ direction: "column",
177
+ tableLocalId: localId || '',
178
+ indexes: indexes,
179
+ hoveredCell: hoveredCell,
180
+ previewWidth: previewWidth,
181
+ forceDefaultHandle: !isHover,
182
+ previewHeight: previewHeight,
183
+ appearance: appearance,
184
+ onClick: handleClick,
185
+ onMouseOver: handleMouseOver,
186
+ onMouseOut: handleMouseOut,
187
+ toggleDragMenu: toggleDragMenuHandler,
188
+ editorView: editorView,
189
+ api: api
190
+ }) : /*#__PURE__*/React.createElement(DragHandle, {
176
191
  isDragMenuTarget: !isHover,
177
192
  direction: "column",
178
193
  tableLocalId: localId || '',
@@ -1,7 +1,6 @@
1
1
  import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
4
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
4
  import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
6
5
  import { containsHeaderColumn } from '../../pm-plugins/utils/nodes';
7
6
  import { getRowHeights } from '../../pm-plugins/utils/row-controls';
@@ -99,7 +98,7 @@ const TableFloatingColumnControls = ({
99
98
  isNumberColumnEnabled: isNumberColumnEnabled,
100
99
  isDragging: isDragging,
101
100
  getScrollOffset: getScrollOffset,
102
- api: editorExperiment('platform_editor_table_use_shared_state_hook', true) ? api : undefined
101
+ api: fg('platform_editor_table_use_shared_state_hook_fg') ? api : undefined
103
102
  }), isDragging && /*#__PURE__*/React.createElement(ColumnDropTargets, {
104
103
  tableRef: tableRef,
105
104
  isHeaderSticky: (stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.sticky) && hasHeaderRow,
@@ -1,9 +1,10 @@
1
1
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
2
2
 
3
3
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
4
- import { injectIntl } from 'react-intl-next';
4
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
5
  import { CellSelection } from '@atlaskit/editor-tables';
6
6
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
8
9
  import { clearHoverSelection } from '../../../pm-plugins/commands';
9
10
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
@@ -12,7 +13,7 @@ import { getRowHeights, getRowsParams } from '../../../pm-plugins/utils/row-cont
12
13
  import { getSelectedRowIndexes } from '../../../pm-plugins/utils/selection';
13
14
  import { TableCssClassName as ClassName } from '../../../types';
14
15
  import { dropTargetExtendedWidth } from '../../consts';
15
- import { DragHandle } from '../../DragHandle';
16
+ import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
16
17
  import RowDropTarget from '../RowDropTarget';
17
18
  const getSelectedRows = selection => {
18
19
  if (selection instanceof CellSelection && selection.isRowSelection()) {
@@ -24,7 +25,7 @@ const getSelectedRows = selection => {
24
25
  }
25
26
  return [];
26
27
  };
27
- const DragControlsComponent = ({
28
+ export const DragControls = ({
28
29
  tableRef,
29
30
  tableNode,
30
31
  tableWidth,
@@ -37,14 +38,16 @@ const DragControlsComponent = ({
37
38
  hoverRows,
38
39
  selectRow,
39
40
  selectRows,
40
- updateCellHoverLocation
41
+ updateCellHoverLocation,
42
+ api,
43
+ selection
41
44
  }) => {
42
45
  var _tableNode$attrs$loca, _tableNode$attrs;
43
46
  const [isDragging, setIsDragging] = useState(false);
44
47
  const rowHeights = getRowHeights(tableRef);
45
48
  const rowsParams = getRowsParams(rowHeights);
46
49
  const heights = rowHeights.map(height => `${height - 1}px`).join(' ');
47
- const selectedRowIndexes = getSelectedRows(editorView.state.selection);
50
+ const selectedRowIndexes = getSelectedRows(selection !== null && selection !== void 0 ? selection : editorView.state.selection);
48
51
  const currentNodeLocalId = (_tableNode$attrs$loca = tableNode === null || tableNode === void 0 ? void 0 : (_tableNode$attrs = tableNode.attrs) === null || _tableNode$attrs === void 0 ? void 0 : _tableNode$attrs.localId) !== null && _tableNode$attrs$loca !== void 0 ? _tableNode$attrs$loca : '';
49
52
  useEffect(() => {
50
53
  return monitorForElements({
@@ -155,7 +158,23 @@ const DragControlsComponent = ({
155
158
  pointerEvents: 'none'
156
159
  },
157
160
  "data-testid": `table-floating-row-${isHover ? rowIndex : selectedRowIndexes[0]}-drag-handle`
158
- }, /*#__PURE__*/React.createElement(DragHandle, {
161
+ }, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(DragHandleWithSharedState, {
162
+ isDragMenuTarget: !isHover,
163
+ direction: "row",
164
+ tableLocalId: currentNodeLocalId,
165
+ indexes: indexes,
166
+ forceDefaultHandle: !isHover,
167
+ previewWidth: tableWidth,
168
+ previewHeight: previewHeight,
169
+ appearance: appearance,
170
+ hoveredCell: hoveredCell,
171
+ onClick: handleClick,
172
+ onMouseOver: handleMouseOver,
173
+ onMouseOut: handleMouseOut,
174
+ toggleDragMenu: toggleDragMenuHandler,
175
+ editorView: editorView,
176
+ api: api
177
+ }) : /*#__PURE__*/React.createElement(DragHandle, {
159
178
  isDragMenuTarget: !isHover,
160
179
  direction: "row",
161
180
  tableLocalId: currentNodeLocalId,
@@ -259,4 +278,40 @@ const DragControlsComponent = ({
259
278
  }))), rowHandles())
260
279
  );
261
280
  };
262
- export const DragControls = injectIntl(DragControlsComponent);
281
+ export const DragControlsWithSelection = ({
282
+ editorView,
283
+ tableRef,
284
+ tableNode,
285
+ tableWidth,
286
+ tableActive,
287
+ hoveredCell,
288
+ isInDanger,
289
+ isTableHovered,
290
+ isResizing,
291
+ hoverRows,
292
+ selectRow,
293
+ selectRows,
294
+ updateCellHoverLocation,
295
+ api
296
+ }) => {
297
+ const {
298
+ selectionState
299
+ } = useSharedPluginState(api, ['selection']);
300
+ return /*#__PURE__*/React.createElement(DragControls, {
301
+ editorView: editorView,
302
+ tableRef: tableRef,
303
+ tableNode: tableNode,
304
+ tableWidth: tableWidth,
305
+ tableActive: tableActive,
306
+ hoveredCell: hoveredCell,
307
+ isInDanger: isInDanger,
308
+ isTableHovered: isTableHovered,
309
+ isResizing: isResizing,
310
+ hoverRows: hoverRows,
311
+ selectRow: selectRow,
312
+ selectRows: selectRows,
313
+ updateCellHoverLocation: updateCellHoverLocation,
314
+ api: api,
315
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
316
+ });
317
+ };
@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
2
2
  import { browser } from '@atlaskit/editor-common/browser';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { findTable } from '@atlaskit/editor-tables/utils';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
7
  import { hoverCell, hoverRows, selectRow, selectRows } from '../../pm-plugins/commands';
7
8
  import { isTableNested } from '../../pm-plugins/utils/nodes';
@@ -11,7 +12,8 @@ import { DragCornerControls, DragCornerControlsWithSelection } from './CornerCon
11
12
  import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
12
13
  import NumberColumn from './NumberColumn';
13
14
  import { RowControls } from './RowControls/ClassicControls';
14
- import { DragControls } from './RowControls/DragControls';
15
+ import { DragControls, DragControlsWithSelection } from './RowControls/DragControls';
16
+ // Row controls
15
17
  export const TableFloatingControls = ({
16
18
  editorView,
17
19
  tableRef,
@@ -114,18 +116,36 @@ export const TableFloatingControls = ({
114
116
  updateCellHoverLocation: updateCellHoverLocation,
115
117
  stickyTop: stickyTop,
116
118
  isDragAndDropEnabled: isDragAndDropEnabled
117
- }) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && (editorExperiment('platform_editor_table_use_shared_state_hook', true) ? /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
119
+ }) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
118
120
  editorView: editorView,
119
121
  tableRef: tableRef,
120
122
  isInDanger: isInDanger,
121
123
  isResizing: isResizing,
122
124
  api: api
123
- }) : /*#__PURE__*/React.createElement(DragCornerControls, {
125
+ }), /*#__PURE__*/React.createElement(DragControlsWithSelection, {
126
+ tableRef: tableRef,
127
+ tableNode: tableNode,
128
+ hoveredCell: hoveredCell,
129
+ isTableHovered: isTableHovered,
130
+ editorView: editorView,
131
+ tableActive: tableActive,
132
+ isInDanger: isInDanger,
133
+ isResizing: isResizing
134
+ // Ignored via go/ees005
135
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
136
+ ,
137
+ tableWidth: tableWrapperWidth,
138
+ hoverRows: _hoverRows,
139
+ selectRow: _selectRow,
140
+ selectRows: _selectRows,
141
+ updateCellHoverLocation: updateCellHoverLocation,
142
+ api: api
143
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && /*#__PURE__*/React.createElement(DragCornerControls, {
124
144
  editorView: editorView,
125
145
  tableRef: tableRef,
126
146
  isInDanger: isInDanger,
127
147
  isResizing: isResizing
128
- })), /*#__PURE__*/React.createElement(DragControls, {
148
+ }), /*#__PURE__*/React.createElement(DragControls, {
129
149
  tableRef: tableRef,
130
150
  tableNode: tableNode,
131
151
  hoveredCell: hoveredCell,
@@ -142,7 +162,7 @@ export const TableFloatingControls = ({
142
162
  selectRow: _selectRow,
143
163
  selectRows: _selectRows,
144
164
  updateCellHoverLocation: updateCellHoverLocation
145
- })) : editorExperiment('platform_editor_table_use_shared_state_hook', true) ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
165
+ }))) : fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
146
166
  editorView: editorView,
147
167
  tableRef: tableRef,
148
168
  isInDanger: isInDanger,
@@ -26,7 +26,6 @@ import { akEditorTableNumberColumnWidth, akEditorTableToolbarSize as tableToolba
26
26
  import { findTable, 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
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
30
29
  import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
31
30
  import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
32
31
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -693,7 +692,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
693
692
  getEditorFeatureFlags = _this$props11.getEditorFeatureFlags;
694
693
  var isInDanger = this.props.isInDanger;
695
694
  var table = findTable(view.state.selection);
696
- if (editorExperiment('platform_editor_table_use_shared_state_hook', false)) {
695
+ if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
697
696
  var pluginState = getPluginState(view.state);
698
697
  isInDanger = pluginState.isInDanger;
699
698
  }
@@ -829,7 +828,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
829
828
  getEditorFeatureFlags = _this$props12.getEditorFeatureFlags,
830
829
  isTableScalingEnabled = _this$props12.isTableScalingEnabled,
831
830
  allowTableResizing = _this$props12.allowTableResizing,
832
- allowTableAlignment = _this$props12.allowTableAlignment;
831
+ allowTableAlignment = _this$props12.allowTableAlignment,
832
+ selection = _this$props12.selection;
833
833
  var _this$props13 = this.props,
834
834
  isInDanger = _this$props13.isInDanger,
835
835
  hoveredRows = _this$props13.hoveredRows,
@@ -840,7 +840,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
840
840
  showBeforeShadow = _this$state3.showBeforeShadow,
841
841
  showAfterShadow = _this$state3.showAfterShadow;
842
842
  var node = getNode();
843
- if (editorExperiment('platform_editor_table_use_shared_state_hook', false)) {
843
+ if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
844
844
  var pluginState = getPluginState(view.state);
845
845
  isInDanger = pluginState.isInDanger;
846
846
  hoveredRows = pluginState.hoveredRows;
@@ -934,7 +934,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
934
934
  return /*#__PURE__*/React.createElement(TableContainer
935
935
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
936
936
  , {
937
- className: classnames(ClassName.TABLE_CONTAINER, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ClassName.WITH_CONTROLS, allowControls && tableActive), ClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), ClassName.HOVERED_DELETE_BUTTON, isInDanger), ClassName.TABLE_SELECTED, isTableSelected(view.state.selection))),
937
+ className: classnames(ClassName.TABLE_CONTAINER, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ClassName.WITH_CONTROLS, allowControls && tableActive), ClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), ClassName.HOVERED_DELETE_BUTTON, isInDanger), ClassName.TABLE_SELECTED, isTableSelected(selection !== null && selection !== void 0 ? selection : view.state.selection))),
938
938
  editorView: view,
939
939
  getPos: getPos,
940
940
  node: node
@@ -23,10 +23,11 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
23
23
  forwardRef = _ref.forwardRef,
24
24
  allowTableAlignment = _ref.allowTableAlignment,
25
25
  allowTableResizing = _ref.allowTableResizing;
26
- var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media']),
26
+ var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media', 'selection']),
27
27
  widthState = _useSharedPluginState.widthState,
28
28
  tableState = _useSharedPluginState.tableState,
29
- mediaState = _useSharedPluginState.mediaState;
29
+ mediaState = _useSharedPluginState.mediaState,
30
+ selectionState = _useSharedPluginState.selectionState;
30
31
  if (!tableState) {
31
32
  return null;
32
33
  }
@@ -63,7 +64,7 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
63
64
  getPos: getPos,
64
65
  isMediaFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
65
66
  options: options,
66
- allowControls: !!allowControls,
67
+ allowControls: allowControls,
67
68
  isHeaderRowEnabled: isHeaderRowEnabled,
68
69
  isHeaderColumnEnabled: isHeaderColumnEnabled,
69
70
  isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
@@ -86,6 +87,7 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
86
87
  hoveredRows: hoveredRows,
87
88
  hoveredCell: hoveredCell,
88
89
  isTableHovered: isTableHovered,
89
- isWholeTableInDanger: isWholeTableInDanger
90
+ isWholeTableInDanger: isWholeTableInDanger,
91
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
90
92
  });
91
93
  };
@@ -18,7 +18,6 @@ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
18
18
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
19
19
  import { TableMap } from '@atlaskit/editor-tables/table-map';
20
20
  import { fg } from '@atlaskit/platform-feature-flags';
21
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
21
  import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
23
22
  import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop/plugin-key';
24
23
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -134,7 +133,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
134
133
  key: "render",
135
134
  value: function render(props, forwardRef) {
136
135
  var _this3 = this;
137
- if (editorExperiment('platform_editor_table_use_shared_state_hook', true)) {
136
+ if (fg('platform_editor_table_use_shared_state_hook_fg')) {
138
137
  return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
139
138
  forwardRef: forwardRef,
140
139
  getNode: this.getNode,
@@ -102,6 +102,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
102
102
  isTableResizing: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.resizing,
103
103
  isInDanger: tablePluginState.isInDanger,
104
104
  hoveredRows: tablePluginState.hoveredRows,
105
+ hoveredColumns: tablePluginState.hoveredColumns,
105
106
  hoveredCell: tablePluginState.hoveredCell,
106
107
  isTableHovered: tablePluginState.isTableHovered,
107
108
  isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
@@ -1,10 +1,13 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ /* eslint-disable @atlaskit/design-system/no-html-button */
4
+
3
5
  import React, { useEffect, useMemo, useRef, useState } from 'react';
4
6
  import classnames from 'classnames';
5
7
  import ReactDOM from 'react-dom';
6
8
  import { injectIntl } from 'react-intl-next';
7
9
  import { browser } from '@atlaskit/editor-common/browser';
10
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
11
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
9
12
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
10
13
  import { findTable, TableMap } from '@atlaskit/editor-tables';
@@ -35,7 +38,9 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
35
38
  hoveredCell = _ref.hoveredCell,
36
39
  onClick = _ref.onClick,
37
40
  editorView = _ref.editorView,
38
- formatMessage = _ref.intl.formatMessage;
41
+ formatMessage = _ref.intl.formatMessage,
42
+ hoveredColumns = _ref.hoveredColumns,
43
+ hoveredRows = _ref.hoveredRows;
39
44
  var dragHandleDivRef = useRef(null);
40
45
  var _useState = useState(null),
41
46
  _useState2 = _slicedToArray(_useState, 2),
@@ -43,9 +48,13 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
43
48
  setPreviewContainer = _useState2[1];
44
49
  var state = editorView.state,
45
50
  selection = editorView.state.selection;
46
- var _getPluginState = getPluginState(state),
47
- hoveredColumns = _getPluginState.hoveredColumns,
48
- hoveredRows = _getPluginState.hoveredRows;
51
+ if (hoveredColumns === undefined || hoveredRows === undefined) {
52
+ var _getPluginState = getPluginState(state),
53
+ hoveredColumnsState = _getPluginState.hoveredColumns,
54
+ hoveredRowsState = _getPluginState.hoveredRows;
55
+ hoveredColumns = hoveredColumnsState;
56
+ hoveredRows = hoveredRowsState;
57
+ }
49
58
  var _getDnDPluginState = getDnDPluginState(state),
50
59
  _getDnDPluginState$is = _getDnDPluginState.isDragMenuOpen,
51
60
  isDragMenuOpen = _getDnDPluginState$is === void 0 ? false : _getDnDPluginState$is;
@@ -234,4 +243,44 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
234
243
  height: previewHeight
235
244
  }), previewContainer));
236
245
  };
237
- export var DragHandle = injectIntl(DragHandleComponent);
246
+ var DragHandleComponentWithSharedState = function DragHandleComponentWithSharedState(_ref5) {
247
+ var isDragMenuTarget = _ref5.isDragMenuTarget,
248
+ tableLocalId = _ref5.tableLocalId,
249
+ direction = _ref5.direction,
250
+ appearance = _ref5.appearance,
251
+ indexes = _ref5.indexes,
252
+ forceDefaultHandle = _ref5.forceDefaultHandle,
253
+ previewHeight = _ref5.previewHeight,
254
+ previewWidth = _ref5.previewWidth,
255
+ onMouseOver = _ref5.onMouseOver,
256
+ onMouseOut = _ref5.onMouseOut,
257
+ toggleDragMenu = _ref5.toggleDragMenu,
258
+ hoveredCell = _ref5.hoveredCell,
259
+ onClick = _ref5.onClick,
260
+ editorView = _ref5.editorView,
261
+ intl = _ref5.intl,
262
+ api = _ref5.api;
263
+ var _ref6 = useSharedPluginState(api, ['table']),
264
+ tableState = _ref6.tableState;
265
+ return /*#__PURE__*/React.createElement(DragHandleComponent, {
266
+ isDragMenuTarget: isDragMenuTarget,
267
+ tableLocalId: tableLocalId,
268
+ direction: direction,
269
+ appearance: appearance,
270
+ indexes: indexes,
271
+ forceDefaultHandle: forceDefaultHandle,
272
+ previewWidth: previewWidth,
273
+ previewHeight: previewHeight,
274
+ onMouseOver: onMouseOver,
275
+ onMouseOut: onMouseOut,
276
+ toggleDragMenu: toggleDragMenu,
277
+ hoveredCell: hoveredCell,
278
+ onClick: onClick,
279
+ editorView: editorView,
280
+ intl: intl,
281
+ hoveredColumns: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns,
282
+ hoveredRows: tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows
283
+ });
284
+ };
285
+ export var DragHandle = injectIntl(DragHandleComponent);
286
+ export var DragHandleWithSharedState = injectIntl(DragHandleComponentWithSharedState);
@@ -12,7 +12,7 @@ import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
12
12
  import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
13
13
  import { getSelectedColumnIndexes } from '../../../pm-plugins/utils/selection';
14
14
  import { TableCssClassName as ClassName } from '../../../types';
15
- import { DragHandle } from '../../DragHandle';
15
+ import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
16
16
  var getSelectedColumns = function getSelectedColumns(selection) {
17
17
  if (selection instanceof CellSelection && selection.isColSelection()) {
18
18
  var rect = getSelectionRect(selection);
@@ -34,7 +34,6 @@ export var ColumnControls = function ColumnControls(_ref) {
34
34
  isInDanger = _ref.isInDanger,
35
35
  rowHeights = _ref.rowHeights,
36
36
  colWidths = _ref.colWidths,
37
- hasHeaderColumn = _ref.hasHeaderColumn,
38
37
  isTableHovered = _ref.isTableHovered,
39
38
  tableContainerWidth = _ref.tableContainerWidth,
40
39
  isNumberColumnEnabled = _ref.isNumberColumnEnabled,
@@ -167,7 +166,23 @@ export var ColumnControls = function ColumnControls(_ref) {
167
166
  position: 'relative'
168
167
  },
169
168
  "data-testid": "table-floating-column-".concat(isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0], "-drag-handle")
170
- }, /*#__PURE__*/React.createElement(DragHandle, {
169
+ }, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(DragHandleWithSharedState, {
170
+ isDragMenuTarget: !isHover,
171
+ direction: "column",
172
+ tableLocalId: localId || '',
173
+ indexes: indexes,
174
+ hoveredCell: hoveredCell,
175
+ previewWidth: previewWidth,
176
+ forceDefaultHandle: !isHover,
177
+ previewHeight: previewHeight,
178
+ appearance: appearance,
179
+ onClick: handleClick,
180
+ onMouseOver: handleMouseOver,
181
+ onMouseOut: handleMouseOut,
182
+ toggleDragMenu: toggleDragMenuHandler,
183
+ editorView: editorView,
184
+ api: api
185
+ }) : /*#__PURE__*/React.createElement(DragHandle, {
171
186
  isDragMenuTarget: !isHover,
172
187
  direction: "column",
173
188
  tableLocalId: localId || '',
@@ -2,7 +2,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
5
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
5
  import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
7
6
  import { containsHeaderColumn } from '../../pm-plugins/utils/nodes';
8
7
  import { getRowHeights } from '../../pm-plugins/utils/row-controls';
@@ -99,7 +98,7 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
99
98
  isNumberColumnEnabled: isNumberColumnEnabled,
100
99
  isDragging: isDragging,
101
100
  getScrollOffset: getScrollOffset,
102
- api: editorExperiment('platform_editor_table_use_shared_state_hook', true) ? api : undefined
101
+ api: fg('platform_editor_table_use_shared_state_hook_fg') ? api : undefined
103
102
  }), isDragging && /*#__PURE__*/React.createElement(ColumnDropTargets, {
104
103
  tableRef: tableRef,
105
104
  isHeaderSticky: (stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.sticky) && hasHeaderRow,
@@ -2,9 +2,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
3
3
 
4
4
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
5
- import { injectIntl } from 'react-intl-next';
5
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
6
  import { CellSelection } from '@atlaskit/editor-tables';
7
7
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
9
10
  import { clearHoverSelection } from '../../../pm-plugins/commands';
10
11
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
@@ -13,7 +14,7 @@ import { getRowHeights, getRowsParams } from '../../../pm-plugins/utils/row-cont
13
14
  import { getSelectedRowIndexes } from '../../../pm-plugins/utils/selection';
14
15
  import { TableCssClassName as ClassName } from '../../../types';
15
16
  import { dropTargetExtendedWidth } from '../../consts';
16
- import { DragHandle } from '../../DragHandle';
17
+ import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
17
18
  import RowDropTarget from '../RowDropTarget';
18
19
  var getSelectedRows = function getSelectedRows(selection) {
19
20
  if (selection instanceof CellSelection && selection.isRowSelection()) {
@@ -25,7 +26,7 @@ var getSelectedRows = function getSelectedRows(selection) {
25
26
  }
26
27
  return [];
27
28
  };
28
- var DragControlsComponent = function DragControlsComponent(_ref) {
29
+ export var DragControls = function DragControls(_ref) {
29
30
  var _tableNode$attrs$loca, _tableNode$attrs;
30
31
  var tableRef = _ref.tableRef,
31
32
  tableNode = _ref.tableNode,
@@ -39,7 +40,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
39
40
  hoverRows = _ref.hoverRows,
40
41
  selectRow = _ref.selectRow,
41
42
  selectRows = _ref.selectRows,
42
- updateCellHoverLocation = _ref.updateCellHoverLocation;
43
+ updateCellHoverLocation = _ref.updateCellHoverLocation,
44
+ api = _ref.api,
45
+ selection = _ref.selection;
43
46
  var _useState = useState(false),
44
47
  _useState2 = _slicedToArray(_useState, 2),
45
48
  isDragging = _useState2[0],
@@ -49,7 +52,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
49
52
  var heights = rowHeights.map(function (height) {
50
53
  return "".concat(height - 1, "px");
51
54
  }).join(' ');
52
- var selectedRowIndexes = getSelectedRows(editorView.state.selection);
55
+ var selectedRowIndexes = getSelectedRows(selection !== null && selection !== void 0 ? selection : editorView.state.selection);
53
56
  var currentNodeLocalId = (_tableNode$attrs$loca = tableNode === null || tableNode === void 0 || (_tableNode$attrs = tableNode.attrs) === null || _tableNode$attrs === void 0 ? void 0 : _tableNode$attrs.localId) !== null && _tableNode$attrs$loca !== void 0 ? _tableNode$attrs$loca : '';
54
57
  useEffect(function () {
55
58
  return monitorForElements({
@@ -157,7 +160,23 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
157
160
  pointerEvents: 'none'
158
161
  },
159
162
  "data-testid": "table-floating-row-".concat(isHover ? rowIndex : selectedRowIndexes[0], "-drag-handle")
160
- }, /*#__PURE__*/React.createElement(DragHandle, {
163
+ }, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(DragHandleWithSharedState, {
164
+ isDragMenuTarget: !isHover,
165
+ direction: "row",
166
+ tableLocalId: currentNodeLocalId,
167
+ indexes: indexes,
168
+ forceDefaultHandle: !isHover,
169
+ previewWidth: tableWidth,
170
+ previewHeight: previewHeight,
171
+ appearance: appearance,
172
+ hoveredCell: hoveredCell,
173
+ onClick: handleClick,
174
+ onMouseOver: handleMouseOver,
175
+ onMouseOut: handleMouseOut,
176
+ toggleDragMenu: toggleDragMenuHandler,
177
+ editorView: editorView,
178
+ api: api
179
+ }) : /*#__PURE__*/React.createElement(DragHandle, {
161
180
  isDragMenuTarget: !isHover,
162
181
  direction: "row",
163
182
  tableLocalId: currentNodeLocalId,
@@ -261,4 +280,38 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
261
280
  }), rowHandles())
262
281
  );
263
282
  };
264
- export var DragControls = injectIntl(DragControlsComponent);
283
+ export var DragControlsWithSelection = function DragControlsWithSelection(_ref5) {
284
+ var editorView = _ref5.editorView,
285
+ tableRef = _ref5.tableRef,
286
+ tableNode = _ref5.tableNode,
287
+ tableWidth = _ref5.tableWidth,
288
+ tableActive = _ref5.tableActive,
289
+ hoveredCell = _ref5.hoveredCell,
290
+ isInDanger = _ref5.isInDanger,
291
+ isTableHovered = _ref5.isTableHovered,
292
+ isResizing = _ref5.isResizing,
293
+ hoverRows = _ref5.hoverRows,
294
+ selectRow = _ref5.selectRow,
295
+ selectRows = _ref5.selectRows,
296
+ updateCellHoverLocation = _ref5.updateCellHoverLocation,
297
+ api = _ref5.api;
298
+ var _useSharedPluginState = useSharedPluginState(api, ['selection']),
299
+ selectionState = _useSharedPluginState.selectionState;
300
+ return /*#__PURE__*/React.createElement(DragControls, {
301
+ editorView: editorView,
302
+ tableRef: tableRef,
303
+ tableNode: tableNode,
304
+ tableWidth: tableWidth,
305
+ tableActive: tableActive,
306
+ hoveredCell: hoveredCell,
307
+ isInDanger: isInDanger,
308
+ isTableHovered: isTableHovered,
309
+ isResizing: isResizing,
310
+ hoverRows: hoverRows,
311
+ selectRow: selectRow,
312
+ selectRows: selectRows,
313
+ updateCellHoverLocation: updateCellHoverLocation,
314
+ api: api,
315
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
316
+ });
317
+ };