@atlaskit/editor-plugin-table 5.3.7 → 5.3.8

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 (63) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -4
  3. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +3 -2
  4. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -2
  5. package/dist/cjs/plugins/table/types.js +1 -1
  6. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +72 -0
  7. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +20 -3
  8. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  9. package/dist/cjs/plugins/table/ui/ui-styles.js +19 -15
  10. package/dist/cjs/plugins/table/utils/decoration.js +3 -24
  11. package/dist/cjs/plugins/table/utils/dom.js +1 -4
  12. package/dist/cjs/plugins/table/utils/index.js +0 -6
  13. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -4
  14. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +3 -2
  15. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -2
  16. package/dist/es2019/plugins/table/types.js +1 -1
  17. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +60 -0
  18. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +20 -3
  19. package/dist/es2019/plugins/table/ui/common-styles.js +2 -5
  20. package/dist/es2019/plugins/table/ui/ui-styles.js +29 -30
  21. package/dist/es2019/plugins/table/utils/decoration.js +3 -24
  22. package/dist/es2019/plugins/table/utils/dom.js +0 -1
  23. package/dist/es2019/plugins/table/utils/index.js +1 -1
  24. package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -4
  25. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +3 -2
  26. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -2
  27. package/dist/esm/plugins/table/types.js +1 -1
  28. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +63 -0
  29. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +20 -3
  30. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  31. package/dist/esm/plugins/table/ui/ui-styles.js +18 -14
  32. package/dist/esm/plugins/table/utils/decoration.js +3 -24
  33. package/dist/esm/plugins/table/utils/dom.js +0 -3
  34. package/dist/esm/plugins/table/utils/index.js +1 -1
  35. package/dist/types/plugins/table/types.d.ts +1 -1
  36. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +15 -0
  37. package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +3 -0
  38. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
  39. package/dist/types/plugins/table/utils/decoration.d.ts +2 -2
  40. package/dist/types/plugins/table/utils/dom.d.ts +0 -1
  41. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  42. package/dist/types-ts4.5/plugins/table/types.d.ts +1 -1
  43. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +15 -0
  44. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +3 -0
  45. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
  46. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +2 -2
  47. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +0 -1
  48. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  49. package/package.json +1 -1
  50. package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +2 -2
  51. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +84 -34
  52. package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +5 -2
  53. package/src/plugins/table/nodeviews/TableComponent.tsx +15 -15
  54. package/src/plugins/table/pm-plugins/decorations/plugin.ts +3 -2
  55. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -1
  56. package/src/plugins/table/types.ts +1 -1
  57. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +100 -0
  58. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +30 -8
  59. package/src/plugins/table/ui/common-styles.ts +2 -4
  60. package/src/plugins/table/ui/ui-styles.ts +30 -30
  61. package/src/plugins/table/utils/decoration.ts +3 -45
  62. package/src/plugins/table/utils/dom.ts +0 -4
  63. package/src/plugins/table/utils/index.ts +0 -1
@@ -108,38 +108,88 @@ describe('decorations plugin', () => {
108
108
  });
109
109
 
110
110
  describe('when the hovered cell state changes', () => {
111
- describe('should add column control decorations', () => {
112
- ffTest('platform.editor.table.drag-and-drop', () => {
113
- const pluginState = DecorationSet.empty;
114
- const { editorView } = editor(
115
- doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
116
- );
117
-
118
- const transaction = editorView.state.tr.setMeta(pluginKey, {
119
- type: 'HOVER_CELL',
120
- data: {
121
- colIndex: 0,
122
- rowIndex: 0,
123
- },
124
- });
125
-
126
- const oldState = handleDocOrSelectionChanged(
127
- transaction,
128
- pluginState,
129
- editorView.state,
130
- editorView.state,
131
- );
132
-
133
- editorView.dispatch(transaction);
134
- const newState = handleDocOrSelectionChanged(
135
- transaction,
136
- oldState,
137
- editorView.state,
138
- editorView.state,
139
- );
140
-
141
- expect(oldState).not.toEqual(newState);
142
- });
111
+ describe('should not add column control decorations', () => {
112
+ ffTest(
113
+ 'platform.editor.table.drag-and-drop',
114
+ () => {
115
+ const pluginState = DecorationSet.empty;
116
+ const { editorView } = editor(
117
+ doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
118
+ );
119
+
120
+ const transaction = editorView.state.tr.setMeta(pluginKey, {
121
+ type: 'HOVER_CELL',
122
+ data: {
123
+ colIndex: 0,
124
+ rowIndex: 0,
125
+ },
126
+ });
127
+
128
+ const oldState = handleDocOrSelectionChanged(
129
+ transaction,
130
+ pluginState,
131
+ editorView.state,
132
+ editorView.state,
133
+ );
134
+
135
+ editorView.dispatch(transaction);
136
+ const newState = handleDocOrSelectionChanged(
137
+ transaction,
138
+ oldState,
139
+ editorView.state,
140
+ editorView.state,
141
+ );
142
+
143
+ const columnDecorations = newState.find(
144
+ undefined,
145
+ undefined,
146
+ (spec) =>
147
+ spec.key.indexOf(TableDecorations.COLUMN_CONTROLS_DECORATIONS) >
148
+ -1,
149
+ );
150
+
151
+ expect(columnDecorations).toHaveLength(0);
152
+ },
153
+ () => {
154
+ const pluginState = DecorationSet.empty;
155
+ const { editorView } = editor(
156
+ doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
157
+ );
158
+
159
+ const transaction = editorView.state.tr.setMeta(pluginKey, {
160
+ type: 'HOVER_CELL',
161
+ data: {
162
+ colIndex: 0,
163
+ rowIndex: 0,
164
+ },
165
+ });
166
+
167
+ const oldState = handleDocOrSelectionChanged(
168
+ transaction,
169
+ pluginState,
170
+ editorView.state,
171
+ editorView.state,
172
+ );
173
+
174
+ editorView.dispatch(transaction);
175
+ const newState = handleDocOrSelectionChanged(
176
+ transaction,
177
+ oldState,
178
+ editorView.state,
179
+ editorView.state,
180
+ );
181
+
182
+ const columnDecorations = newState.find(
183
+ undefined,
184
+ undefined,
185
+ (spec) =>
186
+ spec.key.indexOf(TableDecorations.COLUMN_CONTROLS_DECORATIONS) >
187
+ -1,
188
+ );
189
+
190
+ expect(columnDecorations).toHaveLength(2);
191
+ },
192
+ );
143
193
  });
144
194
  });
145
195
 
@@ -169,7 +219,7 @@ describe('decorations plugin', () => {
169
219
  });
170
220
 
171
221
  describe('when the table changed', () => {
172
- describe('should re-create the column controls decorations', () => {
222
+ describe('should not re-create the column controls decorations', () => {
173
223
  ffTest(
174
224
  'platform.editor.table.drag-and-drop',
175
225
  () => {
@@ -203,7 +253,7 @@ describe('decorations plugin', () => {
203
253
  -1,
204
254
  );
205
255
 
206
- expect(decorations).toHaveLength(3);
256
+ expect(decorations).toHaveLength(0);
207
257
  },
208
258
  () => {
209
259
  const { editorView } = editor(
@@ -85,7 +85,8 @@ describe('TableFloatingColumnControls', () => {
85
85
  expect(container.innerHTML).toEqual('');
86
86
  });
87
87
 
88
- it('should render a drop target per column', () => {
88
+ // FIXME and unskip: presumably doesn't work becuase TableFloatingColumnControls are now mounted via ReactDOM.createPortal
89
+ it.skip('should render a drop target per column', () => {
89
90
  const { editorView } = editor(
90
91
  doc(p('text'), table()(tr(tdEmpty, tdEmpty, tdEmpty, tdEmpty, tdEmpty))),
91
92
  {
@@ -108,10 +109,12 @@ describe('TableFloatingColumnControls', () => {
108
109
  const dropTargets = screen.getAllByTestId(
109
110
  'table-floating-column-controls-drop-target',
110
111
  );
112
+
111
113
  expect(dropTargets).toHaveLength(5);
112
114
  });
113
115
 
114
- it('should render a drop target per column regardless of row count', () => {
116
+ // FIXME and unskp: presumably doesn't work becuase TableFloatingColumnControls are now mounted via ReactDOM.createPortal
117
+ it.skip('should render a drop target per column regardless of row count', () => {
115
118
  const { editorView } = editor(
116
119
  doc(p('text'), table()(tr(tdEmpty), tr(tdEmpty), tr(tdEmpty))),
117
120
  {
@@ -436,21 +436,21 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
436
436
  );
437
437
 
438
438
  const colControls = (
439
- <div className={ClassName.COLUMN_CONTROLS_WRAPPER}>
440
- <TableFloatingColumnControls
441
- editorView={view}
442
- tableRef={tableRef}
443
- tableActive={tableActive}
444
- hoveredRows={hoveredRows}
445
- ordering={ordering}
446
- hasHeaderRow={hasHeaderRow}
447
- // pass `selection` and `tableHeight` to control re-render
448
- selection={view.state.selection}
449
- headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
450
- stickyHeader={this.state.stickyHeader}
451
- getEditorFeatureFlags={this.props.getEditorFeatureFlags}
452
- />
453
- </div>
439
+ <TableFloatingColumnControls
440
+ editorView={view}
441
+ tableRef={tableRef}
442
+ tableActive={tableActive}
443
+ hoveredRows={hoveredRows}
444
+ hoveredCell={hoveredCell}
445
+ isResizing={isResizing}
446
+ ordering={ordering}
447
+ hasHeaderRow={hasHeaderRow}
448
+ // pass `selection` and `tableHeight` to control re-render
449
+ selection={view.state.selection}
450
+ headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
451
+ stickyHeader={this.state.stickyHeader}
452
+ getEditorFeatureFlags={this.props.getEditorFeatureFlags}
453
+ />
454
454
  );
455
455
 
456
456
  const shadowPadding =
@@ -8,6 +8,7 @@ import type {
8
8
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
9
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
10
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
11
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
12
 
12
13
  import { pluginKey as tablePluginKey } from '../plugin-key';
13
14
  import { pluginKey as tableWidthPluginKey } from '../table-width';
@@ -33,8 +34,8 @@ export const handleDocOrSelectionChanged = (
33
34
 
34
35
  const changedResizing = isResizing !== wasResizing;
35
36
 
36
- // Remove column controls when resizing
37
- if (isResizing) {
37
+ // Remove column controls when resizing and don't add column decoration controls when DnD enabled
38
+ if (isResizing || getBooleanFF('platform.editor.table.drag-and-drop')) {
38
39
  return DecorationSet.empty;
39
40
  } else if (
40
41
  tr.docChanged ||
@@ -60,7 +60,7 @@ const maybeUpdateColumnControlsDecoration: DecorationTransformer = ({
60
60
  return updateDecorations(
61
61
  tr.doc,
62
62
  decorationSet,
63
- createColumnControlsDecoration(tr.selection, meta?.data?.hoveredCell),
63
+ createColumnControlsDecoration(tr.selection),
64
64
  TableDecorations.COLUMN_CONTROLS_DECORATIONS,
65
65
  );
66
66
  };
@@ -299,7 +299,7 @@ export const TableCssClassName = {
299
299
  CONTROLS_CORNER_BUTTON: `${tablePrefixSelector}-corner-button`,
300
300
 
301
301
  /** Controls with drag handle */
302
- COLUMN_CONTROLS_DECORATIONS_WITH_DRAG: `${tablePrefixSelector}-column-controls-decoration-with-drag`,
302
+ COLUMN_CONTROLS_WITH_DRAG: `${tablePrefixSelector}-column-controls-with-drag`,
303
303
  ROW_CONTROLS_WITH_DRAG: `${tablePrefixSelector}-row-controls-with-drag`,
304
304
  DRAG_HANDLE_BUTTON_CONTAINER: `${tablePrefixSelector}-drag-handle-button-container`,
305
305
 
@@ -0,0 +1,100 @@
1
+ import React, { useMemo } from 'react';
2
+
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+
5
+ import type { CellHoverCoordinates } from '../../../types';
6
+ import { TableCssClassName as ClassName } from '../../../types';
7
+ import { getColumnsWidths, getRowHeights } from '../../../utils';
8
+ import { DragHandle } from '../../DragHandle';
9
+
10
+ export interface Props {
11
+ editorView: EditorView;
12
+ tableActive?: boolean;
13
+ tableRef: HTMLTableElement;
14
+ hoveredCell?: CellHoverCoordinates;
15
+ isResizing?: boolean;
16
+ stickyTop?: number;
17
+ tableHeight?: number;
18
+ localId?: string;
19
+ }
20
+
21
+ export const ColumnControls: React.FC<Props> = ({
22
+ editorView,
23
+ tableActive,
24
+ tableRef,
25
+ hoveredCell,
26
+ isResizing,
27
+ tableHeight,
28
+ stickyTop,
29
+ localId,
30
+ }) => {
31
+ const rowHeights = useMemo(() => {
32
+ // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
33
+ if (tableRef && !!tableHeight) {
34
+ return getRowHeights(tableRef);
35
+ }
36
+ return [0];
37
+ }, [tableRef, tableHeight]);
38
+
39
+ if (!tableRef) {
40
+ return null;
41
+ }
42
+
43
+ const firstRow = tableRef.querySelector('tr');
44
+ const hasHeaderRow = firstRow
45
+ ? firstRow.getAttribute('data-header-row')
46
+ : false;
47
+
48
+ const marginTop =
49
+ hasHeaderRow && stickyTop !== undefined ? rowHeights?.[0] ?? 0 : 0;
50
+
51
+ const colWidths = getColumnsWidths(editorView);
52
+ const widths = colWidths
53
+ .map((width) => (width ? `${width - 1}px` : '0px'))
54
+ .join(' ');
55
+
56
+ const colIndex = hoveredCell?.colIndex;
57
+
58
+ const onClick = (
59
+ index: number,
60
+ event: React.MouseEvent<Element, MouseEvent>,
61
+ ) => {};
62
+
63
+ const onMouseOver = () => {};
64
+ const onMouseOut = () => {};
65
+
66
+ return (
67
+ <div className={ClassName.COLUMN_CONTROLS_WITH_DRAG}>
68
+ <div
69
+ className={ClassName.COLUMN_CONTROLS_INNER}
70
+ data-testid="table-floating-column-controls"
71
+ style={{
72
+ gridTemplateColumns: widths,
73
+ marginTop,
74
+ }}
75
+ >
76
+ {tableActive && !isResizing && Number.isFinite(colIndex) && (
77
+ <div
78
+ style={{
79
+ gridColumn: `${(colIndex as number) + 1} / span 1`,
80
+ marginTop: `-15px`,
81
+ }}
82
+ data-column-control-index={colIndex}
83
+ data-testid="table-floating-column-control"
84
+ >
85
+ <DragHandle
86
+ direction="column"
87
+ indexes={[]}
88
+ onClick={(event) => onClick(colIndex as number, event)}
89
+ onMouseOver={onMouseOver}
90
+ onMouseOut={onMouseOut}
91
+ tableLocalId={localId || ''}
92
+ />
93
+ </div>
94
+ )}
95
+ </div>
96
+ </div>
97
+ );
98
+ };
99
+
100
+ export default ColumnControls;
@@ -1,5 +1,7 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
2
 
3
+ import ReactDOM from 'react-dom';
4
+
3
5
  import type { TableColumnOrdering } from '@atlaskit/custom-steps';
4
6
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
7
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
@@ -7,7 +9,10 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
9
  import { findTable } from '@atlaskit/editor-tables';
8
10
 
9
11
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
12
+ import type { CellHoverCoordinates } from '../../types';
13
+ import { TableCssClassName as ClassName } from '../../types';
10
14
 
15
+ import { ColumnControls } from './ColumnControls';
11
16
  import { ColumnDropTargets } from './ColumnDropTargets';
12
17
 
13
18
  export interface Props {
@@ -19,6 +24,8 @@ export interface Props {
19
24
  hasHeaderRow?: boolean;
20
25
  headerRowHeight?: number;
21
26
  hoveredRows?: number[];
27
+ hoveredCell?: CellHoverCoordinates;
28
+ isResizing?: boolean;
22
29
  ordering?: TableColumnOrdering;
23
30
  stickyHeader?: RowStickyState;
24
31
  }
@@ -28,6 +35,8 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
28
35
  tableRef,
29
36
  tableActive,
30
37
  hasHeaderRow,
38
+ hoveredCell,
39
+ isResizing,
31
40
  stickyHeader,
32
41
  selection,
33
42
  }) => {
@@ -80,12 +89,24 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
80
89
  ? stickyHeader.top
81
90
  : undefined;
82
91
 
83
- return (
84
- <div
85
- onMouseDown={(e) => e.preventDefault()}
86
- data-testid="table-floating-column-controls-wrapper"
87
- >
88
- {tableActive && (
92
+ const mountTo = (tableRef && tableRef?.parentElement) || document.body;
93
+
94
+ return ReactDOM.createPortal(
95
+ <div className={ClassName.COLUMN_CONTROLS_WRAPPER}>
96
+ <div
97
+ onMouseDown={(e) => e.preventDefault()}
98
+ data-testid="table-floating-column-controls-wrapper"
99
+ >
100
+ <ColumnControls
101
+ editorView={editorView}
102
+ hoveredCell={hoveredCell}
103
+ tableRef={tableRef}
104
+ isResizing={isResizing}
105
+ tableActive={tableActive}
106
+ stickyTop={tableActive ? stickyTop : undefined}
107
+ tableHeight={tableRect.height}
108
+ localId={selectedLocalId}
109
+ />
89
110
  <ColumnDropTargets
90
111
  editorView={editorView}
91
112
  tableRef={tableRef}
@@ -93,8 +114,9 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
93
114
  tableHeight={tableRect.height}
94
115
  localId={selectedLocalId}
95
116
  />
96
- )}
97
- </div>
117
+ </div>
118
+ </div>,
119
+ mountTo,
98
120
  );
99
121
  };
100
122
 
@@ -69,6 +69,7 @@ import {
69
69
  insertRowButtonWrapper,
70
70
  OverflowShadow,
71
71
  resizeHandle,
72
+ rowControlsWrapperDotStyle,
72
73
  } from './ui-styles';
73
74
 
74
75
  const cornerControlHeight = tableToolbarSize + 1;
@@ -573,6 +574,7 @@ export const tableStyles = (
573
574
  ${breakoutWidthStyling()}
574
575
 
575
576
  ${columnControlsDecoration(props)};
577
+ ${rowControlsWrapperDotStyle(props)};
576
578
 
577
579
  /* Corner controls */
578
580
  .${ClassName.CORNER_CONTROLS} {
@@ -833,10 +835,6 @@ export const tableStyles = (
833
835
  margin-top: 0;
834
836
  }
835
837
 
836
- .${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG} + * {
837
- margin-top: 0;
838
- }
839
-
840
838
  /*
841
839
  * Headings have a top margin by default, but we don't want this on the
842
840
  * first heading within table header cells.
@@ -380,27 +380,51 @@ export const floatingColumnControls = (props: ThemeProps) => {
380
380
  .${ClassName.COLUMN_DROP_TARGET_CONTROLS} {
381
381
  box-sizing: border-box;
382
382
  position: absolute;
383
+ top: 0;
384
+ z-index: -1;
383
385
 
384
386
  .${ClassName.COLUMN_CONTROLS_INNER} {
385
387
  display: flex;
386
388
  flex-direction: row;
387
389
  }
388
390
  }
391
+
392
+ .${ClassName.COLUMN_CONTROLS_WITH_DRAG} {
393
+ box-sizing: border-box;
394
+
395
+ .${ClassName.COLUMN_CONTROLS_INNER} {
396
+ display: grid;
397
+ justify-items: center;
398
+ }
399
+ }
389
400
  `;
390
401
  };
391
402
 
392
- export const columnControlsDecoration = (props: ThemeProps) => {
403
+ export const rowControlsWrapperDotStyle = (props: ThemeProps) => {
393
404
  if (getBooleanFF('platform.editor.table.drag-and-drop')) {
394
405
  return css`
395
- .${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG} {
406
+ div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
407
+ display: none;
408
+ }
409
+ `;
410
+ } else {
411
+ return css`
412
+ div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
413
+ content: ' ';
414
+ background-color: ${tableBorderColor(props)};
396
415
  position: absolute;
397
- // kinda a hacky way to center an element with absolute positioning inside a relative element
398
- top: 25%;
399
- left: 50%;
400
- transform: translate(-50%, -100%);
416
+ height: ${lineMarkerSize}px;
417
+ width: ${lineMarkerSize}px;
418
+ border-radius: 50%;
419
+ pointer-events: none;
420
+ top: -${tableToolbarSize + tableCellBorderWidth}px;
421
+ right: -1px;
401
422
  }
402
423
  `;
403
424
  }
425
+ };
426
+
427
+ export const columnControlsDecoration = (props: ThemeProps) => {
404
428
  if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
405
429
  return css`
406
430
  .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
@@ -452,18 +476,6 @@ export const columnControlsDecoration = (props: ThemeProps) => {
452
476
  // floating dot for adding column button - overriding style on last column to avoid scroll
453
477
  ${getFloatingDotOverrides(props)}
454
478
 
455
- div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
456
- content: ' ';
457
- background-color: ${tableBorderColor(props)};
458
- position: absolute;
459
- height: ${lineMarkerSize}px;
460
- width: ${lineMarkerSize}px;
461
- border-radius: 50%;
462
- pointer-events: none;
463
- top: -${tableToolbarSize + tableCellBorderWidth}px;
464
- right: -1px;
465
- }
466
-
467
479
  .${ClassName.WITH_CONTROLS} .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
468
480
  display: block;
469
481
  }
@@ -572,18 +584,6 @@ export const columnControlsDecoration = (props: ThemeProps) => {
572
584
  // floating dot for adding column button - overriding style on last column to avoid scroll
573
585
  ${getFloatingDotOverrides(props)}
574
586
 
575
- div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
576
- content: ' ';
577
- background-color: ${tableBorderColor(props)};
578
- position: absolute;
579
- height: ${lineMarkerSize}px;
580
- width: ${lineMarkerSize}px;
581
- border-radius: 50%;
582
- pointer-events: none;
583
- top: -${tableToolbarSize + tableCellBorderWidth}px;
584
- right: -1px;
585
- }
586
-
587
587
  .${ClassName.WITH_CONTROLS} .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
588
588
  display: block;
589
589
  }
@@ -24,14 +24,9 @@ import {
24
24
  } from '@atlaskit/editor-tables/utils';
25
25
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
26
26
 
27
- import type {
28
- Cell,
29
- CellColumnPositioning,
30
- CellHoverCoordinates,
31
- } from '../types';
27
+ import type { Cell, CellColumnPositioning } from '../types';
32
28
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
33
29
  import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
34
- import { DragHandle } from '../ui/DragHandle';
35
30
 
36
31
  const filterDecorationByKey = (
37
32
  key: TableDecorations,
@@ -212,48 +207,11 @@ export const createColumnSelectedDecoration = (
212
207
 
213
208
  export const createColumnControlsDecoration = (
214
209
  selection: Selection,
215
- hoverLocation?: CellHoverCoordinates,
216
210
  ): Decoration[] => {
217
- // todo: issue here where table may not be selected yet
218
211
  const cells: ContentNodeWithPos[] = getCellsInRow(0)(selection) || [];
219
- const table = findTable(selection);
220
212
 
221
- if (
222
- getBooleanFF('platform.editor.table.drag-and-drop') &&
223
- hoverLocation &&
224
- !Number.isNaN(hoverLocation?.colIndex) &&
225
- table
226
- ) {
227
- const colIndex = hoverLocation.colIndex as number;
228
- const cell = cells[colIndex];
229
- return [
230
- Decoration.widget(
231
- cell.pos + 1,
232
- () => {
233
- const element = document.createElement('div');
234
- element.classList.add(
235
- ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG,
236
- );
237
- ReactDOM.render(
238
- createElement(DragHandle, {
239
- tableLocalId: table.node.attrs.localId,
240
- direction: 'column',
241
- indexes: [colIndex],
242
- }),
243
- element,
244
- );
245
- return element;
246
- },
247
- {
248
- key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${colIndex}`,
249
- // this decoration should be the first one, even before gap cursor.
250
- side: -100,
251
- destroy: (node) => {
252
- ReactDOM.unmountComponentAtNode(node as HTMLDivElement);
253
- },
254
- },
255
- ),
256
- ];
213
+ if (getBooleanFF('platform.editor.table.drag-and-drop')) {
214
+ return [];
257
215
  } else {
258
216
  let index = 0;
259
217
  return cells.map((cell) => {
@@ -36,10 +36,6 @@ export const isColumnControlsDecorations = (
36
36
  node: HTMLElement | null,
37
37
  ): boolean => containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS);
38
38
 
39
- export const isColumnDragControlsDecorations = (node: HTMLElement | null) =>
40
- containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG) ||
41
- closestElement(node, `.${ClassName.COLUMN_CONTROLS_DECORATIONS_WITH_DRAG}`);
42
-
43
39
  export const isRowControlsButton = (node: HTMLElement | null): boolean =>
44
40
  containsClassName(node, ClassName.ROW_CONTROLS_BUTTON) ||
45
41
  containsClassName(node, ClassName.NUMBERED_COLUMN_BUTTON);
@@ -46,7 +46,6 @@ export {
46
46
  isColumnControlsDecorations,
47
47
  isTableControlsButton,
48
48
  isTableContainerOrWrapper,
49
- isColumnDragControlsDecorations,
50
49
  isRowDragControlsButton,
51
50
  isRowControlsButton,
52
51
  getColumnOrRowIndex,