@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,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
|
-
);
|