@atlaskit/editor-plugin-table 5.4.4 → 5.4.5
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 +7 -0
- package/dist/cjs/plugins/table/types.js +1 -1
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +29 -0
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +21 -20
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +1 -2
- package/dist/cjs/plugins/table/ui/ui-styles.js +10 -13
- package/dist/cjs/plugins/table/utils/decoration.js +7 -6
- package/dist/es2019/plugins/table/types.js +1 -1
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +24 -0
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +21 -20
- package/dist/es2019/plugins/table/ui/common-styles.js +6 -2
- package/dist/es2019/plugins/table/ui/consts.js +0 -1
- package/dist/es2019/plugins/table/ui/ui-styles.js +18 -12
- package/dist/es2019/plugins/table/utils/decoration.js +7 -6
- package/dist/esm/plugins/table/types.js +1 -1
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +22 -0
- package/dist/esm/plugins/table/ui/DragHandle/index.js +21 -20
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/consts.js +0 -1
- package/dist/esm/plugins/table/ui/ui-styles.js +10 -13
- package/dist/esm/plugins/table/utils/decoration.js +7 -6
- package/dist/types/plugins/table/types.d.ts +1 -1
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +13 -0
- package/dist/types/plugins/table/ui/consts.d.ts +0 -1
- package/dist/types/plugins/table/ui/ui-styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +0 -1
- package/package.json +1 -1
- package/src/__tests__/integration/__fixtures__/basic-table.ts +1 -1
- package/src/plugins/table/types.ts +1 -1
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +51 -0
- package/src/plugins/table/ui/DragHandle/index.tsx +30 -33
- package/src/plugins/table/ui/common-styles.ts +5 -2
- package/src/plugins/table/ui/consts.ts +0 -5
- package/src/plugins/table/ui/ui-styles.ts +17 -12
- package/src/plugins/table/utils/decoration.ts +14 -19
- package/src/__tests__/integration/__fixtures__/large-table-with-sticky-header.ts +0 -2311
- package/src/__tests__/integration/__fixtures__/table-and-paragraph-adf.ts +0 -130
- package/src/__tests__/integration/horizontal-scroll-shadows.ts +0 -197
- package/src/__tests__/integration/meta-arrowup-cursor-in-first-row.ts +0 -42
- package/src/__tests__/integration/sticky-header.ts +0 -133
|
@@ -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
|
-
|
|
18
|
-
|
|
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 } =
|
|
57
|
-
editorView.state
|
|
58
|
-
);
|
|
53
|
+
const { isDragAndDropEnabled, hoveredColumns, hoveredRows, hoveredCell } =
|
|
54
|
+
getPluginState(editorView.state);
|
|
59
55
|
|
|
60
|
-
const { dragMenuDirection } =
|
|
56
|
+
const { dragMenuDirection, isDragMenuOpen, dragMenuIndex } =
|
|
57
|
+
getDragDropPluginState(editorView.state);
|
|
61
58
|
|
|
62
59
|
const { selection } = editorView.state;
|
|
63
60
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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
|
-
|
|
159
|
-
type === 'column'
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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) {
|