@atlaskit/editor-plugin-table 7.1.0 → 7.1.2
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 +16 -0
- package/dist/cjs/event-handlers.js +4 -1
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +9 -9
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +4 -11
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/cjs/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/ui/DragHandle/index.js +27 -9
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -3
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +3 -1
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +10 -2
- package/dist/cjs/ui/common-styles.js +2 -1
- package/dist/cjs/ui/consts.js +3 -3
- package/dist/cjs/ui/ui-styles.js +8 -8
- package/dist/cjs/utils/drag-menu.js +42 -29
- package/dist/es2019/event-handlers.js +3 -2
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +8 -8
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +5 -10
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/es2019/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/DragHandle/index.js +26 -8
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/index.js +5 -4
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +3 -3
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +10 -4
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +8 -2
- package/dist/es2019/ui/common-styles.js +24 -5
- package/dist/es2019/ui/consts.js +2 -2
- package/dist/es2019/ui/ui-styles.js +8 -8
- package/dist/es2019/utils/drag-menu.js +29 -24
- package/dist/esm/event-handlers.js +5 -2
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +9 -9
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +5 -12
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/esm/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/DragHandle/index.js +27 -9
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/index.js +5 -4
- package/dist/esm/ui/FloatingContextualMenu/styles.js +4 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +10 -2
- package/dist/esm/ui/common-styles.js +2 -1
- package/dist/esm/ui/consts.js +2 -2
- package/dist/esm/ui/ui-styles.js +8 -8
- package/dist/esm/utils/drag-menu.js +41 -28
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +0 -2
- package/dist/types/ui/consts.d.ts +2 -1
- package/dist/types/ui/ui-styles.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +0 -2
- package/dist/types-ts4.5/ui/consts.d.ts +2 -1
- package/dist/types-ts4.5/ui/ui-styles.d.ts +2 -2
- package/package.json +3 -5
- package/src/__tests__/unit/event-handlers.ts +3 -17
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +1 -1
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -17
- package/src/event-handlers.ts +14 -2
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +11 -8
- package/src/pm-plugins/drag-and-drop/commands.ts +5 -33
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -3
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -5
- package/src/types.ts +1 -0
- package/src/ui/DragHandle/index.tsx +33 -14
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +9 -2
- package/src/ui/FloatingContextualMenu/index.tsx +10 -3
- package/src/ui/FloatingContextualMenu/styles.ts +10 -3
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +21 -5
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +1 -13
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -2
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +22 -8
- package/src/ui/common-styles.ts +20 -4
- package/src/ui/consts.ts +2 -6
- package/src/ui/ui-styles.ts +12 -8
- package/src/utils/drag-menu.ts +48 -32
- package/tsconfig.json +273 -0
|
@@ -74,7 +74,10 @@ const DragControlsComponent = ({
|
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
}, [editorView]);
|
|
77
|
-
const onMouseUp = useCallback(
|
|
77
|
+
const onMouseUp = useCallback(event => {
|
|
78
|
+
if (event.shiftKey) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
78
81
|
toggleDragMenu(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
79
82
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
80
83
|
const rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
@@ -130,13 +133,16 @@ const DragControlsComponent = ({
|
|
|
130
133
|
const currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
131
134
|
const isSelecting = isRowsSelected && !isHover;
|
|
132
135
|
const indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
|
|
136
|
+
const previewHeight = rowHeights.reduce((sum, v, i) => sum + v * (indexes.includes(i) ? 1 : 0), 0);
|
|
133
137
|
return /*#__PURE__*/React.createElement("div", {
|
|
134
138
|
key: type,
|
|
135
139
|
style: {
|
|
136
140
|
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
137
141
|
gridColumn: '2',
|
|
138
142
|
// 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
|
|
143
|
+
display: 'flex',
|
|
139
144
|
width: '9px',
|
|
145
|
+
height: '100%',
|
|
140
146
|
position: 'relative',
|
|
141
147
|
right: '-0.5px'
|
|
142
148
|
},
|
|
@@ -148,7 +154,7 @@ const DragControlsComponent = ({
|
|
|
148
154
|
indexes: indexes,
|
|
149
155
|
forceDefaultHandle: isHover ? false : isRowsSelected,
|
|
150
156
|
previewWidth: tableWidth,
|
|
151
|
-
previewHeight:
|
|
157
|
+
previewHeight: previewHeight,
|
|
152
158
|
appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
|
|
153
159
|
onClick: handleClick,
|
|
154
160
|
onMouseOver: handleMouseOver,
|
|
@@ -204,7 +204,9 @@ const tableWrapperStyles = () => {
|
|
|
204
204
|
};
|
|
205
205
|
|
|
206
206
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4139
|
|
207
|
-
export const tableStyles = props =>
|
|
207
|
+
export const tableStyles = props => {
|
|
208
|
+
var _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$featureFlags4;
|
|
209
|
+
return css`
|
|
208
210
|
.${ClassName.LAYOUT_BUTTON} button {
|
|
209
211
|
background: ${`var(--ds-background-neutral, ${N20A})`};
|
|
210
212
|
color: ${`var(--ds-icon, ${N300})`};
|
|
@@ -223,8 +225,8 @@ export const tableStyles = props => css`
|
|
|
223
225
|
${hoveredDeleteButton()};
|
|
224
226
|
${hoveredCell()};
|
|
225
227
|
${hoveredWarningCell};
|
|
226
|
-
${
|
|
227
|
-
${resizeHandle()};
|
|
228
|
+
${((_props$featureFlags = props.featureFlags) === null || _props$featureFlags === void 0 ? void 0 : _props$featureFlags.tableDragAndDrop) && insertLine()};
|
|
229
|
+
${resizeHandle((_props$featureFlags2 = props.featureFlags) === null || _props$featureFlags2 === void 0 ? void 0 : _props$featureFlags2.tableDragAndDrop)};
|
|
228
230
|
${rangeSelectionStyles};
|
|
229
231
|
|
|
230
232
|
.${ClassName.LAST_ITEM_IN_CELL} {
|
|
@@ -434,7 +436,7 @@ export const tableStyles = props => css`
|
|
|
434
436
|
}
|
|
435
437
|
|
|
436
438
|
${sentinelStyles}
|
|
437
|
-
${OverflowShadow()}
|
|
439
|
+
${OverflowShadow((_props$featureFlags3 = props.featureFlags) === null || _props$featureFlags3 === void 0 ? void 0 : _props$featureFlags3.tableDragAndDrop)}
|
|
438
440
|
${stickyScrollbarStyles(props.featureFlags)}
|
|
439
441
|
|
|
440
442
|
.${ClassName.TABLE_STICKY} .${ClassName.TABLE_STICKY_SHADOW} {
|
|
@@ -653,6 +655,22 @@ export const tableStyles = props => css`
|
|
|
653
655
|
}
|
|
654
656
|
}
|
|
655
657
|
|
|
658
|
+
.${ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE} {
|
|
659
|
+
background: none;
|
|
660
|
+
border: none;
|
|
661
|
+
outline: none;
|
|
662
|
+
position: absolute;
|
|
663
|
+
margin: 0;
|
|
664
|
+
padding: 0;
|
|
665
|
+
display: flex;
|
|
666
|
+
align-items: center;
|
|
667
|
+
cursor: pointer;
|
|
668
|
+
|
|
669
|
+
:focus {
|
|
670
|
+
outline: none;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
656
674
|
.${ClassName.DRAG_HANDLE_BUTTON_CONTAINER} {
|
|
657
675
|
cursor: grab;
|
|
658
676
|
pointer-events: auto;
|
|
@@ -739,7 +757,7 @@ export const tableStyles = props => css`
|
|
|
739
757
|
position: relative;
|
|
740
758
|
float: right;
|
|
741
759
|
margin-left: ${getBooleanFF('platform.editor.custom-table-width') ? akEditorTableToolbarSize : akEditorTableToolbarSize - 1}px;
|
|
742
|
-
top: ${
|
|
760
|
+
top: ${(_props$featureFlags4 = props.featureFlags) !== null && _props$featureFlags4 !== void 0 && _props$featureFlags4.tableDragAndDrop ? 0 : akEditorTableToolbarSize}px;
|
|
743
761
|
width: ${akEditorTableNumberColumnWidth + 1}px;
|
|
744
762
|
box-sizing: border-box;
|
|
745
763
|
}
|
|
@@ -969,6 +987,7 @@ export const tableStyles = props => css`
|
|
|
969
987
|
|
|
970
988
|
${shadowSentinelStyles}
|
|
971
989
|
`;
|
|
990
|
+
};
|
|
972
991
|
export const tableFullPageEditorStyles = css`
|
|
973
992
|
.ProseMirror .${ClassName.TABLE_NODE_WRAPPER} > table {
|
|
974
993
|
margin-left: 0;
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { tableCellBorderWidth, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { akEditorTableBorder, akEditorTableBorderSelected, akEditorTableCellBlanketDeleted, akEditorTableCellBlanketSelected, akEditorTableHeaderCellBackground, akEditorTableToolbar, akEditorTableToolbarSize, akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
|
|
3
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { B200, N0, N20, N200, N20A, N300, R300, R400, R75 } from '@atlaskit/theme/colors';
|
|
5
4
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from '../types';
|
|
6
5
|
|
|
@@ -50,7 +49,8 @@ export const resizeHandlerAreaWidth = RESIZE_HANDLE_AREA_DECORATION_GAP / 3;
|
|
|
50
49
|
export const resizeLineWidth = 2;
|
|
51
50
|
export const resizeHandlerZIndex = columnControlsZIndex + akRichMediaResizeZIndex;
|
|
52
51
|
export const contextualMenuTriggerSize = 16;
|
|
53
|
-
export const contextualMenuDropdownWidth =
|
|
52
|
+
export const contextualMenuDropdownWidth = 180;
|
|
53
|
+
export const contextualMenuDropdownWidthDnD = 250;
|
|
54
54
|
export const stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
55
55
|
export const stickyRowOffsetTop = 8;
|
|
56
56
|
export const stickyHeaderBorderBottomWidth = 1;
|
|
@@ -264,7 +264,7 @@ export const DeleteButton = () => css`
|
|
|
264
264
|
cursor: pointer;
|
|
265
265
|
}
|
|
266
266
|
`;
|
|
267
|
-
export const OverflowShadow =
|
|
267
|
+
export const OverflowShadow = isDragAndDropEnabled => css`
|
|
268
268
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
269
269
|
display: block;
|
|
270
270
|
height: calc(100% - ${tableMarginTop}px);
|
|
@@ -306,14 +306,14 @@ export const OverflowShadow = () => css`
|
|
|
306
306
|
left: ${getBooleanFF('platform.editor.custom-table-width') ? `calc(100% - ${getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? tableOverflowShadowWidthWide : tableOverflowShadowWidth}px)` : `calc(100% - ${getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? tableOverflowShadowWidthWide - 10 : -2}px)`};
|
|
307
307
|
}
|
|
308
308
|
.${ClassName.WITH_CONTROLS} {
|
|
309
|
-
${overflowShadowWidhoutDnD()}
|
|
309
|
+
${overflowShadowWidhoutDnD(isDragAndDropEnabled)}
|
|
310
310
|
.${ClassName.TABLE_LEFT_SHADOW} {
|
|
311
311
|
border-left: 1px solid ${tableBorderColor};
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
`;
|
|
315
|
-
const overflowShadowWidhoutDnD =
|
|
316
|
-
if (!
|
|
315
|
+
const overflowShadowWidhoutDnD = isDragAndDropEnabled => {
|
|
316
|
+
if (!isDragAndDropEnabled) {
|
|
317
317
|
return css`
|
|
318
318
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
319
319
|
height: calc(100% - ${tableMarginTopWithControl}px);
|
|
@@ -680,8 +680,8 @@ const getLastColumnResizerOverrides = () => {
|
|
|
680
680
|
}
|
|
681
681
|
` : '';
|
|
682
682
|
};
|
|
683
|
-
const resizeHandleOverrides =
|
|
684
|
-
if (
|
|
683
|
+
const resizeHandleOverrides = isDragAndDropEnabled => {
|
|
684
|
+
if (isDragAndDropEnabled) {
|
|
685
685
|
return css`
|
|
686
686
|
th.${ClassName.WITH_RESIZE_LINE}::before,
|
|
687
687
|
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
@@ -754,7 +754,7 @@ const resizeHandleOverrides = () => {
|
|
|
754
754
|
}
|
|
755
755
|
`;
|
|
756
756
|
};
|
|
757
|
-
export const resizeHandle =
|
|
757
|
+
export const resizeHandle = isDragAndDropEnabled => css`
|
|
758
758
|
.${ClassName.TABLE_CONTAINER} {
|
|
759
759
|
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
760
760
|
background-color: transparent;
|
|
@@ -769,7 +769,7 @@ export const resizeHandle = () => css`
|
|
|
769
769
|
|
|
770
770
|
${getLastColumnResizerOverrides()}
|
|
771
771
|
|
|
772
|
-
${resizeHandleOverrides()}
|
|
772
|
+
${resizeHandleOverrides(isDragAndDropEnabled)}
|
|
773
773
|
|
|
774
774
|
table
|
|
775
775
|
tr:first-of-type
|
|
@@ -18,7 +18,7 @@ import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizi
|
|
|
18
18
|
import { getClosestSelectionRect } from '../toolbar';
|
|
19
19
|
import { deleteRows } from '../transforms';
|
|
20
20
|
import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
|
|
21
|
-
import { getSelectedColumnIndexes } from './
|
|
21
|
+
import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
22
22
|
const canDecrease = (index, min = 0) => index !== undefined && index > min;
|
|
23
23
|
const canIncrease = (index, max = 0) => index !== undefined && index < max;
|
|
24
24
|
const isDistributeColumnsEnabled = state => {
|
|
@@ -53,34 +53,38 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
53
53
|
}];
|
|
54
54
|
const moveOptions = direction === 'row' ? [{
|
|
55
55
|
label: 'up',
|
|
56
|
-
offset: -1,
|
|
57
|
-
canMove: index => canDrag && canDecrease(index),
|
|
58
56
|
icon: ArrowUpIcon,
|
|
59
|
-
keymap: moveRowUp
|
|
57
|
+
keymap: moveRowUp,
|
|
58
|
+
canMove: selectionRect => canDrag && canDecrease(selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.top),
|
|
59
|
+
getOriginIndexes: getSelectedRowIndexes,
|
|
60
|
+
getTargetIndex: selectionRect => selectionRect.top - 1
|
|
60
61
|
}, {
|
|
61
62
|
label: 'down',
|
|
62
|
-
offset: 1,
|
|
63
|
-
canMove: index => {
|
|
64
|
-
var _tableMap$height;
|
|
65
|
-
return canDrag && canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
66
|
-
},
|
|
67
63
|
icon: ArrowDownIcon,
|
|
68
|
-
keymap: moveRowDown
|
|
64
|
+
keymap: moveRowDown,
|
|
65
|
+
canMove: selectionRect => {
|
|
66
|
+
var _selectionRect$bottom, _tableMap$height;
|
|
67
|
+
return canDrag && canIncrease(((_selectionRect$bottom = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom) !== null && _selectionRect$bottom !== void 0 ? _selectionRect$bottom : 0) - 1, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
68
|
+
},
|
|
69
|
+
getOriginIndexes: getSelectedRowIndexes,
|
|
70
|
+
getTargetIndex: selectionRect => selectionRect.bottom
|
|
69
71
|
}] : [{
|
|
70
72
|
label: 'left',
|
|
71
|
-
offset: -1,
|
|
72
|
-
canMove: index => canDrag && canDecrease(index),
|
|
73
73
|
icon: ArrowLeftIcon,
|
|
74
|
-
keymap: moveColumnLeft
|
|
74
|
+
keymap: moveColumnLeft,
|
|
75
|
+
canMove: selectionRect => canDrag && canDecrease(selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left),
|
|
76
|
+
getOriginIndexes: getSelectedColumnIndexes,
|
|
77
|
+
getTargetIndex: selectionRect => selectionRect.left - 1
|
|
75
78
|
}, {
|
|
76
79
|
label: 'right',
|
|
77
|
-
offset: 1,
|
|
78
|
-
canMove: index => {
|
|
79
|
-
var _tableMap$width;
|
|
80
|
-
return canDrag && canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
81
|
-
},
|
|
82
80
|
icon: ArrowRightIcon,
|
|
83
|
-
keymap: moveColumnRight
|
|
81
|
+
keymap: moveColumnRight,
|
|
82
|
+
canMove: selectionRect => {
|
|
83
|
+
var _selectionRect$right, _tableMap$width;
|
|
84
|
+
return canDrag && canIncrease(((_selectionRect$right = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right) !== null && _selectionRect$right !== void 0 ? _selectionRect$right : 0) - 1, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
85
|
+
},
|
|
86
|
+
getOriginIndexes: getSelectedColumnIndexes,
|
|
87
|
+
getTargetIndex: selectionRect => selectionRect.right
|
|
84
88
|
}];
|
|
85
89
|
const sortOptions = direction === 'column' ? [{
|
|
86
90
|
label: 'increasing',
|
|
@@ -154,19 +158,20 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
154
158
|
keymap: direction === 'row' ? tooltip(deleteRow) : tooltip(deleteColumn)
|
|
155
159
|
}, ...moveOptions.map(({
|
|
156
160
|
label,
|
|
157
|
-
offset,
|
|
158
161
|
canMove,
|
|
159
162
|
icon,
|
|
160
|
-
keymap
|
|
163
|
+
keymap,
|
|
164
|
+
getOriginIndexes,
|
|
165
|
+
getTargetIndex
|
|
161
166
|
}) => ({
|
|
162
167
|
id: `move_${direction}_${label}`,
|
|
163
168
|
title: `Move ${direction} ${label}`,
|
|
164
|
-
disabled: !canMove(
|
|
169
|
+
disabled: !canMove(selectionRect),
|
|
165
170
|
icon,
|
|
166
171
|
onClick: (state, dispatch) => {
|
|
167
|
-
if (canMove(
|
|
172
|
+
if (canMove(selectionRect)) {
|
|
168
173
|
requestAnimationFrame(() => {
|
|
169
|
-
moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, `table-${direction}`,
|
|
174
|
+
moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, `table-${direction}`, getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
170
175
|
});
|
|
171
176
|
return true;
|
|
172
177
|
}
|
|
@@ -10,7 +10,7 @@ import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-
|
|
|
10
10
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
11
11
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
12
12
|
import { deleteColumns, deleteRows } from './transforms';
|
|
13
|
-
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
13
|
+
import { TableCssClassName as ClassName, RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
14
14
|
import { convertHTMLCellIndexToColumnIndex, getColumnIndexMappedToColumnIndexInFirstRow, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragCornerButton, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
15
15
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
16
16
|
var isFocusingCalendar = function isFocusingCalendar(event) {
|
|
@@ -25,12 +25,15 @@ var isFocusingFloatingToolbar = function isFocusingFloatingToolbar(event) {
|
|
|
25
25
|
var isFocusingDragHandles = function isFocusingDragHandles(event) {
|
|
26
26
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.getAttribute('draggable') === 'true';
|
|
27
27
|
};
|
|
28
|
+
var isFocusingDragHandlesClickableZone = function isFocusingDragHandlesClickableZone(event) {
|
|
29
|
+
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.classList.contains(ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE);
|
|
30
|
+
};
|
|
28
31
|
export var handleBlur = function handleBlur(view, event) {
|
|
29
32
|
var state = view.state,
|
|
30
33
|
dispatch = view.dispatch;
|
|
31
34
|
// IE version check for ED-4665
|
|
32
35
|
// Calendar focus check for ED-10466
|
|
33
|
-
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event)) {
|
|
36
|
+
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event) && !isFocusingDragHandlesClickableZone(event)) {
|
|
34
37
|
setEditorFocus(false)(state, dispatch);
|
|
35
38
|
}
|
|
36
39
|
event.preventDefault();
|
|
@@ -39,6 +39,7 @@ export var moveSourceWithAnalytics = function moveSourceWithAnalytics(editorAnal
|
|
|
39
39
|
return function (inputMethod, sourceType, sourceIndexes, targetIndex, tr) {
|
|
40
40
|
return withEditorAnalyticsAPI(function (_ref2) {
|
|
41
41
|
var selection = _ref2.selection;
|
|
42
|
+
var direction = sourceIndexes[0] > targetIndex ? -1 : 1;
|
|
42
43
|
var _getSelectedTableInfo2 = getSelectedTableInfo(selection),
|
|
43
44
|
totalRowCount = _getSelectedTableInfo2.totalRowCount,
|
|
44
45
|
totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
|
|
@@ -52,8 +53,8 @@ export var moveSourceWithAnalytics = function moveSourceWithAnalytics(editorAnal
|
|
|
52
53
|
// This identifies the total amount of row/cols the move operation covered. The distance covered should be a representaion
|
|
53
54
|
// of the minimum distance. This will account for large selection being moved causing a large distance travelled value.
|
|
54
55
|
distance: Math.min.apply(Math, _toConsumableArray(sourceIndexes.map(function (v) {
|
|
55
|
-
return targetIndex - v;
|
|
56
|
-
}))),
|
|
56
|
+
return Math.abs(targetIndex - v);
|
|
57
|
+
}))) * direction,
|
|
57
58
|
// If a drop doesn't actually change anything then we're going to mark the event as cancelled.
|
|
58
59
|
status: sourceIndexes.includes(targetIndex) ? TABLE_STATUS.CANCELLED : TABLE_STATUS.SUCCESS,
|
|
59
60
|
totalRowCount: totalRowCount,
|
|
@@ -80,15 +81,14 @@ export var moveSourceWithAnalyticsViaShortcut = function moveSourceWithAnalytics
|
|
|
80
81
|
}
|
|
81
82
|
var isRow = sourceType === 'table-row';
|
|
82
83
|
var selectedIndexes = isRow ? getSelectedRowIndexes(selectionRect) : getSelectedColumnIndexes(selectionRect);
|
|
83
|
-
|
|
84
|
-
// FIXME: We can move if only one row/column selected
|
|
85
|
-
if (selectedIndexes.length === 0 || selectedIndexes.length > 1) {
|
|
84
|
+
if (selectedIndexes.length === 0) {
|
|
86
85
|
return false;
|
|
87
86
|
}
|
|
88
|
-
|
|
87
|
+
|
|
88
|
+
// const sourceIndex = selectedIndexes[0];
|
|
89
89
|
// we can move only by one row/column
|
|
90
90
|
// 'direction' can only be 1 (for right or down) or -1 (for left or up)
|
|
91
|
-
var targetIndex =
|
|
91
|
+
var targetIndex = Math[direction < 0 ? 'min' : 'max'].apply(Math, _toConsumableArray(selectedIndexes)) + direction;
|
|
92
92
|
|
|
93
93
|
// We can move only if targetIndex is a positive number and is not higher than the total number of rows/columns.
|
|
94
94
|
var _getSelectedTableInfo3 = getSelectedTableInfo(selection),
|
|
@@ -100,7 +100,7 @@ export var moveSourceWithAnalyticsViaShortcut = function moveSourceWithAnalytics
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// We can move only if there are no merged cells in the source or target row/column
|
|
103
|
-
var hasMergedCellsInSource = isRow ? hasMergedCellsInRow(
|
|
103
|
+
var hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
|
|
104
104
|
if (hasMergedCellsInSource) {
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
@@ -108,7 +108,7 @@ export var moveSourceWithAnalyticsViaShortcut = function moveSourceWithAnalytics
|
|
|
108
108
|
if (hasMergedCellsInTarget) {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
|
-
return moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, sourceType,
|
|
111
|
+
return moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
1
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { moveColumn, moveRow
|
|
2
|
+
import { moveColumn, moveRow } from '@atlaskit/editor-tables/utils';
|
|
4
3
|
import { TableDecorations } from '../../types';
|
|
5
4
|
import { createColumnInsertLine, createRowInsertLine, updateDecorations } from '../../utils';
|
|
6
|
-
import { combineTransforms } from '../../utils/transforms';
|
|
7
5
|
import { DragAndDropActionType } from './actions';
|
|
8
6
|
import { DropTargetType } from './consts';
|
|
9
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
@@ -74,15 +72,10 @@ export var moveSource = function moveSource(sourceType, sourceIndexes, targetInd
|
|
|
74
72
|
if (sourceIndexes.includes(targetIndex)) {
|
|
75
73
|
return nextTr.setMeta('addToHistory', false);
|
|
76
74
|
}
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
var isTableRow = sourceType === 'table-row';
|
|
82
|
-
if (isTableRow) {
|
|
83
|
-
return combineTransforms([moveRow(state, sourceIndexes, targetIndex), selectStartOfTable, selectRow(targetIndex)], nextTr);
|
|
84
|
-
}
|
|
85
|
-
return combineTransforms([moveColumn(state, sourceIndexes, targetIndex), selectStartOfTable, selectColumn(targetIndex)], nextTr);
|
|
75
|
+
var move = sourceType === 'table-row' ? moveRow : moveColumn;
|
|
76
|
+
return move(state, sourceIndexes, targetIndex, {
|
|
77
|
+
selectAfterMove: true
|
|
78
|
+
})(nextTr);
|
|
86
79
|
});
|
|
87
80
|
};
|
|
88
81
|
export var toggleDragMenu = function toggleDragMenu(isDragMenuOpen, direction, index) {
|
|
@@ -55,10 +55,7 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
|
55
55
|
indexes = _ref6.indexes;
|
|
56
56
|
|
|
57
57
|
// First; Perform any quick checks so we can abort early.
|
|
58
|
-
if (!indexes || !localId ||
|
|
59
|
-
// FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
|
|
60
|
-
// of more then 1 item.
|
|
61
|
-
indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
|
|
58
|
+
if (!indexes || !localId || !(type === 'table-row' || type === 'table-column')) {
|
|
62
59
|
return false;
|
|
63
60
|
}
|
|
64
61
|
var _getTablePluginState = getTablePluginState(editorView.state),
|
|
@@ -30,11 +30,6 @@ export var getDraggableDataFromEvent = function getDraggableDataFromEvent(_ref)
|
|
|
30
30
|
sourceLocalId !== targetLocalId) {
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
// FIXME: currently we only support a single row/col index being moved, remove this clause when this is no longer the case.
|
|
35
|
-
if (sourceIndexes.length > 1) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
33
|
var targetClosestEdge = (_extractClosestEdge = extractClosestEdge(destination.data)) !== null && _extractClosestEdge !== void 0 ? _extractClosestEdge : targetType === 'table-row' ? 'top' : 'left';
|
|
39
34
|
// NOTE: By default we always insert row/cols at the target index to the top/left (retrospectively of row/cols).
|
|
40
35
|
// This introduces an offset in the event the drop occured closer to the bottom/right of the target. We want
|
package/dist/esm/types.js
CHANGED
|
@@ -93,6 +93,7 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
93
93
|
DRAG_COLUMN_DROP_TARGET_CONTROLS: "".concat(tablePrefixSelector, "-col-drop-target-controls"),
|
|
94
94
|
DRAG_COLUMN_CONTROLS_INNER: "".concat(tablePrefixSelector, "-col-controls__inner"),
|
|
95
95
|
DRAG_HANDLE_BUTTON_CONTAINER: "".concat(tablePrefixSelector, "-drag-handle-button-container"),
|
|
96
|
+
DRAG_HANDLE_BUTTON_CLICKABLE_ZONE: "".concat(tablePrefixSelector, "-drag-handle-button-clickable-zone"),
|
|
96
97
|
DRAG_CORNER_BUTTON: "".concat(tablePrefixSelector, "-drag-corner-button"),
|
|
97
98
|
DRAG_CORNER_BUTTON_INNER: "".concat(tablePrefixSelector, "-drag-corner-button-inner"),
|
|
98
99
|
/** disabled classes */
|
|
@@ -11,6 +11,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/ut
|
|
|
11
11
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
12
12
|
import { TableCssClassName as ClassName } from '../../types';
|
|
13
13
|
import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
14
|
+
import { dragTableInsertColumnButtonSize } from '../consts';
|
|
14
15
|
import { DragPreview } from '../DragPreview';
|
|
15
16
|
import { HandleIconComponent } from './HandleIconComponent';
|
|
16
17
|
var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
@@ -42,11 +43,13 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
42
43
|
hoveredColumns = _getPluginState.hoveredColumns,
|
|
43
44
|
hoveredRows = _getPluginState.hoveredRows;
|
|
44
45
|
var selection = editorView.state.selection;
|
|
45
|
-
var
|
|
46
|
-
var
|
|
46
|
+
var isRow = direction === 'row';
|
|
47
|
+
var isColumn = direction === 'column';
|
|
48
|
+
var isRowHandleHovered = isRow && hoveredRows.length > 0;
|
|
49
|
+
var isColumnHandleHovered = isColumn && hoveredColumns.length > 0;
|
|
47
50
|
var hasMergedCells = useMemo(function () {
|
|
48
|
-
return
|
|
49
|
-
}, [indexes,
|
|
51
|
+
return isRow ? hasMergedCellsInRow(indexes[0])(selection) : hasMergedCellsInColumn(indexes[0])(selection);
|
|
52
|
+
}, [indexes, isRow, selection]);
|
|
50
53
|
var handleIconProps = {
|
|
51
54
|
forceDefaultHandle: forceDefaultHandle,
|
|
52
55
|
isColumnHandleHovered: isColumnHandleHovered,
|
|
@@ -83,7 +86,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
83
86
|
// be generated.
|
|
84
87
|
container.style.left = "-".concat(rect.width - 0.0001, "px");
|
|
85
88
|
}
|
|
86
|
-
if (
|
|
89
|
+
if (isRow) {
|
|
87
90
|
return {
|
|
88
91
|
x: 12,
|
|
89
92
|
y: rect.height / 2
|
|
@@ -107,17 +110,32 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
|
|
|
107
110
|
}
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
|
-
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, _canDrag]);
|
|
111
|
-
var showDragMenuAnchorId =
|
|
113
|
+
}, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells, _canDrag]);
|
|
114
|
+
var showDragMenuAnchorId = isRow ? 'drag-handle-button-row' : 'drag-handle-button-column';
|
|
112
115
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
116
|
+
className: ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE,
|
|
117
|
+
"data-testid": "table-drag-handle-clickable-zone-button",
|
|
118
|
+
style: {
|
|
119
|
+
height: isRow ? "calc(100% - ".concat(dragTableInsertColumnButtonSize, "px)") : "var(--ds-space-200, 16px)",
|
|
120
|
+
// 16px here because it's the size of drag handle button's large side
|
|
121
|
+
width: isRow ? "var(--ds-space-200, 16px)" // 16px here because it's the size of drag handle button's large side
|
|
122
|
+
: "calc(100% - ".concat(dragTableInsertColumnButtonSize, "px)"),
|
|
123
|
+
left: isRow ? '3px' : undefined,
|
|
124
|
+
bottom: isColumn ? '0' : undefined,
|
|
125
|
+
alignSelf: isColumn ? 'none' : 'center',
|
|
126
|
+
zIndex: isColumn ? '-1' : 'auto'
|
|
127
|
+
},
|
|
128
|
+
onClick: onClick
|
|
129
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
113
130
|
id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
|
|
114
131
|
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, _defineProperty({}, ClassName.DRAG_HANDLE_DISABLED, !_canDrag || hasMergedCells)),
|
|
115
132
|
ref: dragHandleDivRef,
|
|
116
133
|
style: {
|
|
117
|
-
transform:
|
|
134
|
+
transform: isColumn ? 'none' : 'rotate(90deg)',
|
|
135
|
+
alignSelf: isColumn ? 'none' : 'center'
|
|
118
136
|
},
|
|
119
137
|
"data-testid": "table-drag-handle-button",
|
|
120
|
-
"aria-label": formatMessage(
|
|
138
|
+
"aria-label": formatMessage(isRow ? messages.rowDragHandle : messages.columnDragHandle),
|
|
121
139
|
onMouseOver: onMouseOver,
|
|
122
140
|
onMouseOut: onMouseOut,
|
|
123
141
|
onMouseUp: function onMouseUp(e) {
|
|
@@ -37,7 +37,7 @@ import { getNewResizeStateFromSelectedColumns } from '../../pm-plugins/table-res
|
|
|
37
37
|
import { canMergeCells } from '../../transforms';
|
|
38
38
|
import { TableCssClassName as ClassName } from '../../types';
|
|
39
39
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from '../../utils';
|
|
40
|
-
import { contextualMenuDropdownWidth } from '../consts';
|
|
40
|
+
import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD } from '../consts';
|
|
41
41
|
import { AddColRightIcon, AddRowBelowIcon, MergeCellsIcon, SplitCellIcon } from '../icons';
|
|
42
42
|
import { cellColourPreviewStyles, elementBeforeIconStyles } from './styles';
|
|
43
43
|
export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
@@ -530,7 +530,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
530
530
|
onMouseEnter: this.handleItemMouseEnter,
|
|
531
531
|
onMouseLeave: this.handleItemMouseLeave,
|
|
532
532
|
fitHeight: 188,
|
|
533
|
-
fitWidth: contextualMenuDropdownWidth,
|
|
533
|
+
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth,
|
|
534
534
|
boundariesElement: boundariesElement,
|
|
535
535
|
offset: offset,
|
|
536
536
|
section: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && getBooleanFF('platform.editor.menu.group-items') ? {
|
|
@@ -5,7 +5,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
5
5
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
8
|
-
import { contextualMenuDropdownWidth, contextualMenuTriggerSize } from '../consts';
|
|
8
|
+
import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD, contextualMenuTriggerSize } from '../consts';
|
|
9
9
|
import ContextualMenu from './ContextualMenu';
|
|
10
10
|
import { tablePopupStyles } from './styles';
|
|
11
11
|
var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
@@ -19,7 +19,8 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
19
19
|
getEditorContainerWidth = _ref.getEditorContainerWidth;
|
|
20
20
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
21
21
|
var _getPluginState = getPluginState(editorView.state),
|
|
22
|
-
targetCellPosition = _getPluginState.targetCellPosition
|
|
22
|
+
targetCellPosition = _getPluginState.targetCellPosition,
|
|
23
|
+
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
23
24
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
@@ -42,7 +43,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
42
43
|
boundariesElement: boundariesElement,
|
|
43
44
|
scrollableElement: scrollableElement,
|
|
44
45
|
fitHeight: 188,
|
|
45
|
-
fitWidth: contextualMenuDropdownWidth
|
|
46
|
+
fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth
|
|
46
47
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
47
48
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
48
49
|
,
|
|
@@ -51,7 +52,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
51
52
|
offset: [-7, 0],
|
|
52
53
|
stick: true
|
|
53
54
|
}, jsx("div", {
|
|
54
|
-
css: tablePopupStyles
|
|
55
|
+
css: tablePopupStyles(isDragAndDropEnabled)
|
|
55
56
|
}, jsx(ContextualMenu, {
|
|
56
57
|
editorView: editorView,
|
|
57
58
|
offset: [contextualMenuTriggerSize / 2, -contextualMenuTriggerSize],
|
|
@@ -4,7 +4,7 @@ import { css } from '@emotion/react';
|
|
|
4
4
|
import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
|
|
5
5
|
import { N60A, N90 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { TableCssClassName as ClassName } from '../../types';
|
|
7
|
-
import { contextualMenuDropdownWidth } from '../consts';
|
|
7
|
+
import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD } from '../consts';
|
|
8
8
|
export var cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
|
|
9
9
|
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &::before {\n background: ", ";\n }\n"])), selectedColor);
|
|
10
10
|
};
|
|
@@ -12,4 +12,6 @@ export var elementBeforeIconStyles = css(_templateObject2 || (_templateObject2 =
|
|
|
12
12
|
|
|
13
13
|
// TODO Delete this comment after verifying space token -> previous value `padding: 8px`
|
|
14
14
|
// TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
|
|
15
|
-
export var tablePopupStyles =
|
|
15
|
+
export var tablePopupStyles = function tablePopupStyles(isDragAndDropEnabled) {
|
|
16
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 20px;\n height: 20px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 20px;\n color: ", ";\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 14px;\n height: 14px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 14px;\n color: ", ";\n }\n }\n"])), ClassName.CONTEXTUAL_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth, "var(--ds-space-100, 8px)", ClassName.CONTEXTUAL_MENU_ICON, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"), ClassName.CONTEXTUAL_MENU_ICON_SMALL, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"));
|
|
17
|
+
};
|
|
@@ -97,9 +97,12 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
97
97
|
clearHoverSelection()(state, dispatch);
|
|
98
98
|
}
|
|
99
99
|
}, [editorView, tableActive]);
|
|
100
|
-
var handleMouseUp = useCallback(function () {
|
|
100
|
+
var handleMouseUp = useCallback(function (event) {
|
|
101
101
|
var state = editorView.state,
|
|
102
102
|
dispatch = editorView.dispatch;
|
|
103
|
+
if (event.shiftKey) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
103
106
|
toggleDragMenu(undefined, 'column', colIndex)(state, dispatch);
|
|
104
107
|
}, [editorView, colIndex]);
|
|
105
108
|
var colIndexes = useMemo(function () {
|
|
@@ -124,7 +127,7 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
124
127
|
};
|
|
125
128
|
}, [tableWrapper, handleScroll]);
|
|
126
129
|
var generateHandleByType = function generateHandleByType(type) {
|
|
127
|
-
var _rowHeights$reduce, _colWidths;
|
|
130
|
+
var _rowHeights$reduce, _colWidths$reduce;
|
|
128
131
|
if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
|
|
129
132
|
return null;
|
|
130
133
|
}
|
|
@@ -145,6 +148,9 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
145
148
|
|
|
146
149
|
// this indexes are used to calculate the drag and drop source
|
|
147
150
|
var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
|
|
151
|
+
var previewWidth = (_colWidths$reduce = colWidths === null || colWidths === void 0 ? void 0 : colWidths.reduce(function (sum, v, i) {
|
|
152
|
+
return sum + (v !== null && v !== void 0 ? v : tableCellMinWidth) * (indexes.includes(i) ? 1 : 0);
|
|
153
|
+
}, 0)) !== null && _colWidths$reduce !== void 0 ? _colWidths$reduce : tableCellMinWidth;
|
|
148
154
|
return /*#__PURE__*/React.createElement("div", {
|
|
149
155
|
key: type,
|
|
150
156
|
style: {
|
|
@@ -154,7 +160,9 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
154
160
|
alignItems: 'center',
|
|
155
161
|
height: 'fit-content',
|
|
156
162
|
placeSelf: 'center',
|
|
157
|
-
zIndex: 99
|
|
163
|
+
zIndex: 99,
|
|
164
|
+
width: '100%',
|
|
165
|
+
position: 'relative'
|
|
158
166
|
},
|
|
159
167
|
"data-column-control-index": hoveredCell.colIndex,
|
|
160
168
|
"data-testid": "table-floating-column-".concat(isSelecting ? selectedColIndexes[0] : colIndex, "-drag-handle")
|
|
@@ -164,7 +172,7 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
164
172
|
tableLocalId: localId || '',
|
|
165
173
|
indexes: indexes,
|
|
166
174
|
forceDefaultHandle: isHover ? false : isColumnsSelected,
|
|
167
|
-
previewWidth:
|
|
175
|
+
previewWidth: previewWidth,
|
|
168
176
|
previewHeight: previewHeight,
|
|
169
177
|
appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
|
|
170
178
|
onClick: handleClick,
|