@atlaskit/editor-plugin-table 5.4.4 → 5.4.6

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 (64) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/table/types.js +1 -1
  3. package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +29 -0
  4. package/dist/cjs/plugins/table/ui/DragHandle/index.js +21 -20
  5. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  6. package/dist/cjs/plugins/table/ui/consts.js +1 -2
  7. package/dist/cjs/plugins/table/ui/ui-styles.js +10 -13
  8. package/dist/cjs/plugins/table/utils/decoration.js +7 -6
  9. package/dist/es2019/plugins/table/types.js +1 -1
  10. package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +24 -0
  11. package/dist/es2019/plugins/table/ui/DragHandle/index.js +21 -20
  12. package/dist/es2019/plugins/table/ui/common-styles.js +6 -2
  13. package/dist/es2019/plugins/table/ui/consts.js +0 -1
  14. package/dist/es2019/plugins/table/ui/ui-styles.js +18 -12
  15. package/dist/es2019/plugins/table/utils/decoration.js +7 -6
  16. package/dist/esm/plugins/table/types.js +1 -1
  17. package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +22 -0
  18. package/dist/esm/plugins/table/ui/DragHandle/index.js +21 -20
  19. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  20. package/dist/esm/plugins/table/ui/consts.js +0 -1
  21. package/dist/esm/plugins/table/ui/ui-styles.js +10 -13
  22. package/dist/esm/plugins/table/utils/decoration.js +7 -6
  23. package/dist/types/plugins/table/types.d.ts +1 -1
  24. package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +13 -0
  25. package/dist/types/plugins/table/ui/consts.d.ts +0 -1
  26. package/dist/types/plugins/table/ui/ui-styles.d.ts +0 -1
  27. package/dist/types-ts4.5/plugins/table/types.d.ts +1 -1
  28. package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +13 -0
  29. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +0 -1
  30. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +0 -1
  31. package/package.json +4 -4
  32. package/src/plugins/table/types.ts +1 -1
  33. package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +51 -0
  34. package/src/plugins/table/ui/DragHandle/index.tsx +30 -33
  35. package/src/plugins/table/ui/common-styles.ts +5 -2
  36. package/src/plugins/table/ui/consts.ts +0 -5
  37. package/src/plugins/table/ui/ui-styles.ts +17 -12
  38. package/src/plugins/table/utils/decoration.ts +14 -19
  39. package/tsconfig.dev.json +0 -3
  40. package/src/__tests__/integration/__fixtures__/auto-size-documents.ts +0 -434
  41. package/src/__tests__/integration/__fixtures__/basic-table-with-merged-cell.ts +0 -112
  42. package/src/__tests__/integration/__fixtures__/basic-table.ts +0 -120
  43. package/src/__tests__/integration/__fixtures__/empty-layout.ts +0 -35
  44. package/src/__tests__/integration/__fixtures__/empty-paragraph-underneath-table.ts +0 -396
  45. package/src/__tests__/integration/__fixtures__/even-columns.ts +0 -493
  46. package/src/__tests__/integration/__fixtures__/large-table-with-sticky-header.ts +0 -2311
  47. package/src/__tests__/integration/__fixtures__/layout-documents.ts +0 -606
  48. package/src/__tests__/integration/__fixtures__/merged-rows-and-cols-document.ts +0 -343
  49. package/src/__tests__/integration/__fixtures__/nested-in-expand.ts +0 -129
  50. package/src/__tests__/integration/__fixtures__/nested-in-extension.ts +0 -163
  51. package/src/__tests__/integration/__fixtures__/paragraph-and-table-adf.ts +0 -132
  52. package/src/__tests__/integration/__fixtures__/resize-documents.ts +0 -1605
  53. package/src/__tests__/integration/__fixtures__/scale.ts +0 -825
  54. package/src/__tests__/integration/__fixtures__/table-and-paragraph-adf.ts +0 -130
  55. package/src/__tests__/integration/__fixtures__/table-inside-layout.ts +0 -145
  56. package/src/__tests__/integration/__fixtures__/table-with-min-width-columns-document.ts +0 -175
  57. package/src/__tests__/integration/__fixtures__/table-with-multiline-date.adf.json +0 -168
  58. package/src/__tests__/integration/__fixtures__/table-with-text-and-empty-row.ts +0 -216
  59. package/src/__tests__/integration/__snapshots__/copy-button.ts.snap +0 -423
  60. package/src/__tests__/integration/copy-button.ts +0 -179
  61. package/src/__tests__/integration/horizontal-scroll-shadows.ts +0 -197
  62. package/src/__tests__/integration/meta-arrowup-cursor-in-first-row.ts +0 -42
  63. package/src/__tests__/integration/sticky-header.ts +0 -133
  64. package/src/__tests__/integration/table-controls-selection.ts +0 -71
@@ -13,7 +13,6 @@ 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)";
17
16
  export declare const tableBorderDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-border-danger)">;
18
17
  export declare const tableToolbarDeleteColor: import("@atlaskit/theme").ThemedValue<"var(--ds-background-danger-pressed)">;
19
18
  export declare const tableCellHoverDeleteIconColor: import("@atlaskit/theme").ThemedValue<"var(--ds-icon-inverse)">;
@@ -14,7 +14,6 @@ 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;
18
17
  export declare const hoveredCell: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
19
18
  export declare const hoveredWarningCell: import("@emotion/react").SerializedStyles;
20
19
  export declare const resizeHandle: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.4.4",
3
+ "version": "5.4.6",
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": "^34.0.1",
31
31
  "@atlaskit/custom-steps": "^0.0.5",
32
- "@atlaskit/editor-common": "^76.23.0",
32
+ "@atlaskit/editor-common": "^76.24.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",
@@ -42,9 +42,9 @@
42
42
  "@atlaskit/icon": "^22.0.0",
43
43
  "@atlaskit/platform-feature-flags": "^0.2.1",
44
44
  "@atlaskit/pragmatic-drag-and-drop": "^0.24.0",
45
- "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^0.7.0",
45
+ "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^0.8.0",
46
46
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.12.0",
47
- "@atlaskit/primitives": "^1.12.0",
47
+ "@atlaskit/primitives": "^1.13.0",
48
48
  "@atlaskit/theme": "^12.6.0",
49
49
  "@atlaskit/tokens": "^1.29.0",
50
50
  "@atlaskit/tooltip": "^18.0.0",
@@ -341,8 +341,8 @@ export const TableCssClassName = {
341
341
  HOVERED_COLUMN: `${tablePrefixSelector}-hovered-column`,
342
342
  HOVERED_ROW: `${tablePrefixSelector}-hovered-row`,
343
343
  HOVERED_TABLE: `${tablePrefixSelector}-hovered-table`,
344
+ HOVERED_NO_HIGHLIGHT: `${tablePrefixSelector}-hovered-no-highlight`,
344
345
  HOVERED_CELL: `${tablePrefixSelector}-hovered-cell`,
345
- HOVERED_DISABLED_CELL: `${tablePrefixSelector}-hovered-disabled`,
346
346
  HOVERED_CELL_IN_DANGER: 'danger',
347
347
  HOVERED_CELL_ACTIVE: 'active',
348
348
  HOVERED_CELL_WARNING: `${tablePrefixSelector}-hovered-cell__warning`,
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ DragHandleDisabledIcon,
5
+ DragHandleIcon,
6
+ MinimisedHandleIcon,
7
+ } from '../icons';
8
+
9
+ type HandleIconProps = {
10
+ hasMergedCells: boolean;
11
+ direction: 'row' | 'column';
12
+ isDragMenuOpen: boolean | undefined;
13
+ isRowHandleHovered: boolean;
14
+ isColumnHandleHovered: boolean;
15
+ isCurrentRowSelected: boolean;
16
+ isCurrentColumnSelected: boolean;
17
+ dragMenuDirection: 'row' | 'column' | undefined;
18
+ };
19
+
20
+ export const HandleIconComponent = (props: HandleIconProps) => {
21
+ const {
22
+ direction,
23
+ isDragMenuOpen,
24
+ isRowHandleHovered,
25
+ isColumnHandleHovered,
26
+ hasMergedCells,
27
+ isCurrentRowSelected,
28
+ isCurrentColumnSelected,
29
+ dragMenuDirection,
30
+ } = props;
31
+ const isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
32
+ const isCurrentRowOrColumnSelected =
33
+ isCurrentRowSelected || isCurrentColumnSelected;
34
+ const isDragMenuOpenOnCurrentRowOrColumn =
35
+ isDragMenuOpen &&
36
+ dragMenuDirection === direction &&
37
+ isCurrentRowOrColumnSelected;
38
+
39
+ const showNormalHandle = hasMergedCells ? (
40
+ <DragHandleDisabledIcon />
41
+ ) : (
42
+ <DragHandleIcon />
43
+ );
44
+
45
+ // hoverred handle or open drag menu
46
+ if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
47
+ return showNormalHandle;
48
+ }
49
+
50
+ return <MinimisedHandleIcon />;
51
+ };
@@ -14,11 +14,8 @@ import type { TableDirection } from '../../types';
14
14
  import { TableCssClassName as ClassName } from '../../types';
15
15
  import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
16
16
  import { DragPreview } from '../DragPreview';
17
- import {
18
- DragHandleDisabledIcon,
19
- DragHandleIcon,
20
- MinimisedHandleIcon,
21
- } from '../icons';
17
+
18
+ import { HandleIconComponent } from './HandleIconComponent';
22
19
 
23
20
  type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
24
21
 
@@ -53,19 +50,26 @@ export const DragHandle = ({
53
50
  const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(
54
51
  null,
55
52
  );
56
- const { isDragAndDropEnabled, hoveredColumns, hoveredRows } = getPluginState(
57
- editorView.state,
58
- );
53
+ const { isDragAndDropEnabled, hoveredColumns, hoveredRows, hoveredCell } =
54
+ getPluginState(editorView.state);
59
55
 
60
- const { dragMenuDirection } = getDragDropPluginState(editorView.state);
56
+ const { dragMenuDirection, isDragMenuOpen, dragMenuIndex } =
57
+ getDragDropPluginState(editorView.state);
61
58
 
62
59
  const { selection } = editorView.state;
63
60
 
64
- const isRowHovered = direction === 'row' && hoveredRows.length > 0;
65
- const isColumnHovered = direction === 'column' && hoveredColumns.length > 0;
66
- const isRowSelected = dragMenuDirection === 'row' && direction === 'row';
67
- const isColumnSelected =
68
- dragMenuDirection === 'column' && direction === 'column';
61
+ const isCurrentRowSelected =
62
+ isDragMenuOpen &&
63
+ direction === 'row' &&
64
+ hoveredCell.rowIndex === dragMenuIndex;
65
+ const isCurrentColumnSelected =
66
+ isDragMenuOpen &&
67
+ direction === 'column' &&
68
+ hoveredCell.colIndex === dragMenuIndex;
69
+
70
+ const isRowHandleHovered = direction === 'row' && hoveredRows.length > 0;
71
+ const isColumnHandleHovered =
72
+ direction === 'column' && hoveredColumns.length > 0;
69
73
 
70
74
  const hasMergedCells = useMemo(
71
75
  () =>
@@ -75,6 +79,17 @@ export const DragHandle = ({
75
79
  [indexes, direction, selection],
76
80
  );
77
81
 
82
+ const handleIconProps = {
83
+ hasMergedCells,
84
+ direction,
85
+ isDragMenuOpen,
86
+ isRowHandleHovered,
87
+ isColumnHandleHovered,
88
+ isCurrentRowSelected,
89
+ isCurrentColumnSelected,
90
+ dragMenuDirection,
91
+ };
92
+
78
93
  useEffect(() => {
79
94
  const dragHandleDivRefCurrent = dragHandleDivRef.current;
80
95
 
@@ -118,24 +133,6 @@ export const DragHandle = ({
118
133
  hasMergedCells,
119
134
  ]);
120
135
 
121
- const handleIcon = useMemo(() => {
122
- switch (true) {
123
- // select but hover to other cells
124
- case isRowHovered:
125
- case isColumnHovered:
126
- case isRowSelected || isColumnSelected: // when handle selected
127
- return hasMergedCells ? <DragHandleDisabledIcon /> : <DragHandleIcon />;
128
- default:
129
- return <MinimisedHandleIcon />;
130
- }
131
- }, [
132
- isRowHovered,
133
- isRowSelected,
134
- isColumnHovered,
135
- isColumnSelected,
136
- hasMergedCells,
137
- ]);
138
-
139
136
  return (
140
137
  <button
141
138
  className={classnames(
@@ -156,7 +153,7 @@ export const DragHandle = ({
156
153
  onMouseUp={onMouseUp}
157
154
  onClick={onClick}
158
155
  >
159
- {handleIcon}
156
+ <HandleIconComponent {...handleIconProps} />
160
157
  {previewContainer &&
161
158
  previewWidth !== undefined &&
162
159
  previewHeight !== undefined &&
@@ -57,7 +57,6 @@ import {
57
57
  columnControlsDecoration,
58
58
  columnControlsLineMarker,
59
59
  DeleteButton,
60
- disabledCell,
61
60
  dragCornerControlButton,
62
61
  dragInsertButtonWrapper,
63
62
  floatingColumnControls,
@@ -337,7 +336,6 @@ export const tableStyles = (
337
336
  ${columnControlsLineMarker()};
338
337
  ${hoveredDeleteButton(props)};
339
338
  ${hoveredCell(props)};
340
- ${disabledCell(props)};
341
339
  ${hoveredWarningCell};
342
340
  ${getBooleanFF('platform.editor.table.drag-and-drop') && insertLine(props)};
343
341
  ${resizeHandle(props)};
@@ -1051,6 +1049,11 @@ export const tableStyles = (
1051
1049
  ${tableBorderStyles(props)};
1052
1050
  z-index: ${akEditorUnitZIndex * 100};
1053
1051
  }
1052
+
1053
+ &.${ClassName.HOVERED_NO_HIGHLIGHT}.${ClassName.HOVERED_CELL_IN_DANGER}::after {
1054
+ ${tableBorderStyles(props)};
1055
+ z-index: ${akEditorUnitZIndex * 100};
1056
+ }
1054
1057
  }
1055
1058
  }
1056
1059
  ${tableRowControlStyles()}
@@ -98,11 +98,6 @@ export const tableCellDeleteColor = themed({
98
98
  dark: token('color.blanket.danger', akEditorTableCellBlanketDeleted),
99
99
  });
100
100
 
101
- export const tableCellDisabledColor = token(
102
- 'color.background.accent.gray.subtler.hovered',
103
- '#C1C7D0',
104
- );
105
-
106
101
  export const tableBorderDeleteColor = themed({
107
102
  light: token('color.border.danger', R400),
108
103
  dark: token('color.border.danger', R400),
@@ -32,7 +32,6 @@ import {
32
32
  tableBorderDeleteColor,
33
33
  tableBorderSelectedColor,
34
34
  tableCellDeleteColor,
35
- tableCellDisabledColor,
36
35
  tableCellHoverDeleteIconBackground,
37
36
  tableCellHoverDeleteIconColor,
38
37
  tableCellSelectedDeleteIconBackground,
@@ -737,21 +736,23 @@ export const hoveredDeleteButton = (props: ThemeProps) => css`
737
736
  .${ClassName.SELECTED_CELL}::after {
738
737
  background: ${tableCellDeleteColor(props)};
739
738
  }
740
- }
741
- `;
742
739
 
743
- export const disabledCell = (props: ThemeProps) => css`
744
- :not(.${ClassName.IS_RESIZING})
745
- .${ClassName.TABLE_CONTAINER}:not(.${ClassName.HOVERED_DELETE_BUTTON}) {
746
- .${ClassName.HOVERED_CELL}.${ClassName.HOVERED_DISABLED_CELL} {
747
- position: relative;
748
- border: 1px solid ${tableCellDisabledColor};
749
- }
750
- .${ClassName.HOVERED_CELL}.${ClassName.HOVERED_DISABLED_CELL}::after {
751
- border: 1px solid ${tableCellDisabledColor};
740
+ .${ClassName.TABLE_NODE_WRAPPER} > table {
741
+ td.${ClassName.HOVERED_NO_HIGHLIGHT}::after {
742
+ background: ${tableCellDeleteColor(props)};
743
+ border: 1px solid ${tableBorderDeleteColor(props)};
744
+ }
745
+ th.${ClassName.HOVERED_NO_HIGHLIGHT} {
746
+ background-color: unset;
747
+ }
748
+ th.${ClassName.HOVERED_NO_HIGHLIGHT}::after {
749
+ background: ${tableCellDeleteColor(props)};
750
+ border: 1px solid ${tableBorderDeleteColor(props)};
751
+ }
752
752
  }
753
753
  }
754
754
  `;
755
+
755
756
  export const hoveredCell = (props: ThemeProps) => css`
756
757
  :not(.${ClassName.IS_RESIZING})
757
758
  .${ClassName.TABLE_CONTAINER}:not(.${ClassName.HOVERED_DELETE_BUTTON}) {
@@ -759,6 +760,10 @@ export const hoveredCell = (props: ThemeProps) => css`
759
760
  position: relative;
760
761
  border: 1px solid ${tableBorderSelectedColor(props)};
761
762
  }
763
+ .${ClassName.HOVERED_CELL}.${ClassName.HOVERED_NO_HIGHLIGHT} {
764
+ position: relative;
765
+ border: 1px solid ${tableBorderColor(props)};
766
+ }
762
767
  }
763
768
  `;
764
769
 
@@ -28,8 +28,6 @@ import type { Cell, CellColumnPositioning } from '../types';
28
28
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
29
29
  import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
30
30
 
31
- import { hasMergedCellsInColumn, hasMergedCellsInRow } from './merged-cells';
32
-
33
31
  const filterDecorationByKey = (
34
32
  key: TableDecorations,
35
33
  decorationSet: DecorationSet,
@@ -99,13 +97,6 @@ export const createControlsHoverDecoration = (
99
97
 
100
98
  let updatedCells: number[] = cells.map((x) => x.pos);
101
99
 
102
- const hasMergedCells =
103
- type === 'row'
104
- ? hasMergedCellsInRow(hoveredIndexes[0])(tr.selection)
105
- : hasMergedCellsInColumn(hoveredIndexes[0])(tr.selection);
106
-
107
- let disabled: boolean = hasMergedCells;
108
-
109
100
  // ED-15246 fixed trello card table overflow issue
110
101
  // If columns / rows have been merged the hovered selection is different to the actual selection
111
102
  // So If the table cells are in danger we want to create a "rectangle" selection
@@ -151,17 +142,21 @@ export const createControlsHoverDecoration = (
151
142
  if (selected) {
152
143
  classes.push(ClassName.SELECTED_CELL);
153
144
  }
154
- if (isDragAndDropEnable && disabled) {
155
- classes.push(ClassName.HOVERED_DISABLED_CELL);
156
- }
157
145
 
158
- classes.push(
159
- type === 'column'
160
- ? ClassName.HOVERED_COLUMN
161
- : type === 'row'
162
- ? ClassName.HOVERED_ROW
163
- : ClassName.HOVERED_TABLE,
164
- );
146
+ if (isDragAndDropEnable) {
147
+ if (type === 'column' || type === 'row') {
148
+ classes.pop();
149
+ classes.push(ClassName.HOVERED_NO_HIGHLIGHT);
150
+ }
151
+ } else {
152
+ classes.push(
153
+ type === 'column'
154
+ ? ClassName.HOVERED_COLUMN
155
+ : type === 'row'
156
+ ? ClassName.HOVERED_ROW
157
+ : ClassName.HOVERED_TABLE,
158
+ );
159
+ }
165
160
 
166
161
  let key: TableDecorations;
167
162
  switch (type) {
package/tsconfig.dev.json CHANGED
@@ -108,9 +108,6 @@
108
108
  {
109
109
  "path": "../../../build/test-tooling/visual-regression/tsconfig.app.json"
110
110
  },
111
- {
112
- "path": "../../../build/test-tooling/webdriver-runner/tsconfig.app.json"
113
- },
114
111
  {
115
112
  "path": "../../platform/feature-flags-test-utils/tsconfig.app.json"
116
113
  }