@atlaskit/editor-plugin-table 12.2.6 → 12.2.7
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 +8 -0
- package/package.json +4 -4
- package/afm-cc/tsconfig.json +0 -123
- package/afm-dev-agents/tsconfig.json +0 -123
- package/afm-jira/tsconfig.json +0 -123
- package/afm-passionfruit/tsconfig.json +0 -123
- package/afm-post-office/tsconfig.json +0 -123
- package/afm-rovo-extension/tsconfig.json +0 -123
- package/afm-townsquare/tsconfig.json +0 -123
- package/afm-volt/tsconfig.json +0 -114
- package/build/tsconfig.json +0 -23
- package/docs/0-intro.tsx +0 -57
- package/src/index.ts +0 -21
- package/src/nodeviews/ExternalDropTargets.tsx +0 -91
- package/src/nodeviews/OverflowShadowsObserver.ts +0 -156
- package/src/nodeviews/TableCell.ts +0 -134
- package/src/nodeviews/TableComponent.tsx +0 -1590
- package/src/nodeviews/TableComponentWithSharedState.tsx +0 -278
- package/src/nodeviews/TableContainer.tsx +0 -926
- package/src/nodeviews/TableNodeViewBase.ts +0 -29
- package/src/nodeviews/TableResizer.tsx +0 -884
- package/src/nodeviews/TableRow.ts +0 -830
- package/src/nodeviews/TableStickyScrollbar.ts +0 -211
- package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +0 -15
- package/src/nodeviews/__mocks__/OverridableMock.ts +0 -26
- package/src/nodeviews/table-container-styles.ts +0 -9
- package/src/nodeviews/table-node-views.ts +0 -76
- package/src/nodeviews/table.tsx +0 -530
- package/src/nodeviews/toDOM.ts +0 -244
- package/src/nodeviews/types.ts +0 -36
- package/src/nodeviews/update-overflow-shadows.ts +0 -11
- package/src/pm-plugins/analytics/actions.ts +0 -21
- package/src/pm-plugins/analytics/commands.ts +0 -47
- package/src/pm-plugins/analytics/plugin-factory.ts +0 -9
- package/src/pm-plugins/analytics/plugin-key.ts +0 -5
- package/src/pm-plugins/analytics/plugin.ts +0 -80
- package/src/pm-plugins/analytics/reducer.ts +0 -27
- package/src/pm-plugins/analytics/types.ts +0 -20
- package/src/pm-plugins/analytics/utils/moved-event.ts +0 -51
- package/src/pm-plugins/commands/clear.ts +0 -43
- package/src/pm-plugins/commands/collapse.ts +0 -17
- package/src/pm-plugins/commands/column-resize.ts +0 -478
- package/src/pm-plugins/commands/commands-with-analytics.ts +0 -715
- package/src/pm-plugins/commands/delete.ts +0 -42
- package/src/pm-plugins/commands/display-mode.ts +0 -18
- package/src/pm-plugins/commands/go-to-next-cell.ts +0 -198
- package/src/pm-plugins/commands/hover.ts +0 -242
- package/src/pm-plugins/commands/index.ts +0 -51
- package/src/pm-plugins/commands/insert.ts +0 -438
- package/src/pm-plugins/commands/misc.ts +0 -811
- package/src/pm-plugins/commands/referentiality.ts +0 -15
- package/src/pm-plugins/commands/selection.ts +0 -537
- package/src/pm-plugins/commands/sort.ts +0 -102
- package/src/pm-plugins/commands/split-cell.ts +0 -28
- package/src/pm-plugins/commands/toggle.ts +0 -109
- package/src/pm-plugins/create-plugin-config.ts +0 -17
- package/src/pm-plugins/decorations/plugin.ts +0 -107
- package/src/pm-plugins/decorations/utils/column-controls.ts +0 -91
- package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -71
- package/src/pm-plugins/decorations/utils/compose-decorations.ts +0 -9
- package/src/pm-plugins/decorations/utils/types.ts +0 -16
- package/src/pm-plugins/default-table-selection.ts +0 -14
- package/src/pm-plugins/drag-and-drop/actions.ts +0 -48
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -222
- package/src/pm-plugins/drag-and-drop/commands.ts +0 -194
- package/src/pm-plugins/drag-and-drop/consts.ts +0 -7
- package/src/pm-plugins/drag-and-drop/plugin-factory.ts +0 -33
- package/src/pm-plugins/drag-and-drop/plugin-key.ts +0 -5
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -398
- package/src/pm-plugins/drag-and-drop/reducer.ts +0 -38
- package/src/pm-plugins/drag-and-drop/types.ts +0 -18
- package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +0 -49
- package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +0 -9
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -73
- package/src/pm-plugins/handlers.ts +0 -161
- package/src/pm-plugins/keymap.ts +0 -436
- package/src/pm-plugins/main.ts +0 -433
- package/src/pm-plugins/plugin-factory.ts +0 -42
- package/src/pm-plugins/plugin-key.ts +0 -8
- package/src/pm-plugins/reducer.ts +0 -145
- package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -102
- package/src/pm-plugins/sticky-headers/commands.ts +0 -8
- package/src/pm-plugins/sticky-headers/plugin-key.ts +0 -5
- package/src/pm-plugins/sticky-headers/plugin-state.ts +0 -52
- package/src/pm-plugins/sticky-headers/plugin.ts +0 -12
- package/src/pm-plugins/sticky-headers/types.ts +0 -20
- package/src/pm-plugins/sticky-headers/util.ts +0 -18
- package/src/pm-plugins/table-analytics.ts +0 -100
- package/src/pm-plugins/table-local-id.ts +0 -213
- package/src/pm-plugins/table-resizing/commands.ts +0 -116
- package/src/pm-plugins/table-resizing/event-handlers.ts +0 -352
- package/src/pm-plugins/table-resizing/plugin-factory.ts +0 -29
- package/src/pm-plugins/table-resizing/plugin-key.ts +0 -5
- package/src/pm-plugins/table-resizing/plugin.ts +0 -94
- package/src/pm-plugins/table-resizing/reducer.ts +0 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -306
- package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -120
- package/src/pm-plugins/table-resizing/utils/consts.ts +0 -11
- package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -118
- package/src/pm-plugins/table-resizing/utils/dom.ts +0 -132
- package/src/pm-plugins/table-resizing/utils/misc.ts +0 -282
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -34
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -289
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -417
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -290
- package/src/pm-plugins/table-resizing/utils/types.ts +0 -25
- package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +0 -1
- package/src/pm-plugins/table-selection-keymap.ts +0 -64
- package/src/pm-plugins/table-size-selector.ts +0 -39
- package/src/pm-plugins/table-width-in-comment-fix.ts +0 -113
- package/src/pm-plugins/table-width.ts +0 -153
- package/src/pm-plugins/transforms/column-width.ts +0 -249
- package/src/pm-plugins/transforms/delete-columns.ts +0 -281
- package/src/pm-plugins/transforms/delete-rows.ts +0 -154
- package/src/pm-plugins/transforms/fix-tables.ts +0 -249
- package/src/pm-plugins/transforms/merge.ts +0 -301
- package/src/pm-plugins/transforms/replace-table.ts +0 -38
- package/src/pm-plugins/transforms/split.ts +0 -90
- package/src/pm-plugins/utils/alignment.ts +0 -33
- package/src/pm-plugins/utils/analytics.ts +0 -238
- package/src/pm-plugins/utils/collapse.ts +0 -93
- package/src/pm-plugins/utils/column-controls.ts +0 -250
- package/src/pm-plugins/utils/create.ts +0 -64
- package/src/pm-plugins/utils/decoration.ts +0 -672
- package/src/pm-plugins/utils/dom.ts +0 -251
- package/src/pm-plugins/utils/drag-menu.tsx +0 -491
- package/src/pm-plugins/utils/get-allow-add-column-custom-step.ts +0 -10
- package/src/pm-plugins/utils/guidelines.ts +0 -30
- package/src/pm-plugins/utils/merged-cells.ts +0 -239
- package/src/pm-plugins/utils/nodes.ts +0 -162
- package/src/pm-plugins/utils/paste.ts +0 -386
- package/src/pm-plugins/utils/row-controls.ts +0 -211
- package/src/pm-plugins/utils/selection.ts +0 -17
- package/src/pm-plugins/utils/snapping.ts +0 -136
- package/src/pm-plugins/utils/table.ts +0 -60
- package/src/pm-plugins/utils/update-plugin-state-decorations.ts +0 -13
- package/src/pm-plugins/view-mode-sort/consts.ts +0 -3
- package/src/pm-plugins/view-mode-sort/index.ts +0 -291
- package/src/pm-plugins/view-mode-sort/plugin-key.ts +0 -7
- package/src/pm-plugins/view-mode-sort/types.ts +0 -23
- package/src/pm-plugins/view-mode-sort/utils.ts +0 -136
- package/src/tablePlugin.tsx +0 -971
- package/src/tablePluginType.ts +0 -102
- package/src/types/index.ts +0 -592
- package/src/ui/ColumnResizeWidget/index.tsx +0 -61
- package/src/ui/ContentComponent.tsx +0 -311
- package/src/ui/DragHandle/HandleIconComponent.tsx +0 -21
- package/src/ui/DragHandle/index.tsx +0 -391
- package/src/ui/DragPreview/index.tsx +0 -51
- package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +0 -59
- package/src/ui/FloatingContextualButton/FixedButton.tsx +0 -203
- package/src/ui/FloatingContextualButton/index.tsx +0 -168
- package/src/ui/FloatingContextualButton/styles.ts +0 -69
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +0 -931
- package/src/ui/FloatingContextualMenu/index.tsx +0 -141
- package/src/ui/FloatingContextualMenu/styles.ts +0 -77
- package/src/ui/FloatingDeleteButton/DeleteButton.tsx +0 -54
- package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +0 -65
- package/src/ui/FloatingDeleteButton/index.tsx +0 -383
- package/src/ui/FloatingDeleteButton/types.ts +0 -3
- package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -668
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +0 -221
- package/src/ui/FloatingDragMenu/index.tsx +0 -136
- package/src/ui/FloatingDragMenu/styles.ts +0 -83
- package/src/ui/FloatingInsertButton/InsertButton.tsx +0 -263
- package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -131
- package/src/ui/FloatingInsertButton/index.tsx +0 -314
- package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +0 -31
- package/src/ui/SizeSelector/index.tsx +0 -74
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -397
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +0 -105
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +0 -63
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -151
- package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +0 -106
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +0 -143
- package/src/ui/TableFloatingControls/CornerControls/types.ts +0 -12
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +0 -88
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +0 -175
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +0 -131
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -429
- package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +0 -96
- package/src/ui/TableFloatingControls/index.tsx +0 -275
- package/src/ui/TableFullWidthLabel/index.tsx +0 -38
- package/src/ui/common-styles.ts +0 -1218
- package/src/ui/consts.ts +0 -109
- package/src/ui/event-handlers.ts +0 -662
- package/src/ui/global-styles.tsx +0 -55
- package/src/ui/hooks/useInternalTablePluginStateSelector.ts +0 -38
- package/src/ui/icons/AddColLeftIcon.tsx +0 -37
- package/src/ui/icons/AddColRightIcon.tsx +0 -37
- package/src/ui/icons/AddRowAboveIcon.tsx +0 -22
- package/src/ui/icons/AddRowBelowIcon.tsx +0 -39
- package/src/ui/icons/DragHandleDisabledIcon.tsx +0 -25
- package/src/ui/icons/DragHandleIcon.tsx +0 -16
- package/src/ui/icons/DragInMotionIcon.tsx +0 -54
- package/src/ui/icons/MergeCellsIcon.tsx +0 -26
- package/src/ui/icons/MinimisedHandle.tsx +0 -15
- package/src/ui/icons/SortingIconWrapper.tsx +0 -43
- package/src/ui/icons/SplitCellIcon.tsx +0 -34
- package/src/ui/toolbar.tsx +0 -1153
- package/src/ui/ui-styles.ts +0 -960
- package/tsconfig.app.json +0 -135
- package/tsconfig.dev.json +0 -54
- package/tsconfig.json +0 -18
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import type { SyntheticEvent } from 'react';
|
|
2
|
-
import React, { Component } from 'react';
|
|
3
|
-
|
|
4
|
-
import { createPortal } from 'react-dom';
|
|
5
|
-
|
|
6
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
10
|
-
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
11
|
-
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
13
|
-
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
14
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
15
|
-
import { getSelectionRect, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
16
|
-
|
|
17
|
-
import { clearHoverSelection, hoverColumns, hoverRows } from '../../pm-plugins/commands';
|
|
18
|
-
import {
|
|
19
|
-
deleteColumnsWithAnalytics,
|
|
20
|
-
deleteRowsWithAnalytics,
|
|
21
|
-
} from '../../pm-plugins/commands/commands-with-analytics';
|
|
22
|
-
import { getPluginState as getTablePluginState } from '../../pm-plugins/plugin-factory';
|
|
23
|
-
import type { RowStickyState } from '../../pm-plugins/sticky-headers/types';
|
|
24
|
-
import {
|
|
25
|
-
getColumnDeleteButtonParams,
|
|
26
|
-
getColumnsWidths,
|
|
27
|
-
} from '../../pm-plugins/utils/column-controls';
|
|
28
|
-
import { getRowDeleteButtonParams, getRowHeights } from '../../pm-plugins/utils/row-controls';
|
|
29
|
-
import type { PluginInjectionAPI, TableDirection } from '../../types';
|
|
30
|
-
import { TableCssClassName as ClassName } from '../../types';
|
|
31
|
-
import { stickyRowZIndex } from '../consts';
|
|
32
|
-
|
|
33
|
-
import DeleteButton from './DeleteButton';
|
|
34
|
-
import getPopupOptions from './getPopUpOptions';
|
|
35
|
-
import type { CellSelectionType } from './types';
|
|
36
|
-
|
|
37
|
-
export interface Props {
|
|
38
|
-
editorView: EditorView;
|
|
39
|
-
selection: Selection;
|
|
40
|
-
api: PluginInjectionAPI | undefined | null;
|
|
41
|
-
tableRef?: HTMLTableElement;
|
|
42
|
-
mountPoint?: HTMLElement;
|
|
43
|
-
boundariesElement?: HTMLElement;
|
|
44
|
-
scrollableElement?: HTMLElement;
|
|
45
|
-
stickyHeaders?: RowStickyState;
|
|
46
|
-
isNumberColumnEnabled?: boolean;
|
|
47
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface State {
|
|
51
|
-
selectionType?: CellSelectionType;
|
|
52
|
-
left: number;
|
|
53
|
-
top: number;
|
|
54
|
-
indexes: number[];
|
|
55
|
-
position?: string;
|
|
56
|
-
scrollLeft: number;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getSelectionType(selection: Selection): TableDirection | undefined {
|
|
60
|
-
if (!isTableSelected(selection) && selection instanceof CellSelection) {
|
|
61
|
-
if (selection.isRowSelection()) {
|
|
62
|
-
return 'row';
|
|
63
|
-
}
|
|
64
|
-
if (selection.isColSelection()) {
|
|
65
|
-
return 'column';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Ignored via go/ees005
|
|
73
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
74
|
-
class FloatingDeleteButton extends Component<Props, State> {
|
|
75
|
-
static displayName = 'FloatingDeleteButton';
|
|
76
|
-
|
|
77
|
-
wrapper: HTMLElement | null = null;
|
|
78
|
-
|
|
79
|
-
constructor(props: Props) {
|
|
80
|
-
super(props);
|
|
81
|
-
|
|
82
|
-
this.state = {
|
|
83
|
-
selectionType: undefined,
|
|
84
|
-
top: 0,
|
|
85
|
-
left: 0,
|
|
86
|
-
indexes: [],
|
|
87
|
-
scrollLeft: 0,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
shouldComponentUpdate(_: Props, nextState: State) {
|
|
92
|
-
return (
|
|
93
|
-
this.state.selectionType !== nextState.selectionType ||
|
|
94
|
-
this.state.left !== nextState.left ||
|
|
95
|
-
this.state.top !== nextState.top ||
|
|
96
|
-
this.state.scrollLeft !== nextState.scrollLeft
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
componentDidMount() {
|
|
101
|
-
this.updateWrapper();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
componentDidUpdate() {
|
|
105
|
-
this.updateWrapper();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
updateWrapper = () => {
|
|
109
|
-
const tableWrapper = closestElement(this.props.tableRef, `.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
110
|
-
if (tableWrapper) {
|
|
111
|
-
this.wrapper = tableWrapper;
|
|
112
|
-
// Ignored via go/ees005
|
|
113
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
114
|
-
this.wrapper.addEventListener('scroll', this.onWrapperScrolled);
|
|
115
|
-
|
|
116
|
-
this.setState({
|
|
117
|
-
scrollLeft: tableWrapper.scrollLeft,
|
|
118
|
-
});
|
|
119
|
-
} else {
|
|
120
|
-
if (this.wrapper) {
|
|
121
|
-
// unsubscribe if we previously had one and it just went away
|
|
122
|
-
// Ignored via go/ees005
|
|
123
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
124
|
-
this.wrapper.removeEventListener('scroll', this.onWrapperScrolled);
|
|
125
|
-
|
|
126
|
-
// and reset scroll position
|
|
127
|
-
this.setState({
|
|
128
|
-
scrollLeft: 0,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this.wrapper = null;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
componentWillUnmount() {
|
|
137
|
-
if (this.wrapper) {
|
|
138
|
-
// Ignored via go/ees005
|
|
139
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
140
|
-
this.wrapper.removeEventListener('scroll', this.onWrapperScrolled);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
onWrapperScrolled = (e: Event) => {
|
|
145
|
-
// Ignored via go/ees005
|
|
146
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
147
|
-
const wrapper = e.target as HTMLElement;
|
|
148
|
-
this.setState({
|
|
149
|
-
scrollLeft: wrapper.scrollLeft,
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* We derivate the button state from the properties passed.
|
|
155
|
-
* We do this in here because we need this information in different places
|
|
156
|
-
* and this prevent to do multiple width calculations in the same component.
|
|
157
|
-
*/
|
|
158
|
-
static getDerivedStateFromProps(
|
|
159
|
-
nextProps: Readonly<Props>,
|
|
160
|
-
prevState: State,
|
|
161
|
-
): Partial<State> | null {
|
|
162
|
-
const selectionType = getSelectionType(nextProps.selection);
|
|
163
|
-
|
|
164
|
-
const inStickyMode = nextProps.stickyHeaders && nextProps.stickyHeaders.sticky;
|
|
165
|
-
|
|
166
|
-
const rect = getSelectionRect(nextProps.selection);
|
|
167
|
-
|
|
168
|
-
// only tie row delete to sticky header if it's the only thing
|
|
169
|
-
// in the selection, otherwise the row delete will hover around
|
|
170
|
-
// the rest of the selection
|
|
171
|
-
const firstRowInSelection = rect && rect.top === 0 && rect.bottom === 1;
|
|
172
|
-
const shouldStickyButton = inStickyMode && firstRowInSelection;
|
|
173
|
-
const stickyTop = nextProps.stickyHeaders
|
|
174
|
-
? nextProps.stickyHeaders.top + nextProps.stickyHeaders.padding
|
|
175
|
-
: 0;
|
|
176
|
-
|
|
177
|
-
if (selectionType) {
|
|
178
|
-
switch (selectionType) {
|
|
179
|
-
case 'column': {
|
|
180
|
-
// Calculate the button position and indexes for columns
|
|
181
|
-
const columnsWidths = getColumnsWidths(nextProps.editorView);
|
|
182
|
-
const deleteBtnParams = getColumnDeleteButtonParams(
|
|
183
|
-
columnsWidths,
|
|
184
|
-
nextProps.editorView.state.selection,
|
|
185
|
-
);
|
|
186
|
-
if (deleteBtnParams) {
|
|
187
|
-
return {
|
|
188
|
-
...deleteBtnParams,
|
|
189
|
-
// Ignored via go/ees005
|
|
190
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
191
|
-
top: inStickyMode ? nextProps.stickyHeaders!.top : 0,
|
|
192
|
-
position: inStickyMode ? 'sticky' : undefined,
|
|
193
|
-
selectionType,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
case 'row': {
|
|
199
|
-
// Calculate the button position and indexes for rows
|
|
200
|
-
if (nextProps.tableRef) {
|
|
201
|
-
const rowHeights = getRowHeights(nextProps.tableRef);
|
|
202
|
-
const offsetTop = inStickyMode ? -rowHeights[0] : 0;
|
|
203
|
-
|
|
204
|
-
const deleteBtnParams = getRowDeleteButtonParams(
|
|
205
|
-
rowHeights,
|
|
206
|
-
nextProps.editorView.state.selection,
|
|
207
|
-
shouldStickyButton ? stickyTop : offsetTop,
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
if (deleteBtnParams) {
|
|
211
|
-
return {
|
|
212
|
-
...deleteBtnParams,
|
|
213
|
-
position: shouldStickyButton ? 'sticky' : undefined,
|
|
214
|
-
left: 0,
|
|
215
|
-
selectionType: selectionType,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// Clean state if no type
|
|
226
|
-
if (prevState.selectionType !== selectionType) {
|
|
227
|
-
return {
|
|
228
|
-
selectionType: undefined,
|
|
229
|
-
top: 0,
|
|
230
|
-
left: 0,
|
|
231
|
-
indexes: [],
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Do nothing if doesn't change anything
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
private handleMouseEnter = () => {
|
|
240
|
-
const { state, dispatch } = this.props.editorView;
|
|
241
|
-
switch (this.state.selectionType) {
|
|
242
|
-
case 'row': {
|
|
243
|
-
// Ignored via go/ees005
|
|
244
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
245
|
-
return hoverRows(this.state.indexes!, true)(state, dispatch, this.props.editorView);
|
|
246
|
-
}
|
|
247
|
-
case 'column': {
|
|
248
|
-
// Ignored via go/ees005
|
|
249
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
250
|
-
return hoverColumns(this.state.indexes!, true)(state, dispatch, this.props.editorView);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return false;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
private handleMouseLeave = () => {
|
|
257
|
-
const { state, dispatch } = this.props.editorView;
|
|
258
|
-
return clearHoverSelection()(state, dispatch);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* @private
|
|
265
|
-
* @memberof FloatingDeleteButton
|
|
266
|
-
*/
|
|
267
|
-
private handleClick = (event: SyntheticEvent) => {
|
|
268
|
-
event.preventDefault();
|
|
269
|
-
const { editorAnalyticsAPI } = this.props;
|
|
270
|
-
let { state, dispatch } = this.props.editorView;
|
|
271
|
-
const {
|
|
272
|
-
pluginConfig: { isHeaderRowRequired },
|
|
273
|
-
} = getTablePluginState(state);
|
|
274
|
-
|
|
275
|
-
const rect = getSelectionRect(state.selection);
|
|
276
|
-
if (rect) {
|
|
277
|
-
switch (this.state.selectionType) {
|
|
278
|
-
case 'column': {
|
|
279
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI, this.props.api)(INPUT_METHOD.BUTTON, rect)(
|
|
280
|
-
state,
|
|
281
|
-
dispatch,
|
|
282
|
-
this.props.editorView,
|
|
283
|
-
);
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
case 'row': {
|
|
287
|
-
deleteRowsWithAnalytics(editorAnalyticsAPI)(
|
|
288
|
-
INPUT_METHOD.BUTTON,
|
|
289
|
-
rect,
|
|
290
|
-
!!isHeaderRowRequired,
|
|
291
|
-
)(state, dispatch);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
({ state, dispatch } = this.props.editorView);
|
|
297
|
-
clearHoverSelection()(state, dispatch);
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
render() {
|
|
301
|
-
const { mountPoint, boundariesElement, tableRef } = this.props;
|
|
302
|
-
const { selectionType } = this.state;
|
|
303
|
-
|
|
304
|
-
if (!selectionType || !tableRef) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const tableContainerWrapper = closestElement(tableRef, `.${ClassName.TABLE_CONTAINER}`);
|
|
309
|
-
|
|
310
|
-
const button = (
|
|
311
|
-
<DeleteButton
|
|
312
|
-
removeLabel={selectionType === 'column' ? messages.removeColumns : messages.removeRows}
|
|
313
|
-
onClick={this.handleClick}
|
|
314
|
-
onMouseEnter={this.handleMouseEnter}
|
|
315
|
-
onMouseLeave={this.handleMouseLeave}
|
|
316
|
-
/>
|
|
317
|
-
);
|
|
318
|
-
|
|
319
|
-
const popupOpts = getPopupOptions({
|
|
320
|
-
left: this.state.left,
|
|
321
|
-
top: this.state.top,
|
|
322
|
-
selectionType: this.state.selectionType,
|
|
323
|
-
tableWrapper: this.wrapper,
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
const mountTo = tableContainerWrapper || mountPoint;
|
|
327
|
-
if (this.state.position === 'sticky' && mountTo) {
|
|
328
|
-
const headerRow = tableRef.querySelector('tr.sticky');
|
|
329
|
-
if (headerRow) {
|
|
330
|
-
// Ignored via go/ees005
|
|
331
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
332
|
-
const rect = headerRow!.getBoundingClientRect();
|
|
333
|
-
|
|
334
|
-
const calculatePosition = popupOpts.onPositionCalculated || ((pos) => pos);
|
|
335
|
-
const pos = calculatePosition({
|
|
336
|
-
left: this.state.left,
|
|
337
|
-
top: this.state.top,
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
return createPortal(
|
|
341
|
-
<div
|
|
342
|
-
style={{
|
|
343
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
344
|
-
position: 'fixed',
|
|
345
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
346
|
-
top: pos.top,
|
|
347
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
348
|
-
zIndex: stickyRowZIndex,
|
|
349
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
350
|
-
left:
|
|
351
|
-
rect.left +
|
|
352
|
-
(pos.left || 0) -
|
|
353
|
-
(this.state.selectionType === 'column' ? this.state.scrollLeft : 0) -
|
|
354
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
355
|
-
(this.props.isNumberColumnEnabled ? akEditorTableNumberColumnWidth : 0),
|
|
356
|
-
}}
|
|
357
|
-
>
|
|
358
|
-
{button}
|
|
359
|
-
</div>,
|
|
360
|
-
mountTo,
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return (
|
|
366
|
-
<Popup
|
|
367
|
-
target={tableRef}
|
|
368
|
-
mountTo={mountTo}
|
|
369
|
-
boundariesElement={tableContainerWrapper || boundariesElement}
|
|
370
|
-
scrollableElement={this.wrapper || undefined}
|
|
371
|
-
forcePlacement={true}
|
|
372
|
-
allowOutOfBounds
|
|
373
|
-
// Ignored via go/ees005
|
|
374
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
375
|
-
{...popupOpts}
|
|
376
|
-
>
|
|
377
|
-
{button}
|
|
378
|
-
</Popup>
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
export default FloatingDeleteButton;
|