@atlaskit/editor-plugin-table 5.7.8 → 5.7.10
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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/cjs/types.js +6 -1
- package/dist/cjs/ui/DragHandle/index.js +5 -5
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/cjs/ui/ui-styles.js +6 -2
- package/dist/cjs/utils/decoration.js +14 -4
- package/dist/es2019/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/es2019/types.js +6 -1
- package/dist/es2019/ui/DragHandle/index.js +5 -5
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/es2019/ui/ui-styles.js +108 -65
- package/dist/es2019/utils/decoration.js +14 -4
- package/dist/esm/nodeviews/ExternalDropTargets.js +2 -1
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/esm/types.js +6 -1
- package/dist/esm/ui/DragHandle/index.js +5 -5
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/esm/ui/ui-styles.js +7 -3
- package/dist/esm/utils/decoration.js +14 -4
- package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types/types.d.ts +5 -0
- package/dist/types/utils/decoration.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +5 -0
- package/dist/types-ts4.5/utils/decoration.d.ts +2 -2
- package/package.json +4 -5
- package/src/__tests__/unit/analytics.ts +5 -1
- package/src/__tests__/unit/ui/RowDragControls.tsx +5 -4
- package/src/nodeviews/ExternalDropTargets.tsx +1 -0
- package/src/pm-plugins/drag-and-drop/commands.ts +3 -2
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -4
- package/src/types.ts +6 -0
- package/src/ui/DragHandle/index.tsx +3 -3
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +35 -37
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +33 -33
- package/src/ui/ui-styles.ts +115 -64
- package/src/utils/decoration.ts +27 -8
|
@@ -228,39 +228,39 @@ const DragControlsComponent = ({
|
|
|
228
228
|
: rowIndexes;
|
|
229
229
|
|
|
230
230
|
return (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
231
|
+
<div
|
|
232
|
+
key={type}
|
|
233
|
+
style={{
|
|
234
|
+
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
235
|
+
gridColumn: '2',
|
|
236
|
+
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
237
|
+
width: '9px',
|
|
238
|
+
position: 'relative',
|
|
239
|
+
right: '-0.5px',
|
|
240
|
+
}}
|
|
241
|
+
data-testid={`table-floating-row-${
|
|
242
|
+
isSelecting ? selectedRowIndexes[0] : rowIndex
|
|
243
|
+
}-drag-handle`}
|
|
244
|
+
>
|
|
245
|
+
<DragHandle
|
|
246
|
+
isDragMenuTarget={!isHover}
|
|
247
|
+
direction="row"
|
|
248
|
+
tableLocalId={currentNodeLocalId}
|
|
249
|
+
indexes={indexes}
|
|
250
|
+
forceDefaultHandle={isHover ? false : isRowsSelected}
|
|
251
|
+
previewWidth={tableWidth}
|
|
252
|
+
previewHeight={rowHeights[rowIndex!]}
|
|
253
|
+
appearance={
|
|
254
|
+
isSelecting ? currentSelectionAppearance : hoveredAppearance
|
|
255
|
+
}
|
|
256
|
+
onClick={handleClick}
|
|
257
|
+
onMouseOver={handleMouseOver}
|
|
258
|
+
onMouseOut={handleMouseOut}
|
|
259
|
+
onMouseUp={onMouseUp}
|
|
260
|
+
editorView={editorView}
|
|
261
|
+
canDrag={canDrag}
|
|
262
|
+
/>
|
|
263
|
+
</div>
|
|
264
264
|
);
|
|
265
265
|
};
|
|
266
266
|
|
package/src/ui/ui-styles.ts
CHANGED
|
@@ -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
|
-
|
|
904
|
-
position: absolute;
|
|
932
|
+
${tableCellColumnInsertLineStyles}
|
|
905
933
|
left: -1px;
|
|
906
934
|
top: -1px;
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
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
|
-
|
|
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
|
-
|
|
926
|
-
position: absolute;
|
|
960
|
+
${tableCellColumnInsertLineStyles}
|
|
927
961
|
left: ${token('space.negative.025', '-2px')};
|
|
928
962
|
top: -1px;
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
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
|
-
|
|
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
|
-
|
|
948
|
-
position: absolute;
|
|
988
|
+
${tableCellColumnInsertLineStyles}
|
|
949
989
|
right: -1px;
|
|
950
990
|
top: -1px;
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
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
|
-
|
|
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
|
-
|
|
970
|
-
position: absolute;
|
|
971
|
-
left: ${token('space.negative.025', '-2px')};
|
|
1016
|
+
${tableCellRowInsertLineStyles}
|
|
972
1017
|
top: -1px;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
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
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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
|
-
|
|
992
|
-
position: absolute;
|
|
993
|
-
left: ${token('space.negative.025', '-2px')};
|
|
1040
|
+
${tableCellRowInsertLineStyles}
|
|
994
1041
|
bottom: 0;
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
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
|
-
|
|
1003
|
-
left: ${token('space.negative.025', '-2px')};
|
|
1052
|
+
${tableCellRowInsertLineStyles}
|
|
1004
1053
|
bottom: 0;
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
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
|
`;
|
package/src/utils/decoration.ts
CHANGED
|
@@ -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
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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
|
-
|
|
671
|
-
|
|
672
|
-
|
|
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) => {
|