@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,161 +0,0 @@
|
|
|
1
|
-
// #region Imports
|
|
2
|
-
import { TableSortStep } from '@atlaskit/custom-steps';
|
|
3
|
-
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
4
|
-
import { isTextInput } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
-
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
7
|
-
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
-
|
|
12
|
-
import type { TablePluginState } from '../types';
|
|
13
|
-
|
|
14
|
-
import { defaultTableSelection } from './default-table-selection';
|
|
15
|
-
import { pluginKey as tableResizingPluginKey } from './table-resizing/plugin-key';
|
|
16
|
-
import { isTableCollapsible } from './utils/collapse';
|
|
17
|
-
import {
|
|
18
|
-
checkIfHeaderColumnEnabled,
|
|
19
|
-
checkIfHeaderRowEnabled,
|
|
20
|
-
checkIfNumberColumnEnabled,
|
|
21
|
-
} from './utils/nodes';
|
|
22
|
-
|
|
23
|
-
const nextTableSorting = (
|
|
24
|
-
tr: Transaction | ReadonlyTransaction,
|
|
25
|
-
table?: ContentNodeWithPos,
|
|
26
|
-
): TableColumnOrdering | undefined => {
|
|
27
|
-
const tableSortStep: TableSortStep = tr.steps.find(
|
|
28
|
-
(step) => step instanceof TableSortStep,
|
|
29
|
-
) as TableSortStep;
|
|
30
|
-
|
|
31
|
-
return tableSortStep && table && table.pos === tableSortStep.pos ? tableSortStep.next : undefined;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const nextResizeHandleColumnIndex = (
|
|
35
|
-
tr: Transaction | ReadonlyTransaction,
|
|
36
|
-
resizeHandleColumnIndex?: number,
|
|
37
|
-
): number | undefined => {
|
|
38
|
-
if (tr.getMeta(tableResizingPluginKey)) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return resizeHandleColumnIndex;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
type BuilderTablePluginState = (props: {
|
|
46
|
-
tr: Transaction | ReadonlyTransaction;
|
|
47
|
-
table?: ContentNodeWithPos;
|
|
48
|
-
}) => (pluginState: TablePluginState) => TablePluginState;
|
|
49
|
-
|
|
50
|
-
const updateTargetCellPosition: BuilderTablePluginState =
|
|
51
|
-
({ tr, table }) =>
|
|
52
|
-
(pluginState: TablePluginState) => {
|
|
53
|
-
const tableNode = table && table.node;
|
|
54
|
-
if (!tableNode) {
|
|
55
|
-
return {
|
|
56
|
-
...pluginState,
|
|
57
|
-
targetCellPosition: undefined,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const { tableCell, tableHeader } = tr.doc.type.schema.nodes;
|
|
62
|
-
const cell = findParentNodeOfType([tableCell, tableHeader])(tr.selection);
|
|
63
|
-
const targetCellPosition = cell ? cell.pos : undefined;
|
|
64
|
-
|
|
65
|
-
if (pluginState.targetCellPosition === targetCellPosition) {
|
|
66
|
-
return pluginState;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
...pluginState,
|
|
71
|
-
targetCellPosition,
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const updateTableNodePluginState: BuilderTablePluginState =
|
|
76
|
-
({ tr, table }) =>
|
|
77
|
-
(pluginState) => {
|
|
78
|
-
const tableNode = table && table.node;
|
|
79
|
-
|
|
80
|
-
if (!tableNode || isTextInput(tr)) {
|
|
81
|
-
return pluginState;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
...pluginState,
|
|
86
|
-
...defaultTableSelection,
|
|
87
|
-
tableNode,
|
|
88
|
-
ordering: nextTableSorting(tr, table),
|
|
89
|
-
resizeHandleColumnIndex: nextResizeHandleColumnIndex(tr, pluginState.resizeHandleColumnIndex),
|
|
90
|
-
isNumberColumnEnabled: checkIfNumberColumnEnabled(tr.selection),
|
|
91
|
-
isHeaderColumnEnabled: checkIfHeaderColumnEnabled(tr.selection),
|
|
92
|
-
isHeaderRowEnabled: checkIfHeaderRowEnabled(tr.selection),
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const updateCollapseHandler: BuilderTablePluginState =
|
|
97
|
-
({ tr, table }) =>
|
|
98
|
-
(pluginState) => {
|
|
99
|
-
const tableNode = table && table.node;
|
|
100
|
-
const schema = tr.doc.type.schema;
|
|
101
|
-
const allowCollapse = pluginState.pluginConfig.allowCollapse;
|
|
102
|
-
const isExpandInSchema = schema.nodes.expand !== undefined;
|
|
103
|
-
const isCollapseEnabled = allowCollapse && isExpandInSchema;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* If we don't have focus, or collapse isn't allowed, or a table node doesn't
|
|
107
|
-
* exist, we don't need to waste extra checks below
|
|
108
|
-
*/
|
|
109
|
-
if (!pluginState.editorHasFocus || !isCollapseEnabled || !tableNode) {
|
|
110
|
-
return pluginState;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const expandNodeType = schema.nodes.expand as NodeType;
|
|
114
|
-
const isTableCollapsed = expandNodeType && !!findParentNodeOfType(expandNodeType)(tr.selection);
|
|
115
|
-
|
|
116
|
-
const trCanBeCollapsed = isTableCollapsible(tr).tableIsCollapsible;
|
|
117
|
-
|
|
118
|
-
// We're focused on a table + we're not inside an expand
|
|
119
|
-
const canCollapseTable: boolean =
|
|
120
|
-
!!pluginState.tableNode &&
|
|
121
|
-
// is it already collapsed?
|
|
122
|
-
!isTableCollapsed &&
|
|
123
|
-
!!trCanBeCollapsed;
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
pluginState.isTableCollapsed !== isTableCollapsed ||
|
|
127
|
-
pluginState.canCollapseTable !== canCollapseTable
|
|
128
|
-
) {
|
|
129
|
-
return {
|
|
130
|
-
...pluginState,
|
|
131
|
-
isTableCollapsed,
|
|
132
|
-
canCollapseTable,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return pluginState;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const buildPluginState =
|
|
140
|
-
(builders: Array<BuilderTablePluginState>): BuilderTablePluginState =>
|
|
141
|
-
(props) =>
|
|
142
|
-
(pluginState) => {
|
|
143
|
-
if (!props.table) {
|
|
144
|
-
return pluginState.targetCellPosition
|
|
145
|
-
? { ...pluginState, targetCellPosition: undefined }
|
|
146
|
-
: pluginState;
|
|
147
|
-
}
|
|
148
|
-
return builders.reduce(
|
|
149
|
-
(_pluginState, transform) => transform(props)(_pluginState),
|
|
150
|
-
pluginState,
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export const handleDocOrSelectionChanged = (
|
|
155
|
-
tr: Transaction | ReadonlyTransaction,
|
|
156
|
-
pluginState: TablePluginState,
|
|
157
|
-
): TablePluginState =>
|
|
158
|
-
buildPluginState([updateTargetCellPosition, updateTableNodePluginState, updateCollapseHandler])({
|
|
159
|
-
tr,
|
|
160
|
-
table: findTable(tr.selection),
|
|
161
|
-
})(pluginState);
|
package/src/pm-plugins/keymap.ts
DELETED
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
|
-
|
|
3
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import {
|
|
5
|
-
ACTION,
|
|
6
|
-
ACTION_SUBJECT,
|
|
7
|
-
ACTION_SUBJECT_ID,
|
|
8
|
-
EVENT_TYPE,
|
|
9
|
-
INPUT_METHOD,
|
|
10
|
-
} from '@atlaskit/editor-common/analytics';
|
|
11
|
-
import {
|
|
12
|
-
addColumnAfter,
|
|
13
|
-
addColumnAfterVO,
|
|
14
|
-
addColumnBefore,
|
|
15
|
-
addColumnBeforeVO,
|
|
16
|
-
addRowAfter,
|
|
17
|
-
addRowAfterVO,
|
|
18
|
-
addRowBefore,
|
|
19
|
-
addRowBeforeVO,
|
|
20
|
-
backspace,
|
|
21
|
-
bindKeymapWithCommand,
|
|
22
|
-
decreaseMediaSize,
|
|
23
|
-
deleteColumn,
|
|
24
|
-
deleteRow,
|
|
25
|
-
escape,
|
|
26
|
-
focusToContextMenuTrigger,
|
|
27
|
-
increaseMediaSize,
|
|
28
|
-
moveColumnLeft,
|
|
29
|
-
moveColumnRight,
|
|
30
|
-
moveDown,
|
|
31
|
-
moveLeft,
|
|
32
|
-
moveRight,
|
|
33
|
-
moveRowDown,
|
|
34
|
-
moveRowUp,
|
|
35
|
-
moveUp,
|
|
36
|
-
nextCell,
|
|
37
|
-
previousCell,
|
|
38
|
-
startColumnResizing,
|
|
39
|
-
toggleTable,
|
|
40
|
-
} from '@atlaskit/editor-common/keymaps';
|
|
41
|
-
import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
42
|
-
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
43
|
-
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
44
|
-
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
45
|
-
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
46
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
47
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
48
|
-
|
|
49
|
-
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
50
|
-
import type { PluginInjectionAPI, PluginInjectionAPIWithA11y } from '../types';
|
|
51
|
-
|
|
52
|
-
import { goToNextCell, moveCursorBackward, setFocusToCellMenu } from './commands';
|
|
53
|
-
import {
|
|
54
|
-
activateNextResizeArea,
|
|
55
|
-
initiateKeyboardColumnResizing,
|
|
56
|
-
stopKeyboardColumnResizing,
|
|
57
|
-
} from './commands/column-resize';
|
|
58
|
-
import {
|
|
59
|
-
addRowAroundSelection,
|
|
60
|
-
changeColumnWidthByStepWithAnalytics,
|
|
61
|
-
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut,
|
|
62
|
-
deleteTableIfSelectedWithAnalytics,
|
|
63
|
-
emptyMultipleCellsWithAnalytics,
|
|
64
|
-
} from './commands/commands-with-analytics';
|
|
65
|
-
import { goToNextCellVertical } from './commands/go-to-next-cell';
|
|
66
|
-
import {
|
|
67
|
-
addColumnAfter as addColumnAfterCommand,
|
|
68
|
-
addColumnBefore as addColumnBeforeCommand,
|
|
69
|
-
createTable,
|
|
70
|
-
insertTableWithNestingSupport,
|
|
71
|
-
} from './commands/insert';
|
|
72
|
-
|
|
73
|
-
export function keymapPlugin(
|
|
74
|
-
getEditorContainerWidth: GetEditorContainerWidth,
|
|
75
|
-
api: PluginInjectionAPI | undefined | null,
|
|
76
|
-
nodeViewPortalProviderAPI: PortalProviderAPI,
|
|
77
|
-
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
78
|
-
dragAndDropEnabled?: boolean,
|
|
79
|
-
isTableScalingEnabled = false,
|
|
80
|
-
isTableAlignmentEnabled = false,
|
|
81
|
-
isFullWidthEnabled?: boolean,
|
|
82
|
-
pluginInjectionApi?: PluginInjectionAPIWithA11y,
|
|
83
|
-
getIntl?: () => IntlShape,
|
|
84
|
-
isTableFixedColumnWidthsOptionEnabled = false,
|
|
85
|
-
shouldUseIncreasedScalingPercent?: boolean,
|
|
86
|
-
isCommentEditor?: boolean,
|
|
87
|
-
isChromelessEditor?: boolean,
|
|
88
|
-
isTableResizingEnabled?: boolean,
|
|
89
|
-
): SafePlugin {
|
|
90
|
-
const list = {};
|
|
91
|
-
|
|
92
|
-
const ariaNotifyPlugin = pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify;
|
|
93
|
-
|
|
94
|
-
bindKeymapWithCommand(
|
|
95
|
-
// Ignored via go/ees005
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
97
|
-
nextCell.common!,
|
|
98
|
-
goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1),
|
|
99
|
-
list,
|
|
100
|
-
);
|
|
101
|
-
bindKeymapWithCommand(
|
|
102
|
-
// Ignored via go/ees005
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
104
|
-
previousCell.common!,
|
|
105
|
-
goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1),
|
|
106
|
-
list,
|
|
107
|
-
);
|
|
108
|
-
bindKeymapWithCommand(
|
|
109
|
-
// Ignored via go/ees005
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
111
|
-
toggleTable.common!,
|
|
112
|
-
fg('platform_editor_use_nested_table_pm_nodes')
|
|
113
|
-
? editorCommandToPMCommand(
|
|
114
|
-
insertTableWithNestingSupport(
|
|
115
|
-
{
|
|
116
|
-
isTableScalingEnabled,
|
|
117
|
-
isTableAlignmentEnabled,
|
|
118
|
-
isFullWidthModeEnabled: !!isFullWidthEnabled,
|
|
119
|
-
isCommentEditor: isCommentEditor,
|
|
120
|
-
isChromelessEditor: isChromelessEditor,
|
|
121
|
-
isTableResizingEnabled,
|
|
122
|
-
},
|
|
123
|
-
api,
|
|
124
|
-
{
|
|
125
|
-
action: ACTION.INSERTED,
|
|
126
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
127
|
-
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
128
|
-
attributes: { inputMethod: INPUT_METHOD.SHORTCUT },
|
|
129
|
-
eventType: EVENT_TYPE.TRACK,
|
|
130
|
-
},
|
|
131
|
-
),
|
|
132
|
-
)
|
|
133
|
-
: createTable(
|
|
134
|
-
isTableScalingEnabled,
|
|
135
|
-
isTableAlignmentEnabled,
|
|
136
|
-
!!isFullWidthEnabled,
|
|
137
|
-
editorAnalyticsAPI,
|
|
138
|
-
isCommentEditor,
|
|
139
|
-
isChromelessEditor,
|
|
140
|
-
isTableResizingEnabled,
|
|
141
|
-
),
|
|
142
|
-
list,
|
|
143
|
-
);
|
|
144
|
-
bindKeymapWithCommand(
|
|
145
|
-
// Ignored via go/ees005
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
147
|
-
backspace.common!,
|
|
148
|
-
chainCommands(
|
|
149
|
-
deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD),
|
|
150
|
-
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD),
|
|
151
|
-
),
|
|
152
|
-
list,
|
|
153
|
-
);
|
|
154
|
-
// Ignored via go/ees005
|
|
155
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
156
|
-
bindKeymapWithCommand(backspace.common!, moveCursorBackward, list);
|
|
157
|
-
|
|
158
|
-
// Add row/column shortcuts
|
|
159
|
-
bindKeymapWithCommand(
|
|
160
|
-
// Ignored via go/ees005
|
|
161
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
162
|
-
addRowBefore.common!,
|
|
163
|
-
addRowAroundSelection(editorAnalyticsAPI)('TOP'),
|
|
164
|
-
list,
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
bindKeymapWithCommand(
|
|
168
|
-
// Ignored via go/ees005
|
|
169
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
170
|
-
addRowAfter.common!,
|
|
171
|
-
addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'),
|
|
172
|
-
list,
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
bindKeymapWithCommand(
|
|
176
|
-
// Ignored via go/ees005
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
178
|
-
addColumnBefore.common!,
|
|
179
|
-
addColumnBeforeCommand(
|
|
180
|
-
api,
|
|
181
|
-
isTableScalingEnabled,
|
|
182
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
183
|
-
shouldUseIncreasedScalingPercent,
|
|
184
|
-
),
|
|
185
|
-
list,
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
bindKeymapWithCommand(
|
|
189
|
-
// Ignored via go/ees005
|
|
190
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
191
|
-
addColumnAfter.common!,
|
|
192
|
-
addColumnAfterCommand(
|
|
193
|
-
api,
|
|
194
|
-
isTableScalingEnabled,
|
|
195
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
196
|
-
shouldUseIncreasedScalingPercent,
|
|
197
|
-
),
|
|
198
|
-
list,
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
bindKeymapWithCommand(
|
|
202
|
-
// Ignored via go/ees005
|
|
203
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
204
|
-
addRowBeforeVO.common!,
|
|
205
|
-
addRowAroundSelection(editorAnalyticsAPI)('TOP'),
|
|
206
|
-
list,
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
bindKeymapWithCommand(
|
|
210
|
-
// Ignored via go/ees005
|
|
211
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
212
|
-
addRowAfterVO.common!,
|
|
213
|
-
addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'),
|
|
214
|
-
list,
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
bindKeymapWithCommand(
|
|
218
|
-
// Ignored via go/ees005
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
220
|
-
addColumnBeforeVO.common!,
|
|
221
|
-
addColumnBeforeCommand(
|
|
222
|
-
api,
|
|
223
|
-
isTableScalingEnabled,
|
|
224
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
225
|
-
shouldUseIncreasedScalingPercent,
|
|
226
|
-
),
|
|
227
|
-
list,
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
bindKeymapWithCommand(
|
|
231
|
-
// Ignored via go/ees005
|
|
232
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
233
|
-
addColumnAfterVO.common!,
|
|
234
|
-
addColumnAfterCommand(
|
|
235
|
-
api,
|
|
236
|
-
isTableScalingEnabled,
|
|
237
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
238
|
-
shouldUseIncreasedScalingPercent,
|
|
239
|
-
),
|
|
240
|
-
list,
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
if (dragAndDropEnabled) {
|
|
244
|
-
// Move row/column shortcuts
|
|
245
|
-
/**
|
|
246
|
-
* NOTE: If the keyboard shortcut for moving rows or columns is changed, we need to update the handleKeyDown function
|
|
247
|
-
* in packages/editor/editor-plugin-table/src/pm-plugins/drag-and-drop/plugin.ts
|
|
248
|
-
* to make sure the logic for holding the shortcut keys is valid
|
|
249
|
-
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
250
|
-
*/
|
|
251
|
-
|
|
252
|
-
bindKeymapWithCommand(
|
|
253
|
-
// Ignored via go/ees005
|
|
254
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
255
|
-
moveRowDown.common!,
|
|
256
|
-
moveSourceWithAnalyticsViaShortcut(
|
|
257
|
-
editorAnalyticsAPI,
|
|
258
|
-
ariaNotifyPlugin,
|
|
259
|
-
getIntl,
|
|
260
|
-
)('table-row', 1),
|
|
261
|
-
list,
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
bindKeymapWithCommand(
|
|
265
|
-
// Ignored via go/ees005
|
|
266
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
267
|
-
moveRowUp.common!,
|
|
268
|
-
moveSourceWithAnalyticsViaShortcut(
|
|
269
|
-
editorAnalyticsAPI,
|
|
270
|
-
ariaNotifyPlugin,
|
|
271
|
-
getIntl,
|
|
272
|
-
)('table-row', -1),
|
|
273
|
-
list,
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
bindKeymapWithCommand(
|
|
277
|
-
// Ignored via go/ees005
|
|
278
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
279
|
-
moveColumnLeft.common!,
|
|
280
|
-
moveSourceWithAnalyticsViaShortcut(
|
|
281
|
-
editorAnalyticsAPI,
|
|
282
|
-
ariaNotifyPlugin,
|
|
283
|
-
getIntl,
|
|
284
|
-
)('table-column', -1),
|
|
285
|
-
list,
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
bindKeymapWithCommand(
|
|
289
|
-
// Ignored via go/ees005
|
|
290
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
291
|
-
moveColumnRight.common!,
|
|
292
|
-
moveSourceWithAnalyticsViaShortcut(
|
|
293
|
-
editorAnalyticsAPI,
|
|
294
|
-
ariaNotifyPlugin,
|
|
295
|
-
getIntl,
|
|
296
|
-
)('table-column', 1),
|
|
297
|
-
list,
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
// Delete row/column shortcuts
|
|
301
|
-
bindKeymapWithCommand(
|
|
302
|
-
// Ignored via go/ees005
|
|
303
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
304
|
-
deleteColumn.common!,
|
|
305
|
-
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
|
|
306
|
-
editorAnalyticsAPI,
|
|
307
|
-
api,
|
|
308
|
-
isTableScalingEnabled,
|
|
309
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
310
|
-
shouldUseIncreasedScalingPercent,
|
|
311
|
-
),
|
|
312
|
-
list,
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
bindKeymapWithCommand(
|
|
316
|
-
// Ignored via go/ees005
|
|
317
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
318
|
-
deleteRow.common!,
|
|
319
|
-
deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
|
|
320
|
-
editorAnalyticsAPI,
|
|
321
|
-
api,
|
|
322
|
-
isTableScalingEnabled,
|
|
323
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
324
|
-
shouldUseIncreasedScalingPercent,
|
|
325
|
-
),
|
|
326
|
-
list,
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
bindKeymapWithCommand(
|
|
331
|
-
// Ignored via go/ees005
|
|
332
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
333
|
-
startColumnResizing.common!,
|
|
334
|
-
initiateKeyboardColumnResizing({
|
|
335
|
-
ariaNotify: ariaNotifyPlugin,
|
|
336
|
-
getIntl: getIntl,
|
|
337
|
-
nodeViewPortalProviderAPI,
|
|
338
|
-
}),
|
|
339
|
-
list,
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
bindKeymapWithCommand(
|
|
343
|
-
// Ignored via go/ees005
|
|
344
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
345
|
-
moveRight.common!,
|
|
346
|
-
activateNextResizeArea({
|
|
347
|
-
direction: 1,
|
|
348
|
-
ariaNotify: ariaNotifyPlugin,
|
|
349
|
-
getIntl: getIntl,
|
|
350
|
-
nodeViewPortalProviderAPI,
|
|
351
|
-
}),
|
|
352
|
-
list,
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
bindKeymapWithCommand(
|
|
356
|
-
// Ignored via go/ees005
|
|
357
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
358
|
-
moveLeft.common!,
|
|
359
|
-
activateNextResizeArea({
|
|
360
|
-
direction: -1,
|
|
361
|
-
ariaNotify: ariaNotifyPlugin,
|
|
362
|
-
getIntl: getIntl,
|
|
363
|
-
nodeViewPortalProviderAPI,
|
|
364
|
-
}),
|
|
365
|
-
list,
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
bindKeymapWithCommand(
|
|
369
|
-
// Ignored via go/ees005
|
|
370
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
371
|
-
moveDown.common!,
|
|
372
|
-
goToNextCellVertical(1),
|
|
373
|
-
list,
|
|
374
|
-
);
|
|
375
|
-
|
|
376
|
-
bindKeymapWithCommand(
|
|
377
|
-
// Ignored via go/ees005
|
|
378
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
379
|
-
moveUp.common!,
|
|
380
|
-
goToNextCellVertical(-1),
|
|
381
|
-
list,
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
bindKeymapWithCommand(
|
|
385
|
-
// Ignored via go/ees005
|
|
386
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
387
|
-
decreaseMediaSize.common!,
|
|
388
|
-
changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI, api)(
|
|
389
|
-
-10,
|
|
390
|
-
getEditorContainerWidth,
|
|
391
|
-
isTableScalingEnabled,
|
|
392
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
393
|
-
!!isCommentEditor,
|
|
394
|
-
INPUT_METHOD.SHORTCUT,
|
|
395
|
-
ariaNotifyPlugin,
|
|
396
|
-
getIntl,
|
|
397
|
-
),
|
|
398
|
-
list,
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
bindKeymapWithCommand(
|
|
402
|
-
// Ignored via go/ees005
|
|
403
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
404
|
-
increaseMediaSize.common!,
|
|
405
|
-
changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI, api)(
|
|
406
|
-
10,
|
|
407
|
-
getEditorContainerWidth,
|
|
408
|
-
isTableScalingEnabled,
|
|
409
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
410
|
-
!!isCommentEditor,
|
|
411
|
-
INPUT_METHOD.SHORTCUT,
|
|
412
|
-
ariaNotifyPlugin,
|
|
413
|
-
getIntl,
|
|
414
|
-
),
|
|
415
|
-
list,
|
|
416
|
-
);
|
|
417
|
-
|
|
418
|
-
bindKeymapWithCommand(
|
|
419
|
-
// Ignored via go/ees005
|
|
420
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
421
|
-
escape.common!,
|
|
422
|
-
stopKeyboardColumnResizing({
|
|
423
|
-
ariaNotify: ariaNotifyPlugin,
|
|
424
|
-
getIntl: getIntl,
|
|
425
|
-
}),
|
|
426
|
-
list,
|
|
427
|
-
);
|
|
428
|
-
|
|
429
|
-
// Ignored via go/ees005
|
|
430
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
431
|
-
bindKeymapWithCommand(focusToContextMenuTrigger.common!, setFocusToCellMenu(), list);
|
|
432
|
-
|
|
433
|
-
return keymap(list) as SafePlugin;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export default keymapPlugin;
|