@atlaskit/editor-plugin-table 7.1.4 → 7.2.1
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 +17 -0
- package/dist/cjs/nodeviews/TableComponent.js +0 -3
- package/dist/cjs/nodeviews/table.js +1 -4
- package/dist/cjs/plugin.js +0 -1
- package/dist/cjs/pm-plugins/drag-and-drop/actions.js +1 -2
- package/dist/cjs/pm-plugins/drag-and-drop/consts.js +2 -3
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +14 -39
- package/dist/cjs/pm-plugins/drag-and-drop/reducer.js +0 -2
- package/dist/cjs/pm-plugins/main.js +3 -0
- package/dist/cjs/ui/DragHandle/index.js +3 -5
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +0 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -3
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +1 -3
- package/dist/cjs/ui/TableFloatingControls/index.js +4 -7
- package/dist/es2019/nodeviews/TableComponent.js +0 -3
- package/dist/es2019/nodeviews/table.js +1 -5
- package/dist/es2019/plugin.js +0 -1
- package/dist/es2019/pm-plugins/drag-and-drop/actions.js +1 -2
- package/dist/es2019/pm-plugins/drag-and-drop/consts.js +1 -2
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +15 -39
- package/dist/es2019/pm-plugins/drag-and-drop/reducer.js +0 -5
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/ui/DragHandle/index.js +3 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +0 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -3
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +1 -3
- package/dist/es2019/ui/TableFloatingControls/index.js +4 -7
- package/dist/esm/nodeviews/TableComponent.js +0 -3
- package/dist/esm/nodeviews/table.js +1 -4
- package/dist/esm/plugin.js +0 -1
- package/dist/esm/pm-plugins/drag-and-drop/actions.js +1 -2
- package/dist/esm/pm-plugins/drag-and-drop/consts.js +1 -2
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +15 -39
- package/dist/esm/pm-plugins/drag-and-drop/reducer.js +0 -2
- package/dist/esm/pm-plugins/main.js +4 -1
- package/dist/esm/ui/DragHandle/index.js +3 -5
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +0 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -3
- package/dist/esm/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +1 -3
- package/dist/esm/ui/TableFloatingControls/index.js +4 -7
- package/dist/types/nodeviews/TableComponent.d.ts +0 -1
- package/dist/types/pm-plugins/drag-and-drop/actions.d.ts +1 -4
- package/dist/types/pm-plugins/drag-and-drop/consts.d.ts +0 -1
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/drag-and-drop/types.d.ts +0 -1
- package/dist/types/ui/DragHandle/index.d.ts +0 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +0 -1
- package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +0 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/actions.d.ts +1 -4
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/consts.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +0 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +0 -1
- package/package.json +5 -5
- package/src/nodeviews/TableComponent.tsx +0 -4
- package/src/nodeviews/table.tsx +0 -3
- package/src/plugin.tsx +0 -1
- package/src/pm-plugins/drag-and-drop/actions.ts +1 -9
- package/src/pm-plugins/drag-and-drop/consts.ts +0 -2
- package/src/pm-plugins/drag-and-drop/plugin.ts +17 -49
- package/src/pm-plugins/drag-and-drop/reducer.ts +0 -5
- package/src/pm-plugins/drag-and-drop/types.ts +0 -1
- package/src/pm-plugins/main.ts +4 -0
- package/src/ui/DragHandle/index.tsx +2 -5
- package/src/ui/FloatingDragMenu/DragMenu.tsx +1 -3
- package/src/ui/FloatingDragMenu/index.tsx +0 -3
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -3
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -3
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -3
- package/src/ui/TableFloatingControls/index.tsx +1 -6
- package/src/__tests__/unit/pm-plugins/drag-and-drop/plugin.ts +0 -112
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
import type { TableDirection } from '../../types';
|
|
3
3
|
import type { DropTargetType } from './consts';
|
|
4
|
-
import type { DragAndDropPluginState } from './types';
|
|
5
4
|
export interface DragAndDropAction<T, D> {
|
|
6
5
|
type: T;
|
|
7
6
|
data: D;
|
|
@@ -10,7 +9,6 @@ export declare const DragAndDropActionType: {
|
|
|
10
9
|
readonly SET_DROP_TARGET: "SET_DROP_TARGET";
|
|
11
10
|
readonly CLEAR_DROP_TARGET: "CLEAR_DROP_TARGET";
|
|
12
11
|
readonly TOGGLE_DRAG_MENU: "TOGGLE_DRAG_MENU";
|
|
13
|
-
readonly UPDATE: "UPDATE";
|
|
14
12
|
};
|
|
15
13
|
export type DragAndDropSetDropTargetAction = DragAndDropAction<typeof DragAndDropActionType.SET_DROP_TARGET, {
|
|
16
14
|
type: DropTargetType;
|
|
@@ -25,5 +23,4 @@ export type DragAndDropToggleDragMenuAction = DragAndDropAction<typeof DragAndDr
|
|
|
25
23
|
direction: TableDirection;
|
|
26
24
|
index: number;
|
|
27
25
|
}>;
|
|
28
|
-
export type
|
|
29
|
-
export type DragAndDropPluginAction = DragAndDropSetDropTargetAction | DragAndDropClearDropTargetAction | DragAndDropToggleDragMenuAction | DragAndDropUpdateAction;
|
|
26
|
+
export type DragAndDropPluginAction = DragAndDropSetDropTargetAction | DragAndDropClearDropTargetAction | DragAndDropToggleDragMenuAction;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
|
|
5
|
-
export declare const createPlugin: (dispatch: Dispatch, eventDispatcher: EventDispatcher, editorAnalyticsAPI?: EditorAnalyticsAPI) => SafePlugin<DragAndDropPluginState>;
|
|
4
|
+
export declare const createPlugin: (dispatch: Dispatch, eventDispatcher: EventDispatcher, editorAnalyticsAPI?: EditorAnalyticsAPI) => SafePlugin<import("./types").DragAndDropPluginState>;
|
|
@@ -17,7 +17,6 @@ type DragHandleProps = {
|
|
|
17
17
|
onMouseOut?: MouseEventHandler;
|
|
18
18
|
onMouseUp?: MouseEventHandler;
|
|
19
19
|
editorView: EditorView;
|
|
20
|
-
canDrag?: boolean;
|
|
21
20
|
isDragMenuTarget: boolean;
|
|
22
21
|
};
|
|
23
22
|
export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & WrappedComponentProps<"intl">>> & {
|
|
@@ -19,10 +19,9 @@ type DragMenuProps = {
|
|
|
19
19
|
scrollableElement?: HTMLElement;
|
|
20
20
|
pluginConfig?: PluginConfig;
|
|
21
21
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
22
|
-
canDrag?: boolean;
|
|
23
22
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
24
23
|
};
|
|
25
|
-
export declare const DragMenu: ({ direction, index, isOpen, editorView, tableNode, mountPoint, boundariesElement, scrollableElement, targetCellPosition, getEditorContainerWidth,
|
|
24
|
+
export declare const DragMenu: ({ direction, index, isOpen, editorView, tableNode, mountPoint, boundariesElement, scrollableElement, targetCellPosition, getEditorContainerWidth, editorAnalyticsAPI, pluginConfig, intl: { formatMessage }, }: DragMenuProps & WrappedComponentProps) => jsx.JSX.Element | null;
|
|
26
25
|
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<DragMenuProps & WrappedComponentProps<"intl">>> & {
|
|
27
26
|
WrappedComponent: import("react").ComponentType<DragMenuProps & WrappedComponentProps<"intl">>;
|
|
28
27
|
};
|
|
@@ -17,13 +17,12 @@ export interface Props {
|
|
|
17
17
|
index?: number;
|
|
18
18
|
targetCellPosition?: number;
|
|
19
19
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
20
|
-
canDrag?: boolean;
|
|
21
20
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
22
21
|
stickyHeaders?: RowStickyState;
|
|
23
22
|
pluginConfig?: PluginConfig;
|
|
24
23
|
}
|
|
25
24
|
declare const FloatingDragMenu: {
|
|
26
|
-
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth,
|
|
25
|
+
({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, editorAnalyticsAPI, stickyHeaders, pluginConfig, }: Props): JSX.Element | null;
|
|
27
26
|
displayName: string;
|
|
28
27
|
};
|
|
29
28
|
export default FloatingDragMenu;
|
|
@@ -14,10 +14,9 @@ export interface ColumnControlsProps {
|
|
|
14
14
|
colWidths?: (number | undefined)[];
|
|
15
15
|
hasHeaderColumn?: boolean;
|
|
16
16
|
isTableHovered?: boolean;
|
|
17
|
-
canDrag?: boolean;
|
|
18
17
|
tableContainerWidth?: number;
|
|
19
18
|
isNumberColumnEnabled?: boolean;
|
|
20
19
|
isDragging?: boolean;
|
|
21
20
|
}
|
|
22
|
-
export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered,
|
|
21
|
+
export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, }: ColumnControlsProps) => JSX.Element;
|
|
23
22
|
export default ColumnControls;
|
|
@@ -13,7 +13,6 @@ type DragControlsProps = {
|
|
|
13
13
|
isInDanger?: boolean;
|
|
14
14
|
isResizing?: boolean;
|
|
15
15
|
isTableHovered?: boolean;
|
|
16
|
-
canDrag?: boolean;
|
|
17
16
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
18
17
|
selectRow: (row: number, expand: boolean) => void;
|
|
19
18
|
selectRows: (rowIndexes: number[]) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.1
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"runReact18": false
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^35.
|
|
32
|
-
"@atlaskit/custom-steps": "^0.0.
|
|
31
|
+
"@atlaskit/adf-schema": "^35.5.1",
|
|
32
|
+
"@atlaskit/custom-steps": "^0.0.12",
|
|
33
33
|
"@atlaskit/editor-common": "^77.2.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.2",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@atlaskit/analytics-next": "^9.
|
|
67
|
+
"@atlaskit/analytics-next": "^9.2.0",
|
|
68
68
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
69
69
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
70
70
|
"@atlaskit/editor-plugin-grid": "^0.3.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@atlaskit/editor-test-helpers": "^18.15.0",
|
|
73
73
|
"@atlaskit/visual-regression": "*",
|
|
74
74
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
75
|
-
"@atlassian/feature-flags-test-utils": "^0.
|
|
75
|
+
"@atlassian/feature-flags-test-utils": "^0.2.0",
|
|
76
76
|
"@testing-library/dom": "^8.17.1",
|
|
77
77
|
"@testing-library/react": "^12.1.5",
|
|
78
78
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -95,7 +95,6 @@ export interface ComponentProps {
|
|
|
95
95
|
isHeaderColumnEnabled: boolean;
|
|
96
96
|
isMediaFullscreen?: boolean;
|
|
97
97
|
isDragAndDropEnabled?: boolean;
|
|
98
|
-
canDrag?: boolean;
|
|
99
98
|
tableActive: boolean;
|
|
100
99
|
ordering: TableColumnOrdering;
|
|
101
100
|
isResizing?: boolean;
|
|
@@ -442,7 +441,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
442
441
|
getPos,
|
|
443
442
|
pluginInjectionApi,
|
|
444
443
|
isDragAndDropEnabled,
|
|
445
|
-
canDrag,
|
|
446
444
|
getEditorFeatureFlags,
|
|
447
445
|
} = this.props;
|
|
448
446
|
|
|
@@ -472,7 +470,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
472
470
|
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
|
473
471
|
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
474
472
|
isDragAndDropEnabled={isDragAndDropEnabled}
|
|
475
|
-
canDrag={canDrag}
|
|
476
473
|
ordering={ordering}
|
|
477
474
|
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
478
475
|
hasHeaderRow={hasHeaderRow}
|
|
@@ -500,7 +497,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
500
497
|
selection={view.state.selection}
|
|
501
498
|
headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
|
|
502
499
|
stickyHeader={this.state.stickyHeader}
|
|
503
|
-
canDrag={canDrag}
|
|
504
500
|
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
505
501
|
tableContainerWidth={tableContainerWidth}
|
|
506
502
|
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
package/src/nodeviews/table.tsx
CHANGED
|
@@ -215,9 +215,7 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
215
215
|
tableResizingPluginState,
|
|
216
216
|
tableWidthPluginState,
|
|
217
217
|
pluginState,
|
|
218
|
-
// containerWidth,
|
|
219
218
|
mediaState,
|
|
220
|
-
tableDragAndDropState,
|
|
221
219
|
} = pluginStates;
|
|
222
220
|
const containerWidth = props.getEditorContainerWidth();
|
|
223
221
|
|
|
@@ -253,7 +251,6 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
253
251
|
isHeaderRowEnabled={pluginState!.isHeaderRowEnabled}
|
|
254
252
|
isHeaderColumnEnabled={pluginState!.isHeaderColumnEnabled}
|
|
255
253
|
isDragAndDropEnabled={pluginState!.isDragAndDropEnabled}
|
|
256
|
-
canDrag={tableDragAndDropState?.canDrag ?? false}
|
|
257
254
|
tableActive={tableActive}
|
|
258
255
|
ordering={pluginState!.ordering as TableColumnOrdering}
|
|
259
256
|
isResizing={isResizing}
|
package/src/plugin.tsx
CHANGED
|
@@ -517,7 +517,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
517
517
|
direction={dragAndDropState?.dragMenuDirection}
|
|
518
518
|
index={dragAndDropState?.dragMenuIndex}
|
|
519
519
|
isOpen={!!dragAndDropState?.isDragMenuOpen && !isResizing}
|
|
520
|
-
canDrag={dragAndDropState?.canDrag}
|
|
521
520
|
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
522
521
|
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
523
522
|
stickyHeaders={stickyHeader}
|
|
@@ -3,7 +3,6 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import type { TableDirection } from '../../types';
|
|
4
4
|
|
|
5
5
|
import type { DropTargetType } from './consts';
|
|
6
|
-
import type { DragAndDropPluginState } from './types';
|
|
7
6
|
|
|
8
7
|
export interface DragAndDropAction<T, D> {
|
|
9
8
|
type: T;
|
|
@@ -14,7 +13,6 @@ export const DragAndDropActionType = {
|
|
|
14
13
|
SET_DROP_TARGET: 'SET_DROP_TARGET',
|
|
15
14
|
CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
|
|
16
15
|
TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU',
|
|
17
|
-
UPDATE: 'UPDATE',
|
|
18
16
|
} as const;
|
|
19
17
|
|
|
20
18
|
export type DragAndDropSetDropTargetAction = DragAndDropAction<
|
|
@@ -42,14 +40,8 @@ export type DragAndDropToggleDragMenuAction = DragAndDropAction<
|
|
|
42
40
|
}
|
|
43
41
|
>;
|
|
44
42
|
|
|
45
|
-
export type DragAndDropUpdateAction = DragAndDropAction<
|
|
46
|
-
typeof DragAndDropActionType.UPDATE,
|
|
47
|
-
Partial<DragAndDropPluginState>
|
|
48
|
-
>;
|
|
49
|
-
|
|
50
43
|
// NOTE: This should be a Union of all possible actions
|
|
51
44
|
export type DragAndDropPluginAction =
|
|
52
45
|
| DragAndDropSetDropTargetAction
|
|
53
46
|
| DragAndDropClearDropTargetAction
|
|
54
|
-
| DragAndDropToggleDragMenuAction
|
|
55
|
-
| DragAndDropUpdateAction;
|
|
47
|
+
| DragAndDropToggleDragMenuAction;
|
|
@@ -28,10 +28,9 @@ import {
|
|
|
28
28
|
clearDropTargetWithAnalytics,
|
|
29
29
|
moveSourceWithAnalytics,
|
|
30
30
|
} from './commands-with-analytics';
|
|
31
|
-
import {
|
|
31
|
+
import { DropTargetType } from './consts';
|
|
32
32
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
33
33
|
import { pluginKey } from './plugin-key';
|
|
34
|
-
import type { DragAndDropPluginState } from './types';
|
|
35
34
|
import { getDraggableDataFromEvent } from './utils/monitor';
|
|
36
35
|
|
|
37
36
|
const destroyFn = (editorView: EditorView, editorAnalyticsAPI: any) => {
|
|
@@ -243,23 +242,14 @@ export const createPlugin = (
|
|
|
243
242
|
isDragMenuOpen: false,
|
|
244
243
|
dragMenuIndex: 0,
|
|
245
244
|
isDragging: false,
|
|
246
|
-
canDrag: false,
|
|
247
245
|
})),
|
|
248
246
|
key: pluginKey,
|
|
249
247
|
appendTransaction: (transactions, oldState, newState) => {
|
|
250
|
-
const {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const {
|
|
255
|
-
targetCellPosition: newTargetCellPosition,
|
|
256
|
-
tableNode: newTableNode,
|
|
257
|
-
} = getTablePluginState(newState);
|
|
258
|
-
const { isDragMenuOpen, dragMenuIndex, canDrag } =
|
|
259
|
-
getPluginState(newState);
|
|
260
|
-
|
|
261
|
-
const stateChanges: Array<Partial<DragAndDropPluginState>> = [];
|
|
262
|
-
const tr = newState.tr;
|
|
248
|
+
const { targetCellPosition: oldTargetCellPosition } =
|
|
249
|
+
getTablePluginState(oldState);
|
|
250
|
+
const { targetCellPosition: newTargetCellPosition } =
|
|
251
|
+
getTablePluginState(newState);
|
|
252
|
+
const { isDragMenuOpen, dragMenuIndex } = getPluginState(newState);
|
|
263
253
|
|
|
264
254
|
// What's happening here? you asked... In a nutshell;
|
|
265
255
|
// If the target cell position changes while the drag menu is open then we want to close the drag menu if it has been opened.
|
|
@@ -267,6 +257,15 @@ export const createPlugin = (
|
|
|
267
257
|
// to check if the new target cell position is pointed at a different cell than what the drag menu was opened on.
|
|
268
258
|
if (oldTargetCellPosition !== newTargetCellPosition) {
|
|
269
259
|
if (isDragMenuOpen) {
|
|
260
|
+
const tr = newState.tr;
|
|
261
|
+
const action = {
|
|
262
|
+
type: DragAndDropActionType.TOGGLE_DRAG_MENU,
|
|
263
|
+
data: {
|
|
264
|
+
isDragMenuOpen: false,
|
|
265
|
+
direction: undefined,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
|
|
270
269
|
if (newTargetCellPosition !== undefined) {
|
|
271
270
|
const cells = getCellsInRow(dragMenuIndex)(tr.selection);
|
|
272
271
|
// ED-20673 check if it is a cell selection,
|
|
@@ -279,44 +278,13 @@ export const createPlugin = (
|
|
|
279
278
|
cells[0].node !== tr.doc.nodeAt(newTargetCellPosition) &&
|
|
280
279
|
!isCellSelection
|
|
281
280
|
) {
|
|
282
|
-
|
|
283
|
-
isDragMenuOpen: false,
|
|
284
|
-
dragMenuDirection: undefined,
|
|
285
|
-
});
|
|
281
|
+
return tr.setMeta(pluginKey, action);
|
|
286
282
|
} // else NOP
|
|
287
283
|
} else {
|
|
288
|
-
|
|
289
|
-
isDragMenuOpen: false,
|
|
290
|
-
dragMenuDirection: undefined,
|
|
291
|
-
});
|
|
284
|
+
return tr.setMeta(pluginKey, action);
|
|
292
285
|
}
|
|
293
286
|
}
|
|
294
287
|
}
|
|
295
|
-
|
|
296
|
-
if (oldTableNode?.nodeSize !== newTableNode?.nodeSize) {
|
|
297
|
-
const nextCanDrag =
|
|
298
|
-
(newTableNode?.nodeSize ?? 0) < DRAGGABLE_TABLE_NODE_SIZE_LIMIT;
|
|
299
|
-
|
|
300
|
-
if (canDrag !== nextCanDrag) {
|
|
301
|
-
stateChanges.push({
|
|
302
|
-
canDrag: nextCanDrag,
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if (stateChanges.length) {
|
|
308
|
-
return tr
|
|
309
|
-
.setMeta(pluginKey, {
|
|
310
|
-
type: DragAndDropActionType.UPDATE,
|
|
311
|
-
data: {
|
|
312
|
-
...stateChanges.reduce(
|
|
313
|
-
(state, cur) => ({ ...state, ...cur }),
|
|
314
|
-
{},
|
|
315
|
-
),
|
|
316
|
-
},
|
|
317
|
-
})
|
|
318
|
-
.setMeta('addToHistory', false);
|
|
319
|
-
}
|
|
320
288
|
},
|
|
321
289
|
view: (editorView: EditorView) => {
|
|
322
290
|
return {
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
transformSliceToRemoveOpenBodiedExtension,
|
|
22
22
|
transformSliceToRemoveOpenExpand,
|
|
23
23
|
transformSliceToRemoveOpenLayoutNodes,
|
|
24
|
+
transformSliceToRemoveOpenMultiBodiedExtension,
|
|
24
25
|
} from '@atlaskit/editor-common/transforms';
|
|
25
26
|
import type {
|
|
26
27
|
GetEditorContainerWidth,
|
|
@@ -281,6 +282,9 @@ export const createPlugin = (
|
|
|
281
282
|
/** If a partial paste of bodied extension, paste only text */
|
|
282
283
|
slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
|
|
283
284
|
|
|
285
|
+
/** If a partial paste of multi bodied extension, paste only children */
|
|
286
|
+
slice = transformSliceToRemoveOpenMultiBodiedExtension(slice, schema);
|
|
287
|
+
|
|
284
288
|
slice = transformSliceToCorrectEmptyTableCells(slice, schema);
|
|
285
289
|
|
|
286
290
|
if (!pluginConfig.allowColumnResizing) {
|
|
@@ -37,7 +37,6 @@ type DragHandleProps = {
|
|
|
37
37
|
onMouseOut?: MouseEventHandler;
|
|
38
38
|
onMouseUp?: MouseEventHandler;
|
|
39
39
|
editorView: EditorView;
|
|
40
|
-
canDrag?: boolean;
|
|
41
40
|
isDragMenuTarget: boolean; // this is identify which current handle component is
|
|
42
41
|
};
|
|
43
42
|
|
|
@@ -55,7 +54,6 @@ const DragHandleComponent = ({
|
|
|
55
54
|
onMouseUp,
|
|
56
55
|
onClick,
|
|
57
56
|
editorView,
|
|
58
|
-
canDrag = false,
|
|
59
57
|
intl: { formatMessage },
|
|
60
58
|
}: DragHandleProps & WrappedComponentProps) => {
|
|
61
59
|
const dragHandleDivRef = useRef<HTMLButtonElement>(null);
|
|
@@ -94,7 +92,7 @@ const DragHandleComponent = ({
|
|
|
94
92
|
return draggable({
|
|
95
93
|
element: dragHandleDivRefCurrent,
|
|
96
94
|
canDrag: () => {
|
|
97
|
-
return
|
|
95
|
+
return !hasMergedCells;
|
|
98
96
|
},
|
|
99
97
|
getInitialData() {
|
|
100
98
|
return {
|
|
@@ -138,7 +136,6 @@ const DragHandleComponent = ({
|
|
|
138
136
|
isRow,
|
|
139
137
|
editorView.state.selection,
|
|
140
138
|
hasMergedCells,
|
|
141
|
-
canDrag,
|
|
142
139
|
]);
|
|
143
140
|
|
|
144
141
|
const showDragMenuAnchorId = isRow
|
|
@@ -170,7 +167,7 @@ const DragHandleComponent = ({
|
|
|
170
167
|
ClassName.DRAG_HANDLE_BUTTON_CONTAINER,
|
|
171
168
|
appearance,
|
|
172
169
|
{
|
|
173
|
-
[ClassName.DRAG_HANDLE_DISABLED]:
|
|
170
|
+
[ClassName.DRAG_HANDLE_DISABLED]: hasMergedCells,
|
|
174
171
|
},
|
|
175
172
|
)}
|
|
176
173
|
ref={dragHandleDivRef}
|
|
@@ -94,7 +94,6 @@ type DragMenuProps = {
|
|
|
94
94
|
scrollableElement?: HTMLElement;
|
|
95
95
|
pluginConfig?: PluginConfig;
|
|
96
96
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
97
|
-
canDrag?: boolean;
|
|
98
97
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
99
98
|
};
|
|
100
99
|
|
|
@@ -265,7 +264,6 @@ export const DragMenu = ({
|
|
|
265
264
|
scrollableElement,
|
|
266
265
|
targetCellPosition,
|
|
267
266
|
getEditorContainerWidth,
|
|
268
|
-
canDrag,
|
|
269
267
|
editorAnalyticsAPI,
|
|
270
268
|
pluginConfig,
|
|
271
269
|
intl: { formatMessage },
|
|
@@ -291,7 +289,7 @@ export const DragMenu = ({
|
|
|
291
289
|
const dragMenuConfig = getDragMenuConfig(
|
|
292
290
|
direction,
|
|
293
291
|
getEditorContainerWidth,
|
|
294
|
-
|
|
292
|
+
!shouldMoveDisabled,
|
|
295
293
|
hasMergedCellsInTable,
|
|
296
294
|
editorView,
|
|
297
295
|
tableMap,
|
|
@@ -29,7 +29,6 @@ export interface Props {
|
|
|
29
29
|
index?: number;
|
|
30
30
|
targetCellPosition?: number;
|
|
31
31
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
32
|
-
canDrag?: boolean;
|
|
33
32
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
34
33
|
stickyHeaders?: RowStickyState;
|
|
35
34
|
pluginConfig?: PluginConfig;
|
|
@@ -46,7 +45,6 @@ const FloatingDragMenu = ({
|
|
|
46
45
|
index,
|
|
47
46
|
targetCellPosition,
|
|
48
47
|
getEditorContainerWidth,
|
|
49
|
-
canDrag,
|
|
50
48
|
editorAnalyticsAPI,
|
|
51
49
|
stickyHeaders,
|
|
52
50
|
pluginConfig,
|
|
@@ -105,7 +103,6 @@ const FloatingDragMenu = ({
|
|
|
105
103
|
index={index}
|
|
106
104
|
targetCellPosition={targetCellPosition}
|
|
107
105
|
getEditorContainerWidth={getEditorContainerWidth}
|
|
108
|
-
canDrag={canDrag}
|
|
109
106
|
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
110
107
|
pluginConfig={pluginConfig}
|
|
111
108
|
/>
|
|
@@ -36,7 +36,6 @@ export interface ColumnControlsProps {
|
|
|
36
36
|
colWidths?: (number | undefined)[];
|
|
37
37
|
hasHeaderColumn?: boolean;
|
|
38
38
|
isTableHovered?: boolean;
|
|
39
|
-
canDrag?: boolean;
|
|
40
39
|
tableContainerWidth?: number;
|
|
41
40
|
isNumberColumnEnabled?: boolean;
|
|
42
41
|
isDragging?: boolean;
|
|
@@ -66,7 +65,6 @@ export const ColumnControls = ({
|
|
|
66
65
|
colWidths,
|
|
67
66
|
hasHeaderColumn,
|
|
68
67
|
isTableHovered,
|
|
69
|
-
canDrag,
|
|
70
68
|
tableContainerWidth,
|
|
71
69
|
isNumberColumnEnabled,
|
|
72
70
|
isDragging,
|
|
@@ -289,7 +287,6 @@ export const ColumnControls = ({
|
|
|
289
287
|
onMouseOut={handleMouseOut}
|
|
290
288
|
onMouseUp={handleMouseUp}
|
|
291
289
|
editorView={editorView}
|
|
292
|
-
canDrag={canDrag}
|
|
293
290
|
/>
|
|
294
291
|
</div>
|
|
295
292
|
);
|
|
@@ -35,7 +35,6 @@ export interface Props {
|
|
|
35
35
|
ordering?: TableColumnOrdering;
|
|
36
36
|
stickyHeader?: RowStickyState;
|
|
37
37
|
isTableHovered?: boolean;
|
|
38
|
-
canDrag?: boolean;
|
|
39
38
|
tableContainerWidth?: number;
|
|
40
39
|
isNumberColumnEnabled?: boolean;
|
|
41
40
|
}
|
|
@@ -52,7 +51,6 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
52
51
|
selection,
|
|
53
52
|
isInDanger,
|
|
54
53
|
isTableHovered,
|
|
55
|
-
canDrag,
|
|
56
54
|
tableContainerWidth,
|
|
57
55
|
isNumberColumnEnabled,
|
|
58
56
|
}) => {
|
|
@@ -157,7 +155,6 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
157
155
|
rowHeights={rowHeights}
|
|
158
156
|
colWidths={colWidths}
|
|
159
157
|
hasHeaderColumn={hasHeaderColumn}
|
|
160
|
-
canDrag={canDrag}
|
|
161
158
|
tableContainerWidth={tableContainerWidth}
|
|
162
159
|
isNumberColumnEnabled={isNumberColumnEnabled}
|
|
163
160
|
isDragging={isDragging}
|
|
@@ -47,7 +47,6 @@ type DragControlsProps = {
|
|
|
47
47
|
isInDanger?: boolean;
|
|
48
48
|
isResizing?: boolean;
|
|
49
49
|
isTableHovered?: boolean;
|
|
50
|
-
canDrag?: boolean;
|
|
51
50
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
52
51
|
selectRow: (row: number, expand: boolean) => void;
|
|
53
52
|
selectRows: (rowIndexes: number[]) => void;
|
|
@@ -75,7 +74,6 @@ const DragControlsComponent = ({
|
|
|
75
74
|
isInDanger,
|
|
76
75
|
isResizing,
|
|
77
76
|
isTableHovered,
|
|
78
|
-
canDrag,
|
|
79
77
|
hoverRows,
|
|
80
78
|
selectRow,
|
|
81
79
|
selectRows,
|
|
@@ -273,7 +271,6 @@ const DragControlsComponent = ({
|
|
|
273
271
|
onMouseOut={handleMouseOut}
|
|
274
272
|
onMouseUp={onMouseUp}
|
|
275
273
|
editorView={editorView}
|
|
276
|
-
canDrag={canDrag}
|
|
277
274
|
/>
|
|
278
275
|
</div>
|
|
279
276
|
);
|
|
@@ -29,7 +29,6 @@ export interface Props {
|
|
|
29
29
|
isHeaderColumnEnabled?: boolean;
|
|
30
30
|
isNumberColumnEnabled?: boolean;
|
|
31
31
|
isDragAndDropEnabled?: boolean;
|
|
32
|
-
canDrag?: boolean;
|
|
33
32
|
hasHeaderRow?: boolean;
|
|
34
33
|
headerRowHeight?: number;
|
|
35
34
|
hoveredRows?: number[];
|
|
@@ -107,7 +106,6 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
107
106
|
stickyHeader,
|
|
108
107
|
hoveredCell,
|
|
109
108
|
isTableHovered,
|
|
110
|
-
canDrag,
|
|
111
109
|
} = this.props;
|
|
112
110
|
return (
|
|
113
111
|
this.state.tableWrapperWidth !== nextState.tableWrapperWidth ||
|
|
@@ -125,8 +123,7 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
125
123
|
headerRowHeight !== nextProps.headerRowHeight ||
|
|
126
124
|
stickyHeader !== nextProps.stickyHeader ||
|
|
127
125
|
hoveredCell !== nextProps.hoveredCell ||
|
|
128
|
-
isTableHovered !== nextProps.isTableHovered
|
|
129
|
-
canDrag !== nextProps.canDrag
|
|
126
|
+
isTableHovered !== nextProps.isTableHovered
|
|
130
127
|
);
|
|
131
128
|
}
|
|
132
129
|
|
|
@@ -153,7 +150,6 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
153
150
|
isDragAndDropEnabled,
|
|
154
151
|
hoveredCell,
|
|
155
152
|
isTableHovered,
|
|
156
|
-
canDrag,
|
|
157
153
|
} = this.props;
|
|
158
154
|
|
|
159
155
|
if (!tableRef) {
|
|
@@ -213,7 +209,6 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
213
209
|
selectRow={this.selectRow}
|
|
214
210
|
selectRows={this.selectRows}
|
|
215
211
|
updateCellHoverLocation={this.updateCellHoverLocation}
|
|
216
|
-
canDrag={canDrag}
|
|
217
212
|
/>
|
|
218
213
|
</>
|
|
219
214
|
) : (
|