@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,668 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
-
/**
|
|
3
|
-
* @jsxRuntime classic
|
|
4
|
-
* @jsx jsx
|
|
5
|
-
*/
|
|
6
|
-
/** @jsxFrag */
|
|
7
|
-
import React, { useEffect, useState } from 'react';
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
|
-
import { jsx } from '@emotion/react';
|
|
11
|
-
import type { IntlShape, MessageDescriptor, WrappedComponentProps } from 'react-intl-next';
|
|
12
|
-
import { injectIntl } from 'react-intl-next';
|
|
13
|
-
|
|
14
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
15
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
16
|
-
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
17
|
-
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
18
|
-
import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
19
|
-
import {
|
|
20
|
-
backgroundPaletteTooltipMessages,
|
|
21
|
-
cellBackgroundColorPalette,
|
|
22
|
-
ColorPalette,
|
|
23
|
-
getSelectedRowAndColumnFromPalette,
|
|
24
|
-
} from '@atlaskit/editor-common/ui-color';
|
|
25
|
-
import {
|
|
26
|
-
ArrowKeyNavigationProvider,
|
|
27
|
-
ArrowKeyNavigationType,
|
|
28
|
-
} from '@atlaskit/editor-common/ui-menu';
|
|
29
|
-
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
30
|
-
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
31
|
-
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
32
|
-
import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
33
|
-
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
34
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
35
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
36
|
-
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
37
|
-
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
38
|
-
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
39
|
-
import {
|
|
40
|
-
findCellRectClosestToPos,
|
|
41
|
-
getSelectionRect,
|
|
42
|
-
isSelectionType,
|
|
43
|
-
} from '@atlaskit/editor-tables/utils';
|
|
44
|
-
import PaintBucketIcon from '@atlaskit/icon/core/migration/paint-bucket--editor-background-color';
|
|
45
|
-
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
46
|
-
import { Box, xcss } from '@atlaskit/primitives';
|
|
47
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
48
|
-
import Toggle from '@atlaskit/toggle';
|
|
49
|
-
|
|
50
|
-
import { clearHoverSelection, hoverColumns, hoverRows } from '../../pm-plugins/commands';
|
|
51
|
-
import {
|
|
52
|
-
setColorWithAnalytics,
|
|
53
|
-
toggleHeaderColumnWithAnalytics,
|
|
54
|
-
toggleHeaderRowWithAnalytics,
|
|
55
|
-
toggleNumberColumnWithAnalytics,
|
|
56
|
-
} from '../../pm-plugins/commands/commands-with-analytics';
|
|
57
|
-
import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
|
|
58
|
-
import { getPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
59
|
-
import { getPluginState as getTablePluginState } from '../../pm-plugins/plugin-factory';
|
|
60
|
-
import type { DragMenuConfig, DragMenuOptionIdType } from '../../pm-plugins/utils/drag-menu';
|
|
61
|
-
import { getDragMenuConfig } from '../../pm-plugins/utils/drag-menu';
|
|
62
|
-
import {
|
|
63
|
-
checkIfHeaderColumnEnabled,
|
|
64
|
-
checkIfHeaderRowEnabled,
|
|
65
|
-
checkIfNumberColumnEnabled,
|
|
66
|
-
} from '../../pm-plugins/utils/nodes';
|
|
67
|
-
import { getSelectedColumnIndexes, getSelectedRowIndexes } from '../../pm-plugins/utils/selection';
|
|
68
|
-
import { TableCssClassName as ClassName } from '../../types';
|
|
69
|
-
import type { PluginConfig, PluginInjectionAPI, TableDirection } from '../../types';
|
|
70
|
-
import { colorPalletteColumns } from '../consts';
|
|
71
|
-
|
|
72
|
-
import { DropdownMenu } from './DropdownMenu';
|
|
73
|
-
import { cellColourPreviewStyles, dragMenuBackgroundColorStyles, toggleStyles } from './styles';
|
|
74
|
-
|
|
75
|
-
type DragMenuProps = {
|
|
76
|
-
direction?: TableDirection;
|
|
77
|
-
index?: number;
|
|
78
|
-
target?: Element;
|
|
79
|
-
tableNode?: PmNode;
|
|
80
|
-
editorView: EditorView;
|
|
81
|
-
isOpen?: boolean;
|
|
82
|
-
targetCellPosition?: number;
|
|
83
|
-
pluginConfig?: PluginConfig;
|
|
84
|
-
getEditorContainerWidth: GetEditorContainerWidth;
|
|
85
|
-
api: PluginInjectionAPI | undefined | null;
|
|
86
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
87
|
-
fitWidth?: number;
|
|
88
|
-
fitHeight?: number;
|
|
89
|
-
mountPoint?: HTMLElement;
|
|
90
|
-
boundariesElement?: HTMLElement;
|
|
91
|
-
scrollableElement?: HTMLElement;
|
|
92
|
-
isTableScalingEnabled?: boolean;
|
|
93
|
-
shouldUseIncreasedScalingPercent?: boolean;
|
|
94
|
-
isTableFixedColumnWidthsOptionEnabled?: boolean;
|
|
95
|
-
ariaNotifyPlugin?: (
|
|
96
|
-
message: string,
|
|
97
|
-
ariaLiveElementAttributes?: AriaLiveElementAttributes,
|
|
98
|
-
) => void;
|
|
99
|
-
isCommentEditor?: boolean;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
type PluralOptionType = 'noOfCols' | 'noOfRows' | 'noOfCells' | null;
|
|
103
|
-
interface MessageType {
|
|
104
|
-
message: MessageDescriptor;
|
|
105
|
-
plural: PluralOptionType;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const MapDragMenuOptionIdToMessage: Record<DragMenuOptionIdType, MessageType> = {
|
|
109
|
-
add_row_above: {
|
|
110
|
-
message: messages.addRowAbove,
|
|
111
|
-
plural: null,
|
|
112
|
-
},
|
|
113
|
-
add_row_below: {
|
|
114
|
-
message: messages.addRowBelow,
|
|
115
|
-
plural: null,
|
|
116
|
-
},
|
|
117
|
-
add_column_left: {
|
|
118
|
-
message: messages.addColumnLeft,
|
|
119
|
-
plural: null,
|
|
120
|
-
},
|
|
121
|
-
add_column_right: {
|
|
122
|
-
message: messages.addColumnRight,
|
|
123
|
-
plural: null,
|
|
124
|
-
},
|
|
125
|
-
distribute_columns: {
|
|
126
|
-
message: messages.distributeColumns,
|
|
127
|
-
plural: 'noOfCols',
|
|
128
|
-
},
|
|
129
|
-
clear_cells: {
|
|
130
|
-
message: messages.clearCells,
|
|
131
|
-
plural: 'noOfCells',
|
|
132
|
-
},
|
|
133
|
-
delete_row: {
|
|
134
|
-
message: messages.removeRows,
|
|
135
|
-
plural: 'noOfRows',
|
|
136
|
-
},
|
|
137
|
-
delete_column: {
|
|
138
|
-
message: messages.removeColumns,
|
|
139
|
-
plural: 'noOfCols',
|
|
140
|
-
},
|
|
141
|
-
move_column_left: {
|
|
142
|
-
message: messages.moveColumnLeft,
|
|
143
|
-
plural: 'noOfCols',
|
|
144
|
-
},
|
|
145
|
-
move_column_right: {
|
|
146
|
-
message: messages.moveColumnRight,
|
|
147
|
-
plural: 'noOfCols',
|
|
148
|
-
},
|
|
149
|
-
move_row_up: {
|
|
150
|
-
message: messages.moveRowUp,
|
|
151
|
-
plural: 'noOfRows',
|
|
152
|
-
},
|
|
153
|
-
move_row_down: {
|
|
154
|
-
message: messages.moveRowDown,
|
|
155
|
-
plural: 'noOfRows',
|
|
156
|
-
},
|
|
157
|
-
sort_column_asc: {
|
|
158
|
-
message: messages.sortColumnIncreasing,
|
|
159
|
-
plural: null,
|
|
160
|
-
},
|
|
161
|
-
sort_column_desc: {
|
|
162
|
-
message: messages.sortColumnDecreasing,
|
|
163
|
-
plural: null,
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const getGroupedDragMenuConfig = () => {
|
|
168
|
-
const groupedDragMenuConfig: DragMenuOptionIdType[][] = [
|
|
169
|
-
[
|
|
170
|
-
'add_row_above',
|
|
171
|
-
'add_row_below',
|
|
172
|
-
'add_column_left',
|
|
173
|
-
'add_column_right',
|
|
174
|
-
'distribute_columns',
|
|
175
|
-
'clear_cells',
|
|
176
|
-
'delete_row',
|
|
177
|
-
'delete_column',
|
|
178
|
-
],
|
|
179
|
-
['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down'],
|
|
180
|
-
];
|
|
181
|
-
const sortColumnItems: DragMenuOptionIdType[] = ['sort_column_asc', 'sort_column_desc'];
|
|
182
|
-
groupedDragMenuConfig.unshift(sortColumnItems);
|
|
183
|
-
|
|
184
|
-
return groupedDragMenuConfig;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const elementBeforeIconStyles = xcss({
|
|
188
|
-
marginRight: 'space.negative.075',
|
|
189
|
-
display: 'flex',
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
const convertToDropdownItems = (
|
|
193
|
-
dragMenuConfig: DragMenuConfig[],
|
|
194
|
-
formatMessage: IntlShape['formatMessage'],
|
|
195
|
-
selectionRect?: Rect,
|
|
196
|
-
) => {
|
|
197
|
-
const groupedDragMenuConfig = getGroupedDragMenuConfig();
|
|
198
|
-
const menuItemsArr: MenuItem[][] = [...Array(groupedDragMenuConfig.length)].map(() => []);
|
|
199
|
-
const menuCallback: { [key: string]: Command } = {};
|
|
200
|
-
dragMenuConfig.forEach((item) => {
|
|
201
|
-
const menuGroupIndex = groupedDragMenuConfig.findIndex((group) => group.includes(item.id));
|
|
202
|
-
|
|
203
|
-
if (menuGroupIndex === -1) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const isPlural = Boolean(MapDragMenuOptionIdToMessage[item.id]?.plural);
|
|
208
|
-
let plural = 0;
|
|
209
|
-
|
|
210
|
-
if (isPlural && selectionRect) {
|
|
211
|
-
const { top, bottom, right, left } = selectionRect;
|
|
212
|
-
switch (MapDragMenuOptionIdToMessage[item.id].plural as PluralOptionType) {
|
|
213
|
-
case 'noOfCols': {
|
|
214
|
-
plural = right - left;
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
case 'noOfRows': {
|
|
218
|
-
plural = bottom - top;
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
case 'noOfCells': {
|
|
222
|
-
plural = Math.max(right - left, bottom - top);
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const options = isPlural ? { 0: plural } : undefined;
|
|
229
|
-
|
|
230
|
-
menuItemsArr[menuGroupIndex].push({
|
|
231
|
-
key: item.id,
|
|
232
|
-
content: formatMessage(MapDragMenuOptionIdToMessage[item.id].message, options),
|
|
233
|
-
value: { name: item.id },
|
|
234
|
-
isDisabled: item.disabled,
|
|
235
|
-
elemBefore: item.icon ? (
|
|
236
|
-
<Box xcss={elementBeforeIconStyles}>
|
|
237
|
-
<item.icon
|
|
238
|
-
color="currentColor"
|
|
239
|
-
spacing="spacious"
|
|
240
|
-
label={formatMessage(MapDragMenuOptionIdToMessage[item.id].message, options)}
|
|
241
|
-
LEGACY_fallbackIcon={item.iconFallback ? item.iconFallback : undefined}
|
|
242
|
-
/>
|
|
243
|
-
</Box>
|
|
244
|
-
) : undefined,
|
|
245
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
246
|
-
elemAfter: item.keymap ? <div css={shortcutStyle}>{item.keymap}</div> : undefined,
|
|
247
|
-
});
|
|
248
|
-
item.onClick && (menuCallback[item.id] = item.onClick);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
const menuItems = menuItemsArr.reduce(
|
|
252
|
-
(acc, curr) => {
|
|
253
|
-
curr?.length > 0 && acc.push({ items: curr });
|
|
254
|
-
return acc;
|
|
255
|
-
},
|
|
256
|
-
[] as { items: MenuItem[] }[],
|
|
257
|
-
);
|
|
258
|
-
return { menuItems, menuCallback };
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
const DragMenu = React.memo(
|
|
262
|
-
({
|
|
263
|
-
direction = 'row',
|
|
264
|
-
index,
|
|
265
|
-
target,
|
|
266
|
-
isOpen,
|
|
267
|
-
editorView,
|
|
268
|
-
tableNode,
|
|
269
|
-
targetCellPosition,
|
|
270
|
-
getEditorContainerWidth,
|
|
271
|
-
api,
|
|
272
|
-
editorAnalyticsAPI,
|
|
273
|
-
pluginConfig,
|
|
274
|
-
intl: { formatMessage },
|
|
275
|
-
fitHeight,
|
|
276
|
-
fitWidth,
|
|
277
|
-
mountPoint,
|
|
278
|
-
scrollableElement,
|
|
279
|
-
boundariesElement,
|
|
280
|
-
isTableScalingEnabled,
|
|
281
|
-
shouldUseIncreasedScalingPercent,
|
|
282
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
283
|
-
ariaNotifyPlugin,
|
|
284
|
-
isCommentEditor,
|
|
285
|
-
}: DragMenuProps & WrappedComponentProps) => {
|
|
286
|
-
const { state, dispatch } = editorView;
|
|
287
|
-
const { selection } = state;
|
|
288
|
-
const tableMap = tableNode ? TableMap.get(tableNode) : undefined;
|
|
289
|
-
const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);
|
|
290
|
-
const { isKeyboardModeActive } = getPluginState(state);
|
|
291
|
-
|
|
292
|
-
const selectionRect = isSelectionType(selection, 'cell')
|
|
293
|
-
? // Ignored via go/ees005
|
|
294
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
295
|
-
getSelectionRect(selection)!
|
|
296
|
-
: findCellRectClosestToPos(selection.$from);
|
|
297
|
-
|
|
298
|
-
const hasMergedCellsInTable = tableMap?.hasMergedCells() ?? false;
|
|
299
|
-
const allowBackgroundColor = pluginConfig?.allowBackgroundColor ?? false;
|
|
300
|
-
|
|
301
|
-
const dragMenuConfig = getDragMenuConfig(
|
|
302
|
-
direction,
|
|
303
|
-
getEditorContainerWidth,
|
|
304
|
-
hasMergedCellsInTable,
|
|
305
|
-
editorView,
|
|
306
|
-
api,
|
|
307
|
-
tableMap,
|
|
308
|
-
index,
|
|
309
|
-
targetCellPosition,
|
|
310
|
-
selectionRect,
|
|
311
|
-
editorAnalyticsAPI,
|
|
312
|
-
pluginConfig?.isHeaderRowRequired,
|
|
313
|
-
isTableScalingEnabled,
|
|
314
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
315
|
-
shouldUseIncreasedScalingPercent,
|
|
316
|
-
ariaNotifyPlugin,
|
|
317
|
-
isCommentEditor,
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
const { menuItems, menuCallback } = convertToDropdownItems(
|
|
321
|
-
dragMenuConfig,
|
|
322
|
-
formatMessage,
|
|
323
|
-
selectionRect,
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
const handleSubMenuRef = (ref: HTMLDivElement | null) => {
|
|
327
|
-
const parent = closestElement(
|
|
328
|
-
// Ignored via go/ees005
|
|
329
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
330
|
-
editorView.dom as HTMLElement,
|
|
331
|
-
'.fabric-editor-popup-scroll-parent',
|
|
332
|
-
);
|
|
333
|
-
if (!(parent && ref)) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
const boundariesRect = parent.getBoundingClientRect();
|
|
337
|
-
const rect = ref.getBoundingClientRect();
|
|
338
|
-
if (rect.left + rect.width > boundariesRect.width) {
|
|
339
|
-
ref.style.left = `-${rect.width}px`;
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
const setColor = (color: string) => {
|
|
344
|
-
const { state, dispatch } = editorView;
|
|
345
|
-
setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color)(state, dispatch);
|
|
346
|
-
closeMenu();
|
|
347
|
-
setIsSubmenuOpen(false);
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const createBackgroundColorMenuItem = () => {
|
|
351
|
-
const { targetCellPosition } = getTablePluginState(editorView.state);
|
|
352
|
-
const node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
353
|
-
const background = hexToEditorBackgroundPaletteColor(node?.attrs?.background || '#ffffff');
|
|
354
|
-
|
|
355
|
-
const { selectedRowIndex, selectedColumnIndex } = getSelectedRowAndColumnFromPalette(
|
|
356
|
-
cellBackgroundColorPalette,
|
|
357
|
-
background,
|
|
358
|
-
colorPalletteColumns,
|
|
359
|
-
);
|
|
360
|
-
|
|
361
|
-
return {
|
|
362
|
-
key: 'background',
|
|
363
|
-
content: formatMessage(messages.backgroundColor),
|
|
364
|
-
value: { name: 'background' },
|
|
365
|
-
elemBefore: (
|
|
366
|
-
<Box xcss={elementBeforeIconStyles}>
|
|
367
|
-
<PaintBucketIcon
|
|
368
|
-
color="currentColor"
|
|
369
|
-
spacing="spacious"
|
|
370
|
-
label={formatMessage(messages.backgroundColor)}
|
|
371
|
-
/>
|
|
372
|
-
</Box>
|
|
373
|
-
),
|
|
374
|
-
elemAfter: (
|
|
375
|
-
<div
|
|
376
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
377
|
-
className={DropdownMenuSharedCssClassName.SUBMENU}
|
|
378
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
379
|
-
css={dragMenuBackgroundColorStyles()}
|
|
380
|
-
>
|
|
381
|
-
<div
|
|
382
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
383
|
-
css={cellColourPreviewStyles(background)}
|
|
384
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
385
|
-
className={ClassName.DRAG_SUBMENU_ICON}
|
|
386
|
-
/>
|
|
387
|
-
{isSubmenuOpen && (
|
|
388
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
389
|
-
<div className={ClassName.DRAG_SUBMENU} ref={handleSubMenuRef}>
|
|
390
|
-
<ArrowKeyNavigationProvider
|
|
391
|
-
type={ArrowKeyNavigationType.COLOR}
|
|
392
|
-
selectedRowIndex={selectedRowIndex}
|
|
393
|
-
selectedColumnIndex={selectedColumnIndex}
|
|
394
|
-
handleClose={() => {
|
|
395
|
-
const keyboardEvent = new KeyboardEvent('keydown', {
|
|
396
|
-
key: 'ArrowDown',
|
|
397
|
-
bubbles: true,
|
|
398
|
-
});
|
|
399
|
-
setIsSubmenuOpen(false);
|
|
400
|
-
// Ignored via go/ees005
|
|
401
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
402
|
-
(target as HTMLElement)?.focus();
|
|
403
|
-
target?.dispatchEvent(keyboardEvent);
|
|
404
|
-
}}
|
|
405
|
-
isPopupPositioned={true}
|
|
406
|
-
isOpenedByKeyboard={isKeyboardModeActive}
|
|
407
|
-
>
|
|
408
|
-
<ColorPalette
|
|
409
|
-
cols={colorPalletteColumns}
|
|
410
|
-
onClick={(color) => {
|
|
411
|
-
setColor(color);
|
|
412
|
-
}}
|
|
413
|
-
selectedColor={background}
|
|
414
|
-
paletteOptions={{
|
|
415
|
-
palette: cellBackgroundColorPalette,
|
|
416
|
-
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
417
|
-
hexToPaletteColor: hexToEditorBackgroundPaletteColor,
|
|
418
|
-
}}
|
|
419
|
-
/>
|
|
420
|
-
</ArrowKeyNavigationProvider>
|
|
421
|
-
</div>
|
|
422
|
-
)}
|
|
423
|
-
</div>
|
|
424
|
-
),
|
|
425
|
-
} as MenuItem;
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
const toggleHeaderColumn = () => {
|
|
429
|
-
toggleHeaderColumnWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
const toggleHeaderRow = () => {
|
|
433
|
-
toggleHeaderRowWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
const toggleRowNumbers = () => {
|
|
437
|
-
toggleNumberColumnWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
const createHeaderRowColumnMenuItem = (direction: TableDirection) => {
|
|
441
|
-
return direction === 'column'
|
|
442
|
-
? ({
|
|
443
|
-
key: 'header_column',
|
|
444
|
-
content: formatMessage(messages.headerColumn),
|
|
445
|
-
value: { name: 'header_column' },
|
|
446
|
-
elemAfter: (
|
|
447
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
448
|
-
<div css={toggleStyles}>
|
|
449
|
-
<Toggle
|
|
450
|
-
id="toggle-header-column"
|
|
451
|
-
label={
|
|
452
|
-
expValEquals(
|
|
453
|
-
'platform_editor_enghealth_table_plugin_lable_rule',
|
|
454
|
-
'isEnabled',
|
|
455
|
-
true,
|
|
456
|
-
)
|
|
457
|
-
? formatMessage(messages.headerColumn)
|
|
458
|
-
: undefined
|
|
459
|
-
}
|
|
460
|
-
onChange={toggleHeaderColumn}
|
|
461
|
-
isChecked={checkIfHeaderColumnEnabled(selection)}
|
|
462
|
-
/>
|
|
463
|
-
</div>
|
|
464
|
-
),
|
|
465
|
-
} as MenuItem)
|
|
466
|
-
: ({
|
|
467
|
-
key: 'header_row',
|
|
468
|
-
content: formatMessage(messages.headerRow),
|
|
469
|
-
value: { name: 'header_row' },
|
|
470
|
-
elemAfter: (
|
|
471
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
472
|
-
<div css={toggleStyles}>
|
|
473
|
-
<Toggle
|
|
474
|
-
id="toggle-header-row"
|
|
475
|
-
label={
|
|
476
|
-
expValEquals(
|
|
477
|
-
'platform_editor_enghealth_table_plugin_lable_rule',
|
|
478
|
-
'isEnabled',
|
|
479
|
-
true,
|
|
480
|
-
)
|
|
481
|
-
? formatMessage(messages.headerRow)
|
|
482
|
-
: undefined
|
|
483
|
-
}
|
|
484
|
-
onChange={toggleHeaderRow}
|
|
485
|
-
isChecked={checkIfHeaderRowEnabled(selection)}
|
|
486
|
-
/>
|
|
487
|
-
</div>
|
|
488
|
-
),
|
|
489
|
-
} as MenuItem);
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
const createRowNumbersMenuItem = () => {
|
|
493
|
-
return {
|
|
494
|
-
key: 'row_numbers',
|
|
495
|
-
content: formatMessage(messages.rowNumbers),
|
|
496
|
-
value: { name: 'row_numbers' },
|
|
497
|
-
elemAfter: (
|
|
498
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
499
|
-
<div css={toggleStyles}>
|
|
500
|
-
<Toggle
|
|
501
|
-
id="toggle-row-numbers"
|
|
502
|
-
label={
|
|
503
|
-
expValEquals('platform_editor_enghealth_table_plugin_lable_rule', 'isEnabled', true)
|
|
504
|
-
? formatMessage(messages.numberedColumn)
|
|
505
|
-
: undefined
|
|
506
|
-
}
|
|
507
|
-
onChange={toggleRowNumbers}
|
|
508
|
-
isChecked={checkIfNumberColumnEnabled(selection)}
|
|
509
|
-
/>
|
|
510
|
-
</div>
|
|
511
|
-
),
|
|
512
|
-
} as MenuItem;
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* This function is to check if the menu should be closed or not.
|
|
517
|
-
* As when continously clicking on tyle handle on different rows/columns,
|
|
518
|
-
* should open the menu corresponding to the position of the drag handle.
|
|
519
|
-
* @returns true when the menu should be closed, false otherwise
|
|
520
|
-
*/
|
|
521
|
-
const shouldCloseMenu = (state: EditorState) => {
|
|
522
|
-
const {
|
|
523
|
-
isDragMenuOpen: previousOpenState,
|
|
524
|
-
dragMenuDirection: previousDragMenuDirection,
|
|
525
|
-
dragMenuIndex: previousDragMenuIndex,
|
|
526
|
-
} = getPluginState(state);
|
|
527
|
-
|
|
528
|
-
// menu open but menu direction changed, means user clicked on drag handle of different row/column
|
|
529
|
-
// menu open menu direction not changed, but index changed, means user clicked on drag handle of same row/column, different cells.
|
|
530
|
-
// 2 scenarios above , menu should not be closed.
|
|
531
|
-
if (
|
|
532
|
-
(previousOpenState === true && previousDragMenuDirection !== direction) ||
|
|
533
|
-
(previousOpenState === true &&
|
|
534
|
-
previousDragMenuDirection === direction &&
|
|
535
|
-
previousDragMenuIndex !== index)
|
|
536
|
-
) {
|
|
537
|
-
return false;
|
|
538
|
-
} else {
|
|
539
|
-
return true;
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
const closeMenu = (focusTarget: 'editor' | 'handle' = 'handle') => {
|
|
544
|
-
const { state, dispatch } = editorView;
|
|
545
|
-
if (shouldCloseMenu(state)) {
|
|
546
|
-
if (target && focusTarget === 'handle') {
|
|
547
|
-
(target as HTMLElement | null)?.focus();
|
|
548
|
-
} else {
|
|
549
|
-
editorView.dom.focus();
|
|
550
|
-
}
|
|
551
|
-
toggleDragMenu(false, direction, index)(state, dispatch);
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
const handleMenuItemActivated = ({ item }: { item: MenuItem }) => {
|
|
556
|
-
menuCallback[item.value.name]?.(state, dispatch);
|
|
557
|
-
|
|
558
|
-
switch (item.value.name) {
|
|
559
|
-
case 'background':
|
|
560
|
-
setIsSubmenuOpen(!isSubmenuOpen);
|
|
561
|
-
break;
|
|
562
|
-
case 'header_column':
|
|
563
|
-
toggleHeaderColumn();
|
|
564
|
-
break;
|
|
565
|
-
case 'header_row':
|
|
566
|
-
toggleHeaderRow();
|
|
567
|
-
break;
|
|
568
|
-
case 'row_numbers':
|
|
569
|
-
toggleRowNumbers();
|
|
570
|
-
break;
|
|
571
|
-
default:
|
|
572
|
-
break;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if (
|
|
576
|
-
['header_column', 'header_row', 'row_numbers', 'background'].indexOf(item.value.name) <= -1
|
|
577
|
-
) {
|
|
578
|
-
closeMenu('editor');
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
const handleItemMouseEnter = ({ item }: { item: MenuItem }) => {
|
|
583
|
-
if (!selectionRect) {
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
if (item.value.name === 'background' && !isSubmenuOpen) {
|
|
588
|
-
setIsSubmenuOpen(true);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
if (!item.value.name?.startsWith('delete')) {
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
(item.value.name === 'delete_column'
|
|
596
|
-
? hoverColumns(getSelectedColumnIndexes(selectionRect), true)
|
|
597
|
-
: hoverRows(getSelectedRowIndexes(selectionRect), true))(state, dispatch);
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
// Ignored via go/ees005
|
|
601
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
602
|
-
const handleItemMouseLeave = ({ item }: { item: any }) => {
|
|
603
|
-
if (item.value.name === 'background' && isSubmenuOpen) {
|
|
604
|
-
setIsSubmenuOpen(false);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
if (
|
|
608
|
-
['sort_column_asc', 'sort_column_desc', 'delete_column', 'delete_row'].indexOf(
|
|
609
|
-
item.value.name,
|
|
610
|
-
) > -1
|
|
611
|
-
) {
|
|
612
|
-
clearHoverSelection()(state, dispatch);
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
useEffect(() => {
|
|
617
|
-
// focus on first menu item automatically when menu renders
|
|
618
|
-
// and user is using keyboard
|
|
619
|
-
if (isOpen && target && isKeyboardModeActive) {
|
|
620
|
-
const keyboardEvent = new KeyboardEvent('keydown', {
|
|
621
|
-
key: 'ArrowDown',
|
|
622
|
-
bubbles: true,
|
|
623
|
-
});
|
|
624
|
-
target.dispatchEvent(keyboardEvent);
|
|
625
|
-
}
|
|
626
|
-
}, [isOpen, target, isKeyboardModeActive]);
|
|
627
|
-
|
|
628
|
-
if (!menuItems) {
|
|
629
|
-
return null;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
if (allowBackgroundColor) {
|
|
633
|
-
menuItems[1].items.unshift(createBackgroundColorMenuItem());
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// If first row, add toggle for Header row, default is true
|
|
637
|
-
// If first column, add toggle for Header column, default is false
|
|
638
|
-
if (index === 0) {
|
|
639
|
-
menuItems.push({ items: [createHeaderRowColumnMenuItem(direction)] });
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// All rows, add toggle for numbered rows, default is false
|
|
643
|
-
if (direction === 'row') {
|
|
644
|
-
index === 0
|
|
645
|
-
? menuItems[menuItems.length - 1].items.push(createRowNumbersMenuItem())
|
|
646
|
-
: menuItems.push({ items: [createRowNumbersMenuItem()] });
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
return (
|
|
650
|
-
<DropdownMenu
|
|
651
|
-
disableKeyboardHandling={isSubmenuOpen}
|
|
652
|
-
section={{ hasSeparator: true }}
|
|
653
|
-
items={menuItems}
|
|
654
|
-
onItemActivated={handleMenuItemActivated}
|
|
655
|
-
onMouseEnter={handleItemMouseEnter}
|
|
656
|
-
onMouseLeave={handleItemMouseLeave}
|
|
657
|
-
handleClose={closeMenu}
|
|
658
|
-
fitHeight={fitHeight}
|
|
659
|
-
fitWidth={fitWidth}
|
|
660
|
-
direction={direction}
|
|
661
|
-
boundariesElement={boundariesElement}
|
|
662
|
-
scrollableElement={scrollableElement}
|
|
663
|
-
/>
|
|
664
|
-
);
|
|
665
|
-
},
|
|
666
|
-
);
|
|
667
|
-
|
|
668
|
-
export default injectIntl(DragMenu);
|