@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,203 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import rafSchedule from 'raf-schd';
|
|
4
|
-
import { createPortal } from 'react-dom';
|
|
5
|
-
|
|
6
|
-
import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
-
import { token } from '@atlaskit/tokens';
|
|
8
|
-
|
|
9
|
-
import type { RowStickyState } from '../../pm-plugins/sticky-headers/types';
|
|
10
|
-
import { TableCssClassName as ClassName } from '../../types';
|
|
11
|
-
import { insertColumnButtonOffset } from '../common-styles';
|
|
12
|
-
|
|
13
|
-
const BUTTON_WIDTH = 20;
|
|
14
|
-
|
|
15
|
-
interface Props {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
mountTo: HTMLElement;
|
|
18
|
-
offset: number;
|
|
19
|
-
stickyHeader: RowStickyState;
|
|
20
|
-
targetCellPosition: number;
|
|
21
|
-
targetCellRef: HTMLElement;
|
|
22
|
-
tableWrapper: HTMLElement;
|
|
23
|
-
isContextualMenuOpen: boolean | undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface CalcLeftPosData {
|
|
27
|
-
buttonWidth: number;
|
|
28
|
-
cellRectLeft: number;
|
|
29
|
-
cellRefWidth: number;
|
|
30
|
-
offset: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const calcLeftPos = ({
|
|
34
|
-
buttonWidth,
|
|
35
|
-
cellRectLeft,
|
|
36
|
-
cellRefWidth,
|
|
37
|
-
offset,
|
|
38
|
-
}: CalcLeftPosData) => {
|
|
39
|
-
return cellRectLeft + cellRefWidth - buttonWidth - offset;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const calcObserverTargetMargin = (
|
|
43
|
-
tableWrapper: HTMLElement,
|
|
44
|
-
fixedButtonRefCurrent: HTMLElement,
|
|
45
|
-
) => {
|
|
46
|
-
const tableWrapperRect = tableWrapper.getBoundingClientRect();
|
|
47
|
-
const fixedButtonRect = fixedButtonRefCurrent.getBoundingClientRect();
|
|
48
|
-
const scrollLeft = tableWrapper.scrollLeft;
|
|
49
|
-
return fixedButtonRect.left - tableWrapperRect.left + scrollLeft;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const FixedButton = ({
|
|
53
|
-
children,
|
|
54
|
-
isContextualMenuOpen,
|
|
55
|
-
mountTo,
|
|
56
|
-
offset,
|
|
57
|
-
stickyHeader,
|
|
58
|
-
tableWrapper,
|
|
59
|
-
targetCellPosition,
|
|
60
|
-
targetCellRef,
|
|
61
|
-
}: Props) => {
|
|
62
|
-
const fixedButtonRef = useRef<HTMLDivElement | null>(null);
|
|
63
|
-
const observerTargetRef = useRef<HTMLDivElement | null>(null);
|
|
64
|
-
|
|
65
|
-
// Using refs here rather than state to prevent heaps of renders on scroll
|
|
66
|
-
const scrollDataRef = useRef(0);
|
|
67
|
-
const leftPosDataRef = useRef(0);
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
const observerTargetRefCurrent = observerTargetRef.current;
|
|
71
|
-
const fixedButtonRefCurrent = fixedButtonRef.current;
|
|
72
|
-
|
|
73
|
-
if (fixedButtonRefCurrent && observerTargetRefCurrent) {
|
|
74
|
-
scrollDataRef.current = tableWrapper.scrollLeft;
|
|
75
|
-
leftPosDataRef.current = 0;
|
|
76
|
-
// Hide the button initially in case there's a flash of the button being
|
|
77
|
-
// outside the table before the Intersection Observer fires
|
|
78
|
-
fixedButtonRefCurrent.style.visibility = 'hidden';
|
|
79
|
-
|
|
80
|
-
const margin = calcObserverTargetMargin(tableWrapper, fixedButtonRefCurrent);
|
|
81
|
-
|
|
82
|
-
// Much more simple and predictable to add this margin to the observer target
|
|
83
|
-
// rather than using it to calculate the rootMargin values
|
|
84
|
-
observerTargetRefCurrent.style.marginLeft = `${margin}px`;
|
|
85
|
-
|
|
86
|
-
const observer = new IntersectionObserver(
|
|
87
|
-
(entries) => {
|
|
88
|
-
entries.forEach((entry) => {
|
|
89
|
-
if (entry.isIntersecting) {
|
|
90
|
-
fixedButtonRefCurrent.style.visibility = 'visible';
|
|
91
|
-
} else {
|
|
92
|
-
fixedButtonRefCurrent.style.visibility = 'hidden';
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
root: tableWrapper,
|
|
98
|
-
rootMargin: `0px ${insertColumnButtonOffset}px 0px 0px`,
|
|
99
|
-
threshold: 1,
|
|
100
|
-
},
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
const handleScroll = rafSchedule((event) => {
|
|
104
|
-
if (fixedButtonRef.current) {
|
|
105
|
-
const delta = event.target.scrollLeft - scrollDataRef.current;
|
|
106
|
-
const style = `translateX(${leftPosDataRef.current - delta}px)`;
|
|
107
|
-
fixedButtonRef.current.style.transform = style;
|
|
108
|
-
|
|
109
|
-
scrollDataRef.current = event.target.scrollLeft;
|
|
110
|
-
leftPosDataRef.current = leftPosDataRef.current - delta;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
observer.observe(observerTargetRefCurrent);
|
|
115
|
-
// Ignored via go/ees005
|
|
116
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
117
|
-
tableWrapper.addEventListener('scroll', handleScroll);
|
|
118
|
-
|
|
119
|
-
return () => {
|
|
120
|
-
// Ignored via go/ees005
|
|
121
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
122
|
-
tableWrapper.removeEventListener('scroll', handleScroll);
|
|
123
|
-
fixedButtonRefCurrent.style.transform = '';
|
|
124
|
-
observer.unobserve(observerTargetRefCurrent);
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}, [
|
|
128
|
-
fixedButtonRef,
|
|
129
|
-
observerTargetRef,
|
|
130
|
-
tableWrapper,
|
|
131
|
-
targetCellPosition,
|
|
132
|
-
targetCellRef,
|
|
133
|
-
isContextualMenuOpen,
|
|
134
|
-
]);
|
|
135
|
-
|
|
136
|
-
const fixedButtonTop = 0;
|
|
137
|
-
|
|
138
|
-
const containerLeft = useMemo(() => {
|
|
139
|
-
const container = targetCellRef.closest('[data-editor-container="true"]');
|
|
140
|
-
return container?.getBoundingClientRect().left || 0;
|
|
141
|
-
}, [targetCellRef]);
|
|
142
|
-
|
|
143
|
-
const left = useMemo(() => {
|
|
144
|
-
const targetCellRect = targetCellRef.getBoundingClientRect();
|
|
145
|
-
const baseLeft = calcLeftPos({
|
|
146
|
-
buttonWidth: BUTTON_WIDTH,
|
|
147
|
-
cellRectLeft: targetCellRect.left,
|
|
148
|
-
cellRefWidth: targetCellRef.clientWidth,
|
|
149
|
-
offset,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
return baseLeft - containerLeft;
|
|
153
|
-
}, [containerLeft, targetCellRef, offset]);
|
|
154
|
-
|
|
155
|
-
// Using a portal here to ensure wrapperRef has the tableWrapper as an
|
|
156
|
-
// ancestor. This is required to make the Intersection Observer work.
|
|
157
|
-
return createPortal(
|
|
158
|
-
// Using observerTargetRef here for our Intersection Observer. There is issues
|
|
159
|
-
// getting the observer to work just using the fixedButtonRef, possible due
|
|
160
|
-
// to using position fixed on this Element, or possibly due to its position
|
|
161
|
-
// being changed on scroll.
|
|
162
|
-
<div
|
|
163
|
-
ref={observerTargetRef}
|
|
164
|
-
style={{
|
|
165
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
166
|
-
position: 'absolute',
|
|
167
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
168
|
-
top: token('space.0', '0px'),
|
|
169
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
170
|
-
left: token('space.0', '0px'),
|
|
171
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
172
|
-
width: token('space.250', '20px'), // BUTTON_WIDTH
|
|
173
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
174
|
-
height: token('space.250', '20px'), // BUTTON_WIDTH
|
|
175
|
-
}}
|
|
176
|
-
>
|
|
177
|
-
<div
|
|
178
|
-
ref={fixedButtonRef}
|
|
179
|
-
style={{
|
|
180
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
181
|
-
position: 'fixed',
|
|
182
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
183
|
-
top: fixedButtonTop + stickyHeader.padding + offset * 2,
|
|
184
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
185
|
-
zIndex: akEditorTableCellOnStickyHeaderZIndex,
|
|
186
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
187
|
-
left,
|
|
188
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
189
|
-
width: token('space.250', '20px'), // BUTTON_WIDTH
|
|
190
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
191
|
-
height: token('space.250', '20px'), // BUTTON_WIDTH
|
|
192
|
-
}}
|
|
193
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
194
|
-
className={ClassName.CONTEXTUAL_MENU_BUTTON_FIXED}
|
|
195
|
-
>
|
|
196
|
-
{children}
|
|
197
|
-
</div>
|
|
198
|
-
</div>,
|
|
199
|
-
mountTo,
|
|
200
|
-
);
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export default FixedButton;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import React, { useEffect } from 'react';
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { jsx } from '@emotion/react';
|
|
9
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
10
|
-
import { injectIntl } from 'react-intl-next';
|
|
11
|
-
|
|
12
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
13
|
-
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
14
|
-
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
15
|
-
import { focusToContextMenuTrigger } from '@atlaskit/editor-common/keymaps';
|
|
16
|
-
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
17
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
18
|
-
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
19
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
20
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
21
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
22
|
-
import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
23
|
-
import ExpandIcon from '@atlaskit/icon/core/migration/chevron-down';
|
|
24
|
-
|
|
25
|
-
import { toggleContextualMenu } from '../../pm-plugins/commands';
|
|
26
|
-
import type { RowStickyState } from '../../pm-plugins/sticky-headers/types';
|
|
27
|
-
import { TableCssClassName as ClassName } from '../../types';
|
|
28
|
-
|
|
29
|
-
// Ignored via go/ees005
|
|
30
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
31
|
-
import FixedButton from './FixedButton';
|
|
32
|
-
import { tableFloatingCellButtonSelectedStyles, tableFloatingCellButtonStyles } from './styles';
|
|
33
|
-
|
|
34
|
-
export interface Props {
|
|
35
|
-
editorView: EditorView;
|
|
36
|
-
tableWrapper?: HTMLElement;
|
|
37
|
-
tableNode?: PMNode;
|
|
38
|
-
targetCellPosition: number;
|
|
39
|
-
isContextualMenuOpen?: boolean;
|
|
40
|
-
mountPoint?: HTMLElement;
|
|
41
|
-
boundariesElement?: HTMLElement;
|
|
42
|
-
scrollableElement?: HTMLElement;
|
|
43
|
-
isNumberColumnEnabled?: boolean;
|
|
44
|
-
stickyHeader?: RowStickyState;
|
|
45
|
-
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
46
|
-
isCellMenuOpenByKeyboard?: boolean;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const BUTTON_OFFSET = 3;
|
|
50
|
-
|
|
51
|
-
const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponentProps) => {
|
|
52
|
-
const {
|
|
53
|
-
editorView,
|
|
54
|
-
isContextualMenuOpen,
|
|
55
|
-
mountPoint,
|
|
56
|
-
scrollableElement,
|
|
57
|
-
stickyHeader,
|
|
58
|
-
tableWrapper,
|
|
59
|
-
targetCellPosition,
|
|
60
|
-
isCellMenuOpenByKeyboard,
|
|
61
|
-
intl: { formatMessage },
|
|
62
|
-
} = props; // : Props & WrappedComponentProps
|
|
63
|
-
|
|
64
|
-
const handleClick = () => {
|
|
65
|
-
const { state, dispatch } = editorView;
|
|
66
|
-
// Clicking outside the dropdown handles toggling the menu closed
|
|
67
|
-
// (otherwise these two toggles combat each other).
|
|
68
|
-
// In the event a user clicks the chevron button again
|
|
69
|
-
// That will count as clicking outside the dropdown and
|
|
70
|
-
// will be toggled appropriately
|
|
71
|
-
if (!isContextualMenuOpen) {
|
|
72
|
-
toggleContextualMenu()(state, dispatch);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
77
|
-
const targetCellRef: Node | undefined = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
78
|
-
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
81
|
-
const { state, dispatch } = editorView;
|
|
82
|
-
// open the menu when the keyboard shortcut is pressed
|
|
83
|
-
toggleContextualMenu()(state, dispatch);
|
|
84
|
-
}
|
|
85
|
-
}, [isCellMenuOpenByKeyboard, isContextualMenuOpen, editorView]);
|
|
86
|
-
|
|
87
|
-
if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const labelCellOptions = formatMessage(messages.cellOptions);
|
|
92
|
-
|
|
93
|
-
const button = (
|
|
94
|
-
<div
|
|
95
|
-
css={[
|
|
96
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
97
|
-
tableFloatingCellButtonStyles(),
|
|
98
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
99
|
-
isContextualMenuOpen && tableFloatingCellButtonSelectedStyles(),
|
|
100
|
-
]}
|
|
101
|
-
>
|
|
102
|
-
<ToolbarButton
|
|
103
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
104
|
-
className={ClassName.CONTEXTUAL_MENU_BUTTON}
|
|
105
|
-
selected={isContextualMenuOpen}
|
|
106
|
-
title={labelCellOptions}
|
|
107
|
-
keymap={focusToContextMenuTrigger}
|
|
108
|
-
onClick={handleClick}
|
|
109
|
-
iconBefore={<ExpandIcon label="" color="currentColor" size="small" />}
|
|
110
|
-
aria-label={labelCellOptions}
|
|
111
|
-
aria-expanded={isContextualMenuOpen}
|
|
112
|
-
/>
|
|
113
|
-
</div>
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const parentSticky =
|
|
117
|
-
targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
118
|
-
if (stickyHeader && parentSticky && tableWrapper) {
|
|
119
|
-
return (
|
|
120
|
-
<FixedButton
|
|
121
|
-
offset={BUTTON_OFFSET}
|
|
122
|
-
stickyHeader={stickyHeader}
|
|
123
|
-
tableWrapper={tableWrapper}
|
|
124
|
-
targetCellPosition={targetCellPosition}
|
|
125
|
-
targetCellRef={targetCellRef}
|
|
126
|
-
mountTo={tableWrapper}
|
|
127
|
-
isContextualMenuOpen={isContextualMenuOpen}
|
|
128
|
-
>
|
|
129
|
-
{button}
|
|
130
|
-
</FixedButton>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<Popup
|
|
136
|
-
alignX="right"
|
|
137
|
-
alignY="start"
|
|
138
|
-
target={targetCellRef}
|
|
139
|
-
mountTo={tableWrapper || mountPoint}
|
|
140
|
-
boundariesElement={targetCellRef}
|
|
141
|
-
scrollableElement={scrollableElement}
|
|
142
|
-
offset={[BUTTON_OFFSET, -BUTTON_OFFSET]}
|
|
143
|
-
forcePlacement
|
|
144
|
-
allowOutOfBounds
|
|
145
|
-
zIndex={akEditorSmallZIndex}
|
|
146
|
-
>
|
|
147
|
-
{button}
|
|
148
|
-
</Popup>
|
|
149
|
-
);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const FloatingContextualButton = injectIntl(FloatingContextualButtonInner);
|
|
153
|
-
|
|
154
|
-
export default function (props: Props) {
|
|
155
|
-
return (
|
|
156
|
-
<ErrorBoundary
|
|
157
|
-
component={ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON}
|
|
158
|
-
dispatchAnalyticsEvent={props.dispatchAnalyticsEvent}
|
|
159
|
-
fallbackComponent={null}
|
|
160
|
-
>
|
|
161
|
-
<FloatingContextualButton
|
|
162
|
-
// Ignored via go/ees005
|
|
163
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
164
|
-
{...props}
|
|
165
|
-
/>
|
|
166
|
-
</ErrorBoundary>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
|
-
import { css } from '@emotion/react';
|
|
3
|
-
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
-
import { N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
|
|
6
|
-
import { token } from '@atlaskit/tokens';
|
|
7
|
-
|
|
8
|
-
import { contextualMenuTriggerSize } from '../consts';
|
|
9
|
-
|
|
10
|
-
export const tableFloatingCellButtonStyles = () =>
|
|
11
|
-
css({
|
|
12
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
13
|
-
'> div': {
|
|
14
|
-
// Sits behind button to provide surface-color background
|
|
15
|
-
background: token('elevation.surface', N20),
|
|
16
|
-
borderRadius: token('border.radius', '3px'),
|
|
17
|
-
display: 'flex',
|
|
18
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
19
|
-
height: `${contextualMenuTriggerSize + 2}px`,
|
|
20
|
-
flexDirection: 'column',
|
|
21
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
22
|
-
...(fg('platform-visual-refresh-icons') && {
|
|
23
|
-
width: token('space.250', '20px'),
|
|
24
|
-
}),
|
|
25
|
-
},
|
|
26
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
27
|
-
'&& button': {
|
|
28
|
-
background: token('color.background.neutral', 'none'),
|
|
29
|
-
flexDirection: 'column',
|
|
30
|
-
margin: token('space.025', '2px'),
|
|
31
|
-
outline: `2px solid ${token('elevation.surface', N0)}`,
|
|
32
|
-
borderRadius: '1px',
|
|
33
|
-
padding: 0,
|
|
34
|
-
height: 'calc(100% - 4px)',
|
|
35
|
-
display: 'flex',
|
|
36
|
-
},
|
|
37
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
38
|
-
'&& button:hover': {
|
|
39
|
-
background: token('color.background.neutral.hovered', N30A),
|
|
40
|
-
},
|
|
41
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
42
|
-
'&& button:active': {
|
|
43
|
-
background: token('color.background.neutral.pressed', 'rgba(179, 212, 255, 0.6)'),
|
|
44
|
-
},
|
|
45
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
46
|
-
'&& button > span': {
|
|
47
|
-
margin: `0px ${token('space.negative.050', '-4px')}`,
|
|
48
|
-
},
|
|
49
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
50
|
-
'&& span': {
|
|
51
|
-
pointerEvents: 'none',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export const tableFloatingCellButtonSelectedStyles = () =>
|
|
56
|
-
css({
|
|
57
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
58
|
-
'&& button': {
|
|
59
|
-
background: token('color.background.selected', N700),
|
|
60
|
-
},
|
|
61
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
62
|
-
'&& button:hover': {
|
|
63
|
-
background: token('color.background.selected.hovered', N700),
|
|
64
|
-
},
|
|
65
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
66
|
-
'&& button:active': {
|
|
67
|
-
background: token('color.background.selected.pressed', N700),
|
|
68
|
-
},
|
|
69
|
-
});
|