@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,491 +0,0 @@
1
- import React from 'react';
2
-
3
- import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
4
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
6
- import {
7
- addColumnAfter,
8
- addColumnBefore,
9
- addRowAfter,
10
- addRowBefore,
11
- backspace,
12
- deleteColumn,
13
- deleteRow,
14
- moveColumnLeft,
15
- moveColumnRight,
16
- moveRowDown,
17
- moveRowUp,
18
- tooltip,
19
- } from '@atlaskit/editor-common/keymaps';
20
- import type {
21
- Command,
22
- CommandDispatch,
23
- DropdownOptionT,
24
- GetEditorContainerWidth,
25
- } from '@atlaskit/editor-common/types';
26
- import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
27
- import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
28
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
29
- import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
30
- import SortAscendingIcon from '@atlaskit/icon/core/sort-ascending';
31
- import SortDescendingIcon from '@atlaskit/icon/core/sort-descending';
32
- import TableCellClearIcon from '@atlaskit/icon/core/table-cell-clear';
33
- import TableColumnAddLeftIcon from '@atlaskit/icon/core/table-column-add-left';
34
- import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right';
35
- import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
36
- import TableColumnMoveLeftIcon from '@atlaskit/icon/core/table-column-move-left';
37
- import TableColumnMoveRightIcon from '@atlaskit/icon/core/table-column-move-right';
38
- import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
39
- import TableRowAddAboveIcon from '@atlaskit/icon/core/table-row-add-above';
40
- import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
41
- import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
42
- import TableRowMoveDownIcon from '@atlaskit/icon/core/table-row-move-down';
43
- import TableRowMoveUpIcon from '@atlaskit/icon/core/table-row-move-up';
44
- import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
45
- import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
46
- import ArrowRightIcon from '@atlaskit/icon/glyph/arrow-right';
47
- import ArrowUpIcon from '@atlaskit/icon/glyph/arrow-up';
48
- import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
49
- import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
50
- import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
51
- import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
52
- import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
53
- import type { NewIconProps } from '@atlaskit/icon/types';
54
-
55
- import type { DraggableData, DraggableType, PluginInjectionAPI, TableDirection } from '../../types';
56
- import { AddColLeftIcon } from '../../ui/icons/AddColLeftIcon';
57
- import { AddColRightIcon } from '../../ui/icons/AddColRightIcon';
58
- import { AddRowAboveIcon } from '../../ui/icons/AddRowAboveIcon';
59
- import { AddRowBelowIcon } from '../../ui/icons/AddRowBelowIcon';
60
- import { getClosestSelectionRect } from '../../ui/toolbar';
61
- import {
62
- deleteColumnsWithAnalytics,
63
- deleteRowsWithAnalytics,
64
- distributeColumnsWidthsWithAnalytics,
65
- emptyMultipleCellsWithAnalytics,
66
- insertColumnWithAnalytics,
67
- insertRowWithAnalytics,
68
- sortColumnWithAnalytics,
69
- } from '../commands/commands-with-analytics';
70
- import { moveSourceWithAnalytics } from '../drag-and-drop/commands-with-analytics';
71
- import { getPluginState as getTablePluginState } from '../plugin-factory';
72
- import { getNewResizeStateFromSelectedColumns } from '../table-resizing/utils/resize-state';
73
-
74
- import {
75
- hasMergedCellsInSelection,
76
- hasMergedCellsWithColumnNextToColumnIndex,
77
- hasMergedCellsWithRowNextToRowIndex,
78
- } from './merged-cells';
79
- import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
80
-
81
- export const getTargetIndex = (selectedIndexes: number[], direction: DraggableData['direction']) =>
82
- Math[direction < 0 ? 'min' : 'max'](...selectedIndexes) + direction;
83
-
84
- export const canMove = (
85
- sourceType: DraggableType,
86
- direction: DraggableData['direction'],
87
- totalItemsOfSourceTypeCount: number,
88
- selection: Selection,
89
- selectionRect?: Rect,
90
- ) => {
91
- if (!selectionRect) {
92
- return false;
93
- }
94
-
95
- const isRow = sourceType === 'table-row';
96
- const selectedIndexes = isRow
97
- ? getSelectedRowIndexes(selectionRect)
98
- : getSelectedColumnIndexes(selectionRect);
99
- const targetIndex = getTargetIndex(selectedIndexes, direction);
100
-
101
- const isValidTargetIndex = targetIndex >= 0 && targetIndex < totalItemsOfSourceTypeCount;
102
- if (!isValidTargetIndex) {
103
- return false;
104
- }
105
-
106
- // We can't move column when target has merged cells with other columns
107
- // We can't move row when target has merged cells with other rows
108
- const hasMergedCellsInTarget = isRow
109
- ? hasMergedCellsWithRowNextToRowIndex(targetIndex, selection)
110
- : hasMergedCellsWithColumnNextToColumnIndex(targetIndex, selection);
111
- if (hasMergedCellsInTarget) {
112
- return false;
113
- }
114
-
115
- // We can't move if selection in the source is not a rectangle
116
- if (hasMergedCellsInSelection(selectedIndexes, isRow ? 'row' : 'column')(selection)) {
117
- return false;
118
- }
119
-
120
- return true;
121
- };
122
-
123
- const isDistributeColumnsEnabled = (state: EditorState) => {
124
- const rect = getClosestSelectionRect(state);
125
- if (rect) {
126
- const selectedColIndexes = getSelectedColumnIndexes(rect);
127
- return selectedColIndexes.length > 1;
128
- }
129
- return false;
130
- };
131
-
132
- export type DragMenuOptionIdType =
133
- | 'add_row_above'
134
- | 'add_row_below'
135
- | 'add_column_left'
136
- | 'add_column_right'
137
- | 'distribute_columns'
138
- | 'clear_cells'
139
- | 'delete_row'
140
- | 'delete_column'
141
- | 'move_column_left'
142
- | 'move_column_right'
143
- | 'move_row_up'
144
- | 'move_row_down'
145
- | 'sort_column_asc'
146
- | 'sort_column_desc';
147
-
148
- export interface DragMenuConfig extends Omit<DropdownOptionT<Command>, 'icon'> {
149
- id: DragMenuOptionIdType;
150
- icon?: React.ComponentType<React.PropsWithChildren<NewIconProps>>;
151
- iconFallback?: React.ComponentType<React.PropsWithChildren<NewIconProps>>;
152
- keymap?: string;
153
- }
154
-
155
- const defaultSelectionRect = { left: 0, top: 0, right: 0, bottom: 0 };
156
-
157
- export const getDragMenuConfig = (
158
- direction: TableDirection,
159
- getEditorContainerWidth: GetEditorContainerWidth,
160
- hasMergedCellsInTable: boolean,
161
- editorView: EditorView,
162
- api: PluginInjectionAPI | undefined | null,
163
- tableMap?: TableMap,
164
- index?: number,
165
- targetCellPosition?: number,
166
- selectionRect?: Rect,
167
- editorAnalyticsAPI?: EditorAnalyticsAPI,
168
- isHeaderRowRequired?: boolean,
169
- isTableScalingEnabled = false,
170
- isTableFixedColumnWidthsOptionEnabled = false,
171
- shouldUseIncreasedScalingPercent = false,
172
- ariaNotifyPlugin?: (
173
- message: string,
174
- ariaLiveElementAttributes?: AriaLiveElementAttributes,
175
- ) => void,
176
- isCommentEditor = false,
177
- ): DragMenuConfig[] => {
178
- const { selection } = editorView.state;
179
- const { getIntl } = getTablePluginState(editorView.state);
180
- const addOptions =
181
- direction === 'row'
182
- ? [
183
- {
184
- label: 'above',
185
- offset: 0,
186
- icon: () => (
187
- <TableRowAddAboveIcon
188
- LEGACY_fallbackIcon={AddRowAboveIcon}
189
- spacing={'spacious'}
190
- label={''}
191
- />
192
- ),
193
- keymap: addRowBefore,
194
- },
195
- {
196
- label: 'below',
197
- offset: 1,
198
- icon: () => (
199
- <TableRowAddBelowIcon
200
- LEGACY_fallbackIcon={AddRowBelowIcon}
201
- spacing={'spacious'}
202
- label={''}
203
- />
204
- ),
205
- keymap: addRowAfter,
206
- },
207
- ]
208
- : [
209
- {
210
- label: 'left',
211
- offset: 0,
212
- icon: () => (
213
- <TableColumnAddLeftIcon
214
- LEGACY_fallbackIcon={AddColLeftIcon}
215
- spacing={'spacious'}
216
- label={''}
217
- />
218
- ),
219
- keymap: addColumnBefore,
220
- },
221
- {
222
- label: 'right',
223
- offset: 1,
224
- icon: () => (
225
- <TableColumnAddRightIcon
226
- LEGACY_fallbackIcon={AddColRightIcon}
227
- spacing={'spacious'}
228
- label={''}
229
- />
230
- ),
231
- keymap: addColumnAfter,
232
- },
233
- ];
234
- const moveOptions =
235
- direction === 'row'
236
- ? [
237
- {
238
- label: 'up',
239
- icon: () => (
240
- <TableRowMoveUpIcon
241
- LEGACY_fallbackIcon={ArrowUpIcon}
242
- spacing={'spacious'}
243
- label={''}
244
- />
245
- ),
246
- keymap: moveRowUp,
247
- canMove: canMove('table-row', -1, tableMap?.height ?? 0, selection, selectionRect),
248
- getOriginIndexes: getSelectedRowIndexes,
249
- getTargetIndex: (selectionRect: Rect) => selectionRect.top - 1,
250
- },
251
- {
252
- label: 'down',
253
- icon: () => (
254
- <TableRowMoveDownIcon
255
- LEGACY_fallbackIcon={ArrowDownIcon}
256
- spacing={'spacious'}
257
- label={''}
258
- />
259
- ),
260
- keymap: moveRowDown,
261
- canMove: canMove('table-row', 1, tableMap?.height ?? 0, selection, selectionRect),
262
- getOriginIndexes: getSelectedRowIndexes,
263
- getTargetIndex: (selectionRect: Rect) => selectionRect.bottom,
264
- },
265
- ]
266
- : [
267
- {
268
- label: 'left',
269
- icon: () => (
270
- <TableColumnMoveLeftIcon
271
- LEGACY_fallbackIcon={ArrowLeftIcon}
272
- spacing={'spacious'}
273
- label={''}
274
- />
275
- ),
276
- keymap: moveColumnLeft,
277
- canMove: canMove('table-column', -1, tableMap?.width ?? 0, selection, selectionRect),
278
- getOriginIndexes: getSelectedColumnIndexes,
279
- getTargetIndex: (selectionRect: Rect) => selectionRect.left - 1,
280
- },
281
- {
282
- label: 'right',
283
- icon: () => (
284
- <TableColumnMoveRightIcon
285
- LEGACY_fallbackIcon={ArrowRightIcon}
286
- spacing={'spacious'}
287
- label={''}
288
- />
289
- ),
290
- keymap: moveColumnRight,
291
- canMove: canMove('table-column', 1, tableMap?.width ?? 0, selection, selectionRect),
292
- getOriginIndexes: getSelectedColumnIndexes,
293
- getTargetIndex: (selectionRect: Rect) => selectionRect.right,
294
- },
295
- ];
296
- const sortOptions =
297
- direction === 'column'
298
- ? [
299
- {
300
- label: 'increasing',
301
- order: SortOrder.ASC,
302
- icon: () => (
303
- <SortAscendingIcon
304
- LEGACY_fallbackIcon={HipchatChevronDoubleUpIcon}
305
- spacing={'spacious'}
306
- label={''}
307
- />
308
- ),
309
- },
310
- {
311
- label: 'decreasing',
312
- order: SortOrder.DESC,
313
- icon: () => (
314
- <SortDescendingIcon
315
- LEGACY_fallbackIcon={HipchatChevronDoubleDownIcon}
316
- spacing={'spacious'}
317
- label={''}
318
- />
319
- ),
320
- },
321
- ]
322
- : [];
323
- const sortConfigs = [
324
- ...sortOptions.map(({ label, order, icon }) => ({
325
- id: `sort_column_${order}`,
326
- title: `Sort ${label}`,
327
- disabled: hasMergedCellsInTable,
328
- icon: icon,
329
- onClick: (state: EditorState, dispatch?: CommandDispatch) => {
330
- sortColumnWithAnalytics(editorAnalyticsAPI)(
331
- INPUT_METHOD.TABLE_CONTEXT_MENU,
332
- index ?? 0,
333
- order,
334
- )(state, dispatch);
335
- return true;
336
- },
337
- })),
338
- ];
339
- const restConfigs = [
340
- ...addOptions.map(({ label, offset, icon, keymap }) => ({
341
- id: `add_${direction}_${label}`,
342
- title: `Add ${direction} ${label}`,
343
- icon: icon,
344
- onClick: (state: EditorState, dispatch?: CommandDispatch) => {
345
- if (direction === 'row') {
346
- insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
347
- index: (index ?? 0) + offset,
348
- moveCursorToInsertedRow: true,
349
- })(state, dispatch);
350
- } else {
351
- insertColumnWithAnalytics(
352
- api,
353
- editorAnalyticsAPI,
354
- isTableScalingEnabled,
355
- isTableFixedColumnWidthsOptionEnabled,
356
- shouldUseIncreasedScalingPercent,
357
- )(INPUT_METHOD.TABLE_CONTEXT_MENU, (index ?? 0) + offset)(state, dispatch, editorView);
358
- }
359
- return true;
360
- },
361
- keymap: keymap && tooltip(keymap),
362
- })),
363
- direction === 'column'
364
- ? {
365
- id: 'distribute_columns',
366
- title: 'Distribute columns',
367
- disabled: !isDistributeColumnsEnabled(editorView.state),
368
- onClick: (state: EditorState, dispatch?: CommandDispatch) => {
369
- const selectionRect = getClosestSelectionRect(state);
370
- if (selectionRect) {
371
- const newResizeState = getNewResizeStateFromSelectedColumns(
372
- selectionRect,
373
- state,
374
- editorView.domAtPos.bind(editorView),
375
- getEditorContainerWidth,
376
- isTableScalingEnabled,
377
- isTableFixedColumnWidthsOptionEnabled,
378
- isCommentEditor,
379
- );
380
-
381
- if (newResizeState) {
382
- distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI, api)(
383
- INPUT_METHOD.TABLE_CONTEXT_MENU,
384
- newResizeState,
385
- )(state, dispatch);
386
- return true;
387
- }
388
- return false;
389
- }
390
- return false;
391
- },
392
- icon: () => (
393
- <TableColumnsDistributeIcon
394
- LEGACY_fallbackIcon={EditorLayoutThreeEqualIcon}
395
- spacing={'spacious'}
396
- label={''}
397
- />
398
- ),
399
- }
400
- : undefined,
401
- {
402
- id: 'clear_cells',
403
- title: 'Clear cells',
404
- onClick: (state: EditorState, dispatch?: CommandDispatch) => {
405
- emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(
406
- INPUT_METHOD.TABLE_CONTEXT_MENU,
407
- targetCellPosition,
408
- )(state, dispatch);
409
- return true;
410
- },
411
- icon: () => (
412
- <TableCellClearIcon LEGACY_fallbackIcon={CrossCircleIcon} spacing={'spacious'} label={''} />
413
- ),
414
- keymap: tooltip(backspace),
415
- },
416
- {
417
- id: `delete_${direction}`,
418
- title: `Delete ${direction}`,
419
- onClick: (state: EditorState, dispatch?: CommandDispatch) => {
420
- if (direction === 'row') {
421
- deleteRowsWithAnalytics(editorAnalyticsAPI)(
422
- INPUT_METHOD.TABLE_CONTEXT_MENU,
423
- selectionRect ?? defaultSelectionRect,
424
- !!isHeaderRowRequired,
425
- )(state, dispatch);
426
- } else {
427
- deleteColumnsWithAnalytics(
428
- editorAnalyticsAPI,
429
- api,
430
- isTableScalingEnabled,
431
- isTableFixedColumnWidthsOptionEnabled,
432
- shouldUseIncreasedScalingPercent,
433
- isCommentEditor,
434
- )(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect ?? defaultSelectionRect)(
435
- state,
436
- dispatch,
437
- editorView,
438
- );
439
- }
440
- return true;
441
- },
442
- icon:
443
- direction === 'row'
444
- ? () => (
445
- <TableRowDeleteIcon
446
- LEGACY_fallbackIcon={RemoveIcon}
447
- spacing={'spacious'}
448
- label={''}
449
- />
450
- )
451
- : () => (
452
- <TableColumnDeleteIcon
453
- LEGACY_fallbackIcon={RemoveIcon}
454
- spacing={'spacious'}
455
- label={''}
456
- />
457
- ),
458
- keymap: direction === 'row' ? tooltip(deleteRow) : tooltip(deleteColumn),
459
- },
460
- ...moveOptions.map(({ label, canMove, icon, keymap, getOriginIndexes, getTargetIndex }) => ({
461
- id: `move_${direction}_${label}`,
462
- title: `Move ${direction} ${label}`,
463
- disabled: !canMove,
464
- icon: icon,
465
- onClick: (state: EditorState, dispatch?: CommandDispatch) => {
466
- if (canMove) {
467
- requestAnimationFrame(() => {
468
- moveSourceWithAnalytics(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(
469
- INPUT_METHOD.TABLE_CONTEXT_MENU,
470
- `table-${direction}`,
471
- // Ignored via go/ees005
472
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
473
- getOriginIndexes(selectionRect!),
474
- // Ignored via go/ees005
475
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
476
- getTargetIndex(selectionRect!),
477
- )(editorView.state, editorView.dispatch);
478
- });
479
- return true;
480
- }
481
- return false;
482
- },
483
- keymap: keymap && tooltip(keymap),
484
- })),
485
- ];
486
-
487
- const allConfigs = [...restConfigs];
488
- allConfigs.unshift(...sortConfigs);
489
-
490
- return allConfigs.filter(Boolean) as DragMenuConfig[];
491
- };
@@ -1,10 +0,0 @@
1
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
-
3
- import { getPluginState } from '../plugin-factory';
4
-
5
- export function getAllowAddColumnCustomStep(state: EditorState): boolean {
6
- const tablePluginState = getPluginState(state);
7
- return (
8
- Boolean(tablePluginState) && Boolean(tablePluginState.pluginConfig.allowAddColumnWithCustomStep)
9
- );
10
- }
@@ -1,30 +0,0 @@
1
- import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
2
- import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
3
-
4
- import type { GuidelineExcludeConfig } from './snapping';
5
- import { calculateDefaultSnappings, calculateDefaultTablePreserveSnappings } from './snapping';
6
-
7
- // NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
8
- // If we don't do this then the guidelines will not align correctly to the edge of the table
9
- export const defaultGuidelines = createFixedGuidelinesFromLengths([
10
- 0,
11
- ...calculateDefaultSnappings(-1),
12
- ]) as GuidelineConfig[];
13
-
14
- export const PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET = -1;
15
- export const defaultGuidelinesForPreserveTable = (
16
- lengthOffset: number,
17
- editorContainerWidth: number,
18
- exclude: GuidelineExcludeConfig = {
19
- innerGuidelines: false,
20
- breakoutPoints: false,
21
- },
22
- ) => {
23
- const lengths = calculateDefaultTablePreserveSnappings(
24
- lengthOffset, // was hardcoded to -1 here, created PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET instead.
25
- editorContainerWidth,
26
- exclude,
27
- );
28
-
29
- return createFixedGuidelinesFromLengths(lengths, undefined, true) as GuidelineConfig[];
30
- };