@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.
Files changed (204) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +4 -4
  3. package/afm-cc/tsconfig.json +0 -123
  4. package/afm-dev-agents/tsconfig.json +0 -123
  5. package/afm-jira/tsconfig.json +0 -123
  6. package/afm-passionfruit/tsconfig.json +0 -123
  7. package/afm-post-office/tsconfig.json +0 -123
  8. package/afm-rovo-extension/tsconfig.json +0 -123
  9. package/afm-townsquare/tsconfig.json +0 -123
  10. package/afm-volt/tsconfig.json +0 -114
  11. package/build/tsconfig.json +0 -23
  12. package/docs/0-intro.tsx +0 -57
  13. package/src/index.ts +0 -21
  14. package/src/nodeviews/ExternalDropTargets.tsx +0 -91
  15. package/src/nodeviews/OverflowShadowsObserver.ts +0 -156
  16. package/src/nodeviews/TableCell.ts +0 -134
  17. package/src/nodeviews/TableComponent.tsx +0 -1590
  18. package/src/nodeviews/TableComponentWithSharedState.tsx +0 -278
  19. package/src/nodeviews/TableContainer.tsx +0 -926
  20. package/src/nodeviews/TableNodeViewBase.ts +0 -29
  21. package/src/nodeviews/TableResizer.tsx +0 -884
  22. package/src/nodeviews/TableRow.ts +0 -830
  23. package/src/nodeviews/TableStickyScrollbar.ts +0 -211
  24. package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +0 -15
  25. package/src/nodeviews/__mocks__/OverridableMock.ts +0 -26
  26. package/src/nodeviews/table-container-styles.ts +0 -9
  27. package/src/nodeviews/table-node-views.ts +0 -76
  28. package/src/nodeviews/table.tsx +0 -530
  29. package/src/nodeviews/toDOM.ts +0 -244
  30. package/src/nodeviews/types.ts +0 -36
  31. package/src/nodeviews/update-overflow-shadows.ts +0 -11
  32. package/src/pm-plugins/analytics/actions.ts +0 -21
  33. package/src/pm-plugins/analytics/commands.ts +0 -47
  34. package/src/pm-plugins/analytics/plugin-factory.ts +0 -9
  35. package/src/pm-plugins/analytics/plugin-key.ts +0 -5
  36. package/src/pm-plugins/analytics/plugin.ts +0 -80
  37. package/src/pm-plugins/analytics/reducer.ts +0 -27
  38. package/src/pm-plugins/analytics/types.ts +0 -20
  39. package/src/pm-plugins/analytics/utils/moved-event.ts +0 -51
  40. package/src/pm-plugins/commands/clear.ts +0 -43
  41. package/src/pm-plugins/commands/collapse.ts +0 -17
  42. package/src/pm-plugins/commands/column-resize.ts +0 -478
  43. package/src/pm-plugins/commands/commands-with-analytics.ts +0 -715
  44. package/src/pm-plugins/commands/delete.ts +0 -42
  45. package/src/pm-plugins/commands/display-mode.ts +0 -18
  46. package/src/pm-plugins/commands/go-to-next-cell.ts +0 -198
  47. package/src/pm-plugins/commands/hover.ts +0 -242
  48. package/src/pm-plugins/commands/index.ts +0 -51
  49. package/src/pm-plugins/commands/insert.ts +0 -438
  50. package/src/pm-plugins/commands/misc.ts +0 -811
  51. package/src/pm-plugins/commands/referentiality.ts +0 -15
  52. package/src/pm-plugins/commands/selection.ts +0 -537
  53. package/src/pm-plugins/commands/sort.ts +0 -102
  54. package/src/pm-plugins/commands/split-cell.ts +0 -28
  55. package/src/pm-plugins/commands/toggle.ts +0 -109
  56. package/src/pm-plugins/create-plugin-config.ts +0 -17
  57. package/src/pm-plugins/decorations/plugin.ts +0 -107
  58. package/src/pm-plugins/decorations/utils/column-controls.ts +0 -91
  59. package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -71
  60. package/src/pm-plugins/decorations/utils/compose-decorations.ts +0 -9
  61. package/src/pm-plugins/decorations/utils/types.ts +0 -16
  62. package/src/pm-plugins/default-table-selection.ts +0 -14
  63. package/src/pm-plugins/drag-and-drop/actions.ts +0 -48
  64. package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -222
  65. package/src/pm-plugins/drag-and-drop/commands.ts +0 -194
  66. package/src/pm-plugins/drag-and-drop/consts.ts +0 -7
  67. package/src/pm-plugins/drag-and-drop/plugin-factory.ts +0 -33
  68. package/src/pm-plugins/drag-and-drop/plugin-key.ts +0 -5
  69. package/src/pm-plugins/drag-and-drop/plugin.ts +0 -398
  70. package/src/pm-plugins/drag-and-drop/reducer.ts +0 -38
  71. package/src/pm-plugins/drag-and-drop/types.ts +0 -18
  72. package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +0 -49
  73. package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +0 -9
  74. package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -73
  75. package/src/pm-plugins/handlers.ts +0 -161
  76. package/src/pm-plugins/keymap.ts +0 -436
  77. package/src/pm-plugins/main.ts +0 -433
  78. package/src/pm-plugins/plugin-factory.ts +0 -42
  79. package/src/pm-plugins/plugin-key.ts +0 -8
  80. package/src/pm-plugins/reducer.ts +0 -145
  81. package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -102
  82. package/src/pm-plugins/sticky-headers/commands.ts +0 -8
  83. package/src/pm-plugins/sticky-headers/plugin-key.ts +0 -5
  84. package/src/pm-plugins/sticky-headers/plugin-state.ts +0 -52
  85. package/src/pm-plugins/sticky-headers/plugin.ts +0 -12
  86. package/src/pm-plugins/sticky-headers/types.ts +0 -20
  87. package/src/pm-plugins/sticky-headers/util.ts +0 -18
  88. package/src/pm-plugins/table-analytics.ts +0 -100
  89. package/src/pm-plugins/table-local-id.ts +0 -213
  90. package/src/pm-plugins/table-resizing/commands.ts +0 -116
  91. package/src/pm-plugins/table-resizing/event-handlers.ts +0 -352
  92. package/src/pm-plugins/table-resizing/plugin-factory.ts +0 -29
  93. package/src/pm-plugins/table-resizing/plugin-key.ts +0 -5
  94. package/src/pm-plugins/table-resizing/plugin.ts +0 -94
  95. package/src/pm-plugins/table-resizing/reducer.ts +0 -37
  96. package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -306
  97. package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -120
  98. package/src/pm-plugins/table-resizing/utils/consts.ts +0 -11
  99. package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -118
  100. package/src/pm-plugins/table-resizing/utils/dom.ts +0 -132
  101. package/src/pm-plugins/table-resizing/utils/misc.ts +0 -282
  102. package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -34
  103. package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -289
  104. package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -417
  105. package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -290
  106. package/src/pm-plugins/table-resizing/utils/types.ts +0 -25
  107. package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +0 -1
  108. package/src/pm-plugins/table-selection-keymap.ts +0 -64
  109. package/src/pm-plugins/table-size-selector.ts +0 -39
  110. package/src/pm-plugins/table-width-in-comment-fix.ts +0 -113
  111. package/src/pm-plugins/table-width.ts +0 -153
  112. package/src/pm-plugins/transforms/column-width.ts +0 -249
  113. package/src/pm-plugins/transforms/delete-columns.ts +0 -281
  114. package/src/pm-plugins/transforms/delete-rows.ts +0 -154
  115. package/src/pm-plugins/transforms/fix-tables.ts +0 -249
  116. package/src/pm-plugins/transforms/merge.ts +0 -301
  117. package/src/pm-plugins/transforms/replace-table.ts +0 -38
  118. package/src/pm-plugins/transforms/split.ts +0 -90
  119. package/src/pm-plugins/utils/alignment.ts +0 -33
  120. package/src/pm-plugins/utils/analytics.ts +0 -238
  121. package/src/pm-plugins/utils/collapse.ts +0 -93
  122. package/src/pm-plugins/utils/column-controls.ts +0 -250
  123. package/src/pm-plugins/utils/create.ts +0 -64
  124. package/src/pm-plugins/utils/decoration.ts +0 -672
  125. package/src/pm-plugins/utils/dom.ts +0 -251
  126. package/src/pm-plugins/utils/drag-menu.tsx +0 -491
  127. package/src/pm-plugins/utils/get-allow-add-column-custom-step.ts +0 -10
  128. package/src/pm-plugins/utils/guidelines.ts +0 -30
  129. package/src/pm-plugins/utils/merged-cells.ts +0 -239
  130. package/src/pm-plugins/utils/nodes.ts +0 -162
  131. package/src/pm-plugins/utils/paste.ts +0 -386
  132. package/src/pm-plugins/utils/row-controls.ts +0 -211
  133. package/src/pm-plugins/utils/selection.ts +0 -17
  134. package/src/pm-plugins/utils/snapping.ts +0 -136
  135. package/src/pm-plugins/utils/table.ts +0 -60
  136. package/src/pm-plugins/utils/update-plugin-state-decorations.ts +0 -13
  137. package/src/pm-plugins/view-mode-sort/consts.ts +0 -3
  138. package/src/pm-plugins/view-mode-sort/index.ts +0 -291
  139. package/src/pm-plugins/view-mode-sort/plugin-key.ts +0 -7
  140. package/src/pm-plugins/view-mode-sort/types.ts +0 -23
  141. package/src/pm-plugins/view-mode-sort/utils.ts +0 -136
  142. package/src/tablePlugin.tsx +0 -971
  143. package/src/tablePluginType.ts +0 -102
  144. package/src/types/index.ts +0 -592
  145. package/src/ui/ColumnResizeWidget/index.tsx +0 -61
  146. package/src/ui/ContentComponent.tsx +0 -311
  147. package/src/ui/DragHandle/HandleIconComponent.tsx +0 -21
  148. package/src/ui/DragHandle/index.tsx +0 -391
  149. package/src/ui/DragPreview/index.tsx +0 -51
  150. package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +0 -59
  151. package/src/ui/FloatingContextualButton/FixedButton.tsx +0 -203
  152. package/src/ui/FloatingContextualButton/index.tsx +0 -168
  153. package/src/ui/FloatingContextualButton/styles.ts +0 -69
  154. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +0 -931
  155. package/src/ui/FloatingContextualMenu/index.tsx +0 -141
  156. package/src/ui/FloatingContextualMenu/styles.ts +0 -77
  157. package/src/ui/FloatingDeleteButton/DeleteButton.tsx +0 -54
  158. package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +0 -65
  159. package/src/ui/FloatingDeleteButton/index.tsx +0 -383
  160. package/src/ui/FloatingDeleteButton/types.ts +0 -3
  161. package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -668
  162. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +0 -221
  163. package/src/ui/FloatingDragMenu/index.tsx +0 -136
  164. package/src/ui/FloatingDragMenu/styles.ts +0 -83
  165. package/src/ui/FloatingInsertButton/InsertButton.tsx +0 -263
  166. package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -131
  167. package/src/ui/FloatingInsertButton/index.tsx +0 -314
  168. package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +0 -31
  169. package/src/ui/SizeSelector/index.tsx +0 -74
  170. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -397
  171. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +0 -105
  172. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +0 -63
  173. package/src/ui/TableFloatingColumnControls/index.tsx +0 -151
  174. package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +0 -106
  175. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +0 -143
  176. package/src/ui/TableFloatingControls/CornerControls/types.ts +0 -12
  177. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +0 -88
  178. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +0 -175
  179. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +0 -131
  180. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -429
  181. package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +0 -96
  182. package/src/ui/TableFloatingControls/index.tsx +0 -275
  183. package/src/ui/TableFullWidthLabel/index.tsx +0 -38
  184. package/src/ui/common-styles.ts +0 -1218
  185. package/src/ui/consts.ts +0 -109
  186. package/src/ui/event-handlers.ts +0 -662
  187. package/src/ui/global-styles.tsx +0 -55
  188. package/src/ui/hooks/useInternalTablePluginStateSelector.ts +0 -38
  189. package/src/ui/icons/AddColLeftIcon.tsx +0 -37
  190. package/src/ui/icons/AddColRightIcon.tsx +0 -37
  191. package/src/ui/icons/AddRowAboveIcon.tsx +0 -22
  192. package/src/ui/icons/AddRowBelowIcon.tsx +0 -39
  193. package/src/ui/icons/DragHandleDisabledIcon.tsx +0 -25
  194. package/src/ui/icons/DragHandleIcon.tsx +0 -16
  195. package/src/ui/icons/DragInMotionIcon.tsx +0 -54
  196. package/src/ui/icons/MergeCellsIcon.tsx +0 -26
  197. package/src/ui/icons/MinimisedHandle.tsx +0 -15
  198. package/src/ui/icons/SortingIconWrapper.tsx +0 -43
  199. package/src/ui/icons/SplitCellIcon.tsx +0 -34
  200. package/src/ui/toolbar.tsx +0 -1153
  201. package/src/ui/ui-styles.ts +0 -960
  202. package/tsconfig.app.json +0 -135
  203. package/tsconfig.dev.json +0 -54
  204. package/tsconfig.json +0 -18
@@ -1,391 +0,0 @@
1
- /* eslint-disable @atlaskit/design-system/no-html-button */
2
- import type { MouseEventHandler } from 'react';
3
- import React, { useEffect, useMemo, useRef, useState } from 'react';
4
-
5
- import classnames from 'classnames';
6
- import ReactDOM from 'react-dom';
7
- import type { WrappedComponentProps } from 'react-intl-next';
8
- import { injectIntl } from 'react-intl-next';
9
-
10
- import { browser } from '@atlaskit/editor-common/browser';
11
- import {
12
- sharedPluginStateHookMigratorFactory,
13
- useSharedPluginState,
14
- useSharedPluginStateWithSelector,
15
- } from '@atlaskit/editor-common/hooks';
16
- import { tableMessages as messages } from '@atlaskit/editor-common/messages';
17
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
18
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
19
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
20
- import { findTable, TableMap } from '@atlaskit/editor-tables';
21
- import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
22
- import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
23
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
24
- import { token } from '@atlaskit/tokens';
25
-
26
- import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
27
- import type { TriggerType } from '../../pm-plugins/drag-and-drop/types';
28
- import { getPluginState } from '../../pm-plugins/plugin-factory';
29
- import {
30
- findDuplicatePosition,
31
- hasMergedCellsInSelection,
32
- } from '../../pm-plugins/utils/merged-cells';
33
- import type { TablePlugin } from '../../tablePluginType';
34
- import { TableCssClassName as ClassName } from '../../types';
35
- import type { CellHoverMeta, TableDirection, TableSharedStateInternal } from '../../types';
36
- import { dragTableInsertColumnButtonSize } from '../consts';
37
- import { DragPreview } from '../DragPreview';
38
-
39
- import { HandleIconComponent } from './HandleIconComponent';
40
-
41
- export type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger' | 'placeholder';
42
-
43
- type DragHandleProps = {
44
- tableLocalId: string;
45
- indexes: number[];
46
- forceDefaultHandle?: boolean;
47
- previewWidth?: number;
48
- previewHeight?: number;
49
- hoveredCell?: CellHoverMeta;
50
- direction?: TableDirection;
51
- appearance?: DragHandleAppearance;
52
- onClick?: MouseEventHandler;
53
- onMouseOver?: MouseEventHandler;
54
- onMouseOut?: MouseEventHandler;
55
- toggleDragMenu?: (
56
- trigger: TriggerType,
57
- event?: React.MouseEvent<HTMLButtonElement, MouseEvent>,
58
- ) => void;
59
- editorView: EditorView;
60
- isDragMenuTarget: boolean; // this is identify which current handle component is
61
- hoveredColumns?: number[];
62
- hoveredRows?: number[];
63
- };
64
-
65
- type DragHandleWithSharedStateProps = Exclude<DragHandleProps, 'hoveredColumns' | 'hoveredRows'> & {
66
- api?: ExtractInjectionAPI<TablePlugin>;
67
- };
68
-
69
- const DragHandleComponent = ({
70
- isDragMenuTarget,
71
- tableLocalId,
72
- direction = 'row',
73
- appearance = 'default',
74
- indexes,
75
- forceDefaultHandle = false,
76
- previewWidth,
77
- previewHeight,
78
- onMouseOver,
79
- onMouseOut,
80
- toggleDragMenu,
81
- hoveredCell,
82
- onClick,
83
- editorView,
84
- intl: { formatMessage },
85
- hoveredColumns,
86
- hoveredRows,
87
- }: DragHandleProps & WrappedComponentProps) => {
88
- const dragHandleDivRef = useRef<HTMLButtonElement>(null);
89
- const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(null);
90
- const {
91
- state,
92
- state: { selection },
93
- } = editorView;
94
-
95
- if (hoveredColumns === undefined || hoveredRows === undefined) {
96
- const { hoveredColumns: hoveredColumnsState, hoveredRows: hoveredRowsState } =
97
- getPluginState(state);
98
- hoveredColumns = hoveredColumnsState;
99
- hoveredRows = hoveredRowsState;
100
- }
101
- const { isDragMenuOpen = false } = getDnDPluginState(state);
102
-
103
- const isRow = direction === 'row';
104
- const isColumn = direction === 'column';
105
-
106
- // Added !isDragMenuOpen check so when hover 'Delete column/row' from drag menu
107
- // the handle of the next column/row does not show the 'hovered' state icon
108
- const isRowHandleHovered = isRow && hoveredRows.length > 0 && !isDragMenuOpen;
109
- const isColumnHandleHovered = isColumn && hoveredColumns.length > 0 && !isDragMenuOpen;
110
-
111
- const hasMergedCells = useMemo(() => {
112
- const table = findTable(selection);
113
- if (!table) {
114
- return false;
115
- }
116
-
117
- const map = TableMap.get(table?.node);
118
-
119
- if (!map.hasMergedCells() || indexes.length < 1) {
120
- return false;
121
- }
122
-
123
- const { mapByColumn, mapByRow } = map;
124
-
125
- // this handle when hover to first column or row which has merged cells.
126
- if (
127
- hoveredCell &&
128
- hoveredCell.rowIndex !== undefined &&
129
- hoveredCell.colIndex !== undefined &&
130
- selection instanceof TextSelection
131
- ) {
132
- const { rowIndex, colIndex } = hoveredCell;
133
-
134
- const mergedPositionInRow = findDuplicatePosition(mapByRow[rowIndex]);
135
- const mergedPositionInCol = findDuplicatePosition(mapByColumn[colIndex]);
136
-
137
- const hasMergedCellsInFirstRowOrColumn =
138
- direction === 'column'
139
- ? mergedPositionInRow.includes(mapByRow[0][colIndex])
140
- : mergedPositionInCol.includes(mapByColumn[0][rowIndex]);
141
-
142
- const isHoveredOnFirstRowOrColumn =
143
- direction === 'column'
144
- ? hoveredCell.rowIndex === 0 && hasMergedCellsInFirstRowOrColumn
145
- : hoveredCell.colIndex === 0 && hasMergedCellsInFirstRowOrColumn;
146
-
147
- if (isHoveredOnFirstRowOrColumn) {
148
- const mergedSizes =
149
- direction === 'column'
150
- ? mapByRow[0].filter((el: number) => el === mapByRow[0][colIndex]).length
151
- : mapByColumn[0].filter((el: number) => el === mapByColumn[0][rowIndex]).length;
152
-
153
- const mergedSelection = hasMergedCellsInSelection(
154
- direction === 'column'
155
- ? [colIndex, colIndex + mergedSizes - 1]
156
- : [rowIndex, rowIndex + mergedSizes - 1],
157
- direction,
158
- )(selection);
159
-
160
- return mergedSelection;
161
- }
162
- }
163
-
164
- return hasMergedCellsInSelection(indexes, direction)(selection);
165
- }, [indexes, selection, direction, hoveredCell]);
166
-
167
- const handleIconProps = {
168
- forceDefaultHandle,
169
- isHandleHovered: isColumnHandleHovered || isRowHandleHovered,
170
- hasMergedCells,
171
- };
172
-
173
- useEffect(() => {
174
- const dragHandleDivRefCurrent = dragHandleDivRef.current;
175
-
176
- if (dragHandleDivRefCurrent) {
177
- return draggable({
178
- element: dragHandleDivRefCurrent,
179
- canDrag: () => {
180
- return !hasMergedCells;
181
- },
182
- getInitialData() {
183
- return {
184
- localId: tableLocalId,
185
- type: `table-${direction}`,
186
- indexes,
187
- };
188
- },
189
- onGenerateDragPreview: ({ nativeSetDragImage }) => {
190
- setCustomNativeDragPreview({
191
- getOffset: ({ container }) => {
192
- const rect = container.getBoundingClientRect();
193
- if (browser.safari) {
194
- // See: https://product-fabric.atlassian.net/browse/ED-21442
195
- // We need to ensure that the preview is not overlaying screen content when the snapshot is taken, otherwise
196
- // safari will composite the screen text elements into the bitmap snapshot. The container is a wrapper which is already
197
- // positioned fixed at top/left 0.
198
- // IMPORTANT: we must not exceed more then the width of the container off-screen otherwise not preview will
199
- // be generated.
200
- container.style.left = `-${rect.width - 0.0001}px`;
201
- }
202
- if (isRow) {
203
- return { x: 12, y: rect.height / 2 };
204
- } else {
205
- return { x: rect.width / 2 + 4, y: 12 };
206
- }
207
- },
208
- render: function render({ container }) {
209
- setPreviewContainer(container);
210
- return () => setPreviewContainer(null);
211
- },
212
- nativeSetDragImage,
213
- });
214
- },
215
- });
216
- }
217
- }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells]);
218
-
219
- const showDragMenuAnchorId = isRow ? 'drag-handle-button-row' : 'drag-handle-button-column';
220
-
221
- return (
222
- <>
223
- <button
224
- type="button"
225
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
226
- className={ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE}
227
- data-testid="table-drag-handle-clickable-zone-button"
228
- style={{
229
- height: isRow
230
- ? // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
231
- `calc(100% - ${dragTableInsertColumnButtonSize}px)`
232
- : `${token('space.200', '16px')}`, // 16px here because it's the size of drag handle button's large side
233
- width: isRow
234
- ? `${token('space.200', '16px')}` // 16px here because it's the size of drag handle button's large side
235
- : // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
236
- `calc(100% - ${dragTableInsertColumnButtonSize}px)`,
237
- left: isRow ? `${token('space.050', '4px')}` : undefined,
238
- bottom: isColumn ? `${token('space.0', '0px')}` : undefined,
239
- alignSelf: isColumn ? 'none' : 'center',
240
- zIndex: isColumn ? '-1' : 'auto',
241
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
242
- pointerEvents: 'auto',
243
- }}
244
- onMouseUp={(e) => {
245
- // should toggle menu if current drag menu open.
246
- // return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
247
- // -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
248
- editorView.focus();
249
- if (isDragMenuOpen) {
250
- toggleDragMenu && toggleDragMenu('mouse', e);
251
- }
252
- }}
253
- onClick={onClick}
254
- aria-label={
255
- expValEquals('platform_editor_enghealth_table_plugin_lable_rule', 'isEnabled', true)
256
- ? formatMessage(messages.dragHandleZone)
257
- : undefined
258
- }
259
- />
260
- <button
261
- type="button"
262
- id={isDragMenuTarget ? showDragMenuAnchorId : undefined}
263
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
264
- className={classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, {
265
- [ClassName.DRAG_HANDLE_DISABLED]: hasMergedCells,
266
- })}
267
- ref={dragHandleDivRef}
268
- style={{
269
- transform: isColumn ? 'none' : 'rotate(90deg)',
270
- alignSelf: isColumn ? 'none' : 'center',
271
- }}
272
- data-testid="table-drag-handle-button"
273
- aria-label={formatMessage(isRow ? messages.rowDragHandle : messages.columnDragHandle)}
274
- aria-expanded={isDragMenuOpen && isDragMenuTarget ? 'true' : 'false'}
275
- aria-haspopup="menu"
276
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
277
- onMouseOver={onMouseOver}
278
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
279
- onMouseOut={onMouseOut}
280
- onMouseUp={(e) => {
281
- // return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
282
- // -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
283
- editorView.focus();
284
- toggleDragMenu && toggleDragMenu('mouse', e);
285
- }}
286
- onClick={onClick}
287
- onKeyDown={(e) => {
288
- if (e.key === 'Enter' || e.key === ' ') {
289
- toggleDragMenu && toggleDragMenu('keyboard');
290
- }
291
- }}
292
- >
293
- {appearance !== 'placeholder' ? (
294
- // cannot block pointer events in Firefox as it breaks Dragging functionality
295
- browser.gecko ? (
296
- // Ignored via go/ees005
297
- // eslint-disable-next-line react/jsx-props-no-spreading
298
- <HandleIconComponent {...handleIconProps} />
299
- ) : (
300
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
301
- <span style={{ pointerEvents: 'none' }}>
302
- <HandleIconComponent
303
- // Ignored via go/ees005
304
- // eslint-disable-next-line react/jsx-props-no-spreading
305
- {...handleIconProps}
306
- />
307
- </span>
308
- )
309
- ) : null}
310
- </button>
311
- {previewContainer &&
312
- previewWidth !== undefined &&
313
- previewHeight !== undefined &&
314
- ReactDOM.createPortal(
315
- <DragPreview direction={direction} width={previewWidth} height={previewHeight} />,
316
- previewContainer,
317
- )}
318
- </>
319
- );
320
- };
321
-
322
- const useSharedState = sharedPluginStateHookMigratorFactory(
323
- (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
324
- const { hoveredColumns, hoveredRows } = useSharedPluginStateWithSelector(
325
- api,
326
- ['table'],
327
- (states) => ({
328
- hoveredColumns: (states.tableState as TableSharedStateInternal)?.hoveredColumns,
329
- hoveredRows: (states.tableState as TableSharedStateInternal)?.hoveredRows,
330
- }),
331
- );
332
- return {
333
- hoveredColumns,
334
- hoveredRows,
335
- };
336
- },
337
- (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
338
- const { tableState } = useSharedPluginState(api, ['table']);
339
- const tableStateInternal = tableState as TableSharedStateInternal;
340
- return {
341
- hoveredColumns: tableStateInternal?.hoveredColumns,
342
- hoveredRows: tableStateInternal?.hoveredRows,
343
- };
344
- },
345
- );
346
-
347
- const DragHandleComponentWithSharedState = ({
348
- isDragMenuTarget,
349
- tableLocalId,
350
- direction,
351
- appearance,
352
- indexes,
353
- forceDefaultHandle,
354
- previewHeight,
355
- previewWidth,
356
- onMouseOver,
357
- onMouseOut,
358
- toggleDragMenu,
359
- hoveredCell,
360
- onClick,
361
- editorView,
362
- intl,
363
- api,
364
- }: DragHandleWithSharedStateProps & WrappedComponentProps) => {
365
- const { hoveredColumns, hoveredRows } = useSharedState(api);
366
- return (
367
- <DragHandleComponent
368
- isDragMenuTarget={isDragMenuTarget}
369
- tableLocalId={tableLocalId}
370
- direction={direction}
371
- appearance={appearance}
372
- indexes={indexes}
373
- forceDefaultHandle={forceDefaultHandle}
374
- previewWidth={previewWidth}
375
- previewHeight={previewHeight}
376
- onMouseOver={onMouseOver}
377
- onMouseOut={onMouseOut}
378
- toggleDragMenu={toggleDragMenu}
379
- hoveredCell={hoveredCell}
380
- onClick={onClick}
381
- editorView={editorView}
382
- intl={intl}
383
- hoveredColumns={hoveredColumns}
384
- hoveredRows={hoveredRows}
385
- />
386
- );
387
- };
388
-
389
- export const DragHandle = injectIntl(DragHandleComponent);
390
-
391
- export const DragHandleWithSharedState = injectIntl(DragHandleComponentWithSharedState);
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
-
3
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
4
- import { Box, xcss } from '@atlaskit/primitives';
5
-
6
- import type { TableDirection } from '../../types';
7
- import { DragInMotionIcon } from '../icons/DragInMotionIcon';
8
-
9
- const boxStyles = xcss({
10
- borderColor: 'color.border.focused',
11
- borderStyle: 'solid',
12
- borderRadius: 'border.radius.100',
13
- borderWidth: 'border.width.outline',
14
- backgroundColor: 'color.blanket.selected',
15
- });
16
-
17
- export const DragPreview = ({
18
- direction,
19
- width,
20
- height,
21
- }: {
22
- direction: TableDirection;
23
- width: number;
24
- height: number;
25
- }) => {
26
- const marginLeft = direction === 'row' ? -14 : width / 2 - 14;
27
- const marginTop = direction === 'row' ? height / 2 - 14 : -10;
28
- const transform = direction === 'row' ? 'rotate(90deg)' : 'none';
29
- return (
30
- <Box
31
- xcss={boxStyles}
32
- style={{
33
- width: `${width}px`,
34
- height: `${height}px`,
35
- }}
36
- >
37
- <DragInMotionIcon
38
- style={{
39
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
40
- position: 'absolute',
41
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
42
- marginLeft: `${marginLeft}px`,
43
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
44
- marginTop: `${marginTop}px`,
45
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
46
- transform: transform,
47
- }}
48
- />
49
- </Box>
50
- );
51
- };
@@ -1,59 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
- import { jsx } from '@emotion/react';
7
-
8
- import { ButtonGroup } from '@atlaskit/button';
9
- import type { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
10
- import {
11
- FloatingToolbarButton as Button,
12
- FloatingToolbarSeparator,
13
- } from '@atlaskit/editor-common/ui';
14
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
15
- import { Box, xcss } from '@atlaskit/primitives';
16
-
17
- const containerStyles = xcss({
18
- marginLeft: 'space.100',
19
- });
20
-
21
- type Props = {
22
- alignmentButtons: FloatingToolbarItem<Command>[];
23
- dispatchCommand: (command: Command) => void;
24
- };
25
-
26
- export const FloatingAlignmentButtons = ({ alignmentButtons, dispatchCommand }: Props) => {
27
- return (
28
- <Box xcss={containerStyles}>
29
- <ButtonGroup>
30
- {alignmentButtons.map((item, idx) => {
31
- switch (item.type) {
32
- case 'separator':
33
- // Ignored via go/ees005
34
- // eslint-disable-next-line react/no-array-index-key
35
- return <FloatingToolbarSeparator key={idx} />;
36
- case 'button':
37
- // Ignored via go/ees005
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- const ButtonIcon = item.icon as React.ComponentClass<any>;
40
- return (
41
- <Button
42
- // Ignored via go/ees005
43
- // eslint-disable-next-line react/no-array-index-key
44
- key={idx}
45
- icon={item.icon ? <ButtonIcon label={item.title} /> : undefined}
46
- title={item.title}
47
- selected={item.selected}
48
- disabled={item.disabled}
49
- onClick={() => {
50
- dispatchCommand(item.onClick);
51
- }}
52
- />
53
- );
54
- }
55
- })}
56
- </ButtonGroup>
57
- </Box>
58
- );
59
- };