@atlaskit/editor-plugin-table 5.3.28 → 5.3.30
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 +12 -0
- package/dist/cjs/plugins/table/nodeviews/ExternalDropTargets.js +75 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +75 -4
- package/dist/cjs/plugins/table/nodeviews/TableRow.js +36 -112
- package/dist/cjs/plugins/table/nodeviews/TableStickyScrollbar.js +9 -9
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -10
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +61 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +21 -15
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +4 -2
- package/dist/es2019/plugins/table/nodeviews/ExternalDropTargets.js +64 -0
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +80 -5
- package/dist/es2019/plugins/table/nodeviews/TableRow.js +4 -78
- package/dist/es2019/plugins/table/nodeviews/TableStickyScrollbar.js +6 -6
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +58 -8
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +55 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -11
- package/dist/es2019/plugins/table/ui/common-styles.js +2 -2
- package/dist/es2019/plugins/table/ui/consts.js +3 -1
- package/dist/esm/plugins/table/nodeviews/ExternalDropTargets.js +65 -0
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +76 -5
- package/dist/esm/plugins/table/nodeviews/TableRow.js +36 -112
- package/dist/esm/plugins/table/nodeviews/TableStickyScrollbar.js +9 -9
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -11
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +52 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +21 -15
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/consts.js +3 -1
- package/dist/types/plugins/table/nodeviews/ExternalDropTargets.d.ts +9 -0
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types/plugins/table/nodeviews/TableRow.d.ts +0 -4
- package/dist/types/plugins/table/nodeviews/TableStickyScrollbar.d.ts +3 -3
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowDropTarget/index.d.ts +8 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -1
- package/dist/types/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types/plugins/table/utils/column-controls.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/ExternalDropTargets.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +0 -4
- package/dist/types-ts4.5/plugins/table/nodeviews/TableStickyScrollbar.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowDropTarget/index.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +2 -2
- package/package.json +3 -3
- package/src/__tests__/unit/ui/RowDragControls.tsx +2 -0
- package/src/plugins/table/nodeviews/ExternalDropTargets.tsx +86 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +92 -7
- package/src/plugins/table/nodeviews/TableRow.ts +2 -65
- package/src/plugins/table/nodeviews/TableStickyScrollbar.ts +6 -6
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +0 -7
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +1 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +2 -7
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +80 -21
- package/src/plugins/table/ui/TableFloatingControls/RowDropTarget/index.tsx +62 -0
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +29 -8
- package/src/plugins/table/ui/common-styles.ts +2 -1
- package/src/plugins/table/ui/consts.ts +3 -0
- package/src/plugins/table/utils/column-controls.ts +2 -2
- package/tsconfig.app.json +2 -2
package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ type DragControlsProps = {
|
|
|
7
7
|
editorView: EditorView;
|
|
8
8
|
tableRef: HTMLTableElement;
|
|
9
9
|
tableNode?: PmNode;
|
|
10
|
+
tableWidth: number;
|
|
10
11
|
tableActive?: boolean;
|
|
11
12
|
hoveredCell?: CellHoverMeta;
|
|
12
13
|
isInDanger?: boolean;
|
|
13
14
|
isResizing?: boolean;
|
|
14
|
-
hasHeaderRow?: boolean;
|
|
15
15
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
16
16
|
selectRow: (row: number, expand: boolean) => void;
|
|
17
17
|
updateCellHoverLocation: (rowIndex: number) => void;
|
|
@@ -26,11 +26,13 @@ export interface Props {
|
|
|
26
26
|
insertRowButtonIndex?: number;
|
|
27
27
|
}
|
|
28
28
|
interface State {
|
|
29
|
-
|
|
29
|
+
tableWrapperWidth: number;
|
|
30
|
+
tableWrapperHeight: number;
|
|
30
31
|
}
|
|
31
32
|
export default class TableFloatingControls extends Component<Props, State> {
|
|
32
33
|
static displayName: string;
|
|
33
34
|
private resizeObserver?;
|
|
35
|
+
constructor(props: Props);
|
|
34
36
|
componentDidMount(): void;
|
|
35
37
|
componentDidUpdate(): void;
|
|
36
38
|
private tryInitResizeObserver;
|
|
@@ -47,8 +47,10 @@ export declare const stickyRowOffsetTop = 8;
|
|
|
47
47
|
export declare const stickyHeaderBorderBottomWidth = 1;
|
|
48
48
|
export declare const tableOverflowShadowWidth = 8;
|
|
49
49
|
export declare const tableOverflowShadowWidthWide = 32;
|
|
50
|
+
export declare const dropTargetsZIndex = 14;
|
|
50
51
|
export declare const TABLE_SNAP_GAP = 9;
|
|
51
52
|
export declare const TABLE_HIGHLIGHT_GAP = 10;
|
|
52
53
|
export declare const TABLE_HIGHLIGHT_TOLERANCE = 2;
|
|
53
54
|
export declare const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
|
|
54
55
|
export declare const dragMenuDropdownWidth = 240;
|
|
56
|
+
export declare const dropTargetExtendedWidth = 150;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
export declare const getColumnsWidths: (view: EditorView) => Array<number | undefined>;
|
|
4
4
|
export declare const isColumnDeleteButtonVisible: (selection: Selection) => boolean;
|
|
5
5
|
export declare const getColumnDeleteButtonParams: (columnsWidths: Array<number | undefined>, selection: Selection) => {
|
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.30",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@atlaskit/icon": "^21.12.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
44
44
|
"@atlaskit/pragmatic-drag-and-drop": "^0.24.0",
|
|
45
|
+
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^0.7.0",
|
|
45
46
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.12.0",
|
|
46
|
-
"@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^0.6.4",
|
|
47
47
|
"@atlaskit/primitives": "^1.10.0",
|
|
48
48
|
"@atlaskit/theme": "^12.6.0",
|
|
49
49
|
"@atlaskit/tokens": "^1.28.0",
|
|
50
|
-
"@atlaskit/tooltip": "^
|
|
50
|
+
"@atlaskit/tooltip": "^18.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"@emotion/react": "^11.7.1",
|
|
53
53
|
"classnames": "^2.2.5",
|
|
@@ -74,6 +74,7 @@ describe('NumberColumn', () => {
|
|
|
74
74
|
hoverRows={jest.fn()}
|
|
75
75
|
selectRow={jest.fn()}
|
|
76
76
|
updateCellHoverLocation={jest.fn()}
|
|
77
|
+
tableWidth={760}
|
|
77
78
|
/>
|
|
78
79
|
</IntlProvider>,
|
|
79
80
|
);
|
|
@@ -110,6 +111,7 @@ describe('NumberColumn', () => {
|
|
|
110
111
|
hoverRows={jest.fn()}
|
|
111
112
|
selectRow={jest.fn()}
|
|
112
113
|
updateCellHoverLocation={jest.fn()}
|
|
114
|
+
tableWidth={760}
|
|
113
115
|
/>
|
|
114
116
|
</IntlProvider>,
|
|
115
117
|
);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
7
|
+
|
|
8
|
+
import type { DraggableSourceData } from '../types';
|
|
9
|
+
import { dropTargetExtendedWidth, dropTargetsZIndex } from '../ui/consts';
|
|
10
|
+
import { ColumnDropTarget } from '../ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget';
|
|
11
|
+
import { getColumnsWidths } from '../utils';
|
|
12
|
+
|
|
13
|
+
export const ExternalDropTargets = ({
|
|
14
|
+
editorView,
|
|
15
|
+
node,
|
|
16
|
+
getScrollOffset,
|
|
17
|
+
getTableWrapperWidth,
|
|
18
|
+
}: {
|
|
19
|
+
editorView: EditorView;
|
|
20
|
+
node?: PMNode;
|
|
21
|
+
getScrollOffset: () => number;
|
|
22
|
+
getTableWrapperWidth: () => number;
|
|
23
|
+
}) => {
|
|
24
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
25
|
+
const currentNodeLocalId = node?.attrs.localId;
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
return monitorForElements({
|
|
29
|
+
canMonitor({ source }) {
|
|
30
|
+
const { type, indexes, localId } =
|
|
31
|
+
source.data as Partial<DraggableSourceData>;
|
|
32
|
+
return (
|
|
33
|
+
type === 'table-column' &&
|
|
34
|
+
!!indexes?.length &&
|
|
35
|
+
localId === currentNodeLocalId
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
onDragStart() {
|
|
39
|
+
setIsDragging(true);
|
|
40
|
+
},
|
|
41
|
+
onDrop() {
|
|
42
|
+
setIsDragging(false);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}, [currentNodeLocalId, editorView]);
|
|
46
|
+
|
|
47
|
+
if (!isDragging) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const colWidths = getColumnsWidths(editorView);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
style={{
|
|
56
|
+
width: getTableWrapperWidth(),
|
|
57
|
+
overflow: 'hidden',
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
top: `-${dropTargetExtendedWidth - tableMarginTop}px`,
|
|
60
|
+
pointerEvents: 'auto',
|
|
61
|
+
zIndex: `${dropTargetsZIndex}`,
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
style={{
|
|
66
|
+
display: 'flex',
|
|
67
|
+
// move drop targets based on table wrapper scroll
|
|
68
|
+
marginLeft: `-${getScrollOffset()}px`,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{colWidths?.map((width, index) => {
|
|
72
|
+
return (
|
|
73
|
+
<ColumnDropTarget
|
|
74
|
+
key={index}
|
|
75
|
+
index={index}
|
|
76
|
+
localId={currentNodeLocalId}
|
|
77
|
+
width={width}
|
|
78
|
+
height={dropTargetExtendedWidth}
|
|
79
|
+
marginTop={0}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
})}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
@@ -33,6 +33,13 @@ import {
|
|
|
33
33
|
} from '@atlaskit/editor-shared-styles';
|
|
34
34
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
35
35
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
36
|
+
import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
37
|
+
import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
|
|
38
|
+
import {
|
|
39
|
+
autoScrollForElements,
|
|
40
|
+
autoScrollWindowForElements,
|
|
41
|
+
} from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
42
|
+
import { unsafeOverflowAutoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element';
|
|
36
43
|
|
|
37
44
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
38
45
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -52,9 +59,10 @@ import {
|
|
|
52
59
|
} from '../pm-plugins/table-resizing/utils';
|
|
53
60
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
54
61
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
55
|
-
import type { PluginInjectionAPI } from '../types';
|
|
62
|
+
import type { DraggableSourceData, PluginInjectionAPI } from '../types';
|
|
56
63
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
57
64
|
import {
|
|
65
|
+
dropTargetExtendedWidth,
|
|
58
66
|
tableOverflowShadowWidth,
|
|
59
67
|
tableOverflowShadowWidthWide,
|
|
60
68
|
} from '../ui/consts';
|
|
@@ -67,6 +75,7 @@ import {
|
|
|
67
75
|
tablesHaveDifferentNoOfColumns,
|
|
68
76
|
} from '../utils';
|
|
69
77
|
|
|
78
|
+
import { ExternalDropTargets } from './ExternalDropTargets';
|
|
70
79
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
71
80
|
import { TableContainer } from './TableContainer';
|
|
72
81
|
import { TableStickyScrollbar } from './TableStickyScrollbar';
|
|
@@ -129,6 +138,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
129
138
|
private isInitialOverflowSent: boolean;
|
|
130
139
|
private initialOverflowCaptureTimerId?: ReturnType<typeof setTimeout>;
|
|
131
140
|
|
|
141
|
+
private dragAndDropCleanupFn?: CleanupFn;
|
|
142
|
+
|
|
132
143
|
constructor(props: ComponentProps) {
|
|
133
144
|
super(props);
|
|
134
145
|
const { options, containerWidth, getNode } = props;
|
|
@@ -160,7 +171,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
componentDidMount() {
|
|
163
|
-
const {
|
|
174
|
+
const {
|
|
175
|
+
allowColumnResizing,
|
|
176
|
+
eventDispatcher,
|
|
177
|
+
options,
|
|
178
|
+
isDragAndDropEnabled,
|
|
179
|
+
getNode,
|
|
180
|
+
} = this.props;
|
|
181
|
+
|
|
164
182
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
165
183
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
166
184
|
passive: true,
|
|
@@ -174,6 +192,53 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
174
192
|
);
|
|
175
193
|
}
|
|
176
194
|
}
|
|
195
|
+
|
|
196
|
+
if (isDragAndDropEnabled) {
|
|
197
|
+
this.dragAndDropCleanupFn = combine(
|
|
198
|
+
autoScrollForElements({
|
|
199
|
+
element: this.wrapper,
|
|
200
|
+
canScroll: ({ source }) => {
|
|
201
|
+
const { localId, type } =
|
|
202
|
+
source.data as Partial<DraggableSourceData>;
|
|
203
|
+
const node = getNode();
|
|
204
|
+
return localId === node?.attrs.localId && type === 'table-column';
|
|
205
|
+
},
|
|
206
|
+
}),
|
|
207
|
+
autoScrollWindowForElements({
|
|
208
|
+
canScroll: ({ source }) => {
|
|
209
|
+
const { localId, type } =
|
|
210
|
+
source.data as Partial<DraggableSourceData>;
|
|
211
|
+
const node = getNode();
|
|
212
|
+
return localId === node?.attrs.localId && type === 'table-row';
|
|
213
|
+
},
|
|
214
|
+
}),
|
|
215
|
+
unsafeOverflowAutoScrollForElements({
|
|
216
|
+
element: this.wrapper,
|
|
217
|
+
canScroll: ({ source }) => {
|
|
218
|
+
const { localId } = source.data as Partial<DraggableSourceData>;
|
|
219
|
+
const node = getNode();
|
|
220
|
+
return localId === node?.attrs.localId;
|
|
221
|
+
},
|
|
222
|
+
getOverflow: () => ({
|
|
223
|
+
fromTopEdge: {
|
|
224
|
+
top: dropTargetExtendedWidth,
|
|
225
|
+
right: dropTargetExtendedWidth,
|
|
226
|
+
left: dropTargetExtendedWidth,
|
|
227
|
+
},
|
|
228
|
+
fromRightEdge: {
|
|
229
|
+
right: dropTargetExtendedWidth,
|
|
230
|
+
top: dropTargetExtendedWidth,
|
|
231
|
+
bottom: dropTargetExtendedWidth,
|
|
232
|
+
},
|
|
233
|
+
fromLeftEdge: {
|
|
234
|
+
top: dropTargetExtendedWidth,
|
|
235
|
+
left: dropTargetExtendedWidth,
|
|
236
|
+
bottom: dropTargetExtendedWidth,
|
|
237
|
+
},
|
|
238
|
+
}),
|
|
239
|
+
}),
|
|
240
|
+
);
|
|
241
|
+
}
|
|
177
242
|
}
|
|
178
243
|
|
|
179
244
|
if (allowColumnResizing) {
|
|
@@ -207,11 +272,20 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
207
272
|
}
|
|
208
273
|
|
|
209
274
|
componentWillUnmount() {
|
|
210
|
-
const {
|
|
275
|
+
const {
|
|
276
|
+
allowColumnResizing,
|
|
277
|
+
eventDispatcher,
|
|
278
|
+
options,
|
|
279
|
+
isDragAndDropEnabled,
|
|
280
|
+
} = this.props;
|
|
211
281
|
if (this.wrapper && !isIE11) {
|
|
212
282
|
this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
|
|
213
283
|
}
|
|
214
284
|
|
|
285
|
+
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
286
|
+
this.dragAndDropCleanupFn();
|
|
287
|
+
}
|
|
288
|
+
|
|
215
289
|
if (getBooleanFF('platform.editor.table-sticky-scrollbar')) {
|
|
216
290
|
if (this.stickyScrollbar) {
|
|
217
291
|
this.stickyScrollbar.dispose();
|
|
@@ -509,9 +583,18 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
509
583
|
)}
|
|
510
584
|
|
|
511
585
|
{allowControls && rowControls}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
586
|
+
{isDragAndDropEnabled && (
|
|
587
|
+
<ExternalDropTargets
|
|
588
|
+
editorView={view}
|
|
589
|
+
node={node}
|
|
590
|
+
getScrollOffset={() => {
|
|
591
|
+
return this.wrapper?.scrollLeft || 0;
|
|
592
|
+
}}
|
|
593
|
+
getTableWrapperWidth={() => {
|
|
594
|
+
return this.wrapper?.clientWidth || 760;
|
|
595
|
+
}}
|
|
596
|
+
/>
|
|
597
|
+
)}
|
|
515
598
|
<div
|
|
516
599
|
style={shadowStyle(showBeforeShadow)}
|
|
517
600
|
className={ClassName.TABLE_LEFT_SHADOW}
|
|
@@ -544,7 +627,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
544
627
|
}
|
|
545
628
|
}
|
|
546
629
|
}}
|
|
547
|
-
|
|
630
|
+
>
|
|
631
|
+
{allowControls && colControls}
|
|
632
|
+
</div>
|
|
548
633
|
{getBooleanFF('platform.editor.table-sticky-scrollbar') && (
|
|
549
634
|
<div
|
|
550
635
|
className={ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER}
|
|
@@ -6,8 +6,6 @@ import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
|
6
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
10
|
-
import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
|
|
11
9
|
|
|
12
10
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
11
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -16,7 +14,7 @@ import {
|
|
|
16
14
|
syncStickyRowToTable,
|
|
17
15
|
updateStickyMargins as updateTableMargin,
|
|
18
16
|
} from '../pm-plugins/table-resizing/utils/dom';
|
|
19
|
-
import type {
|
|
17
|
+
import type { TablePluginState } from '../types';
|
|
20
18
|
import { TableCssClassName as ClassName, TableCssClassName } from '../types';
|
|
21
19
|
import {
|
|
22
20
|
STICKY_HEADER_TOGGLE_TOLERANCE_MS,
|
|
@@ -53,10 +51,9 @@ export default class TableRow
|
|
|
53
51
|
this.isHeaderRow = supportedHeaderRow(node);
|
|
54
52
|
this.isSticky = false;
|
|
55
53
|
|
|
56
|
-
const { pluginConfig
|
|
54
|
+
const { pluginConfig } = getPluginState(view.state);
|
|
57
55
|
|
|
58
56
|
this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
59
|
-
this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
60
57
|
|
|
61
58
|
if (this.isHeaderRow) {
|
|
62
59
|
this.dom.setAttribute('data-header-row', 'true');
|
|
@@ -64,10 +61,6 @@ export default class TableRow
|
|
|
64
61
|
this.subscribe();
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
|
-
|
|
68
|
-
if (this.isDragAndDropEnabled) {
|
|
69
|
-
this.addDropTarget(this.contentDOM);
|
|
70
|
-
}
|
|
71
64
|
}
|
|
72
65
|
|
|
73
66
|
/**
|
|
@@ -75,8 +68,6 @@ export default class TableRow
|
|
|
75
68
|
*/
|
|
76
69
|
private isHeaderRow: boolean;
|
|
77
70
|
private isStickyHeaderEnabled: boolean;
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
private isDragAndDropEnabled: boolean;
|
|
80
71
|
private editorScrollableElement?: HTMLElement | Window;
|
|
81
72
|
private colControlsOffset = 0;
|
|
82
73
|
private focused = false;
|
|
@@ -93,7 +84,6 @@ export default class TableRow
|
|
|
93
84
|
private listening = false;
|
|
94
85
|
private padding: number = 0;
|
|
95
86
|
private top: number = 0;
|
|
96
|
-
private dropTargetCleanup?: () => void;
|
|
97
87
|
|
|
98
88
|
/**
|
|
99
89
|
* Methods: Nodeview Lifecycle
|
|
@@ -140,9 +130,6 @@ export default class TableRow
|
|
|
140
130
|
|
|
141
131
|
this.emitOff(true);
|
|
142
132
|
}
|
|
143
|
-
|
|
144
|
-
// If a drop target cleanup method has been set then we should call it.
|
|
145
|
-
this.dropTargetCleanup?.();
|
|
146
133
|
}
|
|
147
134
|
|
|
148
135
|
ignoreMutation(
|
|
@@ -181,56 +168,6 @@ export default class TableRow
|
|
|
181
168
|
/**
|
|
182
169
|
* Methods
|
|
183
170
|
*/
|
|
184
|
-
|
|
185
|
-
private addDropTarget(element: HTMLElement) {
|
|
186
|
-
const pos = this.getPos()!;
|
|
187
|
-
if (!Number.isFinite(pos)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (this.dropTargetCleanup) {
|
|
192
|
-
this.dropTargetCleanup();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this.dropTargetCleanup = dropTargetForElements({
|
|
196
|
-
element: element,
|
|
197
|
-
canDrop: ({ source }) => {
|
|
198
|
-
const data = source.data as DraggableSourceData;
|
|
199
|
-
const { localId, targetIndex } = this.getCurrentData();
|
|
200
|
-
return (
|
|
201
|
-
// Only draggables of row type can be dropped on this target
|
|
202
|
-
data.type === 'table-row' &&
|
|
203
|
-
// Only draggables which came from the same table can be dropped on this target
|
|
204
|
-
data.localId === localId &&
|
|
205
|
-
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
206
|
-
!!data.indexes?.length &&
|
|
207
|
-
data.indexes?.indexOf(targetIndex) === -1
|
|
208
|
-
);
|
|
209
|
-
},
|
|
210
|
-
getIsSticky: () => true,
|
|
211
|
-
getData: ({ input, element }) => {
|
|
212
|
-
const { localId, targetIndex } = this.getCurrentData();
|
|
213
|
-
const data = {
|
|
214
|
-
localId,
|
|
215
|
-
type: 'table-row',
|
|
216
|
-
targetIndex,
|
|
217
|
-
};
|
|
218
|
-
return attachClosestEdge(data, {
|
|
219
|
-
input,
|
|
220
|
-
element,
|
|
221
|
-
allowedEdges: ['top', 'bottom'],
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
private getCurrentData() {
|
|
228
|
-
const resolvedPos = this.view.state.doc.resolve(this.getPos()!);
|
|
229
|
-
const targetIndex = resolvedPos.index();
|
|
230
|
-
const localId = resolvedPos.parent.attrs.localId;
|
|
231
|
-
return { targetIndex, localId };
|
|
232
|
-
}
|
|
233
|
-
|
|
234
171
|
private headerRowMouseScrollEnd = debounce(() => {
|
|
235
172
|
this.dom.classList.remove('no-pointer-events');
|
|
236
173
|
}, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT);
|
|
@@ -38,7 +38,7 @@ export class TableStickyScrollbar {
|
|
|
38
38
|
this.handleScrollDebounced.cancel();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
this.
|
|
41
|
+
this.deleteIntersectionObserver();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
scrollLeft(left: number) {
|
|
@@ -95,7 +95,7 @@ export class TableStickyScrollbar {
|
|
|
95
95
|
ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
|
|
96
96
|
)
|
|
97
97
|
) {
|
|
98
|
-
this.
|
|
98
|
+
this.sentinelBottomCallback(entry);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
if (
|
|
@@ -103,7 +103,7 @@ export class TableStickyScrollbar {
|
|
|
103
103
|
ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
|
|
104
104
|
)
|
|
105
105
|
) {
|
|
106
|
-
this.
|
|
106
|
+
this.sentinelTopCallback(entry);
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
},
|
|
@@ -123,7 +123,7 @@ export class TableStickyScrollbar {
|
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
private
|
|
126
|
+
private deleteIntersectionObserver() {
|
|
127
127
|
if (this.intersectionObserver) {
|
|
128
128
|
if (this.sentinels.bottom) {
|
|
129
129
|
this.intersectionObserver.unobserve(this.sentinels.bottom);
|
|
@@ -132,7 +132,7 @@ export class TableStickyScrollbar {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
private
|
|
135
|
+
private sentinelBottomCallback(entry: IntersectionObserverEntry) {
|
|
136
136
|
const sentinelIsAboveScrollArea =
|
|
137
137
|
entry.boundingClientRect.top < (entry.rootBounds?.top || 0);
|
|
138
138
|
|
|
@@ -145,7 +145,7 @@ export class TableStickyScrollbar {
|
|
|
145
145
|
this.toggle();
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
private
|
|
148
|
+
private sentinelTopCallback(entry: IntersectionObserverEntry) {
|
|
149
149
|
const sentinelIsBelowScrollArea =
|
|
150
150
|
(entry.rootBounds?.bottom || 0) < entry.boundingClientRect.top;
|
|
151
151
|
|
|
@@ -8,7 +8,6 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
8
8
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
9
9
|
import { getCellsInRow } from '@atlaskit/editor-tables/utils';
|
|
10
10
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
11
|
-
import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
|
|
12
11
|
|
|
13
12
|
import type { DraggableSourceData } from '../../types';
|
|
14
13
|
import {
|
|
@@ -109,14 +108,9 @@ export const createPlugin = (
|
|
|
109
108
|
return localId === tableNode?.attrs.localId;
|
|
110
109
|
},
|
|
111
110
|
onDragStart: ({ location }) => {
|
|
112
|
-
autoScroller.start({ input: location.current.input });
|
|
113
111
|
toggleDragMenu(false)(editorView.state, editorView.dispatch);
|
|
114
112
|
},
|
|
115
113
|
onDrag(event) {
|
|
116
|
-
autoScroller.updateInput({
|
|
117
|
-
input: event.location.current.input,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
114
|
const data = getDraggableDataFromEvent(event);
|
|
121
115
|
// If no data can be found then it's most like we do not want to perform any drag actions
|
|
122
116
|
if (!data) {
|
|
@@ -138,7 +132,6 @@ export const createPlugin = (
|
|
|
138
132
|
);
|
|
139
133
|
},
|
|
140
134
|
onDrop(event) {
|
|
141
|
-
autoScroller.stop();
|
|
142
135
|
const data = getDraggableDataFromEvent(event);
|
|
143
136
|
|
|
144
137
|
// If no data can be found then it's most like we do not want to perform any drop action
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import ReactDOM from 'react-dom';
|
|
4
|
-
|
|
5
3
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
6
4
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
7
5
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -121,13 +119,11 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
121
119
|
? stickyHeader.top
|
|
122
120
|
: undefined;
|
|
123
121
|
|
|
124
|
-
const mountTo = (tableRef && tableRef?.parentElement) || document.body;
|
|
125
|
-
|
|
126
122
|
if (!tableActive) {
|
|
127
123
|
return null;
|
|
128
124
|
}
|
|
129
125
|
|
|
130
|
-
return
|
|
126
|
+
return (
|
|
131
127
|
<div
|
|
132
128
|
className={ClassName.DRAG_COLUMN_CONTROLS_WRAPPER}
|
|
133
129
|
data-testid="table-floating-column-controls-wrapper"
|
|
@@ -155,8 +151,7 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
155
151
|
colWidths={colWidths}
|
|
156
152
|
/>
|
|
157
153
|
)}
|
|
158
|
-
</div
|
|
159
|
-
mountTo,
|
|
154
|
+
</div>
|
|
160
155
|
);
|
|
161
156
|
};
|
|
162
157
|
|