@atlaskit/editor-plugin-table 9.1.3 → 9.2.1

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 (211) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/nodeviews/TableCell.js +0 -2
  3. package/dist/cjs/nodeviews/TableComponent.js +5 -5
  4. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +6 -4
  5. package/dist/cjs/nodeviews/TableContainer.js +13 -2
  6. package/dist/cjs/nodeviews/TableNodeViewBase.js +0 -2
  7. package/dist/cjs/nodeviews/TableResizer.js +5 -10
  8. package/dist/cjs/nodeviews/TableRow.js +0 -2
  9. package/dist/cjs/nodeviews/lazy-node-views.js +4 -16
  10. package/dist/cjs/nodeviews/table.js +3 -10
  11. package/dist/cjs/pm-plugins/commands/column-resize.js +1 -4
  12. package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +4 -16
  13. package/dist/cjs/pm-plugins/commands/insert.js +4 -19
  14. package/dist/cjs/pm-plugins/commands/misc.js +3 -12
  15. package/dist/cjs/pm-plugins/decorations/plugin.js +1 -6
  16. package/dist/cjs/pm-plugins/decorations/utils/column-resizing.js +1 -4
  17. package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
  18. package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -12
  19. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -4
  20. package/dist/cjs/pm-plugins/keymap.js +0 -2
  21. package/dist/cjs/pm-plugins/main.js +1 -6
  22. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +1 -4
  23. package/dist/cjs/pm-plugins/table-resizing/plugin.js +0 -2
  24. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +1 -7
  25. package/dist/cjs/pm-plugins/table-resizing/utils/column-state.js +1 -4
  26. package/dist/cjs/pm-plugins/table-resizing/utils/content-width.js +0 -8
  27. package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
  28. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +1 -4
  29. package/dist/cjs/pm-plugins/table-width.js +1 -6
  30. package/dist/cjs/pm-plugins/transforms/column-width.js +1 -4
  31. package/dist/cjs/pm-plugins/transforms/fix-tables.js +3 -15
  32. package/dist/cjs/pm-plugins/transforms/replace-table.js +1 -4
  33. package/dist/cjs/pm-plugins/transforms/split.js +0 -2
  34. package/dist/cjs/pm-plugins/utils/alignment.js +1 -4
  35. package/dist/cjs/pm-plugins/utils/decoration.js +4 -16
  36. package/dist/cjs/pm-plugins/utils/drag-menu.js +1 -4
  37. package/dist/cjs/pm-plugins/utils/nodes.js +0 -3
  38. package/dist/cjs/pm-plugins/utils/paste.js +4 -0
  39. package/dist/cjs/pm-plugins/utils/row-controls.js +1 -4
  40. package/dist/cjs/tablePlugin.js +1 -0
  41. package/dist/cjs/ui/DragHandle/index.js +55 -6
  42. package/dist/cjs/ui/FloatingInsertButton/getPopupOptions.js +0 -6
  43. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -6
  44. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  45. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +61 -11
  46. package/dist/cjs/ui/TableFloatingControls/index.js +25 -8
  47. package/dist/cjs/ui/toolbar.js +3 -12
  48. package/dist/es2019/nodeviews/TableCell.js +0 -2
  49. package/dist/es2019/nodeviews/TableComponent.js +5 -5
  50. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +6 -4
  51. package/dist/es2019/nodeviews/TableContainer.js +13 -2
  52. package/dist/es2019/nodeviews/TableNodeViewBase.js +0 -2
  53. package/dist/es2019/nodeviews/TableResizer.js +5 -10
  54. package/dist/es2019/nodeviews/TableRow.js +0 -2
  55. package/dist/es2019/nodeviews/lazy-node-views.js +4 -16
  56. package/dist/es2019/nodeviews/table.js +3 -10
  57. package/dist/es2019/pm-plugins/commands/column-resize.js +1 -4
  58. package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +6 -24
  59. package/dist/es2019/pm-plugins/commands/delete.js +1 -4
  60. package/dist/es2019/pm-plugins/commands/insert.js +5 -23
  61. package/dist/es2019/pm-plugins/commands/misc.js +3 -12
  62. package/dist/es2019/pm-plugins/decorations/plugin.js +1 -6
  63. package/dist/es2019/pm-plugins/decorations/utils/column-resizing.js +1 -4
  64. package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
  65. package/dist/es2019/pm-plugins/drag-and-drop/commands.js +4 -16
  66. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +2 -8
  67. package/dist/es2019/pm-plugins/keymap.js +0 -3
  68. package/dist/es2019/pm-plugins/main.js +1 -6
  69. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -4
  70. package/dist/es2019/pm-plugins/table-resizing/plugin.js +0 -3
  71. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -11
  72. package/dist/es2019/pm-plugins/table-resizing/utils/column-state.js +1 -4
  73. package/dist/es2019/pm-plugins/table-resizing/utils/content-width.js +0 -8
  74. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +1 -4
  75. package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
  76. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +2 -8
  77. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -16
  78. package/dist/es2019/pm-plugins/table-width.js +1 -6
  79. package/dist/es2019/pm-plugins/transforms/column-width.js +2 -8
  80. package/dist/es2019/pm-plugins/transforms/delete-columns.js +1 -4
  81. package/dist/es2019/pm-plugins/transforms/fix-tables.js +3 -15
  82. package/dist/es2019/pm-plugins/transforms/replace-table.js +1 -4
  83. package/dist/es2019/pm-plugins/transforms/split.js +0 -2
  84. package/dist/es2019/pm-plugins/utils/alignment.js +1 -4
  85. package/dist/es2019/pm-plugins/utils/decoration.js +4 -16
  86. package/dist/es2019/pm-plugins/utils/drag-menu.js +2 -8
  87. package/dist/es2019/pm-plugins/utils/nodes.js +0 -3
  88. package/dist/es2019/pm-plugins/utils/paste.js +5 -4
  89. package/dist/es2019/pm-plugins/utils/row-controls.js +1 -4
  90. package/dist/es2019/pm-plugins/utils/snapping.js +1 -4
  91. package/dist/es2019/tablePlugin.js +1 -0
  92. package/dist/es2019/ui/DragHandle/index.js +57 -6
  93. package/dist/es2019/ui/FloatingInsertButton/getPopupOptions.js +0 -6
  94. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +19 -7
  95. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  96. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +63 -11
  97. package/dist/es2019/ui/TableFloatingControls/index.js +26 -10
  98. package/dist/es2019/ui/event-handlers.js +1 -4
  99. package/dist/es2019/ui/toolbar.js +9 -36
  100. package/dist/esm/nodeviews/TableCell.js +0 -2
  101. package/dist/esm/nodeviews/TableComponent.js +5 -5
  102. package/dist/esm/nodeviews/TableComponentWithSharedState.js +6 -4
  103. package/dist/esm/nodeviews/TableContainer.js +13 -2
  104. package/dist/esm/nodeviews/TableNodeViewBase.js +0 -2
  105. package/dist/esm/nodeviews/TableResizer.js +5 -10
  106. package/dist/esm/nodeviews/TableRow.js +0 -2
  107. package/dist/esm/nodeviews/lazy-node-views.js +4 -16
  108. package/dist/esm/nodeviews/table.js +3 -10
  109. package/dist/esm/pm-plugins/commands/column-resize.js +1 -4
  110. package/dist/esm/pm-plugins/commands/commands-with-analytics.js +4 -16
  111. package/dist/esm/pm-plugins/commands/insert.js +4 -19
  112. package/dist/esm/pm-plugins/commands/misc.js +3 -12
  113. package/dist/esm/pm-plugins/decorations/plugin.js +1 -6
  114. package/dist/esm/pm-plugins/decorations/utils/column-resizing.js +1 -4
  115. package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
  116. package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -12
  117. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -4
  118. package/dist/esm/pm-plugins/keymap.js +0 -3
  119. package/dist/esm/pm-plugins/main.js +1 -6
  120. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -4
  121. package/dist/esm/pm-plugins/table-resizing/plugin.js +0 -3
  122. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +1 -7
  123. package/dist/esm/pm-plugins/table-resizing/utils/column-state.js +1 -4
  124. package/dist/esm/pm-plugins/table-resizing/utils/content-width.js +0 -8
  125. package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
  126. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +1 -4
  127. package/dist/esm/pm-plugins/table-width.js +1 -6
  128. package/dist/esm/pm-plugins/transforms/column-width.js +1 -4
  129. package/dist/esm/pm-plugins/transforms/fix-tables.js +3 -15
  130. package/dist/esm/pm-plugins/transforms/replace-table.js +1 -4
  131. package/dist/esm/pm-plugins/transforms/split.js +0 -2
  132. package/dist/esm/pm-plugins/utils/alignment.js +1 -4
  133. package/dist/esm/pm-plugins/utils/decoration.js +4 -16
  134. package/dist/esm/pm-plugins/utils/drag-menu.js +1 -4
  135. package/dist/esm/pm-plugins/utils/nodes.js +0 -3
  136. package/dist/esm/pm-plugins/utils/paste.js +4 -0
  137. package/dist/esm/pm-plugins/utils/row-controls.js +1 -4
  138. package/dist/esm/tablePlugin.js +1 -0
  139. package/dist/esm/ui/DragHandle/index.js +54 -5
  140. package/dist/esm/ui/FloatingInsertButton/getPopupOptions.js +0 -6
  141. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +19 -7
  142. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  143. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +61 -11
  144. package/dist/esm/ui/TableFloatingControls/index.js +26 -9
  145. package/dist/esm/ui/toolbar.js +3 -12
  146. package/dist/types/nodeviews/TableComponent.d.ts +3 -1
  147. package/dist/types/nodeviews/TableResizer.d.ts +2 -1
  148. package/dist/types/types/index.d.ts +1 -1
  149. package/dist/types/ui/DragHandle/index.d.ts +21 -0
  150. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  151. package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  152. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -1
  153. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
  154. package/dist/types-ts4.5/types/index.d.ts +1 -1
  155. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +21 -0
  156. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  157. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  158. package/package.json +15 -6
  159. package/src/nodeviews/TableCell.ts +0 -2
  160. package/src/nodeviews/TableComponent.tsx +8 -6
  161. package/src/nodeviews/TableComponentWithSharedState.tsx +4 -2
  162. package/src/nodeviews/TableContainer.tsx +12 -1
  163. package/src/nodeviews/TableNodeViewBase.ts +0 -2
  164. package/src/nodeviews/TableResizer.tsx +9 -5
  165. package/src/nodeviews/TableRow.ts +0 -2
  166. package/src/nodeviews/lazy-node-views.ts +0 -8
  167. package/src/nodeviews/table.tsx +1 -6
  168. package/src/pm-plugins/commands/column-resize.ts +0 -2
  169. package/src/pm-plugins/commands/commands-with-analytics.ts +0 -12
  170. package/src/pm-plugins/commands/delete.ts +0 -2
  171. package/src/pm-plugins/commands/insert.ts +0 -12
  172. package/src/pm-plugins/commands/misc.ts +0 -6
  173. package/src/pm-plugins/decorations/plugin.ts +0 -4
  174. package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -2
  175. package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -6
  176. package/src/pm-plugins/drag-and-drop/commands.ts +0 -8
  177. package/src/pm-plugins/drag-and-drop/plugin.ts +0 -4
  178. package/src/pm-plugins/keymap.ts +0 -2
  179. package/src/pm-plugins/main.ts +0 -4
  180. package/src/pm-plugins/table-resizing/event-handlers.ts +0 -2
  181. package/src/pm-plugins/table-resizing/plugin.ts +0 -2
  182. package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -6
  183. package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -2
  184. package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -6
  185. package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -2
  186. package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -6
  187. package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -4
  188. package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -8
  189. package/src/pm-plugins/table-width.ts +0 -4
  190. package/src/pm-plugins/transforms/column-width.ts +0 -4
  191. package/src/pm-plugins/transforms/delete-columns.ts +0 -2
  192. package/src/pm-plugins/transforms/fix-tables.ts +0 -8
  193. package/src/pm-plugins/transforms/replace-table.ts +0 -2
  194. package/src/pm-plugins/transforms/split.ts +0 -2
  195. package/src/pm-plugins/utils/alignment.ts +0 -2
  196. package/src/pm-plugins/utils/decoration.ts +0 -8
  197. package/src/pm-plugins/utils/drag-menu.ts +0 -4
  198. package/src/pm-plugins/utils/nodes.ts +0 -2
  199. package/src/pm-plugins/utils/paste.ts +4 -2
  200. package/src/pm-plugins/utils/row-controls.ts +0 -2
  201. package/src/pm-plugins/utils/snapping.ts +0 -2
  202. package/src/tablePlugin.tsx +1 -0
  203. package/src/types/index.ts +1 -0
  204. package/src/ui/DragHandle/index.tsx +67 -2
  205. package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -4
  206. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +37 -20
  207. package/src/ui/TableFloatingColumnControls/index.tsx +1 -4
  208. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +86 -27
  209. package/src/ui/TableFloatingControls/index.tsx +55 -32
  210. package/src/ui/event-handlers.ts +0 -2
  211. package/src/ui/toolbar.tsx +0 -18
@@ -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(() => {
@@ -180,8 +184,6 @@ const DragControlsComponent = ({
180
184
  appearance: DragHandleAppearance,
181
185
  gridRow: string,
182
186
  indexes: number[],
183
- // Ignored via go/ees005
184
- // eslint-disable-next-line @typescript-eslint/max-params
185
187
  ) => {
186
188
  const isHover = type === 'hover';
187
189
 
@@ -213,22 +215,42 @@ const DragControlsComponent = ({
213
215
  }}
214
216
  data-testid={`table-floating-row-${isHover ? rowIndex : selectedRowIndexes[0]}-drag-handle`}
215
217
  >
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
- />
218
+ {fg('platform_editor_table_use_shared_state_hook_fg') ? (
219
+ <DragHandleWithSharedState
220
+ isDragMenuTarget={!isHover}
221
+ direction="row"
222
+ tableLocalId={currentNodeLocalId}
223
+ indexes={indexes}
224
+ forceDefaultHandle={!isHover}
225
+ previewWidth={tableWidth}
226
+ previewHeight={previewHeight}
227
+ appearance={appearance}
228
+ hoveredCell={hoveredCell}
229
+ onClick={handleClick}
230
+ onMouseOver={handleMouseOver}
231
+ onMouseOut={handleMouseOut}
232
+ toggleDragMenu={toggleDragMenuHandler}
233
+ editorView={editorView}
234
+ api={api}
235
+ />
236
+ ) : (
237
+ <DragHandle
238
+ isDragMenuTarget={!isHover}
239
+ direction="row"
240
+ tableLocalId={currentNodeLocalId}
241
+ indexes={indexes}
242
+ forceDefaultHandle={!isHover}
243
+ previewWidth={tableWidth}
244
+ previewHeight={previewHeight}
245
+ appearance={appearance}
246
+ hoveredCell={hoveredCell}
247
+ onClick={handleClick}
248
+ onMouseOver={handleMouseOver}
249
+ onMouseOut={handleMouseOut}
250
+ toggleDragMenu={toggleDragMenuHandler}
251
+ editorView={editorView}
252
+ />
253
+ )}
232
254
  </div>
233
255
  );
234
256
  };
@@ -347,4 +369,41 @@ const DragControlsComponent = ({
347
369
  );
348
370
  };
349
371
 
350
- export const DragControls = injectIntl(DragControlsComponent);
372
+ export const DragControlsWithSelection = ({
373
+ editorView,
374
+ tableRef,
375
+ tableNode,
376
+ tableWidth,
377
+ tableActive,
378
+ hoveredCell,
379
+ isInDanger,
380
+ isTableHovered,
381
+ isResizing,
382
+ hoverRows,
383
+ selectRow,
384
+ selectRows,
385
+ updateCellHoverLocation,
386
+ api,
387
+ }: Exclude<DragControlsProps, 'selection'>) => {
388
+ const { selectionState } = useSharedPluginState(api, ['selection']);
389
+
390
+ return (
391
+ <DragControls
392
+ editorView={editorView}
393
+ tableRef={tableRef}
394
+ tableNode={tableNode}
395
+ tableWidth={tableWidth}
396
+ tableActive={tableActive}
397
+ hoveredCell={hoveredCell}
398
+ isInDanger={isInDanger}
399
+ isTableHovered={isTableHovered}
400
+ isResizing={isResizing}
401
+ hoverRows={hoverRows}
402
+ selectRow={selectRow}
403
+ selectRows={selectRows}
404
+ updateCellHoverLocation={updateCellHoverLocation}
405
+ api={api}
406
+ selection={selectionState?.selection}
407
+ />
408
+ );
409
+ };
@@ -2,12 +2,12 @@ import React, { useCallback } from 'react';
2
2
 
3
3
  import type { TableColumnOrdering } from '@atlaskit/custom-steps';
4
4
  import { browser } from '@atlaskit/editor-common/browser';
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
5
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
6
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
7
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
9
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
9
  import { findTable } from '@atlaskit/editor-tables/utils';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
12
 
13
13
  import { hoverCell, hoverRows, selectRow, selectRows } from '../../pm-plugins/commands';
@@ -25,7 +25,7 @@ import {
25
25
  import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
26
26
  import NumberColumn from './NumberColumn';
27
27
  import { RowControls } from './RowControls/ClassicControls';
28
- import { DragControls } from './RowControls/DragControls';
28
+ import { DragControls, DragControlsWithSelection } from './RowControls/DragControls';
29
29
 
30
30
  interface TableFloatingControlsProps {
31
31
  editorView: EditorView;
@@ -51,6 +51,7 @@ interface TableFloatingControlsProps {
51
51
  isChromelessEditor?: boolean;
52
52
  }
53
53
 
54
+ // Row controls
54
55
  export const TableFloatingControls = ({
55
56
  editorView,
56
57
  tableRef,
@@ -123,8 +124,6 @@ export const TableFloatingControls = ({
123
124
  [editorView, tableActive],
124
125
  );
125
126
 
126
- const { featureFlagsState } = useSharedPluginState(api, ['featureFlags']);
127
-
128
127
  if (!tableRef) {
129
128
  return null;
130
129
  }
@@ -142,8 +141,7 @@ export const TableFloatingControls = ({
142
141
  // Ignored via go/ees005
143
142
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
144
143
  const isNested = tablePos !== undefined && isTableNested(editorView.state, tablePos!);
145
- const shouldShowCornerControls =
146
- !featureFlagsState?.elementDragAndDrop || (isNested && !editorExperiment('nested-dnd', true));
144
+ const shouldShowCornerControls = isNested && !editorExperiment('nested-dnd', true);
147
145
 
148
146
  return (
149
147
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -171,42 +169,67 @@ export const TableFloatingControls = ({
171
169
  <>
172
170
  {isDragAndDropEnabled ? (
173
171
  <>
174
- {shouldShowCornerControls &&
175
- (editorExperiment('platform_editor_table_use_shared_state_hook', true) ? (
176
- <DragCornerControlsWithSelection
177
- editorView={editorView}
172
+ {fg('platform_editor_table_use_shared_state_hook_fg') ? (
173
+ <>
174
+ {shouldShowCornerControls && (
175
+ <DragCornerControlsWithSelection
176
+ editorView={editorView}
177
+ tableRef={tableRef}
178
+ isInDanger={isInDanger}
179
+ isResizing={isResizing}
180
+ api={api}
181
+ />
182
+ )}
183
+ <DragControlsWithSelection
178
184
  tableRef={tableRef}
185
+ tableNode={tableNode}
186
+ hoveredCell={hoveredCell}
187
+ isTableHovered={isTableHovered}
188
+ editorView={editorView}
189
+ tableActive={tableActive}
179
190
  isInDanger={isInDanger}
180
191
  isResizing={isResizing}
192
+ // Ignored via go/ees005
193
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
194
+ tableWidth={tableWrapperWidth!}
195
+ hoverRows={_hoverRows}
196
+ selectRow={_selectRow}
197
+ selectRows={_selectRows}
198
+ updateCellHoverLocation={updateCellHoverLocation}
181
199
  api={api}
182
200
  />
183
- ) : (
184
- <DragCornerControls
185
- editorView={editorView}
201
+ </>
202
+ ) : (
203
+ <>
204
+ {shouldShowCornerControls && (
205
+ <DragCornerControls
206
+ editorView={editorView}
207
+ tableRef={tableRef}
208
+ isInDanger={isInDanger}
209
+ isResizing={isResizing}
210
+ />
211
+ )}
212
+ <DragControls
186
213
  tableRef={tableRef}
214
+ tableNode={tableNode}
215
+ hoveredCell={hoveredCell}
216
+ isTableHovered={isTableHovered}
217
+ editorView={editorView}
218
+ tableActive={tableActive}
187
219
  isInDanger={isInDanger}
188
220
  isResizing={isResizing}
221
+ // Ignored via go/ees005
222
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
223
+ tableWidth={tableWrapperWidth!}
224
+ hoverRows={_hoverRows}
225
+ selectRow={_selectRow}
226
+ selectRows={_selectRows}
227
+ updateCellHoverLocation={updateCellHoverLocation}
189
228
  />
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
- />
229
+ </>
230
+ )}
208
231
  </>
209
- ) : editorExperiment('platform_editor_table_use_shared_state_hook', true) ? (
232
+ ) : fg('platform_editor_table_use_shared_state_hook_fg') ? (
210
233
  <FloatingControlsWithSelection
211
234
  editorView={editorView}
212
235
  tableRef={tableRef}
@@ -507,8 +507,6 @@ export const handleCut = (
507
507
  isTableScalingEnabled = false,
508
508
  isTableFixedColumnWidthsOptionEnabled = false,
509
509
  shouldUseIncreasedScalingPercent = false,
510
- // Ignored via go/ees005
511
- // eslint-disable-next-line @typescript-eslint/max-params
512
510
  ): Transaction => {
513
511
  const oldSelection = oldState.tr.selection;
514
512
  let { tr } = newState;
@@ -115,8 +115,6 @@ export const getToolbarMenuConfig = (
115
115
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
116
116
  isTableScalingWithFixedColumnWidthsOptionShown = false,
117
117
  areTableColumnWidthsFixed = false,
118
- // Ignored via go/ees005
119
- // eslint-disable-next-line @typescript-eslint/max-params
120
118
  ): FloatingToolbarItem<Command> => {
121
119
  const optionItem: typeOption = 'item-checkbox';
122
120
 
@@ -209,8 +207,6 @@ export const getToolbarCellOptionsConfig = (
209
207
  isTableFixedColumnWidthsOptionEnabled = false,
210
208
  shouldUseIncreasedScalingPercent = false,
211
209
  isCommentEditor = false,
212
- // Ignored via go/ees005
213
- // eslint-disable-next-line @typescript-eslint/max-params
214
210
  ): FloatingToolbarDropdown<Command> => {
215
211
  const { top, bottom, right, left } = initialSelectionRect;
216
212
  const numberOfColumns = right - left;
@@ -487,8 +483,6 @@ export const getToolbarConfig =
487
483
  options?: TablePluginOptions,
488
484
  isTableFixedColumnWidthsOptionEnabled = false,
489
485
  shouldUseIncreasedScalingPercent = false,
490
- // Ignored via go/ees005
491
- // eslint-disable-next-line @typescript-eslint/max-params
492
486
  ) =>
493
487
  (config: PluginConfig): FloatingToolbarHandler =>
494
488
  (state, intl) => {
@@ -678,8 +672,6 @@ const getCellItems = (
678
672
  isTableFixedColumnWidthsOptionEnabled = false,
679
673
  shouldUseIncreasedScalingPercent = false,
680
674
  isCommentEditor = false,
681
- // Ignored via go/ees005
682
- // eslint-disable-next-line @typescript-eslint/max-params
683
675
  ): Array<FloatingToolbarItem<Command>> => {
684
676
  const initialSelectionRect = getClosestSelectionRect(state);
685
677
  if (initialSelectionRect) {
@@ -711,8 +703,6 @@ const getDistributeConfig =
711
703
  isTableScalingEnabled = false,
712
704
  isTableFixedColumnWidthsOptionEnabled = false,
713
705
  isCommentEditor = false,
714
- // Ignored via go/ees005
715
- // eslint-disable-next-line @typescript-eslint/max-params
716
706
  ): Command =>
717
707
  (state, dispatch, editorView) => {
718
708
  const selectionOrTableRect = getClosestSelectionOrTableRect(state);
@@ -752,8 +742,6 @@ const getColumnSettingItems = (
752
742
  isTableScalingEnabled = false,
753
743
  isTableFixedColumnWidthsOptionEnabled = false,
754
744
  isCommentEditor = false,
755
- // Ignored via go/ees005
756
- // eslint-disable-next-line @typescript-eslint/max-params
757
745
  ): Array<FloatingToolbarItem<Command>> => {
758
746
  const pluginState = getPluginState(editorState);
759
747
  const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
@@ -809,8 +797,6 @@ const getColorPicker = (
809
797
  { formatMessage }: ToolbarMenuContext,
810
798
  editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined,
811
799
  getEditorView: () => EditorView | null,
812
- // Ignored via go/ees005
813
- // eslint-disable-next-line @typescript-eslint/max-params
814
800
  ): Array<FloatingToolbarItem<Command>> => {
815
801
  const { targetCellPosition, pluginConfig } = getPluginState(state);
816
802
  if (!pluginConfig.allowBackgroundColor) {
@@ -902,8 +888,6 @@ const getAlignmentOptionsConfig = (
902
888
  shouldUseIncreasedScalingPercent: boolean,
903
889
  isFullWidthEditor?: boolean,
904
890
  isCommentEditor?: boolean,
905
- // Ignored via go/ees005
906
- // eslint-disable-next-line @typescript-eslint/max-params
907
891
  ): Array<FloatingToolbarDropdown<Command>> => {
908
892
  const tableObject = findTable(editorState.selection);
909
893
 
@@ -1017,8 +1001,6 @@ const isLayoutOptionDisabled = (
1017
1001
  editorView: EditorView | null,
1018
1002
  shouldUseIncreasedScalingPercent: boolean,
1019
1003
  isFullWidthEditor: boolean | undefined,
1020
- // Ignored via go/ees005
1021
- // eslint-disable-next-line @typescript-eslint/max-params
1022
1004
  ) => {
1023
1005
  const { lineLength } = getEditorContainerWidth();
1024
1006
  let tableContainerWidth = getTableContainerWidth(selectedNode);