@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,715 +0,0 @@
1
- import type { IntlShape } from 'react-intl-next/src/types';
2
-
3
- import type { TableLayout } from '@atlaskit/adf-schema';
4
- import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
5
- import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
6
- import type {
7
- AnalyticsEventPayload,
8
- CHANGE_ALIGNMENT_REASON,
9
- EditorAnalyticsAPI,
10
- } from '@atlaskit/editor-common/analytics';
11
- import {
12
- ACTION_SUBJECT,
13
- EVENT_TYPE,
14
- INPUT_METHOD,
15
- TABLE_ACTION,
16
- TABLE_DISPLAY_MODE,
17
- } from '@atlaskit/editor-common/analytics';
18
- import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
19
- import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
20
- import type { Selection } from '@atlaskit/editor-prosemirror/state';
21
- import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
22
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
23
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
24
- import { type Rect, TableMap } from '@atlaskit/editor-tables/table-map';
25
- import {
26
- findCellClosestToPos,
27
- findCellRectClosestToPos,
28
- getSelectionRect,
29
- } from '@atlaskit/editor-tables/utils';
30
-
31
- import type {
32
- AlignmentOptions,
33
- InsertRowMethods,
34
- InsertRowOptions,
35
- PluginInjectionAPI,
36
- RowInsertPosition,
37
- } from '../../types';
38
- import { getPluginState } from '../plugin-factory';
39
- import { distributeColumnsWidths } from '../table-resizing/commands';
40
- import type { ResizeStateWithAnalytics } from '../table-resizing/utils/types';
41
- import { deleteRows } from '../transforms/delete-rows';
42
- import { mergeCells } from '../transforms/merge';
43
- import {
44
- withEditorAnalyticsAPI,
45
- getSelectedCellInfo,
46
- getSelectedTableInfo,
47
- } from '../utils/analytics';
48
- import { checkIfNumberColumnEnabled } from '../utils/nodes';
49
-
50
- import { clearMultipleCells } from './clear';
51
- import { wrapTableInExpand } from './collapse';
52
- import { changeColumnWidthByStep } from './column-resize';
53
- import { deleteColumnsCommand } from './delete';
54
- import { setTableDisplayMode } from './display-mode';
55
- import { insertColumn, insertRow } from './insert';
56
- import {
57
- deleteTable,
58
- deleteTableIfSelected,
59
- getTableSelectionType,
60
- setMultipleCellAttrs,
61
- setTableAlignment,
62
- setTableAlignmentWithTableContentWithPos,
63
- } from './misc';
64
- import { sortByColumn } from './sort';
65
- import { splitCell } from './split-cell';
66
- import { toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn } from './toggle';
67
-
68
- // #region Analytics wrappers
69
- export const emptyMultipleCellsWithAnalytics =
70
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
71
- (
72
- inputMethod:
73
- | INPUT_METHOD.CONTEXT_MENU
74
- | INPUT_METHOD.KEYBOARD
75
- | INPUT_METHOD.FLOATING_TB
76
- | INPUT_METHOD.TABLE_CONTEXT_MENU,
77
- targetCellPosition?: number,
78
- ) =>
79
- withEditorAnalyticsAPI(({ selection }) => {
80
- const { horizontalCells, verticalCells, totalRowCount, totalColumnCount } =
81
- getSelectedCellInfo(selection);
82
-
83
- return {
84
- action: TABLE_ACTION.CLEARED,
85
- actionSubject: ACTION_SUBJECT.TABLE,
86
- actionSubjectId: null,
87
- attributes: {
88
- inputMethod,
89
- horizontalCells,
90
- verticalCells,
91
- totalRowCount,
92
- totalColumnCount,
93
- },
94
- eventType: EVENT_TYPE.TRACK,
95
- };
96
- })(editorAnalyticsAPI)(clearMultipleCells(targetCellPosition));
97
-
98
- export const mergeCellsWithAnalytics =
99
- (editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined) =>
100
- (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) =>
101
- withEditorAnalyticsAPI(({ selection }) => {
102
- const { horizontalCells, verticalCells, totalCells, totalRowCount, totalColumnCount } =
103
- getSelectedCellInfo(selection);
104
-
105
- return {
106
- action: TABLE_ACTION.MERGED,
107
- actionSubject: ACTION_SUBJECT.TABLE,
108
- actionSubjectId: null,
109
- attributes: {
110
- inputMethod,
111
- horizontalCells,
112
- verticalCells,
113
- totalCells,
114
- totalRowCount,
115
- totalColumnCount,
116
- },
117
- eventType: EVENT_TYPE.TRACK,
118
- };
119
- })(editorAnalyticsAPI)((state, dispatch) => {
120
- if (dispatch) {
121
- dispatch(mergeCells(state.tr));
122
- }
123
- return true;
124
- });
125
-
126
- export const splitCellWithAnalytics =
127
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
128
- (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) =>
129
- withEditorAnalyticsAPI(({ selection }) => {
130
- const { totalRowCount, totalColumnCount } = getSelectedCellInfo(selection);
131
- const cell = findCellClosestToPos(selection.$anchor);
132
- if (cell) {
133
- const { rowspan: verticalCells, colspan: horizontalCells } = cell.node.attrs;
134
-
135
- return {
136
- action: TABLE_ACTION.SPLIT,
137
- actionSubject: ACTION_SUBJECT.TABLE,
138
- actionSubjectId: null,
139
- attributes: {
140
- inputMethod,
141
- horizontalCells,
142
- verticalCells,
143
- totalCells: horizontalCells * verticalCells,
144
- totalRowCount,
145
- totalColumnCount,
146
- },
147
- eventType: EVENT_TYPE.TRACK,
148
- };
149
- }
150
- return;
151
- })(editorAnalyticsAPI)(splitCell);
152
-
153
- export const setColorWithAnalytics =
154
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
155
- (
156
- inputMethod:
157
- | INPUT_METHOD.CONTEXT_MENU
158
- | INPUT_METHOD.FLOATING_TB
159
- | INPUT_METHOD.TABLE_CONTEXT_MENU,
160
- cellColor: string,
161
- editorView?: EditorView | null,
162
- ) =>
163
- withEditorAnalyticsAPI(({ selection }) => {
164
- const { horizontalCells, verticalCells, totalCells, totalRowCount, totalColumnCount } =
165
- getSelectedCellInfo(selection);
166
-
167
- return {
168
- action: TABLE_ACTION.COLORED,
169
- actionSubject: ACTION_SUBJECT.TABLE,
170
- actionSubjectId: null,
171
- attributes: {
172
- inputMethod,
173
- cellColor: (
174
- tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor
175
- ).toLowerCase(),
176
- horizontalCells,
177
- verticalCells,
178
- totalCells,
179
- totalRowCount,
180
- totalColumnCount,
181
- },
182
- eventType: EVENT_TYPE.TRACK,
183
- };
184
- })(editorAnalyticsAPI)(setMultipleCellAttrs({ background: cellColor }, editorView));
185
-
186
- export const addRowAroundSelection =
187
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
188
- (side: RowInsertPosition): Command =>
189
- (state, dispatch) => {
190
- const { selection } = state;
191
- const isCellSelection = selection instanceof CellSelection;
192
- const rect = isCellSelection
193
- ? getSelectionRect(selection)
194
- : findCellRectClosestToPos(selection.$from);
195
-
196
- if (!rect) {
197
- return false;
198
- }
199
-
200
- const position = isCellSelection && side === 'TOP' ? rect.top : rect.bottom - 1;
201
-
202
- const offset = side === 'BOTTOM' ? 1 : 0;
203
-
204
- return insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, {
205
- index: position + offset,
206
- moveCursorToInsertedRow: false,
207
- })(state, dispatch);
208
- };
209
-
210
- export const insertRowWithAnalytics =
211
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
212
- (inputMethod: InsertRowMethods, options: InsertRowOptions) =>
213
- withEditorAnalyticsAPI((state) => {
214
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
215
- return {
216
- action: TABLE_ACTION.ADDED_ROW,
217
- actionSubject: ACTION_SUBJECT.TABLE,
218
- actionSubjectId: null,
219
- attributes: {
220
- inputMethod,
221
- position: options.index,
222
- totalRowCount,
223
- totalColumnCount,
224
- },
225
- eventType: EVENT_TYPE.TRACK,
226
- };
227
- })(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow));
228
-
229
- export const changeColumnWidthByStepWithAnalytics =
230
- (
231
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
232
- api: PluginInjectionAPI | undefined | null,
233
- ) =>
234
- (
235
- stepSize: number,
236
- getEditorContainerWidth: GetEditorContainerWidth,
237
- isTableScalingEnabled: boolean,
238
- isTableFixedColumnWidthsOptionEnabled: boolean,
239
- isCommentEditor: boolean,
240
- inputMethod: INPUT_METHOD.SHORTCUT,
241
- ariaNotify?: (message: string) => void,
242
- getIntl?: () => IntlShape,
243
- ) =>
244
- withEditorAnalyticsAPI((state) => {
245
- const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
246
- const {
247
- hoveredCell: { colIndex },
248
- } = getPluginState(state);
249
-
250
- return {
251
- action: TABLE_ACTION.COLUMN_RESIZED,
252
- actionSubject: ACTION_SUBJECT.TABLE,
253
- eventType: EVENT_TYPE.TRACK,
254
- attributes: {
255
- colIndex,
256
- resizedDelta: stepSize,
257
- isLastColumn: colIndex === totalColumnCount - 1,
258
- tableWidth: table?.node.attrs.width,
259
- inputMethod,
260
- totalRowCount,
261
- totalColumnCount,
262
- },
263
- };
264
- })(editorAnalyticsAPI)(
265
- changeColumnWidthByStep({
266
- stepSize: stepSize,
267
- getEditorContainerWidth: getEditorContainerWidth,
268
- isTableScalingEnabled,
269
- isTableFixedColumnWidthsOptionEnabled,
270
- isCommentEditor,
271
- ariaNotify: ariaNotify,
272
- getIntl: getIntl,
273
- api,
274
- }),
275
- );
276
-
277
- export const insertColumnWithAnalytics =
278
- (
279
- api: PluginInjectionAPI | undefined | null,
280
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
281
- isTableScalingEnabled = false,
282
- isTableFixedColumnWidthsOptionEnabled = false,
283
- shouldUseIncreasedScalingPercent = false,
284
- isCommentEditor = false,
285
- ) =>
286
- (
287
- inputMethod:
288
- | INPUT_METHOD.CONTEXT_MENU
289
- | INPUT_METHOD.BUTTON
290
- | INPUT_METHOD.SHORTCUT
291
- | INPUT_METHOD.FLOATING_TB
292
- | INPUT_METHOD.TABLE_CONTEXT_MENU,
293
- position: number,
294
- ) =>
295
- withEditorAnalyticsAPI((state) => {
296
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
297
- return {
298
- action: TABLE_ACTION.ADDED_COLUMN,
299
- actionSubject: ACTION_SUBJECT.TABLE,
300
- actionSubjectId: null,
301
- attributes: {
302
- inputMethod,
303
- position,
304
- totalRowCount,
305
- totalColumnCount,
306
- },
307
- eventType: EVENT_TYPE.TRACK,
308
- };
309
- })(editorAnalyticsAPI)(
310
- insertColumn(
311
- api,
312
- isTableScalingEnabled,
313
- isTableFixedColumnWidthsOptionEnabled,
314
- shouldUseIncreasedScalingPercent,
315
- isCommentEditor,
316
- )(position),
317
- );
318
-
319
- export const deleteRowsWithAnalytics =
320
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
321
- (
322
- inputMethod:
323
- | INPUT_METHOD.CONTEXT_MENU
324
- | INPUT_METHOD.BUTTON
325
- | INPUT_METHOD.FLOATING_TB
326
- | INPUT_METHOD.SHORTCUT
327
- | INPUT_METHOD.TABLE_CONTEXT_MENU,
328
- rect: Rect,
329
- isHeaderRowRequired: boolean,
330
- ) =>
331
- withEditorAnalyticsAPI(({ selection }) => {
332
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(selection);
333
-
334
- return {
335
- action: TABLE_ACTION.DELETED_ROW,
336
- actionSubject: ACTION_SUBJECT.TABLE,
337
- actionSubjectId: null,
338
- attributes: {
339
- inputMethod,
340
- position: rect.top,
341
- count: rect.bottom - rect.top,
342
- totalRowCount,
343
- totalColumnCount,
344
- },
345
- eventType: EVENT_TYPE.TRACK,
346
- };
347
- })(editorAnalyticsAPI)((state, dispatch) => {
348
- if (dispatch) {
349
- dispatch(deleteRows(rect, isHeaderRowRequired)(state.tr));
350
- }
351
- return true;
352
- });
353
-
354
- export const deleteColumnsWithAnalytics =
355
- (
356
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
357
- api: PluginInjectionAPI | undefined | null,
358
- isTableScalingEnabled = false,
359
- isTableFixedColumnWidthsOptionEnabled = false,
360
- shouldUseIncreasedScalingPercent = false,
361
- isCommentEditor = false,
362
- ) =>
363
- (
364
- inputMethod:
365
- | INPUT_METHOD.CONTEXT_MENU
366
- | INPUT_METHOD.BUTTON
367
- | INPUT_METHOD.FLOATING_TB
368
- | INPUT_METHOD.SHORTCUT
369
- | INPUT_METHOD.TABLE_CONTEXT_MENU,
370
- rect: Rect,
371
- ) =>
372
- withEditorAnalyticsAPI(({ selection }) => {
373
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(selection);
374
-
375
- return {
376
- action: TABLE_ACTION.DELETED_COLUMN,
377
- actionSubject: ACTION_SUBJECT.TABLE,
378
- actionSubjectId: null,
379
- attributes: {
380
- inputMethod,
381
- position: rect.left,
382
- count: rect.right - rect.left,
383
- totalRowCount,
384
- totalColumnCount,
385
- },
386
- eventType: EVENT_TYPE.TRACK,
387
- };
388
- })(editorAnalyticsAPI)(
389
- deleteColumnsCommand(
390
- rect,
391
- api,
392
- isTableScalingEnabled,
393
- isTableFixedColumnWidthsOptionEnabled,
394
- shouldUseIncreasedScalingPercent,
395
- isCommentEditor,
396
- ),
397
- );
398
-
399
- export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut =
400
- (
401
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
402
- api: PluginInjectionAPI | undefined | null,
403
- isTableScalingEnabled?: boolean,
404
- isTableFixedColumnWidthsOptionEnabled?: boolean,
405
- shouldUseIncreasedScalingPercent?: boolean,
406
- ): Command =>
407
- (state, dispatch) => {
408
- const { selection } = state;
409
- const isCellSelection = selection instanceof CellSelection;
410
- if (!isCellSelection) {
411
- return false;
412
- }
413
-
414
- const rect = getSelectionRect(selection);
415
- if (!rect) {
416
- return false;
417
- }
418
-
419
- const selectionType = getTableSelectionType(selection);
420
- if (selectionType === 'row') {
421
- const { pluginConfig } = getPluginState(state);
422
- const isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
423
-
424
- return deleteRowsWithAnalytics(editorAnalyticsAPI)(
425
- INPUT_METHOD.SHORTCUT,
426
- rect,
427
- isHeaderRowRequired,
428
- )(state, dispatch);
429
- } else if (selectionType === 'column') {
430
- return deleteColumnsWithAnalytics(
431
- editorAnalyticsAPI,
432
- api,
433
- isTableScalingEnabled,
434
- isTableFixedColumnWidthsOptionEnabled,
435
- shouldUseIncreasedScalingPercent,
436
- )(INPUT_METHOD.SHORTCUT, rect)(state, dispatch);
437
- } else {
438
- return false;
439
- }
440
- };
441
-
442
- const getTableDeletedAnalytics = (
443
- selection: Selection,
444
- inputMethod: INPUT_METHOD.FLOATING_TB | INPUT_METHOD.KEYBOARD,
445
- ): AnalyticsEventPayload => {
446
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(selection);
447
- return {
448
- action: TABLE_ACTION.DELETED,
449
- actionSubject: ACTION_SUBJECT.TABLE,
450
- attributes: {
451
- inputMethod,
452
- totalRowCount,
453
- totalColumnCount,
454
- },
455
- eventType: EVENT_TYPE.TRACK,
456
- };
457
- };
458
-
459
- export const deleteTableWithAnalytics = (
460
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
461
- ) =>
462
- withEditorAnalyticsAPI(({ selection }) =>
463
- getTableDeletedAnalytics(selection, INPUT_METHOD.FLOATING_TB),
464
- )(editorAnalyticsAPI)(deleteTable);
465
-
466
- export const deleteTableIfSelectedWithAnalytics =
467
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
468
- (inputMethod: INPUT_METHOD.FLOATING_TB | INPUT_METHOD.KEYBOARD) =>
469
- withEditorAnalyticsAPI(({ selection }) => getTableDeletedAnalytics(selection, inputMethod))(
470
- editorAnalyticsAPI,
471
- )(deleteTableIfSelected);
472
-
473
- export const toggleHeaderRowWithAnalytics = (
474
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
475
- ) =>
476
- withEditorAnalyticsAPI((state) => {
477
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
478
- const { isHeaderRowEnabled } = getPluginState(state);
479
-
480
- return {
481
- action: TABLE_ACTION.TOGGLED_HEADER_ROW,
482
- actionSubject: ACTION_SUBJECT.TABLE,
483
- actionSubjectId: null,
484
- attributes: {
485
- newState: !isHeaderRowEnabled,
486
- totalRowCount,
487
- totalColumnCount,
488
- },
489
- eventType: EVENT_TYPE.TRACK,
490
- };
491
- })(editorAnalyticsAPI)(toggleHeaderRow);
492
-
493
- export const toggleHeaderColumnWithAnalytics = (
494
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
495
- ) =>
496
- withEditorAnalyticsAPI((state) => {
497
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
498
- const { isHeaderColumnEnabled } = getPluginState(state);
499
-
500
- return {
501
- action: TABLE_ACTION.TOGGLED_HEADER_COLUMN,
502
- actionSubject: ACTION_SUBJECT.TABLE,
503
- actionSubjectId: null,
504
- attributes: {
505
- newState: !isHeaderColumnEnabled,
506
- totalRowCount,
507
- totalColumnCount,
508
- },
509
- eventType: EVENT_TYPE.TRACK,
510
- };
511
- })(editorAnalyticsAPI)(toggleHeaderColumn);
512
-
513
- export const toggleNumberColumnWithAnalytics = (
514
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
515
- ) =>
516
- withEditorAnalyticsAPI((state) => {
517
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
518
- return {
519
- action: TABLE_ACTION.TOGGLED_NUMBER_COLUMN,
520
- actionSubject: ACTION_SUBJECT.TABLE,
521
- actionSubjectId: null,
522
- attributes: {
523
- newState: !checkIfNumberColumnEnabled(state.selection),
524
- totalRowCount,
525
- totalColumnCount,
526
- },
527
- eventType: EVENT_TYPE.TRACK,
528
- };
529
- })(editorAnalyticsAPI)(toggleNumberColumn);
530
-
531
- export const sortColumnWithAnalytics =
532
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
533
- (
534
- inputMethod:
535
- | INPUT_METHOD.CONTEXT_MENU
536
- | INPUT_METHOD.FLOATING_TB
537
- | INPUT_METHOD.TABLE_CONTEXT_MENU,
538
- columnIndex: number,
539
- sortOrder: SortOrder,
540
- ) =>
541
- withEditorAnalyticsAPI((state) => {
542
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
543
- return {
544
- action: TABLE_ACTION.SORTED_COLUMN,
545
- actionSubject: ACTION_SUBJECT.TABLE,
546
- attributes: {
547
- inputMethod,
548
- totalRowCount,
549
- totalColumnCount,
550
- position: columnIndex,
551
- sortOrder,
552
- mode: 'editor',
553
- },
554
- eventType: EVENT_TYPE.TRACK,
555
- };
556
- })(editorAnalyticsAPI)(sortByColumn(columnIndex, sortOrder));
557
-
558
- export const distributeColumnsWidthsWithAnalytics =
559
- (
560
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
561
- api: PluginInjectionAPI | undefined | null,
562
- ) =>
563
- (
564
- inputMethod:
565
- | INPUT_METHOD.CONTEXT_MENU
566
- | INPUT_METHOD.FLOATING_TB
567
- | INPUT_METHOD.TABLE_CONTEXT_MENU,
568
- { resizeState, table, attributes }: ResizeStateWithAnalytics,
569
- ) => {
570
- return withEditorAnalyticsAPI(() => {
571
- return {
572
- action: TABLE_ACTION.DISTRIBUTED_COLUMNS_WIDTHS,
573
- actionSubject: ACTION_SUBJECT.TABLE,
574
- actionSubjectId: null,
575
- attributes: {
576
- inputMethod,
577
- ...attributes,
578
- },
579
- eventType: EVENT_TYPE.TRACK,
580
- };
581
- })(editorAnalyticsAPI)((state, dispatch) => {
582
- if (dispatch) {
583
- distributeColumnsWidths(resizeState, table, api)(state, dispatch);
584
- }
585
- return true;
586
- });
587
- };
588
-
589
- export const wrapTableInExpandWithAnalytics = (
590
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
591
- ) =>
592
- withEditorAnalyticsAPI((state) => {
593
- const { totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
594
- return {
595
- action: TABLE_ACTION.COLLAPSED,
596
- actionSubject: ACTION_SUBJECT.TABLE,
597
- actionSubjectId: null,
598
- attributes: {
599
- totalRowCount,
600
- totalColumnCount,
601
- },
602
- eventType: EVENT_TYPE.TRACK,
603
- };
604
- })(editorAnalyticsAPI)(wrapTableInExpand);
605
-
606
- export const toggleFixedColumnWidthsOptionAnalytics = (
607
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
608
- inputMethod: INPUT_METHOD.FLOATING_TB,
609
- ) =>
610
- withEditorAnalyticsAPI((state) => {
611
- const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
612
-
613
- let previousDisplayMode: TABLE_DISPLAY_MODE;
614
- let newDisplayMode: TABLE_DISPLAY_MODE;
615
-
616
- switch (table?.node.attrs.displayMode) {
617
- case 'fixed':
618
- previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
619
- newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
620
- break;
621
- case 'default':
622
- previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
623
- newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
624
- break;
625
- case null:
626
- default:
627
- previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
628
- newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
629
- }
630
-
631
- return {
632
- action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
633
- actionSubject: ACTION_SUBJECT.TABLE,
634
- attributes: {
635
- inputMethod,
636
- previousDisplayMode,
637
- newDisplayMode,
638
- tableWidth: table?.node.attrs.width,
639
- totalRowCount,
640
- totalColumnCount,
641
- },
642
- eventType: EVENT_TYPE.TRACK,
643
- };
644
- })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
645
-
646
- export const setTableAlignmentWithAnalytics =
647
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isCommentEditor: boolean) =>
648
- (
649
- newAlignment: AlignmentOptions,
650
- // previous alignment could be a breakout value, if so use 'null' to indicate alignment was not previously set
651
- previousAlignment: TableLayout,
652
- inputMethod: INPUT_METHOD.FLOATING_TB,
653
- reason: CHANGE_ALIGNMENT_REASON,
654
- ) =>
655
- withEditorAnalyticsAPI((state) => {
656
- const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
657
-
658
- return {
659
- action: TABLE_ACTION.CHANGED_ALIGNMENT,
660
- actionSubject: ACTION_SUBJECT.TABLE,
661
- actionSubjectId: null,
662
- eventType: EVENT_TYPE.TRACK,
663
- attributes: {
664
- tableWidth: table?.node.attrs.width,
665
- newAlignment,
666
- previousAlignment:
667
- previousAlignment === 'center' || previousAlignment === 'align-start'
668
- ? previousAlignment
669
- : null,
670
- totalRowCount,
671
- totalColumnCount,
672
- inputMethod,
673
- reason,
674
- },
675
- };
676
- })(editorAnalyticsAPI)(
677
- editorCommandToPMCommand(setTableAlignment(newAlignment, isCommentEditor)),
678
- );
679
-
680
- export const setTableAlignmentWithTableContentWithPosWithAnalytics =
681
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
682
- (
683
- newAlignment: AlignmentOptions,
684
- previousAlignment: AlignmentOptions | null,
685
- tableNodeWithPos: NodeWithPos,
686
- inputMethod: INPUT_METHOD.AUTO,
687
- reason: CHANGE_ALIGNMENT_REASON,
688
- ) =>
689
- withEditorAnalyticsAPI(() => {
690
- const map = TableMap.get(tableNodeWithPos.node);
691
- const totalRowCount = map.height;
692
- const totalColumnCount = map.width;
693
-
694
- const attributes = {
695
- tableWidth: tableNodeWithPos.node.attrs.width,
696
- newAlignment: newAlignment,
697
- previousAlignment: previousAlignment,
698
- totalRowCount: totalRowCount,
699
- totalColumnCount: totalColumnCount,
700
- inputMethod: inputMethod,
701
- reason: reason,
702
- };
703
-
704
- return {
705
- action: TABLE_ACTION.CHANGED_ALIGNMENT,
706
- actionSubject: ACTION_SUBJECT.TABLE,
707
- actionSubjectId: null,
708
- eventType: EVENT_TYPE.TRACK,
709
- attributes: attributes,
710
- };
711
- })(editorAnalyticsAPI)(
712
- editorCommandToPMCommand(
713
- setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos),
714
- ),
715
- );