@atlaskit/editor-plugin-table 9.1.2 → 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 (61) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/afm-post-office/tsconfig.json +99 -0
  3. package/dist/cjs/nodeviews/TableComponent.js +5 -5
  4. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +6 -4
  5. package/dist/cjs/nodeviews/table.js +1 -2
  6. package/dist/cjs/tablePlugin.js +1 -0
  7. package/dist/cjs/ui/DragHandle/index.js +55 -6
  8. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +17 -2
  9. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  10. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +60 -7
  11. package/dist/cjs/ui/TableFloatingControls/index.js +24 -4
  12. package/dist/cjs/ui/common-styles.js +1 -2
  13. package/dist/es2019/nodeviews/TableComponent.js +5 -5
  14. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +6 -4
  15. package/dist/es2019/nodeviews/table.js +1 -2
  16. package/dist/es2019/tablePlugin.js +1 -0
  17. package/dist/es2019/ui/DragHandle/index.js +57 -6
  18. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -3
  19. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  20. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +62 -7
  21. package/dist/es2019/ui/TableFloatingControls/index.js +25 -5
  22. package/dist/es2019/ui/common-styles.js +1 -2
  23. package/dist/esm/nodeviews/TableComponent.js +5 -5
  24. package/dist/esm/nodeviews/TableComponentWithSharedState.js +6 -4
  25. package/dist/esm/nodeviews/table.js +1 -2
  26. package/dist/esm/tablePlugin.js +1 -0
  27. package/dist/esm/ui/DragHandle/index.js +54 -5
  28. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -3
  29. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  30. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +60 -7
  31. package/dist/esm/ui/TableFloatingControls/index.js +25 -5
  32. package/dist/esm/ui/common-styles.js +1 -2
  33. package/dist/types/nodeviews/TableComponent.d.ts +3 -1
  34. package/dist/types/tablePluginType.d.ts +21 -18
  35. package/dist/types/types/index.d.ts +1 -1
  36. package/dist/types/ui/DragHandle/index.d.ts +21 -0
  37. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +4 -81
  38. package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -160
  39. package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  40. package/dist/types/ui/TableFloatingControls/index.d.ts +3 -80
  41. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -1
  42. package/dist/types-ts4.5/tablePluginType.d.ts +21 -18
  43. package/dist/types-ts4.5/types/index.d.ts +1 -1
  44. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +21 -0
  45. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +4 -102
  46. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -202
  47. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  48. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +3 -101
  49. package/package.json +8 -5
  50. package/src/nodeviews/TableComponent.tsx +9 -7
  51. package/src/nodeviews/TableComponentWithSharedState.tsx +4 -2
  52. package/src/nodeviews/table.tsx +1 -2
  53. package/src/tablePlugin.tsx +1 -0
  54. package/src/tablePluginType.ts +28 -22
  55. package/src/types/index.ts +1 -0
  56. package/src/ui/DragHandle/index.tsx +67 -2
  57. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +38 -19
  58. package/src/ui/TableFloatingColumnControls/index.tsx +2 -5
  59. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +86 -25
  60. package/src/ui/TableFloatingControls/index.tsx +54 -27
  61. package/src/ui/common-styles.ts +1 -2
@@ -51,10 +51,11 @@ export const TableComponentWithSharedState = ({
51
51
  allowTableAlignment,
52
52
  allowTableResizing,
53
53
  }: TableComponentWithSharedStateProps) => {
54
- const { widthState, tableState, mediaState } = useSharedPluginState(api, [
54
+ const { widthState, tableState, mediaState, selectionState } = useSharedPluginState(api, [
55
55
  'width',
56
56
  'table',
57
57
  'media',
58
+ 'selection',
58
59
  ]);
59
60
 
60
61
  if (!tableState) {
@@ -104,7 +105,7 @@ export const TableComponentWithSharedState = ({
104
105
  getPos={getPos}
105
106
  isMediaFullscreen={mediaState?.isFullscreen}
106
107
  options={options}
107
- allowControls={!!allowControls}
108
+ allowControls={allowControls}
108
109
  isHeaderRowEnabled={isHeaderRowEnabled}
109
110
  isHeaderColumnEnabled={isHeaderColumnEnabled}
110
111
  isDragAndDropEnabled={options?.isDragAndDropEnabled}
@@ -127,6 +128,7 @@ export const TableComponentWithSharedState = ({
127
128
  hoveredCell={hoveredCell}
128
129
  isTableHovered={isTableHovered}
129
130
  isWholeTableInDanger={isWholeTableInDanger}
131
+ selection={selectionState?.selection}
130
132
  />
131
133
  );
132
134
  };
@@ -20,7 +20,6 @@ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
20
20
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
21
21
  import { TableMap } from '@atlaskit/editor-tables/table-map';
22
22
  import { fg } from '@atlaskit/platform-feature-flags';
23
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
24
23
 
25
24
  import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
26
25
  import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop/plugin-key';
@@ -190,7 +189,7 @@ export default class TableView extends ReactNodeView<Props> {
190
189
  };
191
190
 
192
191
  render(props: Props, forwardRef: ForwardRef) {
193
- if (editorExperiment('platform_editor_table_use_shared_state_hook', true)) {
192
+ if (fg('platform_editor_table_use_shared_state_hook_fg')) {
194
193
  return (
195
194
  <TableComponentWithSharedState
196
195
  forwardRef={forwardRef}
@@ -133,6 +133,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
133
133
  isTableResizing: tableWidthResizingPluginState?.resizing,
134
134
  isInDanger: tablePluginState.isInDanger,
135
135
  hoveredRows: tablePluginState.hoveredRows,
136
+ hoveredColumns: tablePluginState.hoveredColumns,
136
137
  hoveredCell: tablePluginState.hoveredCell,
137
138
  isTableHovered: tablePluginState.isTableHovered,
138
139
  isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
@@ -57,32 +57,38 @@ type MediaPlugin = NextEditorPlugin<
57
57
  }
58
58
  >;
59
59
 
60
+ export type TablePluginActions = {
61
+ insertTable: InsertTableAction;
62
+ };
63
+
64
+ export type TablePluginCommands = {
65
+ insertTableWithSize: (
66
+ rowsCount: number,
67
+ colsCount: number,
68
+ inputMethod?: INPUT_METHOD.PICKER,
69
+ ) => EditorCommand;
70
+ };
71
+
72
+ export type TablePluginDependencies = [
73
+ AnalyticsPlugin,
74
+ ContentInsertionPlugin,
75
+ WidthPlugin,
76
+ SelectionPlugin,
77
+ OptionalPlugin<GuidelinePlugin>,
78
+ OptionalPlugin<BatchAttributeUpdatesPlugin>,
79
+ OptionalPlugin<AccessibilityUtilsPlugin>,
80
+ OptionalPlugin<MediaPlugin>,
81
+ OptionalPlugin<EditorViewModePlugin>,
82
+ OptionalPlugin<FeatureFlagsPlugin>,
83
+ ];
84
+
60
85
  export type TablePlugin = NextEditorPlugin<
61
86
  'table',
62
87
  {
63
88
  pluginConfiguration: TablePluginOptions | undefined;
64
- actions: {
65
- insertTable: InsertTableAction;
66
- };
89
+ actions: TablePluginActions;
67
90
  sharedState?: TableSharedState;
68
- commands: {
69
- insertTableWithSize: (
70
- rowsCount: number,
71
- colsCount: number,
72
- inputMethod?: INPUT_METHOD.PICKER,
73
- ) => EditorCommand;
74
- };
75
- dependencies: [
76
- AnalyticsPlugin,
77
- ContentInsertionPlugin,
78
- WidthPlugin,
79
- SelectionPlugin,
80
- OptionalPlugin<GuidelinePlugin>,
81
- OptionalPlugin<BatchAttributeUpdatesPlugin>,
82
- OptionalPlugin<AccessibilityUtilsPlugin>,
83
- OptionalPlugin<MediaPlugin>,
84
- OptionalPlugin<EditorViewModePlugin>,
85
- OptionalPlugin<FeatureFlagsPlugin>,
86
- ];
91
+ commands: TablePluginCommands;
92
+ dependencies: TablePluginDependencies;
87
93
  }
88
94
  >;
@@ -53,6 +53,7 @@ export type TableSharedStateInternal = Pick<
53
53
  | 'ordering'
54
54
  | 'isInDanger'
55
55
  | 'hoveredRows'
56
+ | 'hoveredColumns'
56
57
  | 'hoveredCell'
57
58
  | 'isTableHovered'
58
59
  | 'tableNode'
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @atlaskit/design-system/no-html-button */
1
2
  import type { MouseEventHandler } from 'react';
2
3
  import React, { useEffect, useMemo, useRef, useState } from 'react';
3
4
 
@@ -7,7 +8,9 @@ import type { WrappedComponentProps } from 'react-intl-next';
7
8
  import { injectIntl } from 'react-intl-next';
8
9
 
9
10
  import { browser } from '@atlaskit/editor-common/browser';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
12
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
11
14
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
12
15
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
13
16
  import { findTable, TableMap } from '@atlaskit/editor-tables';
@@ -22,8 +25,9 @@ import {
22
25
  findDuplicatePosition,
23
26
  hasMergedCellsInSelection,
24
27
  } from '../../pm-plugins/utils/merged-cells';
28
+ import type { TablePlugin } from '../../tablePluginType';
25
29
  import { TableCssClassName as ClassName } from '../../types';
26
- import type { CellHoverMeta, TableDirection } from '../../types';
30
+ import type { CellHoverMeta, TableDirection, TableSharedStateInternal } from '../../types';
27
31
  import { dragTableInsertColumnButtonSize } from '../consts';
28
32
  import { DragPreview } from '../DragPreview';
29
33
 
@@ -49,6 +53,12 @@ type DragHandleProps = {
49
53
  ) => void;
50
54
  editorView: EditorView;
51
55
  isDragMenuTarget: boolean; // this is identify which current handle component is
56
+ hoveredColumns?: number[];
57
+ hoveredRows?: number[];
58
+ };
59
+
60
+ type DragHandleWithSharedStateProps = Exclude<DragHandleProps, 'hoveredColumns' | 'hoveredRows'> & {
61
+ api?: ExtractInjectionAPI<TablePlugin>;
52
62
  };
53
63
 
54
64
  const DragHandleComponent = ({
@@ -67,6 +77,8 @@ const DragHandleComponent = ({
67
77
  onClick,
68
78
  editorView,
69
79
  intl: { formatMessage },
80
+ hoveredColumns,
81
+ hoveredRows,
70
82
  }: DragHandleProps & WrappedComponentProps) => {
71
83
  const dragHandleDivRef = useRef<HTMLButtonElement>(null);
72
84
  const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(null);
@@ -74,7 +86,13 @@ const DragHandleComponent = ({
74
86
  state,
75
87
  state: { selection },
76
88
  } = editorView;
77
- const { hoveredColumns, hoveredRows } = getPluginState(state);
89
+
90
+ if (hoveredColumns === undefined || hoveredRows === undefined) {
91
+ const { hoveredColumns: hoveredColumnsState, hoveredRows: hoveredRowsState } =
92
+ getPluginState(state);
93
+ hoveredColumns = hoveredColumnsState;
94
+ hoveredRows = hoveredRowsState;
95
+ }
78
96
  const { isDragMenuOpen = false } = getDnDPluginState(state);
79
97
 
80
98
  const isRow = direction === 'row';
@@ -291,4 +309,51 @@ const DragHandleComponent = ({
291
309
  );
292
310
  };
293
311
 
312
+ const DragHandleComponentWithSharedState = ({
313
+ isDragMenuTarget,
314
+ tableLocalId,
315
+ direction,
316
+ appearance,
317
+ indexes,
318
+ forceDefaultHandle,
319
+ previewHeight,
320
+ previewWidth,
321
+ onMouseOver,
322
+ onMouseOut,
323
+ toggleDragMenu,
324
+ hoveredCell,
325
+ onClick,
326
+ editorView,
327
+ intl,
328
+ api,
329
+ }: DragHandleWithSharedStateProps & WrappedComponentProps) => {
330
+ const { tableState } = useSharedPluginState(api, ['table']) as {
331
+ tableState?: TableSharedStateInternal;
332
+ };
333
+
334
+ return (
335
+ <DragHandleComponent
336
+ isDragMenuTarget={isDragMenuTarget}
337
+ tableLocalId={tableLocalId}
338
+ direction={direction}
339
+ appearance={appearance}
340
+ indexes={indexes}
341
+ forceDefaultHandle={forceDefaultHandle}
342
+ previewWidth={previewWidth}
343
+ previewHeight={previewHeight}
344
+ onMouseOver={onMouseOver}
345
+ onMouseOut={onMouseOut}
346
+ toggleDragMenu={toggleDragMenu}
347
+ hoveredCell={hoveredCell}
348
+ onClick={onClick}
349
+ editorView={editorView}
350
+ intl={intl}
351
+ hoveredColumns={tableState?.hoveredColumns}
352
+ hoveredRows={tableState?.hoveredRows}
353
+ />
354
+ );
355
+ };
356
+
294
357
  export const DragHandle = injectIntl(DragHandleComponent);
358
+
359
+ export const DragHandleWithSharedState = injectIntl(DragHandleComponentWithSharedState);
@@ -27,7 +27,7 @@ import type { TablePlugin } from '../../../tablePluginType';
27
27
  import type { CellHoverMeta, HandleTypes } from '../../../types';
28
28
  import { TableCssClassName as ClassName } from '../../../types';
29
29
  import type { DragHandleAppearance } from '../../DragHandle';
30
- import { DragHandle } from '../../DragHandle';
30
+ import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
31
31
 
32
32
  interface ColumnControlsProps {
33
33
  editorView: EditorView;
@@ -68,7 +68,6 @@ export const ColumnControls = ({
68
68
  isInDanger,
69
69
  rowHeights,
70
70
  colWidths,
71
- hasHeaderColumn,
72
71
  isTableHovered,
73
72
  tableContainerWidth,
74
73
  isNumberColumnEnabled,
@@ -98,7 +97,7 @@ export const ColumnControls = ({
98
97
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
99
98
 
100
99
  const rowControlStickyTop = fg('platform_editor_breakout_use_css') ? 45 : rowHeights?.[0];
101
- const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
100
+ const marginTop = hasHeaderRow && stickyTop !== undefined ? (rowControlStickyTop ?? 0) : 0;
102
101
 
103
102
  const handleClick = useCallback(
104
103
  (event: MouseEvent) => {
@@ -238,22 +237,42 @@ export const ColumnControls = ({
238
237
  isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0]
239
238
  }-drag-handle`}
240
239
  >
241
- <DragHandle
242
- isDragMenuTarget={!isHover}
243
- direction="column"
244
- tableLocalId={localId || ''}
245
- indexes={indexes}
246
- hoveredCell={hoveredCell}
247
- previewWidth={previewWidth}
248
- forceDefaultHandle={!isHover}
249
- previewHeight={previewHeight}
250
- appearance={appearance}
251
- onClick={handleClick}
252
- onMouseOver={handleMouseOver}
253
- onMouseOut={handleMouseOut}
254
- toggleDragMenu={toggleDragMenuHandler}
255
- editorView={editorView}
256
- />
240
+ {fg('platform_editor_table_use_shared_state_hook_fg') ? (
241
+ <DragHandleWithSharedState
242
+ isDragMenuTarget={!isHover}
243
+ direction="column"
244
+ tableLocalId={localId || ''}
245
+ indexes={indexes}
246
+ hoveredCell={hoveredCell}
247
+ previewWidth={previewWidth}
248
+ forceDefaultHandle={!isHover}
249
+ previewHeight={previewHeight}
250
+ appearance={appearance}
251
+ onClick={handleClick}
252
+ onMouseOver={handleMouseOver}
253
+ onMouseOut={handleMouseOut}
254
+ toggleDragMenu={toggleDragMenuHandler}
255
+ editorView={editorView}
256
+ api={api}
257
+ />
258
+ ) : (
259
+ <DragHandle
260
+ isDragMenuTarget={!isHover}
261
+ direction="column"
262
+ tableLocalId={localId || ''}
263
+ indexes={indexes}
264
+ hoveredCell={hoveredCell}
265
+ previewWidth={previewWidth}
266
+ forceDefaultHandle={!isHover}
267
+ previewHeight={previewHeight}
268
+ appearance={appearance}
269
+ onClick={handleClick}
270
+ onMouseOver={handleMouseOver}
271
+ onMouseOut={handleMouseOut}
272
+ toggleDragMenu={toggleDragMenuHandler}
273
+ editorView={editorView}
274
+ />
275
+ )}
257
276
  </div>
258
277
  );
259
278
  };
@@ -7,7 +7,6 @@ import type { Selection } from '@atlaskit/editor-prosemirror/state';
7
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
10
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
10
 
12
11
  import type { RowStickyState } from '../../pm-plugins/sticky-headers/types';
13
12
  import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
@@ -102,7 +101,7 @@ const TableFloatingColumnControls = ({
102
101
 
103
102
  if (stickyTop) {
104
103
  const columnControlTopOffsetFromParent = '-12px';
105
- const headerRowHeight = hasHeaderRow && stickyTop !== undefined ? rowHeights?.[0] ?? 0 : 0;
104
+ const headerRowHeight = hasHeaderRow && stickyTop !== undefined ? (rowHeights?.[0] ?? 0) : 0;
106
105
  containerRef?.current?.style.setProperty(
107
106
  'top',
108
107
  fg('platform_editor_breakout_use_css')
@@ -141,9 +140,7 @@ const TableFloatingColumnControls = ({
141
140
  isNumberColumnEnabled={isNumberColumnEnabled}
142
141
  isDragging={isDragging}
143
142
  getScrollOffset={getScrollOffset}
144
- api={
145
- editorExperiment('platform_editor_table_use_shared_state_hook', true) ? api : undefined
146
- }
143
+ api={fg('platform_editor_table_use_shared_state_hook_fg') ? api : undefined}
147
144
  />
148
145
  {isDragging && (
149
146
  <ColumnDropTargets
@@ -2,14 +2,14 @@
2
2
  import type { MouseEvent } from 'react';
3
3
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
4
4
 
5
- import { injectIntl } from 'react-intl-next';
6
- import type { WrappedComponentProps } from 'react-intl-next';
7
-
5
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
7
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
9
8
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
10
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
11
10
  import { CellSelection } from '@atlaskit/editor-tables';
12
11
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
14
14
  import { token } from '@atlaskit/tokens';
15
15
 
@@ -19,11 +19,12 @@ import type { TriggerType } from '../../../pm-plugins/drag-and-drop/types';
19
19
  import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
20
20
  import { getRowHeights, getRowsParams } from '../../../pm-plugins/utils/row-controls';
21
21
  import { getSelectedRowIndexes } from '../../../pm-plugins/utils/selection';
22
+ import type { TablePlugin } from '../../../tablePluginType';
22
23
  import { TableCssClassName as ClassName } from '../../../types';
23
24
  import type { CellHoverMeta, DraggableSourceData, HandleTypes } from '../../../types';
24
25
  import { dropTargetExtendedWidth } from '../../consts';
25
26
  import type { DragHandleAppearance } from '../../DragHandle';
26
- import { DragHandle } from '../../DragHandle';
27
+ import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
27
28
  import RowDropTarget from '../RowDropTarget';
28
29
 
29
30
  type DragControlsProps = {
@@ -40,6 +41,8 @@ type DragControlsProps = {
40
41
  selectRow: (row: number, expand: boolean) => void;
41
42
  selectRows: (rowIndexes: number[]) => void;
42
43
  updateCellHoverLocation: (rowIndex: number) => void;
44
+ api?: ExtractInjectionAPI<TablePlugin>;
45
+ selection?: Selection;
43
46
  };
44
47
 
45
48
  const getSelectedRows = (selection: Selection) => {
@@ -53,7 +56,7 @@ const getSelectedRows = (selection: Selection) => {
53
56
  return [];
54
57
  };
55
58
 
56
- const DragControlsComponent = ({
59
+ export const DragControls = ({
57
60
  tableRef,
58
61
  tableNode,
59
62
  tableWidth,
@@ -67,13 +70,14 @@ const DragControlsComponent = ({
67
70
  selectRow,
68
71
  selectRows,
69
72
  updateCellHoverLocation,
70
- }: DragControlsProps & WrappedComponentProps) => {
73
+ api,
74
+ selection,
75
+ }: DragControlsProps) => {
71
76
  const [isDragging, setIsDragging] = useState(false);
72
-
73
77
  const rowHeights = getRowHeights(tableRef);
74
78
  const rowsParams = getRowsParams(rowHeights);
75
79
  const heights = rowHeights.map((height) => `${height - 1}px`).join(' ');
76
- const selectedRowIndexes = getSelectedRows(editorView.state.selection);
80
+ const selectedRowIndexes = getSelectedRows(selection ?? editorView.state.selection);
77
81
  const currentNodeLocalId = tableNode?.attrs?.localId ?? '';
78
82
 
79
83
  useEffect(() => {
@@ -213,22 +217,42 @@ const DragControlsComponent = ({
213
217
  }}
214
218
  data-testid={`table-floating-row-${isHover ? rowIndex : selectedRowIndexes[0]}-drag-handle`}
215
219
  >
216
- <DragHandle
217
- isDragMenuTarget={!isHover}
218
- direction="row"
219
- tableLocalId={currentNodeLocalId}
220
- indexes={indexes}
221
- forceDefaultHandle={!isHover}
222
- previewWidth={tableWidth}
223
- previewHeight={previewHeight}
224
- appearance={appearance}
225
- hoveredCell={hoveredCell}
226
- onClick={handleClick}
227
- onMouseOver={handleMouseOver}
228
- onMouseOut={handleMouseOut}
229
- toggleDragMenu={toggleDragMenuHandler}
230
- editorView={editorView}
231
- />
220
+ {fg('platform_editor_table_use_shared_state_hook_fg') ? (
221
+ <DragHandleWithSharedState
222
+ isDragMenuTarget={!isHover}
223
+ direction="row"
224
+ tableLocalId={currentNodeLocalId}
225
+ indexes={indexes}
226
+ forceDefaultHandle={!isHover}
227
+ previewWidth={tableWidth}
228
+ previewHeight={previewHeight}
229
+ appearance={appearance}
230
+ hoveredCell={hoveredCell}
231
+ onClick={handleClick}
232
+ onMouseOver={handleMouseOver}
233
+ onMouseOut={handleMouseOut}
234
+ toggleDragMenu={toggleDragMenuHandler}
235
+ editorView={editorView}
236
+ api={api}
237
+ />
238
+ ) : (
239
+ <DragHandle
240
+ isDragMenuTarget={!isHover}
241
+ direction="row"
242
+ tableLocalId={currentNodeLocalId}
243
+ indexes={indexes}
244
+ forceDefaultHandle={!isHover}
245
+ previewWidth={tableWidth}
246
+ previewHeight={previewHeight}
247
+ appearance={appearance}
248
+ hoveredCell={hoveredCell}
249
+ onClick={handleClick}
250
+ onMouseOver={handleMouseOver}
251
+ onMouseOut={handleMouseOut}
252
+ toggleDragMenu={toggleDragMenuHandler}
253
+ editorView={editorView}
254
+ />
255
+ )}
232
256
  </div>
233
257
  );
234
258
  };
@@ -347,4 +371,41 @@ const DragControlsComponent = ({
347
371
  );
348
372
  };
349
373
 
350
- export const DragControls = injectIntl(DragControlsComponent);
374
+ export const DragControlsWithSelection = ({
375
+ editorView,
376
+ tableRef,
377
+ tableNode,
378
+ tableWidth,
379
+ tableActive,
380
+ hoveredCell,
381
+ isInDanger,
382
+ isTableHovered,
383
+ isResizing,
384
+ hoverRows,
385
+ selectRow,
386
+ selectRows,
387
+ updateCellHoverLocation,
388
+ api,
389
+ }: Exclude<DragControlsProps, 'selection'>) => {
390
+ const { selectionState } = useSharedPluginState(api, ['selection']);
391
+
392
+ return (
393
+ <DragControls
394
+ editorView={editorView}
395
+ tableRef={tableRef}
396
+ tableNode={tableNode}
397
+ tableWidth={tableWidth}
398
+ tableActive={tableActive}
399
+ hoveredCell={hoveredCell}
400
+ isInDanger={isInDanger}
401
+ isTableHovered={isTableHovered}
402
+ isResizing={isResizing}
403
+ hoverRows={hoverRows}
404
+ selectRow={selectRow}
405
+ selectRows={selectRows}
406
+ updateCellHoverLocation={updateCellHoverLocation}
407
+ api={api}
408
+ selection={selectionState?.selection}
409
+ />
410
+ );
411
+ };
@@ -8,6 +8,7 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
9
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { findTable } from '@atlaskit/editor-tables/utils';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
13
 
13
14
  import { hoverCell, hoverRows, selectRow, selectRows } from '../../pm-plugins/commands';
@@ -25,7 +26,7 @@ import {
25
26
  import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
26
27
  import NumberColumn from './NumberColumn';
27
28
  import { RowControls } from './RowControls/ClassicControls';
28
- import { DragControls } from './RowControls/DragControls';
29
+ import { DragControls, DragControlsWithSelection } from './RowControls/DragControls';
29
30
 
30
31
  interface TableFloatingControlsProps {
31
32
  editorView: EditorView;
@@ -51,6 +52,7 @@ interface TableFloatingControlsProps {
51
52
  isChromelessEditor?: boolean;
52
53
  }
53
54
 
55
+ // Row controls
54
56
  export const TableFloatingControls = ({
55
57
  editorView,
56
58
  tableRef,
@@ -171,42 +173,67 @@ export const TableFloatingControls = ({
171
173
  <>
172
174
  {isDragAndDropEnabled ? (
173
175
  <>
174
- {shouldShowCornerControls &&
175
- (editorExperiment('platform_editor_table_use_shared_state_hook', true) ? (
176
- <DragCornerControlsWithSelection
177
- editorView={editorView}
176
+ {fg('platform_editor_table_use_shared_state_hook_fg') ? (
177
+ <>
178
+ {shouldShowCornerControls && (
179
+ <DragCornerControlsWithSelection
180
+ editorView={editorView}
181
+ tableRef={tableRef}
182
+ isInDanger={isInDanger}
183
+ isResizing={isResizing}
184
+ api={api}
185
+ />
186
+ )}
187
+ <DragControlsWithSelection
178
188
  tableRef={tableRef}
189
+ tableNode={tableNode}
190
+ hoveredCell={hoveredCell}
191
+ isTableHovered={isTableHovered}
192
+ editorView={editorView}
193
+ tableActive={tableActive}
179
194
  isInDanger={isInDanger}
180
195
  isResizing={isResizing}
196
+ // Ignored via go/ees005
197
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
198
+ tableWidth={tableWrapperWidth!}
199
+ hoverRows={_hoverRows}
200
+ selectRow={_selectRow}
201
+ selectRows={_selectRows}
202
+ updateCellHoverLocation={updateCellHoverLocation}
181
203
  api={api}
182
204
  />
183
- ) : (
184
- <DragCornerControls
185
- editorView={editorView}
205
+ </>
206
+ ) : (
207
+ <>
208
+ {shouldShowCornerControls && (
209
+ <DragCornerControls
210
+ editorView={editorView}
211
+ tableRef={tableRef}
212
+ isInDanger={isInDanger}
213
+ isResizing={isResizing}
214
+ />
215
+ )}
216
+ <DragControls
186
217
  tableRef={tableRef}
218
+ tableNode={tableNode}
219
+ hoveredCell={hoveredCell}
220
+ isTableHovered={isTableHovered}
221
+ editorView={editorView}
222
+ tableActive={tableActive}
187
223
  isInDanger={isInDanger}
188
224
  isResizing={isResizing}
225
+ // Ignored via go/ees005
226
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
227
+ tableWidth={tableWrapperWidth!}
228
+ hoverRows={_hoverRows}
229
+ selectRow={_selectRow}
230
+ selectRows={_selectRows}
231
+ updateCellHoverLocation={updateCellHoverLocation}
189
232
  />
190
- ))}
191
- <DragControls
192
- tableRef={tableRef}
193
- tableNode={tableNode}
194
- hoveredCell={hoveredCell}
195
- isTableHovered={isTableHovered}
196
- editorView={editorView}
197
- tableActive={tableActive}
198
- isInDanger={isInDanger}
199
- isResizing={isResizing}
200
- // Ignored via go/ees005
201
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
202
- tableWidth={tableWrapperWidth!}
203
- hoverRows={_hoverRows}
204
- selectRow={_selectRow}
205
- selectRows={_selectRows}
206
- updateCellHoverLocation={updateCellHoverLocation}
207
- />
233
+ </>
234
+ )}
208
235
  </>
209
- ) : editorExperiment('platform_editor_table_use_shared_state_hook', true) ? (
236
+ ) : fg('platform_editor_table_use_shared_state_hook_fg') ? (
210
237
  <FloatingControlsWithSelection
211
238
  editorView={editorView}
212
239
  tableRef={tableRef}
@@ -25,7 +25,6 @@ import {
25
25
  } from '@atlaskit/editor-shared-styles';
26
26
  import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
27
27
  import { N0, N40A, R500 } from '@atlaskit/theme/colors';
28
- import { fontSize } from '@atlaskit/theme/constants';
29
28
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
30
29
  import { token } from '@atlaskit/tokens';
31
30
 
@@ -850,7 +849,7 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
850
849
  padding-bottom: 2px;
851
850
  padding: 10px 2px;
852
851
  text-align: center;
853
- font-size: ${relativeFontSizeToBase16(fontSize())};
852
+ font-size: ${relativeFontSizeToBase16(14)};
854
853
  background-color: ${tableHeaderCellBackgroundColor};
855
854
  color: ${tableTextColor};
856
855
  border-color: ${tableBorderColor};