@atlaskit/editor-plugin-table 5.3.25 → 5.3.27

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 (93) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/plugins/table/commands/hover.js +9 -3
  3. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +19 -6
  4. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +6 -1
  5. package/dist/cjs/plugins/table/types.js +3 -0
  6. package/dist/cjs/plugins/table/ui/DragHandle/index.js +16 -4
  7. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +26 -1
  8. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  9. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  10. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  11. package/dist/cjs/plugins/table/ui/consts.js +2 -1
  12. package/dist/cjs/plugins/table/ui/icons/DragHandleDisabledIcon.js +45 -0
  13. package/dist/cjs/plugins/table/ui/icons/index.js +7 -0
  14. package/dist/cjs/plugins/table/ui/ui-styles.js +12 -9
  15. package/dist/cjs/plugins/table/utils/decoration.js +7 -1
  16. package/dist/es2019/plugins/table/commands/hover.js +13 -4
  17. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +19 -6
  18. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +6 -1
  19. package/dist/es2019/plugins/table/types.js +3 -0
  20. package/dist/es2019/plugins/table/ui/DragHandle/index.js +19 -6
  21. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +27 -1
  22. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  23. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  24. package/dist/es2019/plugins/table/ui/common-styles.js +30 -38
  25. package/dist/es2019/plugins/table/ui/consts.js +1 -0
  26. package/dist/es2019/plugins/table/ui/icons/DragHandleDisabledIcon.js +37 -0
  27. package/dist/es2019/plugins/table/ui/icons/index.js +1 -0
  28. package/dist/es2019/plugins/table/ui/ui-styles.js +13 -1
  29. package/dist/es2019/plugins/table/utils/decoration.js +7 -1
  30. package/dist/esm/plugins/table/commands/hover.js +10 -4
  31. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +19 -6
  32. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +6 -1
  33. package/dist/esm/plugins/table/types.js +3 -0
  34. package/dist/esm/plugins/table/ui/DragHandle/index.js +18 -6
  35. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +26 -1
  36. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  37. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  38. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  39. package/dist/esm/plugins/table/ui/consts.js +1 -0
  40. package/dist/esm/plugins/table/ui/icons/DragHandleDisabledIcon.js +38 -0
  41. package/dist/esm/plugins/table/ui/icons/index.js +1 -0
  42. package/dist/esm/plugins/table/ui/ui-styles.js +12 -9
  43. package/dist/esm/plugins/table/utils/decoration.js +7 -1
  44. package/dist/types/plugins/table/types.d.ts +3 -0
  45. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +3 -1
  46. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  47. package/dist/types/plugins/table/ui/icons/DragHandleDisabledIcon.d.ts +6 -0
  48. package/dist/types/plugins/table/ui/icons/index.d.ts +1 -0
  49. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
  50. package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
  51. package/dist/types/plugins/table/utils/selection.d.ts +2 -2
  52. package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
  53. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +3 -1
  54. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  55. package/dist/types-ts4.5/plugins/table/ui/icons/DragHandleDisabledIcon.d.ts +6 -0
  56. package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +1 -0
  57. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
  58. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +1 -1
  59. package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +2 -2
  60. package/package.json +2 -2
  61. package/src/plugins/table/commands/hover.ts +12 -1
  62. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +31 -7
  63. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +7 -1
  64. package/src/plugins/table/types.ts +4 -0
  65. package/src/plugins/table/ui/DragHandle/index.tsx +36 -5
  66. package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +33 -1
  67. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -0
  68. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +1 -0
  69. package/src/plugins/table/ui/common-styles.ts +33 -40
  70. package/src/plugins/table/ui/consts.ts +6 -0
  71. package/src/plugins/table/ui/icons/DragHandleDisabledIcon.tsx +53 -0
  72. package/src/plugins/table/ui/icons/index.ts +1 -0
  73. package/src/plugins/table/ui/ui-styles.ts +13 -0
  74. package/src/plugins/table/utils/decoration.ts +14 -0
  75. package/src/plugins/table/utils/selection.ts +6 -2
  76. package/src/__tests__/integration/__snapshots__/auto-size.ts.snap +0 -612
  77. package/src/__tests__/integration/__snapshots__/delete-columns.ts.snap +0 -820
  78. package/src/__tests__/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +0 -120
  79. package/src/__tests__/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +0 -120
  80. package/src/__tests__/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +0 -229
  81. package/src/__tests__/integration/__snapshots__/insert-row-inside-layout.ts.snap +0 -239
  82. package/src/__tests__/integration/__snapshots__/resize.ts.snap +0 -2685
  83. package/src/__tests__/integration/__snapshots__/scale.ts.snap +0 -1085
  84. package/src/__tests__/integration/arrow-down-into-table.ts +0 -50
  85. package/src/__tests__/integration/auto-size.ts +0 -92
  86. package/src/__tests__/integration/cell-selection.ts +0 -105
  87. package/src/__tests__/integration/delete-columns.ts +0 -99
  88. package/src/__tests__/integration/delete-last-column-in-full-width.ts +0 -73
  89. package/src/__tests__/integration/delete-last-column-with-empty-action.ts +0 -60
  90. package/src/__tests__/integration/delete-last-row-with-empty-action.ts +0 -99
  91. package/src/__tests__/integration/insert-row-inside-layout.ts +0 -52
  92. package/src/__tests__/integration/resize.ts +0 -333
  93. package/src/__tests__/integration/scale.ts +0 -70
@@ -1,4 +1,5 @@
1
1
  import type { MouseEventHandler } from 'react';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { TableDirection } from '../../types';
3
4
  type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
4
5
  type DragHandleProps = {
@@ -12,6 +13,7 @@ type DragHandleProps = {
12
13
  onMouseOver?: MouseEventHandler;
13
14
  onMouseOut?: MouseEventHandler;
14
15
  onMouseUp?: MouseEventHandler;
16
+ editorView: EditorView;
15
17
  };
16
- export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, }: DragHandleProps) => JSX.Element;
18
+ export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, }: DragHandleProps) => JSX.Element;
17
19
  export {};
@@ -13,6 +13,7 @@ export declare const tableBorderSelectedColor: import("@atlaskit/theme").ThemedV
13
13
  export declare const tableCellSelectedDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-subtle)">;
14
14
  export declare const tableCellSelectedDeleteIconBackground: import("@atlaskit/theme").ThemedValue<"var(--ds-background-accent-gray-subtlest)">;
15
15
  export declare const tableCellDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-blanket-danger)">;
16
+ export declare const tableCellDisabledColor: "var(--ds-background-accent-gray-subtler-hovered)";
16
17
  export declare const tableBorderDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-border-danger)">;
17
18
  export declare const tableToolbarDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-background-danger-pressed)">;
18
19
  export declare const tableCellHoverDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-inverse)">;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface DragHandleDisabledIconProps {
3
+ style?: React.CSSProperties;
4
+ }
5
+ export declare const DragHandleDisabledIcon: ({ style, }: DragHandleDisabledIconProps) => JSX.Element;
6
+ export {};
@@ -1,5 +1,6 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
+ export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
3
4
  export { AddRowAboveIcon } from './AddRowAboveIcon';
4
5
  export { AddRowBelowIcon } from './AddRowBelowIcon';
5
6
  export { AddColLeftIcon } from './AddColLeftIcon';
@@ -14,6 +14,7 @@ export declare const floatingColumnControls: (props: ThemeProps) => import("@emo
14
14
  export declare const rowControlsWrapperDotStyle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
15
15
  export declare const columnControlsDecoration: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
16
16
  export declare const hoveredDeleteButton: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
17
+ export declare const disabledCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
17
18
  export declare const hoveredCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
18
19
  export declare const hoveredWarningCell: import("@emotion/react").SerializedStyles;
19
20
  export declare const resizeHandle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
@@ -8,7 +8,7 @@ import { TableDecorations } from '../types';
8
8
  export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
9
9
  export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
10
10
  export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
11
- export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, danger?: boolean, selected?: boolean) => Decoration[];
11
+ export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, isDragAndDropEnable: boolean | undefined, hoveredIndexes: number[], danger?: boolean, selected?: boolean) => Decoration[];
12
12
  export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
13
13
  export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
14
14
  export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
@@ -1,5 +1,5 @@
1
- import { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
2
- import { Rect } from '@atlaskit/editor-tables/table-map';
1
+ import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
3
3
  export declare const isSelectionUpdated: (oldSelection: Selection, newSelection?: Selection) => boolean;
4
4
  export declare const normalizeSelection: (tr: Transaction) => Transaction;
5
5
  export declare const getSelectedColumnIndexes: (selectionRect: Rect) => number[];
@@ -293,6 +293,8 @@ export declare const TableCssClassName: {
293
293
  DRAG_HANDLE_BUTTON_CONTAINER: string;
294
294
  DRAG_CORNER_BUTTON: string;
295
295
  DRAG_CORNER_BUTTON_INNER: string;
296
+ /** disabled classes */
297
+ DRAG_HANDLE_DISABLED: string;
296
298
  /** Other classes */
297
299
  NUMBERED_COLUMN: string;
298
300
  NUMBERED_COLUMN_BUTTON: string;
@@ -301,6 +303,7 @@ export declare const TableCssClassName: {
301
303
  HOVERED_ROW: string;
302
304
  HOVERED_TABLE: string;
303
305
  HOVERED_CELL: string;
306
+ HOVERED_DISABLED_CELL: string;
304
307
  HOVERED_CELL_IN_DANGER: string;
305
308
  HOVERED_CELL_ACTIVE: string;
306
309
  HOVERED_CELL_WARNING: string;
@@ -1,4 +1,5 @@
1
1
  import type { MouseEventHandler } from 'react';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { TableDirection } from '../../types';
3
4
  type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
4
5
  type DragHandleProps = {
@@ -12,6 +13,7 @@ type DragHandleProps = {
12
13
  onMouseOver?: MouseEventHandler;
13
14
  onMouseOut?: MouseEventHandler;
14
15
  onMouseUp?: MouseEventHandler;
16
+ editorView: EditorView;
15
17
  };
16
- export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, }: DragHandleProps) => JSX.Element;
18
+ export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, }: DragHandleProps) => JSX.Element;
17
19
  export {};
@@ -13,6 +13,7 @@ export declare const tableBorderSelectedColor: import("@atlaskit/theme").ThemedV
13
13
  export declare const tableCellSelectedDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-subtle)">;
14
14
  export declare const tableCellSelectedDeleteIconBackground: import("@atlaskit/theme").ThemedValue<"var(--ds-background-accent-gray-subtlest)">;
15
15
  export declare const tableCellDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-blanket-danger)">;
16
+ export declare const tableCellDisabledColor: "var(--ds-background-accent-gray-subtler-hovered)";
16
17
  export declare const tableBorderDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-border-danger)">;
17
18
  export declare const tableToolbarDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-background-danger-pressed)">;
18
19
  export declare const tableCellHoverDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-inverse)">;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface DragHandleDisabledIconProps {
3
+ style?: React.CSSProperties;
4
+ }
5
+ export declare const DragHandleDisabledIcon: ({ style, }: DragHandleDisabledIconProps) => JSX.Element;
6
+ export {};
@@ -1,5 +1,6 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
+ export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
3
4
  export { AddRowAboveIcon } from './AddRowAboveIcon';
4
5
  export { AddRowBelowIcon } from './AddRowBelowIcon';
5
6
  export { AddColLeftIcon } from './AddColLeftIcon';
@@ -14,6 +14,7 @@ export declare const floatingColumnControls: (props: ThemeProps) => import("@emo
14
14
  export declare const rowControlsWrapperDotStyle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
15
15
  export declare const columnControlsDecoration: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
16
16
  export declare const hoveredDeleteButton: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
17
+ export declare const disabledCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
17
18
  export declare const hoveredCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
18
19
  export declare const hoveredWarningCell: import("@emotion/react").SerializedStyles;
19
20
  export declare const resizeHandle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
@@ -8,7 +8,7 @@ import { TableDecorations } from '../types';
8
8
  export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
9
9
  export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
10
10
  export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
11
- export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, danger?: boolean, selected?: boolean) => Decoration[];
11
+ export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row' | 'column' | 'table', tr: Transaction | ReadonlyTransaction, isDragAndDropEnable: boolean | undefined, hoveredIndexes: number[], danger?: boolean, selected?: boolean) => Decoration[];
12
12
  export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
13
13
  export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
14
14
  export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
@@ -1,5 +1,5 @@
1
- import { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
2
- import { Rect } from '@atlaskit/editor-tables/table-map';
1
+ import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
3
3
  export declare const isSelectionUpdated: (oldSelection: Selection, newSelection?: Selection) => boolean;
4
4
  export declare const normalizeSelection: (tr: Transaction) => Transaction;
5
5
  export declare const getSelectedColumnIndexes: (selectionRect: Rect) => number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.3.25",
3
+ "version": "5.3.27",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^32.0.0",
31
31
  "@atlaskit/custom-steps": "^0.0.2",
32
- "@atlaskit/editor-common": "^76.18.0",
32
+ "@atlaskit/editor-common": "^76.20.0",
33
33
  "@atlaskit/editor-palette": "1.5.2",
34
34
  "@atlaskit/editor-plugin-analytics": "^0.3.0",
35
35
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",
@@ -6,7 +6,7 @@ import {
6
6
  getCellsInRow,
7
7
  } from '@atlaskit/editor-tables/utils';
8
8
 
9
- import { createCommand } from '../pm-plugins/plugin-factory';
9
+ import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
10
10
  import type { Cell, CellColumnPositioning } from '../types';
11
11
  import { TableDecorations } from '../types';
12
12
  import {
@@ -57,13 +57,18 @@ export const hoverColumns = (hoveredColumns: number[], isInDanger?: boolean) =>
57
57
  createCommand(
58
58
  (state) => {
59
59
  const cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
60
+
61
+ const { isDragAndDropEnabled } = getPluginState(state);
60
62
  if (!cells) {
61
63
  return false;
62
64
  }
65
+
63
66
  const decorations = createControlsHoverDecoration(
64
67
  cells,
65
68
  'column',
66
69
  state.tr,
70
+ isDragAndDropEnabled,
71
+ hoveredColumns,
67
72
  isInDanger,
68
73
  );
69
74
 
@@ -90,10 +95,13 @@ export const hoverRows = (hoveredRows: number[], isInDanger?: boolean) =>
90
95
  if (!cells) {
91
96
  return false;
92
97
  }
98
+ const { isDragAndDropEnabled } = getPluginState(state);
93
99
  const decorations = createControlsHoverDecoration(
94
100
  cells,
95
101
  'row',
96
102
  state.tr,
103
+ isDragAndDropEnabled,
104
+ hoveredRows,
97
105
  isInDanger,
98
106
  );
99
107
 
@@ -127,10 +135,13 @@ export const hoverTable = (isInDanger?: boolean, isSelected?: boolean) =>
127
135
  if (!cells) {
128
136
  return false;
129
137
  }
138
+ const { isDragAndDropEnabled } = getPluginState(state);
130
139
  const decorations = createControlsHoverDecoration(
131
140
  cells,
132
141
  'table',
133
142
  state.tr,
143
+ isDragAndDropEnabled,
144
+ [],
134
145
  isInDanger,
135
146
  isSelected,
136
147
  );
@@ -131,20 +131,44 @@ export const toggleDragMenu = (
131
131
  (state) => {
132
132
  let {
133
133
  isDragMenuOpen: previousOpenState,
134
- dragMenuDirection,
135
- dragMenuIndex,
134
+ dragMenuDirection: previousDragMenuDirection,
135
+ dragMenuIndex: previousDragMenuIndex,
136
136
  } = getPluginState(state);
137
- if (previousOpenState === isDragMenuOpen) {
137
+
138
+ if (
139
+ previousOpenState === isDragMenuOpen &&
140
+ previousDragMenuDirection === direction &&
141
+ previousDragMenuIndex === index
142
+ ) {
138
143
  return false;
139
144
  }
140
145
 
146
+ let updatedMenuOpenState;
147
+ if (isDragMenuOpen !== undefined) {
148
+ updatedMenuOpenState = isDragMenuOpen;
149
+ } else {
150
+ // menu open but menu direction changed, means user clicked on drag handle of different row/column
151
+ // menu open menu direction not changed, but index changed, means user clicked on drag handle of same row/column, different cells.
152
+ // 2 scenarios above , menu should remain open.
153
+ if (
154
+ (previousOpenState === true &&
155
+ previousDragMenuDirection !== direction) ||
156
+ (previousOpenState === true &&
157
+ previousDragMenuDirection === direction &&
158
+ previousDragMenuIndex !== index)
159
+ ) {
160
+ updatedMenuOpenState = true;
161
+ } else {
162
+ updatedMenuOpenState = !previousOpenState;
163
+ }
164
+ }
165
+
141
166
  return {
142
167
  type: DragAndDropActionType.TOGGLE_DRAG_MENU,
143
168
  data: {
144
- isDragMenuOpen:
145
- isDragMenuOpen === undefined ? !previousOpenState : isDragMenuOpen,
146
- direction: direction ?? dragMenuDirection,
147
- index: index ?? dragMenuIndex,
169
+ isDragMenuOpen: updatedMenuOpenState,
170
+ direction: direction ?? previousDragMenuDirection,
171
+ index: index ?? previousDragMenuIndex,
148
172
  },
149
173
  };
150
174
  },
@@ -5,6 +5,7 @@ import type {
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
8
9
  import { getCellsInRow } from '@atlaskit/editor-tables/utils';
9
10
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
10
11
  import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
@@ -65,10 +66,15 @@ export const createPlugin = (
65
66
 
66
67
  if (newTargetCellPosition !== undefined) {
67
68
  const cells = getCellsInRow(dragMenuIndex)(tr.selection);
69
+ // ED-20673 check if it is a cell selection,
70
+ // when true, a drag handle is clicked and isDragMenuOpen is true here
71
+ // should not close the drag menu.
72
+ const isCellSelection = tr.selection instanceof CellSelection;
68
73
  if (
69
74
  cells &&
70
75
  cells.length &&
71
- cells[0].node !== tr.doc.nodeAt(newTargetCellPosition)
76
+ cells[0].node !== tr.doc.nodeAt(newTargetCellPosition) &&
77
+ !isCellSelection
72
78
  ) {
73
79
  return tr.setMeta(pluginKey, action);
74
80
  } // else NOP
@@ -325,6 +325,9 @@ export const TableCssClassName = {
325
325
  DRAG_CORNER_BUTTON: `${tablePrefixSelector}-drag-corner-button`,
326
326
  DRAG_CORNER_BUTTON_INNER: `${tablePrefixSelector}-drag-corner-button-inner`,
327
327
 
328
+ /** disabled classes */
329
+ DRAG_HANDLE_DISABLED: `${tablePrefixSelector}-drag-handle-disabled`,
330
+
328
331
  /** Other classes */
329
332
  NUMBERED_COLUMN: `${tablePrefixSelector}-numbered-column`,
330
333
  NUMBERED_COLUMN_BUTTON: `${tablePrefixSelector}-numbered-column__button`,
@@ -334,6 +337,7 @@ export const TableCssClassName = {
334
337
  HOVERED_ROW: `${tablePrefixSelector}-hovered-row`,
335
338
  HOVERED_TABLE: `${tablePrefixSelector}-hovered-table`,
336
339
  HOVERED_CELL: `${tablePrefixSelector}-hovered-cell`,
340
+ HOVERED_DISABLED_CELL: `${tablePrefixSelector}-hovered-disabled`,
337
341
  HOVERED_CELL_IN_DANGER: 'danger',
338
342
  HOVERED_CELL_ACTIVE: 'active',
339
343
  HOVERED_CELL_WARNING: `${tablePrefixSelector}-hovered-cell__warning`,
@@ -1,16 +1,19 @@
1
1
  import type { MouseEventHandler } from 'react';
2
- import React, { useEffect, useRef, useState } from 'react';
2
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
3
3
 
4
4
  import classnames from 'classnames';
5
5
  import ReactDOM from 'react-dom';
6
6
 
7
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
8
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
8
9
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
9
10
 
11
+ import { getPluginState } from '../../pm-plugins/plugin-factory';
10
12
  import type { TableDirection } from '../../types';
11
13
  import { TableCssClassName as ClassName } from '../../types';
14
+ import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
12
15
  import { DragPreview } from '../DragPreview';
13
- import { DragHandleIcon } from '../icons';
16
+ import { DragHandleDisabledIcon, DragHandleIcon } from '../icons';
14
17
 
15
18
  type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
16
19
 
@@ -25,6 +28,7 @@ type DragHandleProps = {
25
28
  onMouseOver?: MouseEventHandler;
26
29
  onMouseOut?: MouseEventHandler;
27
30
  onMouseUp?: MouseEventHandler;
31
+ editorView: EditorView;
28
32
  };
29
33
 
30
34
  export const DragHandle = ({
@@ -38,17 +42,32 @@ export const DragHandle = ({
38
42
  onMouseOut,
39
43
  onMouseUp,
40
44
  onClick,
45
+ editorView,
41
46
  }: DragHandleProps) => {
42
47
  const dragHandleDivRef = useRef<HTMLButtonElement>(null);
43
48
  const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(
44
49
  null,
45
50
  );
51
+ const { isDragAndDropEnabled } = getPluginState(editorView.state);
52
+ const { selection } = editorView.state;
53
+
54
+ const hasMergedCells = useMemo(
55
+ () =>
56
+ direction === 'row'
57
+ ? hasMergedCellsInRow(indexes[0])(selection)
58
+ : hasMergedCellsInColumn(indexes[0])(selection),
59
+ [indexes, direction, selection],
60
+ );
46
61
 
47
62
  useEffect(() => {
48
63
  const dragHandleDivRefCurrent = dragHandleDivRef.current;
64
+
49
65
  if (dragHandleDivRefCurrent) {
50
66
  return draggable({
51
67
  element: dragHandleDivRefCurrent,
68
+ canDrag: () => {
69
+ return !hasMergedCells;
70
+ },
52
71
  getInitialData() {
53
72
  return {
54
73
  localId: tableLocalId,
@@ -75,11 +94,23 @@ export const DragHandle = ({
75
94
  },
76
95
  });
77
96
  }
78
- }, [tableLocalId, direction, indexes]);
97
+ }, [
98
+ tableLocalId,
99
+ direction,
100
+ indexes,
101
+ editorView.state.selection,
102
+ hasMergedCells,
103
+ ]);
79
104
 
80
105
  return (
81
106
  <button
82
- className={classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance)}
107
+ className={classnames(
108
+ ClassName.DRAG_HANDLE_BUTTON_CONTAINER,
109
+ appearance,
110
+ isDragAndDropEnabled &&
111
+ hasMergedCells &&
112
+ ClassName.DRAG_HANDLE_DISABLED,
113
+ )}
83
114
  ref={dragHandleDivRef}
84
115
  style={{
85
116
  transform: direction === 'column' ? 'none' : 'rotate(90deg)',
@@ -91,7 +122,7 @@ export const DragHandle = ({
91
122
  onMouseUp={onMouseUp}
92
123
  onClick={onClick}
93
124
  >
94
- <DragHandleIcon />
125
+ {hasMergedCells ? <DragHandleDisabledIcon /> : <DragHandleIcon />}
95
126
  {previewContainer &&
96
127
  previewWidth !== undefined &&
97
128
  previewHeight !== undefined &&
@@ -11,6 +11,7 @@ import {
11
11
  } from '@atlaskit/editor-common/ui-menu';
12
12
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
13
13
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
14
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
14
15
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
15
16
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
16
17
  import { TableMap } from '@atlaskit/editor-tables/table-map';
@@ -23,6 +24,7 @@ import { token } from '@atlaskit/tokens';
23
24
 
24
25
  import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
25
26
  import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
27
+ import { getPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
26
28
  import type { PluginConfig, TableDirection } from '../../types';
27
29
  import { getSelectedColumnIndexes, getSelectedRowIndexes } from '../../utils';
28
30
  import type { DragMenuConfig } from '../../utils/drag-menu';
@@ -132,9 +134,39 @@ export const DragMenu = ({
132
134
 
133
135
  const { menuItems, menuCallback } = convertToDropdownItems(dragMenuConfig);
134
136
 
137
+ /**
138
+ * This function is to check if the menu should be closed or not.
139
+ * As when continously clicking on drag handle on different rows/columns,
140
+ * should open the menu corresponding to the position of the drag handle.
141
+ * @returns true when the menu should be closed, false otherwise
142
+ */
143
+ const shouldCloseMenu = (state: EditorState) => {
144
+ let {
145
+ isDragMenuOpen: previousOpenState,
146
+ dragMenuDirection: previousDragMenuDirection,
147
+ dragMenuIndex: previousDragMenuIndex,
148
+ } = getPluginState(state);
149
+
150
+ // menu open but menu direction changed, means user clicked on drag handle of different row/column
151
+ // menu open menu direction not changed, but index changed, means user clicked on drag handle of same row/column, different cells.
152
+ // 2 scenarios above , menu should not be closed.
153
+ if (
154
+ (previousOpenState === true && previousDragMenuDirection !== direction) ||
155
+ (previousOpenState === true &&
156
+ previousDragMenuDirection === direction &&
157
+ previousDragMenuIndex !== index)
158
+ ) {
159
+ return false;
160
+ } else {
161
+ return true;
162
+ }
163
+ };
164
+
135
165
  const closeMenu = () => {
136
166
  const { state, dispatch } = editorView;
137
- toggleDragMenu(false)(state, dispatch);
167
+ if (shouldCloseMenu(state)) {
168
+ toggleDragMenu(false, direction, index)(state, dispatch);
169
+ }
138
170
  };
139
171
 
140
172
  const handleMenuItemActivated = ({ item }: { item: MenuItem }) => {
@@ -174,6 +174,7 @@ export const ColumnControls = ({
174
174
  onMouseOver={handleMouseOver}
175
175
  onMouseOut={handleMouseOut}
176
176
  onMouseUp={handleMouseUp}
177
+ editorView={editorView}
177
178
  />
178
179
  </div>
179
180
  )}
@@ -180,6 +180,7 @@ const DragControlsComponent = ({
180
180
  onMouseOver={handleMouseOver}
181
181
  onMouseOut={handleMouseOut}
182
182
  onMouseUp={onMouseUp}
183
+ editorView={editorView}
183
184
  />
184
185
  </div>
185
186
  )}
@@ -56,6 +56,7 @@ import {
56
56
  columnControlsDecoration,
57
57
  columnControlsLineMarker,
58
58
  DeleteButton,
59
+ disabledCell,
59
60
  dragCornerControlButton,
60
61
  dragInsertButtonWrapper,
61
62
  floatingColumnControls,
@@ -315,6 +316,7 @@ export const tableStyles = (
315
316
  ${columnControlsLineMarker()};
316
317
  ${hoveredDeleteButton(props)};
317
318
  ${hoveredCell(props)};
319
+ ${disabledCell(props)};
318
320
  ${hoveredWarningCell};
319
321
  ${getBooleanFF('platform.editor.table.drag-and-drop') && insertLine(props)};
320
322
  ${resizeHandle(props)};
@@ -779,58 +781,49 @@ export const tableStyles = (
779
781
  align-items: center;
780
782
  outline: none !important;
781
783
 
782
- svg {
783
- rect {
784
- fill: ${token('color.background.accent.gray.subtlest', '#F1F2F4')};
785
- }
786
- g {
787
- fill: ${token('color.icon.subtle', '#626F86')};
788
- }
789
- }
790
-
791
- &:hover {
792
- svg {
784
+ &:not(.${ClassName.DRAG_HANDLE_DISABLED}) {
785
+ & > svg {
793
786
  rect {
794
- fill: ${token('color.background.accent.blue.subtle', '#579DFF')};
787
+ fill: ${token('color.background.accent.gray.subtlest', '#F1F2F4')};
795
788
  }
796
789
  g {
797
- fill: ${token('color.icon.inverse', '#FFF')};
790
+ fill: ${token('color.icon.subtle', '#626F86')};
798
791
  }
799
792
  }
800
- }
801
793
 
802
- &.selected {
803
- svg {
804
- rect {
805
- fill: ${token('color.background.accent.blue.subtle', '#579DFF')};
806
- }
807
- g {
808
- fill: ${token('color.icon.inverse', '#FFF')};
794
+ &:hover {
795
+ svg {
796
+ rect {
797
+ fill: ${token('color.background.accent.blue.subtle', '#579DFF')};
798
+ }
799
+ g {
800
+ fill: ${token('color.icon.inverse', '#FFF')};
801
+ }
809
802
  }
810
803
  }
811
- }
812
804
 
813
- &.danger {
814
- svg {
815
- rect {
816
- fill: ${token(
817
- 'color.background.accent.red.subtler.pressed',
818
- '#F87462',
819
- )};
820
- }
821
- g {
822
- fill: ${token('color.border.inverse', '#FFF')};
805
+ &.selected {
806
+ svg {
807
+ rect {
808
+ fill: ${token('color.background.accent.blue.subtle', '#579dff')};
809
+ }
810
+ g {
811
+ fill: ${token('color.icon.inverse', '#fff')};
812
+ }
823
813
  }
824
814
  }
825
- }
826
815
 
827
- &.disabled {
828
- svg {
829
- rect {
830
- fill: ${token('color.background.accent.gray.subtlest', '#F1F2F4')};
831
- }
832
- g {
833
- fill: ${token('color.border.inverse', '#FFF')};
816
+ &.danger {
817
+ svg {
818
+ rect {
819
+ fill: ${token(
820
+ 'color.background.accent.red.subtler.pressed',
821
+ '#F87462',
822
+ )};
823
+ }
824
+ g {
825
+ fill: ${token('color.border.inverse', '#FFF')};
826
+ }
834
827
  }
835
828
  }
836
829
  }
@@ -97,6 +97,12 @@ export const tableCellDeleteColor = themed({
97
97
  light: token('color.blanket.danger', akEditorTableCellBlanketDeleted),
98
98
  dark: token('color.blanket.danger', akEditorTableCellBlanketDeleted),
99
99
  });
100
+
101
+ export const tableCellDisabledColor = token(
102
+ 'color.background.accent.gray.subtler.hovered',
103
+ '#C1C7D0',
104
+ );
105
+
100
106
  export const tableBorderDeleteColor = themed({
101
107
  light: token('color.border.danger', R400),
102
108
  dark: token('color.border.danger', R400),