@atlaskit/editor-plugin-table 5.3.26 → 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 (63) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/plugins/table/commands/hover.js +9 -3
  3. package/dist/cjs/plugins/table/types.js +3 -0
  4. package/dist/cjs/plugins/table/ui/DragHandle/index.js +16 -4
  5. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  6. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  7. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  8. package/dist/cjs/plugins/table/ui/consts.js +2 -1
  9. package/dist/cjs/plugins/table/ui/icons/DragHandleDisabledIcon.js +45 -0
  10. package/dist/cjs/plugins/table/ui/icons/index.js +7 -0
  11. package/dist/cjs/plugins/table/ui/ui-styles.js +12 -9
  12. package/dist/cjs/plugins/table/utils/decoration.js +7 -1
  13. package/dist/es2019/plugins/table/commands/hover.js +13 -4
  14. package/dist/es2019/plugins/table/types.js +3 -0
  15. package/dist/es2019/plugins/table/ui/DragHandle/index.js +19 -6
  16. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  17. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  18. package/dist/es2019/plugins/table/ui/common-styles.js +30 -38
  19. package/dist/es2019/plugins/table/ui/consts.js +1 -0
  20. package/dist/es2019/plugins/table/ui/icons/DragHandleDisabledIcon.js +37 -0
  21. package/dist/es2019/plugins/table/ui/icons/index.js +1 -0
  22. package/dist/es2019/plugins/table/ui/ui-styles.js +13 -1
  23. package/dist/es2019/plugins/table/utils/decoration.js +7 -1
  24. package/dist/esm/plugins/table/commands/hover.js +10 -4
  25. package/dist/esm/plugins/table/types.js +3 -0
  26. package/dist/esm/plugins/table/ui/DragHandle/index.js +18 -6
  27. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  28. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  29. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  30. package/dist/esm/plugins/table/ui/consts.js +1 -0
  31. package/dist/esm/plugins/table/ui/icons/DragHandleDisabledIcon.js +38 -0
  32. package/dist/esm/plugins/table/ui/icons/index.js +1 -0
  33. package/dist/esm/plugins/table/ui/ui-styles.js +12 -9
  34. package/dist/esm/plugins/table/utils/decoration.js +7 -1
  35. package/dist/types/plugins/table/types.d.ts +3 -0
  36. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +3 -1
  37. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  38. package/dist/types/plugins/table/ui/icons/DragHandleDisabledIcon.d.ts +6 -0
  39. package/dist/types/plugins/table/ui/icons/index.d.ts +1 -0
  40. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
  41. package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
  42. package/dist/types/plugins/table/utils/selection.d.ts +2 -2
  43. package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
  44. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +3 -1
  45. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  46. package/dist/types-ts4.5/plugins/table/ui/icons/DragHandleDisabledIcon.d.ts +6 -0
  47. package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +1 -0
  48. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
  49. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +1 -1
  50. package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +2 -2
  51. package/package.json +2 -2
  52. package/src/plugins/table/commands/hover.ts +12 -1
  53. package/src/plugins/table/types.ts +4 -0
  54. package/src/plugins/table/ui/DragHandle/index.tsx +36 -5
  55. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -0
  56. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +1 -0
  57. package/src/plugins/table/ui/common-styles.ts +33 -40
  58. package/src/plugins/table/ui/consts.ts +6 -0
  59. package/src/plugins/table/ui/icons/DragHandleDisabledIcon.tsx +53 -0
  60. package/src/plugins/table/ui/icons/index.ts +1 -0
  61. package/src/plugins/table/ui/ui-styles.ts +13 -0
  62. package/src/plugins/table/utils/decoration.ts +14 -0
  63. package/src/plugins/table/utils/selection.ts +6 -2
@@ -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),
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+
3
+ import { token } from '@atlaskit/tokens';
4
+
5
+ interface DragHandleDisabledIconProps {
6
+ style?: React.CSSProperties;
7
+ }
8
+
9
+ export const DragHandleDisabledIcon = ({
10
+ style,
11
+ }: DragHandleDisabledIconProps) => (
12
+ <svg
13
+ width="24"
14
+ height="16"
15
+ viewBox="0 0 24 16"
16
+ fill="none"
17
+ xmlns="http://www.w3.org/2000/svg"
18
+ style={style}
19
+ >
20
+ <rect
21
+ width="24"
22
+ height="16"
23
+ rx="4"
24
+ fill={token('color.background.accent.gray.subtlest', 'Neutral200')}
25
+ />
26
+ <g>
27
+ <rect
28
+ x="7"
29
+ y="4"
30
+ width="2"
31
+ height="8"
32
+ rx="1"
33
+ fill={token('color.icon.disabled', '#091E424F')}
34
+ />
35
+ <rect
36
+ x="11"
37
+ y="4"
38
+ width="2"
39
+ height="8"
40
+ rx="1"
41
+ fill={token('color.icon.disabled', '#091E424F')}
42
+ />
43
+ <rect
44
+ x="15"
45
+ y="4"
46
+ width="2"
47
+ height="8"
48
+ rx="1"
49
+ fill={token('color.icon.disabled', '#091E424F')}
50
+ />
51
+ </g>
52
+ </svg>
53
+ );
@@ -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';
@@ -31,6 +31,7 @@ import {
31
31
  tableBorderDeleteColor,
32
32
  tableBorderSelectedColor,
33
33
  tableCellDeleteColor,
34
+ tableCellDisabledColor,
34
35
  tableCellHoverDeleteIconBackground,
35
36
  tableCellHoverDeleteIconColor,
36
37
  tableCellSelectedDeleteIconBackground,
@@ -707,6 +708,18 @@ export const hoveredDeleteButton = (props: ThemeProps) => css`
707
708
  }
708
709
  `;
709
710
 
711
+ export const disabledCell = (props: ThemeProps) => css`
712
+ :not(.${ClassName.IS_RESIZING})
713
+ .${ClassName.TABLE_CONTAINER}:not(.${ClassName.HOVERED_DELETE_BUTTON}) {
714
+ .${ClassName.HOVERED_CELL}.${ClassName.HOVERED_DISABLED_CELL} {
715
+ position: relative;
716
+ border: 1px solid ${tableCellDisabledColor};
717
+ }
718
+ .${ClassName.HOVERED_CELL}.${ClassName.HOVERED_DISABLED_CELL}::after {
719
+ border: 1px solid ${tableCellDisabledColor};
720
+ }
721
+ }
722
+ `;
710
723
  export const hoveredCell = (props: ThemeProps) => css`
711
724
  :not(.${ClassName.IS_RESIZING})
712
725
  .${ClassName.TABLE_CONTAINER}:not(.${ClassName.HOVERED_DELETE_BUTTON}) {
@@ -28,6 +28,8 @@ 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
+
31
33
  const filterDecorationByKey = (
32
34
  key: TableDecorations,
33
35
  decorationSet: DecorationSet,
@@ -66,6 +68,8 @@ export const createControlsHoverDecoration = (
66
68
  cells: Cell[],
67
69
  type: 'row' | 'column' | 'table',
68
70
  tr: Transaction | ReadonlyTransaction,
71
+ isDragAndDropEnable: boolean | undefined,
72
+ hoveredIndexes: number[],
69
73
  danger?: boolean,
70
74
  selected?: boolean,
71
75
  ): Decoration[] => {
@@ -95,6 +99,13 @@ export const createControlsHoverDecoration = (
95
99
 
96
100
  let updatedCells: number[] = cells.map((x) => x.pos);
97
101
 
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
+
98
109
  // ED-15246 fixed trello card table overflow issue
99
110
  // If columns / rows have been merged the hovered selection is different to the actual selection
100
111
  // So If the table cells are in danger we want to create a "rectangle" selection
@@ -140,6 +151,9 @@ export const createControlsHoverDecoration = (
140
151
  if (selected) {
141
152
  classes.push(ClassName.SELECTED_CELL);
142
153
  }
154
+ if (isDragAndDropEnable && disabled) {
155
+ classes.push(ClassName.HOVERED_DISABLED_CELL);
156
+ }
143
157
 
144
158
  classes.push(
145
159
  type === 'column'
@@ -1,6 +1,10 @@
1
- import { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
1
+ import type {
2
+ Selection,
3
+ Transaction,
4
+ } from '@atlaskit/editor-prosemirror/state';
2
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
- import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
6
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
7
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
4
8
  import {
5
9
  findTable,
6
10
  getSelectionRangeInColumn,