@atlaskit/editor-plugin-table 5.7.9 → 5.8.0

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 (105) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/commands/column-resize.js +155 -0
  4. package/dist/cjs/commands/go-to-next-cell.js +15 -0
  5. package/dist/cjs/commands/selection.js +16 -3
  6. package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -1
  7. package/dist/cjs/plugin.js +2 -1
  8. package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -3
  9. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +2 -1
  10. package/dist/cjs/pm-plugins/keymap.js +9 -0
  11. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +18 -7
  12. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +6 -0
  13. package/dist/cjs/types.js +8 -1
  14. package/dist/cjs/ui/DragHandle/index.js +1 -1
  15. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +187 -17
  16. package/dist/cjs/ui/FloatingDragMenu/index.js +4 -2
  17. package/dist/cjs/ui/FloatingDragMenu/styles.js +19 -0
  18. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
  19. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
  20. package/dist/cjs/ui/consts.js +2 -1
  21. package/dist/cjs/ui/ui-styles.js +6 -2
  22. package/dist/cjs/utils/decoration.js +14 -4
  23. package/dist/es2019/commands/column-resize.js +149 -0
  24. package/dist/es2019/commands/go-to-next-cell.js +13 -0
  25. package/dist/es2019/commands/selection.js +16 -3
  26. package/dist/es2019/nodeviews/ExternalDropTargets.js +2 -1
  27. package/dist/es2019/plugin.js +2 -1
  28. package/dist/es2019/pm-plugins/drag-and-drop/commands.js +3 -3
  29. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +2 -1
  30. package/dist/es2019/pm-plugins/keymap.js +10 -1
  31. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +19 -8
  32. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
  33. package/dist/es2019/types.js +8 -1
  34. package/dist/es2019/ui/DragHandle/index.js +1 -1
  35. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +177 -7
  36. package/dist/es2019/ui/FloatingDragMenu/index.js +4 -2
  37. package/dist/es2019/ui/FloatingDragMenu/styles.js +62 -0
  38. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
  39. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
  40. package/dist/es2019/ui/consts.js +2 -1
  41. package/dist/es2019/ui/ui-styles.js +108 -65
  42. package/dist/es2019/utils/decoration.js +14 -4
  43. package/dist/esm/commands/column-resize.js +149 -0
  44. package/dist/esm/commands/go-to-next-cell.js +15 -0
  45. package/dist/esm/commands/selection.js +16 -3
  46. package/dist/esm/nodeviews/ExternalDropTargets.js +2 -1
  47. package/dist/esm/plugin.js +2 -1
  48. package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -3
  49. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +2 -1
  50. package/dist/esm/pm-plugins/keymap.js +10 -1
  51. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +19 -8
  52. package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
  53. package/dist/esm/types.js +8 -1
  54. package/dist/esm/ui/DragHandle/index.js +1 -1
  55. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +177 -7
  56. package/dist/esm/ui/FloatingDragMenu/index.js +4 -2
  57. package/dist/esm/ui/FloatingDragMenu/styles.js +12 -0
  58. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
  59. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
  60. package/dist/esm/ui/consts.js +2 -1
  61. package/dist/esm/ui/ui-styles.js +7 -3
  62. package/dist/esm/utils/decoration.js +14 -4
  63. package/dist/types/commands/column-resize.d.ts +5 -0
  64. package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  65. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  66. package/dist/types/types.d.ts +7 -0
  67. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
  68. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
  69. package/dist/types/ui/FloatingDragMenu/styles.d.ts +3 -0
  70. package/dist/types/ui/consts.d.ts +1 -1
  71. package/dist/types/utils/decoration.d.ts +2 -2
  72. package/dist/types-ts4.5/commands/column-resize.d.ts +5 -0
  73. package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  74. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  75. package/dist/types-ts4.5/types.d.ts +7 -0
  76. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
  77. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
  78. package/dist/types-ts4.5/ui/FloatingDragMenu/styles.d.ts +3 -0
  79. package/dist/types-ts4.5/ui/consts.d.ts +1 -1
  80. package/dist/types-ts4.5/utils/decoration.d.ts +2 -2
  81. package/package.json +8 -4
  82. package/src/__tests__/unit/analytics.ts +5 -1
  83. package/src/__tests__/unit/ui/FloatingDragMenu.tsx +295 -0
  84. package/src/__tests__/unit/ui/RowDragControls.tsx +5 -4
  85. package/src/commands/column-resize.ts +257 -0
  86. package/src/commands/go-to-next-cell.ts +21 -0
  87. package/src/commands/selection.ts +19 -2
  88. package/src/nodeviews/ExternalDropTargets.tsx +1 -0
  89. package/src/plugin.tsx +1 -0
  90. package/src/pm-plugins/drag-and-drop/commands.ts +3 -2
  91. package/src/pm-plugins/drag-and-drop/plugin.ts +10 -4
  92. package/src/pm-plugins/keymap.ts +35 -0
  93. package/src/pm-plugins/table-resizing/event-handlers.ts +33 -21
  94. package/src/pm-plugins/table-resizing/utils/index.ts +1 -0
  95. package/src/types.ts +9 -0
  96. package/src/ui/DragHandle/index.tsx +1 -1
  97. package/src/ui/FloatingDragMenu/DragMenu.tsx +226 -7
  98. package/src/ui/FloatingDragMenu/index.tsx +4 -1
  99. package/src/ui/FloatingDragMenu/styles.ts +71 -0
  100. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +35 -37
  101. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +33 -33
  102. package/src/ui/consts.ts +6 -1
  103. package/src/ui/ui-styles.ts +115 -64
  104. package/src/utils/decoration.ts +27 -8
  105. package/tsconfig.app.json +3 -0
@@ -7,6 +7,7 @@ import {
7
7
  } from '@atlaskit/editor-common/styles';
8
8
  import {
9
9
  akEditorShadowZIndex,
10
+ akEditorTableBorder,
10
11
  akEditorTableNumberColumnWidth,
11
12
  akEditorUnitZIndex,
12
13
  } from '@atlaskit/editor-shared-styles';
@@ -897,116 +898,166 @@ export const resizeHandle = () => css`
897
898
  `;
898
899
 
899
900
  // Drag and Drop: drop target insert line
901
+ const tableCellColumnInsertLineStyles = css`
902
+ content: ' ';
903
+ position: absolute;
904
+ height: calc(100% + ${tableCellBorderWidth * 2}px);
905
+ width: ${insertLineWidth}px;
906
+ z-index: ${columnControlsZIndex * 2};
907
+ `;
908
+
909
+ const tableCellRowInsertLineStyles = css`
910
+ content: ' ';
911
+ position: absolute;
912
+ left: ${token('space.negative.025', '-2px')};
913
+ height: ${insertLineWidth}px;
914
+ width: calc(100% + ${tableCellBorderWidth * 2}px);
915
+ z-index: ${columnControlsZIndex * 2};
916
+ `;
917
+
918
+ const insertLineActiveColor = css`
919
+ background-color: ${tableBorderSelectedColor};
920
+ `;
921
+
922
+ const insertLineInactiveColor = css`
923
+ background-color: ${token(
924
+ 'color.background.accent.gray.subtler',
925
+ akEditorTableBorder,
926
+ )};
927
+ `;
928
+
900
929
  export const insertLine = () => css`
901
930
  .${ClassName.TABLE_CONTAINER} {
902
931
  td.${ClassName.WITH_FIRST_COLUMN_INSERT_LINE}::before {
903
- content: ' ';
904
- position: absolute;
932
+ ${tableCellColumnInsertLineStyles}
905
933
  left: -1px;
906
934
  top: -1px;
907
- width: ${insertLineWidth}px;
908
- height: calc(100% + ${tableCellBorderWidth * 2}px);
909
- background-color: ${tableBorderSelectedColor};
910
- z-index: ${columnControlsZIndex * 2};
935
+ ${insertLineActiveColor}
936
+ }
937
+
938
+ td.${ClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE}::before {
939
+ ${tableCellColumnInsertLineStyles}
940
+ left: -1px;
941
+ top: -1px;
942
+ ${insertLineInactiveColor}
911
943
  }
912
944
 
913
945
  th.${ClassName.WITH_FIRST_COLUMN_INSERT_LINE}::before {
914
- content: ' ';
946
+ ${tableCellColumnInsertLineStyles}
915
947
  left: -1px;
916
- position: absolute;
917
- width: ${insertLineWidth}px;
918
- height: calc(100% + ${tableCellBorderWidth * 2}px);
919
- background-color: ${tableBorderSelectedColor};
920
- z-index: ${columnControlsZIndex * 2};
921
948
  top: -${tableCellBorderWidth}px;
949
+ ${insertLineActiveColor}
950
+ }
951
+
952
+ th.${ClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE}::before {
953
+ ${tableCellColumnInsertLineStyles}
954
+ left: -1px;
955
+ top: -${tableCellBorderWidth}px;
956
+ ${insertLineInactiveColor}
922
957
  }
923
958
 
924
959
  td.${ClassName.WITH_COLUMN_INSERT_LINE}::before {
925
- content: ' ';
926
- position: absolute;
960
+ ${tableCellColumnInsertLineStyles}
927
961
  left: ${token('space.negative.025', '-2px')};
928
962
  top: -1px;
929
- width: ${insertLineWidth}px;
930
- height: calc(100% + ${tableCellBorderWidth * 2}px);
931
- background-color: ${tableBorderSelectedColor};
932
- z-index: ${columnControlsZIndex * 2};
963
+ ${insertLineActiveColor}
964
+ }
965
+
966
+ td.${ClassName.WITH_COLUMN_INSERT_LINE_INACTIVE}::before {
967
+ ${tableCellColumnInsertLineStyles}
968
+ left: ${token('space.negative.025', '-2px')};
969
+ top: -1px;
970
+ ${insertLineInactiveColor}
933
971
  }
934
972
 
935
973
  th.${ClassName.WITH_COLUMN_INSERT_LINE}::before {
936
- content: ' ';
974
+ ${tableCellColumnInsertLineStyles}
937
975
  left: ${token('space.negative.025', '-2px')};
938
- position: absolute;
939
- width: ${insertLineWidth}px;
940
- height: calc(100% + ${tableCellBorderWidth * 2}px);
941
- background-color: ${tableBorderSelectedColor};
942
- z-index: ${columnControlsZIndex * 2};
943
976
  top: -${tableCellBorderWidth}px;
977
+ ${insertLineActiveColor}
978
+ }
979
+
980
+ th.${ClassName.WITH_COLUMN_INSERT_LINE_INACTIVE}::before {
981
+ ${tableCellColumnInsertLineStyles}
982
+ left: ${token('space.negative.025', '-2px')};
983
+ top: -${tableCellBorderWidth}px;
984
+ ${insertLineInactiveColor}
944
985
  }
945
986
 
946
987
  td.${ClassName.WITH_LAST_COLUMN_INSERT_LINE}::before {
947
- content: ' ';
948
- position: absolute;
988
+ ${tableCellColumnInsertLineStyles}
949
989
  right: -1px;
950
990
  top: -1px;
951
- width: ${insertLineWidth}px;
952
- height: calc(100% + ${tableCellBorderWidth * 2}px);
953
- background-color: ${tableBorderSelectedColor};
954
- z-index: ${columnControlsZIndex * 2};
991
+ ${insertLineActiveColor}
992
+ }
993
+
994
+ td.${ClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE}::before {
995
+ ${tableCellColumnInsertLineStyles}
996
+ right: -1px;
997
+ top: -1px;
998
+ ${insertLineInactiveColor}
955
999
  }
956
1000
 
957
1001
  th.${ClassName.WITH_LAST_COLUMN_INSERT_LINE}::before {
958
- content: ' ';
1002
+ ${tableCellColumnInsertLineStyles}
959
1003
  right: -1px;
960
- position: absolute;
961
- width: ${insertLineWidth}px;
962
- height: calc(100% + ${tableCellBorderWidth * 2}px);
963
- background-color: ${tableBorderSelectedColor};
964
- z-index: ${columnControlsZIndex * 2};
965
1004
  top: -${tableCellBorderWidth}px;
1005
+ ${insertLineActiveColor}
1006
+ }
1007
+
1008
+ th.${ClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE}::before {
1009
+ ${tableCellColumnInsertLineStyles}
1010
+ right: -1px;
1011
+ top: -${tableCellBorderWidth}px;
1012
+ ${insertLineInactiveColor}
966
1013
  }
967
1014
 
968
1015
  td.${ClassName.WITH_ROW_INSERT_LINE}::before {
969
- content: ' ';
970
- position: absolute;
971
- left: ${token('space.negative.025', '-2px')};
1016
+ ${tableCellRowInsertLineStyles}
972
1017
  top: -1px;
973
- height: ${insertLineWidth}px;
974
- width: calc(100% + ${tableCellBorderWidth * 2}px);
975
- background-color: ${tableBorderSelectedColor};
976
- z-index: ${columnControlsZIndex * 2};
1018
+ ${insertLineActiveColor}
1019
+ }
1020
+
1021
+ td.${ClassName.WITH_ROW_INSERT_LINE_INACTIVE}::before {
1022
+ ${tableCellRowInsertLineStyles}
1023
+ top: -1px;
1024
+ ${insertLineInactiveColor}
977
1025
  }
978
1026
 
979
1027
  th.${ClassName.WITH_ROW_INSERT_LINE}::before {
980
- content: ' ';
981
- left: ${token('space.negative.025', '-2px')};
982
- position: absolute;
983
- height: ${insertLineWidth}px;
984
- width: calc(100% + ${tableCellBorderWidth * 2}px);
985
- background-color: ${tableBorderSelectedColor};
986
- z-index: ${columnControlsZIndex * 2};
1028
+ ${tableCellRowInsertLineStyles}
1029
+ top: -1px;
1030
+ ${insertLineActiveColor}
1031
+ }
1032
+
1033
+ th.${ClassName.WITH_ROW_INSERT_LINE_INACTIVE}::before {
1034
+ ${tableCellRowInsertLineStyles}
987
1035
  top: -1px;
1036
+ ${insertLineInactiveColor}
988
1037
  }
989
1038
 
990
1039
  td.${ClassName.WITH_LAST_ROW_INSERT_LINE}::before {
991
- content: ' ';
992
- position: absolute;
993
- left: ${token('space.negative.025', '-2px')};
1040
+ ${tableCellRowInsertLineStyles}
994
1041
  bottom: 0;
995
- height: ${insertLineWidth}px;
996
- width: calc(100% + 2px);
997
- background-color: ${tableBorderSelectedColor};
998
- z-index: ${columnControlsZIndex * 2};
1042
+ ${insertLineActiveColor}
1043
+ }
1044
+
1045
+ td.${ClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE}::before {
1046
+ ${tableCellRowInsertLineStyles}
1047
+ bottom: 0;
1048
+ ${insertLineInactiveColor}
999
1049
  }
1000
1050
 
1001
1051
  th.${ClassName.WITH_LAST_ROW_INSERT_LINE}::before {
1002
- content: ' ';
1003
- left: ${token('space.negative.025', '-2px')};
1052
+ ${tableCellRowInsertLineStyles}
1004
1053
  bottom: 0;
1005
- position: absolute;
1006
- height: ${insertLineWidth}px;
1007
- width: calc(100% + ${tableCellBorderWidth * 2}px);
1008
- background-color: ${tableBorderSelectedColor};
1009
- z-index: ${columnControlsZIndex * 2};
1054
+ ${insertLineActiveColor}
1055
+ }
1056
+
1057
+ th.${ClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE}::before {
1058
+ ${tableCellRowInsertLineStyles}
1059
+ bottom: 0;
1060
+ ${insertLineInactiveColor}
1010
1061
  }
1011
1062
  }
1012
1063
  `;
@@ -593,6 +593,7 @@ export const createColumnLineResize = (
593
593
  export const createColumnInsertLine = (
594
594
  columnIndex: number,
595
595
  selection: Selection,
596
+ hasMergedCells: boolean,
596
597
  ): Decoration[] => {
597
598
  const table = findTable(selection);
598
599
  if (!table) {
@@ -606,11 +607,21 @@ export const createColumnInsertLine = (
606
607
  if (isLastColumn) {
607
608
  columnIndex -= 1;
608
609
  }
609
- const decorationClassName = isFirstColumn
610
- ? ClassName.WITH_FIRST_COLUMN_INSERT_LINE
611
- : isLastColumn
612
- ? ClassName.WITH_LAST_COLUMN_INSERT_LINE
613
- : ClassName.WITH_COLUMN_INSERT_LINE;
610
+
611
+ let decorationClassName: string;
612
+ if (hasMergedCells) {
613
+ decorationClassName = isFirstColumn
614
+ ? ClassName.WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE
615
+ : isLastColumn
616
+ ? ClassName.WITH_LAST_COLUMN_INSERT_LINE_INACTIVE
617
+ : ClassName.WITH_COLUMN_INSERT_LINE_INACTIVE;
618
+ } else {
619
+ decorationClassName = isFirstColumn
620
+ ? ClassName.WITH_FIRST_COLUMN_INSERT_LINE
621
+ : isLastColumn
622
+ ? ClassName.WITH_LAST_COLUMN_INSERT_LINE
623
+ : ClassName.WITH_COLUMN_INSERT_LINE;
624
+ }
614
625
 
615
626
  const cellPositions = makeArray(map.height)
616
627
  .map((rowIndex) => map.map[map.width * rowIndex + columnIndex])
@@ -650,6 +661,7 @@ export const createColumnInsertLine = (
650
661
  export const createRowInsertLine = (
651
662
  rowIndex: number,
652
663
  selection: Selection,
664
+ hasMergedCells: boolean,
653
665
  ): Decoration[] => {
654
666
  const table = findTable(selection);
655
667
  if (!table) {
@@ -667,9 +679,16 @@ export const createRowInsertLine = (
667
679
  return [];
668
680
  }
669
681
 
670
- const decorationClassName = isLastRow
671
- ? ClassName.WITH_LAST_ROW_INSERT_LINE
672
- : ClassName.WITH_ROW_INSERT_LINE;
682
+ let decorationClassName: string;
683
+ if (hasMergedCells) {
684
+ decorationClassName = isLastRow
685
+ ? ClassName.WITH_LAST_ROW_INSERT_LINE_INACTIVE
686
+ : ClassName.WITH_ROW_INSERT_LINE_INACTIVE;
687
+ } else {
688
+ decorationClassName = isLastRow
689
+ ? ClassName.WITH_LAST_ROW_INSERT_LINE
690
+ : ClassName.WITH_ROW_INSERT_LINE;
691
+ }
673
692
 
674
693
  return cells
675
694
  .map((cell, index) => {
package/tsconfig.app.json CHANGED
@@ -84,6 +84,9 @@
84
84
  {
85
85
  "path": "../../design-system/theme/tsconfig.app.json"
86
86
  },
87
+ {
88
+ "path": "../../design-system/toggle/tsconfig.app.json"
89
+ },
87
90
  {
88
91
  "path": "../../design-system/tokens/tsconfig.app.json"
89
92
  },