@atlaskit/editor-plugin-table 5.3.12 → 5.3.14
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 +18 -0
- package/dist/cjs/plugins/table/event-handlers.js +6 -3
- package/dist/cjs/plugins/table/index.js +16 -2
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +22 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -7
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
- package/dist/cjs/plugins/table/types.js +9 -2
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +80 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +62 -0
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +52 -4
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +12 -3
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +44 -5
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +6 -4
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +44 -20
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +3 -2
- package/dist/cjs/plugins/table/ui/ui-styles.js +27 -24
- package/dist/cjs/plugins/table/utils/dom.js +12 -4
- package/dist/cjs/plugins/table/utils/drag-menu.js +59 -0
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/index.js +16 -2
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +20 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +7 -0
- package/dist/es2019/plugins/table/types.js +9 -2
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +77 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +56 -0
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +53 -2
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +9 -3
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +46 -6
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +45 -22
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +51 -3
- package/dist/es2019/plugins/table/ui/consts.js +2 -1
- package/dist/es2019/plugins/table/ui/ui-styles.js +23 -1
- package/dist/es2019/plugins/table/utils/dom.js +5 -1
- package/dist/es2019/plugins/table/utils/drag-menu.js +44 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +7 -4
- package/dist/esm/plugins/table/index.js +16 -2
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +21 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -7
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
- package/dist/esm/plugins/table/types.js +9 -2
- package/dist/esm/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +73 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +55 -0
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +51 -3
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +9 -3
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -6
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -22
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -0
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/consts.js +2 -1
- package/dist/esm/plugins/table/ui/ui-styles.js +26 -23
- package/dist/esm/plugins/table/utils/dom.js +11 -3
- package/dist/esm/plugins/table/utils/drag-menu.js +52 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
- package/dist/types/plugins/table/types.d.ts +10 -2
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +4 -2
- package/dist/types/plugins/table/ui/DragPreview/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
- package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +6 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +5 -5
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +4 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types/plugins/table/utils/drag-menu.d.ts +7 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +10 -2
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +4 -2
- package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +6 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +5 -5
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +7 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +3 -2
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +40 -194
- package/src/__tests__/unit/ui/RowDragControls.tsx +9 -11
- package/src/plugins/table/event-handlers.ts +15 -3
- package/src/plugins/table/index.tsx +18 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +2 -1
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +2 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -3
- package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +14 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +32 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +50 -2
- package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +7 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +5 -0
- package/src/plugins/table/types.ts +14 -2
- package/src/plugins/table/ui/DragHandle/index.tsx +5 -1
- package/src/plugins/table/ui/DragPreview/index.tsx +2 -1
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +2 -1
- package/src/plugins/table/ui/FloatingDeleteButton/types.ts +3 -1
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +99 -0
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +91 -0
- package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +79 -4
- package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +31 -7
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +28 -13
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +47 -3
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +11 -4
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +65 -25
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +7 -0
- package/src/plugins/table/ui/common-styles.ts +57 -2
- package/src/plugins/table/ui/consts.ts +2 -0
- package/src/plugins/table/ui/ui-styles.ts +27 -1
- package/src/plugins/table/utils/dom.ts +11 -4
- package/src/plugins/table/utils/drag-menu.ts +65 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/tsconfig.app.json +3 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
3
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
@@ -8,6 +9,7 @@ export interface Props {
|
|
|
8
9
|
editorView: EditorView;
|
|
9
10
|
selection?: Selection;
|
|
10
11
|
tableRef?: HTMLTableElement;
|
|
12
|
+
tableNode?: PmNode;
|
|
11
13
|
tableActive?: boolean;
|
|
12
14
|
isInDanger?: boolean;
|
|
13
15
|
isResizing?: boolean;
|
|
@@ -21,6 +23,7 @@ export interface Props {
|
|
|
21
23
|
hoveredCell?: CellHoverMeta;
|
|
22
24
|
ordering?: TableColumnOrdering;
|
|
23
25
|
stickyHeader?: RowStickyState;
|
|
26
|
+
insertRowButtonIndex?: number;
|
|
24
27
|
}
|
|
25
28
|
interface State {
|
|
26
29
|
tableHeight: number;
|
|
@@ -3,6 +3,7 @@ export declare const InsertMarker: (props: ThemeProps, cssString?: string) => im
|
|
|
3
3
|
export declare const HeaderButton: (props: ThemeProps, cssString?: string) => import("@emotion/react").SerializedStyles;
|
|
4
4
|
export declare const HeaderButtonHover: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
5
5
|
export declare const HeaderButtonDanger: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
6
|
+
export declare const dragInsertButtonWrapper: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
6
7
|
export declare const insertColumnButtonWrapper: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
7
8
|
export declare const insertRowButtonWrapper: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
8
9
|
export declare const columnControlsLineMarker: () => import("@emotion/react").SerializedStyles;
|
|
@@ -8,10 +8,13 @@ export declare const getColumnOrRowIndex: (target: HTMLElement) => [
|
|
|
8
8
|
];
|
|
9
9
|
export declare const isColumnControlsDecorations: (node: HTMLElement | null) => boolean;
|
|
10
10
|
export declare const isRowControlsButton: (node: HTMLElement | null) => boolean;
|
|
11
|
-
export declare const isRowDragControlsButton: (node: HTMLElement | null) => true | HTMLElement | null;
|
|
12
11
|
export declare const isResizeHandleDecoration: (node: HTMLElement | null) => boolean;
|
|
13
12
|
export declare const isTableControlsButton: (node: HTMLElement | null) => boolean;
|
|
14
13
|
export declare const isTableContainerOrWrapper: (node: HTMLElement | null) => boolean;
|
|
14
|
+
/** drag-and-drop classes */
|
|
15
|
+
export declare const isRowDragControlsButton: (node: HTMLElement | null) => true | HTMLElement | null;
|
|
16
|
+
export declare const isDragRowFloatingInsertDot: (node: HTMLElement | null) => boolean;
|
|
17
|
+
export declare const isDragColumnFloatingInsertDot: (node: HTMLElement | null) => boolean;
|
|
15
18
|
export declare const getMousePositionHorizontalRelativeByElement: (mouseEvent: MouseEvent, elementContentRects?: ElementContentRects, gapInPixels?: number) => 'left' | 'right' | null;
|
|
16
19
|
export declare const getMousePositionVerticalRelativeByElement: (mouseEvent: MouseEvent) => 'top' | 'bottom' | null;
|
|
17
20
|
export declare const updateResizeHandles: (tableRef?: HTMLElement) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command, DropdownOptionT } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
3
|
+
import type { TableDirection } from '../types';
|
|
4
|
+
export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getDragMenuConfig: (direction: TableDirection, tableMap?: TableMap, index?: number) => DragMenuConfig[];
|
|
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
|
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
|
|
3
3
|
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
|
|
5
|
-
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowDragControlsButton, isRowControlsButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, } from './dom';
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowDragControlsButton, isRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, } from './dom';
|
|
6
6
|
export { getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
|
|
8
8
|
export type { RowParams } from './row-controls';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.14",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
41
41
|
"@atlaskit/pragmatic-drag-and-drop": "^0.23.0",
|
|
42
42
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.11.8",
|
|
43
|
-
"@atlaskit/
|
|
43
|
+
"@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^0.6.4",
|
|
44
|
+
"@atlaskit/primitives": "^1.7.0",
|
|
44
45
|
"@atlaskit/theme": "^12.6.0",
|
|
45
46
|
"@atlaskit/tokens": "^1.28.0",
|
|
46
47
|
"@atlaskit/tooltip": "^17.8.0",
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
tdEmpty,
|
|
24
24
|
tr,
|
|
25
25
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
26
|
-
import { ffTest } from '@atlassian/feature-flags-test-utils';
|
|
27
26
|
|
|
28
27
|
import tablePlugin from '../../../../plugins/table';
|
|
29
28
|
import { selectColumn } from '../../../../plugins/table/commands';
|
|
@@ -55,141 +54,27 @@ describe('decorations plugin', () => {
|
|
|
55
54
|
// ED-8457
|
|
56
55
|
describe('when there is a selection pointer set', () => {
|
|
57
56
|
describe('should remove the column selected decorations', () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
() => {
|
|
61
|
-
const { editorView } = editor(
|
|
62
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
selectColumn(1)(editorView.state, editorView.dispatch);
|
|
66
|
-
|
|
67
|
-
const { tr: transaction } = editorView.state;
|
|
68
|
-
|
|
69
|
-
transaction.setMeta('pointer', true);
|
|
70
|
-
transaction.setSelection(Selection.atStart(transaction.doc));
|
|
71
|
-
editorView.dispatch(transaction);
|
|
72
|
-
|
|
73
|
-
const decorationSet = getDecorations(editorView.state);
|
|
74
|
-
|
|
75
|
-
const columnSelectedDecorations = decorationSet.find(
|
|
76
|
-
undefined,
|
|
77
|
-
undefined,
|
|
78
|
-
(spec) => spec.key.indexOf(TableDecorations.COLUMN_SELECTED) > -1,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
expect(columnSelectedDecorations).toHaveLength(0);
|
|
82
|
-
},
|
|
83
|
-
() => {
|
|
84
|
-
const { editorView } = editor(
|
|
85
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
selectColumn(1)(editorView.state, editorView.dispatch);
|
|
89
|
-
|
|
90
|
-
const { tr: transaction } = editorView.state;
|
|
91
|
-
|
|
92
|
-
transaction.setMeta('pointer', true);
|
|
93
|
-
transaction.setSelection(Selection.atStart(transaction.doc));
|
|
94
|
-
editorView.dispatch(transaction);
|
|
95
|
-
|
|
96
|
-
const decorationSet = getDecorations(editorView.state);
|
|
97
|
-
|
|
98
|
-
const columnSelectedDecorations = decorationSet.find(
|
|
99
|
-
undefined,
|
|
100
|
-
undefined,
|
|
101
|
-
(spec) => spec.key.indexOf(TableDecorations.COLUMN_SELECTED) > -1,
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
expect(columnSelectedDecorations).toHaveLength(0);
|
|
105
|
-
},
|
|
57
|
+
const { editorView } = editor(
|
|
58
|
+
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
106
59
|
);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
60
|
|
|
110
|
-
|
|
111
|
-
describe('should not add column control decorations', () => {
|
|
112
|
-
ffTest(
|
|
113
|
-
'platform.editor.table.drag-and-drop',
|
|
114
|
-
() => {
|
|
115
|
-
const pluginState = DecorationSet.empty;
|
|
116
|
-
const { editorView } = editor(
|
|
117
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
118
|
-
);
|
|
61
|
+
selectColumn(1)(editorView.state, editorView.dispatch);
|
|
119
62
|
|
|
120
|
-
|
|
121
|
-
type: 'HOVER_CELL',
|
|
122
|
-
data: {
|
|
123
|
-
colIndex: 0,
|
|
124
|
-
rowIndex: 0,
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const oldState = handleDocOrSelectionChanged(
|
|
129
|
-
transaction,
|
|
130
|
-
pluginState,
|
|
131
|
-
editorView.state,
|
|
132
|
-
editorView.state,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
editorView.dispatch(transaction);
|
|
136
|
-
const newState = handleDocOrSelectionChanged(
|
|
137
|
-
transaction,
|
|
138
|
-
oldState,
|
|
139
|
-
editorView.state,
|
|
140
|
-
editorView.state,
|
|
141
|
-
);
|
|
63
|
+
const { tr: transaction } = editorView.state;
|
|
142
64
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
(spec) =>
|
|
147
|
-
spec.key.indexOf(TableDecorations.COLUMN_CONTROLS_DECORATIONS) >
|
|
148
|
-
-1,
|
|
149
|
-
);
|
|
65
|
+
transaction.setMeta('pointer', true);
|
|
66
|
+
transaction.setSelection(Selection.atStart(transaction.doc));
|
|
67
|
+
editorView.dispatch(transaction);
|
|
150
68
|
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
() => {
|
|
154
|
-
const pluginState = DecorationSet.empty;
|
|
155
|
-
const { editorView } = editor(
|
|
156
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
const transaction = editorView.state.tr.setMeta(pluginKey, {
|
|
160
|
-
type: 'HOVER_CELL',
|
|
161
|
-
data: {
|
|
162
|
-
colIndex: 0,
|
|
163
|
-
rowIndex: 0,
|
|
164
|
-
},
|
|
165
|
-
});
|
|
69
|
+
const decorationSet = getDecorations(editorView.state);
|
|
166
70
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
editorView.state,
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
editorView.dispatch(transaction);
|
|
175
|
-
const newState = handleDocOrSelectionChanged(
|
|
176
|
-
transaction,
|
|
177
|
-
oldState,
|
|
178
|
-
editorView.state,
|
|
179
|
-
editorView.state,
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
const columnDecorations = newState.find(
|
|
183
|
-
undefined,
|
|
184
|
-
undefined,
|
|
185
|
-
(spec) =>
|
|
186
|
-
spec.key.indexOf(TableDecorations.COLUMN_CONTROLS_DECORATIONS) >
|
|
187
|
-
-1,
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
expect(columnDecorations).toHaveLength(2);
|
|
191
|
-
},
|
|
71
|
+
const columnSelectedDecorations = decorationSet.find(
|
|
72
|
+
undefined,
|
|
73
|
+
undefined,
|
|
74
|
+
(spec) => spec.key.indexOf(TableDecorations.COLUMN_SELECTED) > -1,
|
|
192
75
|
);
|
|
76
|
+
|
|
77
|
+
expect(columnSelectedDecorations).toHaveLength(0);
|
|
193
78
|
});
|
|
194
79
|
});
|
|
195
80
|
|
|
@@ -220,75 +105,36 @@ describe('decorations plugin', () => {
|
|
|
220
105
|
|
|
221
106
|
describe('when the table changed', () => {
|
|
222
107
|
describe('should not re-create the column controls decorations', () => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
228
|
-
);
|
|
229
|
-
const { state } = editorView;
|
|
230
|
-
|
|
231
|
-
const nextPluginState = handleDocOrSelectionChanged(
|
|
232
|
-
editorView.state.tr,
|
|
233
|
-
DecorationSet.empty,
|
|
234
|
-
editorView.state,
|
|
235
|
-
state,
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
const { tr: transaction } = state;
|
|
239
|
-
editorView.dispatch(addColumnAt(2)(transaction));
|
|
240
|
-
|
|
241
|
-
const newState = handleDocOrSelectionChanged(
|
|
242
|
-
transaction,
|
|
243
|
-
nextPluginState,
|
|
244
|
-
editorView.state,
|
|
245
|
-
state,
|
|
246
|
-
);
|
|
247
|
-
const expectedDecorationSet = newState;
|
|
248
|
-
const decorations = expectedDecorationSet.find(
|
|
249
|
-
undefined,
|
|
250
|
-
undefined,
|
|
251
|
-
(spec) =>
|
|
252
|
-
spec.key.indexOf(TableDecorations.COLUMN_CONTROLS_DECORATIONS) >
|
|
253
|
-
-1,
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
expect(decorations).toHaveLength(0);
|
|
257
|
-
},
|
|
258
|
-
() => {
|
|
259
|
-
const { editorView } = editor(
|
|
260
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
261
|
-
);
|
|
262
|
-
const { state } = editorView;
|
|
263
|
-
|
|
264
|
-
const nextPluginState = handleDocOrSelectionChanged(
|
|
265
|
-
editorView.state.tr,
|
|
266
|
-
DecorationSet.empty,
|
|
267
|
-
editorView.state,
|
|
268
|
-
state,
|
|
269
|
-
);
|
|
108
|
+
const { editorView } = editor(
|
|
109
|
+
doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
110
|
+
);
|
|
111
|
+
const { state } = editorView;
|
|
270
112
|
|
|
271
|
-
|
|
272
|
-
|
|
113
|
+
const nextPluginState = handleDocOrSelectionChanged(
|
|
114
|
+
editorView.state.tr,
|
|
115
|
+
DecorationSet.empty,
|
|
116
|
+
editorView.state,
|
|
117
|
+
state,
|
|
118
|
+
);
|
|
273
119
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
nextPluginState,
|
|
277
|
-
editorView.state,
|
|
278
|
-
state,
|
|
279
|
-
);
|
|
280
|
-
const expectedDecorationSet = newState;
|
|
281
|
-
const decorations = expectedDecorationSet.find(
|
|
282
|
-
undefined,
|
|
283
|
-
undefined,
|
|
284
|
-
(spec) =>
|
|
285
|
-
spec.key.indexOf(TableDecorations.COLUMN_CONTROLS_DECORATIONS) >
|
|
286
|
-
-1,
|
|
287
|
-
);
|
|
120
|
+
const { tr: transaction } = state;
|
|
121
|
+
editorView.dispatch(addColumnAt(2)(transaction));
|
|
288
122
|
|
|
289
|
-
|
|
290
|
-
|
|
123
|
+
const newState = handleDocOrSelectionChanged(
|
|
124
|
+
transaction,
|
|
125
|
+
nextPluginState,
|
|
126
|
+
editorView.state,
|
|
127
|
+
state,
|
|
291
128
|
);
|
|
129
|
+
const expectedDecorationSet = newState;
|
|
130
|
+
const decorations = expectedDecorationSet.find(
|
|
131
|
+
undefined,
|
|
132
|
+
undefined,
|
|
133
|
+
(spec) =>
|
|
134
|
+
spec.key.indexOf(TableDecorations.COLUMN_CONTROLS_DECORATIONS) > -1,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
expect(decorations).toHaveLength(3);
|
|
292
138
|
});
|
|
293
139
|
});
|
|
294
140
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
4
|
import { IntlProvider } from 'react-intl-next';
|
|
5
5
|
|
|
6
6
|
import type { DocBuilder } from '@atlaskit/editor-common/types';
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
|
|
30
30
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
31
31
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
32
|
-
import { TableCssClassName as ClassName } from '../../../plugins/table/types';
|
|
32
|
+
// import { TableCssClassName as ClassName } from '../../../plugins/table/types';
|
|
33
33
|
import { DragControls } from '../../../plugins/table/ui/TableFloatingControls/RowControls';
|
|
34
34
|
|
|
35
35
|
describe('NumberColumn', () => {
|
|
@@ -63,7 +63,7 @@ describe('NumberColumn', () => {
|
|
|
63
63
|
);
|
|
64
64
|
const ref = editorView.dom.querySelector('table');
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
render(
|
|
67
67
|
<IntlProvider locale="en">
|
|
68
68
|
<DragControls
|
|
69
69
|
tableRef={ref!}
|
|
@@ -77,11 +77,9 @@ describe('NumberColumn', () => {
|
|
|
77
77
|
</IntlProvider>,
|
|
78
78
|
);
|
|
79
79
|
|
|
80
|
-
const
|
|
81
|
-
`.${ClassName.ROW_CONTROLS_WITH_DRAG}`,
|
|
82
|
-
);
|
|
80
|
+
const dragHandle = screen.getAllByTestId('table-floating-row-drag-handle');
|
|
83
81
|
|
|
84
|
-
expect(
|
|
82
|
+
expect(dragHandle.length).toBe(1);
|
|
85
83
|
});
|
|
86
84
|
|
|
87
85
|
it('should not render any drag handle containers if hoveredCell is undefined', () => {
|
|
@@ -98,7 +96,7 @@ describe('NumberColumn', () => {
|
|
|
98
96
|
);
|
|
99
97
|
const ref = editorView.dom.querySelector('table');
|
|
100
98
|
|
|
101
|
-
|
|
99
|
+
render(
|
|
102
100
|
<IntlProvider locale="en">
|
|
103
101
|
<DragControls
|
|
104
102
|
tableRef={ref!}
|
|
@@ -115,10 +113,10 @@ describe('NumberColumn', () => {
|
|
|
115
113
|
</IntlProvider>,
|
|
116
114
|
);
|
|
117
115
|
|
|
118
|
-
const
|
|
119
|
-
|
|
116
|
+
const dragHandle = screen.queryAllByTestId(
|
|
117
|
+
'table-floating-row-drag-handle',
|
|
120
118
|
);
|
|
121
119
|
|
|
122
|
-
expect(
|
|
120
|
+
expect(dragHandle.length).toBe(0);
|
|
123
121
|
});
|
|
124
122
|
});
|
|
@@ -55,6 +55,8 @@ import {
|
|
|
55
55
|
isCell,
|
|
56
56
|
isColumnControlsDecorations,
|
|
57
57
|
isCornerButton,
|
|
58
|
+
isDragColumnFloatingInsertDot,
|
|
59
|
+
isDragRowFloatingInsertDot,
|
|
58
60
|
isInsertRowButton,
|
|
59
61
|
isResizeHandleDecoration,
|
|
60
62
|
isRowControlsButton,
|
|
@@ -78,6 +80,12 @@ const isFocusingFloatingToolbar = (event: Event) =>
|
|
|
78
80
|
event.relatedTarget instanceof HTMLElement &&
|
|
79
81
|
event.relatedTarget.closest('[role="toolbar"]');
|
|
80
82
|
|
|
83
|
+
const isFocusingDragHandles = (event: Event) =>
|
|
84
|
+
event instanceof FocusEvent &&
|
|
85
|
+
event.relatedTarget instanceof HTMLElement &&
|
|
86
|
+
event.relatedTarget.closest('button') &&
|
|
87
|
+
event.relatedTarget.getAttribute('draggable') === 'true';
|
|
88
|
+
|
|
81
89
|
export const handleBlur = (view: EditorView, event: Event): boolean => {
|
|
82
90
|
const { state, dispatch } = view;
|
|
83
91
|
// IE version check for ED-4665
|
|
@@ -86,7 +94,8 @@ export const handleBlur = (view: EditorView, event: Event): boolean => {
|
|
|
86
94
|
browser.ie_version !== 11 &&
|
|
87
95
|
!isFocusingCalendar(event) &&
|
|
88
96
|
!isFocusingModal(event) &&
|
|
89
|
-
!isFocusingFloatingToolbar(event)
|
|
97
|
+
!isFocusingFloatingToolbar(event) &&
|
|
98
|
+
!isFocusingDragHandles(event)
|
|
90
99
|
) {
|
|
91
100
|
setEditorFocus(false)(state, dispatch);
|
|
92
101
|
}
|
|
@@ -312,7 +321,10 @@ export const handleMouseMove = (
|
|
|
312
321
|
}
|
|
313
322
|
const element = event.target;
|
|
314
323
|
|
|
315
|
-
if (
|
|
324
|
+
if (
|
|
325
|
+
isColumnControlsDecorations(element) ||
|
|
326
|
+
isDragColumnFloatingInsertDot(element)
|
|
327
|
+
) {
|
|
316
328
|
const { state, dispatch } = view;
|
|
317
329
|
const { insertColumnButtonIndex } = getPluginState(state);
|
|
318
330
|
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
@@ -330,7 +342,7 @@ export const handleMouseMove = (
|
|
|
330
342
|
}
|
|
331
343
|
}
|
|
332
344
|
|
|
333
|
-
if (isRowControlsButton(element)) {
|
|
345
|
+
if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
|
|
334
346
|
const { state, dispatch } = view;
|
|
335
347
|
const { insertRowButtonIndex } = getPluginState(state);
|
|
336
348
|
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
@@ -75,6 +75,7 @@ import type { ColumnResizingPluginState, PluginConfig } from './types';
|
|
|
75
75
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
76
76
|
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
77
77
|
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
78
|
+
import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
78
79
|
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
79
80
|
import LayoutButton from './ui/LayoutButton';
|
|
80
81
|
import { isLayoutSupported } from './utils';
|
|
@@ -363,6 +364,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
363
364
|
stickyHeadersState,
|
|
364
365
|
tablePluginState,
|
|
365
366
|
tableWidthPluginState,
|
|
367
|
+
dragAndDropState,
|
|
366
368
|
}) => {
|
|
367
369
|
const { state } = editorView;
|
|
368
370
|
const isColumnResizing = resizingPluginState?.dragging;
|
|
@@ -381,6 +383,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
381
383
|
insertRowButtonIndex,
|
|
382
384
|
isHeaderColumnEnabled,
|
|
383
385
|
isHeaderRowEnabled,
|
|
386
|
+
isDragAndDropEnabled,
|
|
384
387
|
tableWrapperTarget,
|
|
385
388
|
} = tablePluginState!;
|
|
386
389
|
|
|
@@ -441,6 +444,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
441
444
|
insertRowButtonIndex={insertRowButtonIndex}
|
|
442
445
|
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
443
446
|
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
447
|
+
isDragAndDropEnabled={isDragAndDropEnabled}
|
|
444
448
|
editorView={editorView}
|
|
445
449
|
mountPoint={popupsMountPoint}
|
|
446
450
|
boundariesElement={popupsBoundariesElement}
|
|
@@ -467,7 +471,20 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
467
471
|
}
|
|
468
472
|
/>
|
|
469
473
|
)}
|
|
470
|
-
{
|
|
474
|
+
{isDragAndDropEnabled && (
|
|
475
|
+
<FloatingDragMenu
|
|
476
|
+
editorView={editorView}
|
|
477
|
+
mountPoint={popupsMountPoint}
|
|
478
|
+
boundariesElement={popupsBoundariesElement}
|
|
479
|
+
tableRef={tableRef as HTMLTableElement}
|
|
480
|
+
tableNode={tableNode}
|
|
481
|
+
targetCellPosition={targetCellPosition}
|
|
482
|
+
direction={dragAndDropState?.dragMenuDirection}
|
|
483
|
+
index={dragAndDropState?.dragMenuIndex}
|
|
484
|
+
isOpen={!!dragAndDropState?.isDragMenuOpen && !isResizing}
|
|
485
|
+
/>
|
|
486
|
+
)}
|
|
487
|
+
{allowControls && !isDragAndDropEnabled && !isResizing && (
|
|
471
488
|
<FloatingDeleteButton
|
|
472
489
|
editorView={editorView}
|
|
473
490
|
selection={editorView.state.selection}
|
|
@@ -416,6 +416,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
416
416
|
<TableFloatingControls
|
|
417
417
|
editorView={view}
|
|
418
418
|
tableRef={tableRef}
|
|
419
|
+
tableNode={node}
|
|
419
420
|
tableActive={tableActive}
|
|
420
421
|
hoveredRows={hoveredRows}
|
|
421
422
|
hoveredCell={hoveredCell}
|
|
@@ -423,7 +424,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
423
424
|
isResizing={isResizing}
|
|
424
425
|
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
|
425
426
|
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
426
|
-
isDragAndDropEnabled={
|
|
427
|
+
isDragAndDropEnabled={isDragAndDropEnabled}
|
|
427
428
|
ordering={ordering}
|
|
428
429
|
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
429
430
|
hasHeaderRow={hasHeaderRow}
|
|
@@ -40,8 +40,7 @@ export const handleDocOrSelectionChanged = (
|
|
|
40
40
|
} else if (
|
|
41
41
|
tr.docChanged ||
|
|
42
42
|
tr.selection instanceof CellSelection ||
|
|
43
|
-
changedResizing
|
|
44
|
-
tr.getMeta(tablePluginKey)?.type === 'HOVER_CELL'
|
|
43
|
+
changedResizing
|
|
45
44
|
) {
|
|
46
45
|
return buildColumnControlsDecorations({
|
|
47
46
|
decorationSet,
|
|
@@ -72,11 +71,6 @@ export const createPlugin = () => {
|
|
|
72
71
|
apply: (tr, decorationSet, oldState, newState) => {
|
|
73
72
|
let pluginState = decorationSet;
|
|
74
73
|
const meta = tr.getMeta(tablePluginKey);
|
|
75
|
-
const previousHover = tablePluginKey.getState(oldState)?.hoveredCell;
|
|
76
|
-
const newHover = tablePluginKey.getState(newState)?.hoveredCell;
|
|
77
|
-
const changedCellHover =
|
|
78
|
-
previousHover?.colIndex !== newHover?.colIndex ||
|
|
79
|
-
previousHover?.rowIndex !== newHover?.rowIndex;
|
|
80
74
|
|
|
81
75
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
82
76
|
pluginState = meta.data.decorationSet;
|
|
@@ -85,8 +79,7 @@ export const createPlugin = () => {
|
|
|
85
79
|
if (
|
|
86
80
|
tr.docChanged ||
|
|
87
81
|
tr.selectionSet ||
|
|
88
|
-
tr.getMeta(tableWidthPluginKey)
|
|
89
|
-
changedCellHover
|
|
82
|
+
tr.getMeta(tableWidthPluginKey)
|
|
90
83
|
) {
|
|
91
84
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
92
85
|
return handleDocOrSelectionChanged(
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
findControlsHoverDecoration,
|
|
16
16
|
updateDecorations,
|
|
17
17
|
} from '../../../utils/decoration';
|
|
18
|
-
import { pluginKey as tablePluginKey } from '../../plugin-key';
|
|
19
18
|
|
|
20
19
|
import { composeDecorations } from './compose-decorations';
|
|
21
20
|
import type { DecorationTransformer } from './types';
|
|
@@ -50,10 +49,9 @@ const maybeUpdateColumnControlsDecoration: DecorationTransformer = ({
|
|
|
50
49
|
tr,
|
|
51
50
|
}): DecorationSet => {
|
|
52
51
|
const table = findTable(tr.selection);
|
|
53
|
-
const meta = tr.getMeta(tablePluginKey);
|
|
54
52
|
|
|
55
53
|
// avoid re-drawing state if dnd decorations don't need to be updated
|
|
56
|
-
if (!table
|
|
54
|
+
if (!table) {
|
|
57
55
|
return decorationSet;
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
|
|
3
|
+
import type { TableDirection } from '../../types';
|
|
4
|
+
|
|
3
5
|
import type { DropTargetType } from './consts';
|
|
4
6
|
|
|
5
7
|
export interface DragAndDropAction<T, D> {
|
|
@@ -10,6 +12,7 @@ export interface DragAndDropAction<T, D> {
|
|
|
10
12
|
export const DragAndDropActionType = {
|
|
11
13
|
SET_DROP_TARGET: 'SET_DROP_TARGET',
|
|
12
14
|
CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
|
|
15
|
+
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU',
|
|
13
16
|
} as const;
|
|
14
17
|
|
|
15
18
|
export type DragAndDropSetDropTargetAction = DragAndDropAction<
|
|
@@ -28,7 +31,17 @@ export type DragAndDropClearDropTargetAction = DragAndDropAction<
|
|
|
28
31
|
}
|
|
29
32
|
>;
|
|
30
33
|
|
|
34
|
+
export type DragAndDropToggleDragMenuAction = DragAndDropAction<
|
|
35
|
+
typeof DragAndDropActionType.TOGGLE_DRAG_MENU,
|
|
36
|
+
{
|
|
37
|
+
isDragMenuOpen: boolean;
|
|
38
|
+
direction: TableDirection;
|
|
39
|
+
index: number;
|
|
40
|
+
}
|
|
41
|
+
>;
|
|
42
|
+
|
|
31
43
|
// NOTE: This should be a Union of all possible actions
|
|
32
44
|
export type DragAndDropPluginAction =
|
|
33
45
|
| DragAndDropSetDropTargetAction
|
|
34
|
-
| DragAndDropClearDropTargetAction
|
|
46
|
+
| DragAndDropClearDropTargetAction
|
|
47
|
+
| DragAndDropToggleDragMenuAction;
|