@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
package/src/tablePlugin.tsx
DELETED
|
@@ -1,971 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
tableCell,
|
|
5
|
-
tableCellWithNestedTable,
|
|
6
|
-
tableHeader,
|
|
7
|
-
tableHeaderWithLocalId,
|
|
8
|
-
tableHeaderWithNestedTable,
|
|
9
|
-
tableRow,
|
|
10
|
-
tableRowWithNestedTable,
|
|
11
|
-
tableRowWithLocalId,
|
|
12
|
-
tableCellWithLocalId,
|
|
13
|
-
tableCellWithNestedTableWithLocalId,
|
|
14
|
-
tableRowWithNestedTableWithLocalId,
|
|
15
|
-
tableHeaderWithNestedTableWithLocalId,
|
|
16
|
-
} from '@atlaskit/adf-schema';
|
|
17
|
-
import {
|
|
18
|
-
ACTION,
|
|
19
|
-
ACTION_SUBJECT,
|
|
20
|
-
ACTION_SUBJECT_ID,
|
|
21
|
-
EVENT_TYPE,
|
|
22
|
-
INPUT_METHOD,
|
|
23
|
-
TABLE_ACTION,
|
|
24
|
-
} from '@atlaskit/editor-common/analytics';
|
|
25
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
26
|
-
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
27
|
-
import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
|
|
28
|
-
import {
|
|
29
|
-
sharedPluginStateHookMigratorFactory,
|
|
30
|
-
useSharedPluginState,
|
|
31
|
-
useSharedPluginStateWithSelector,
|
|
32
|
-
} from '@atlaskit/editor-common/hooks';
|
|
33
|
-
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
34
|
-
import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
35
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
36
|
-
import {
|
|
37
|
-
getParentOfTypeCount,
|
|
38
|
-
getPositionAfterTopParentNodeOfType,
|
|
39
|
-
} from '@atlaskit/editor-common/nesting';
|
|
40
|
-
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
41
|
-
import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
|
|
42
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
43
|
-
import type {
|
|
44
|
-
Command,
|
|
45
|
-
EditorPlugin,
|
|
46
|
-
ExtractInjectionAPI,
|
|
47
|
-
GetEditorContainerWidth,
|
|
48
|
-
} from '@atlaskit/editor-common/types';
|
|
49
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
50
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
51
|
-
import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
52
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
53
|
-
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
54
|
-
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
55
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
56
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
57
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
58
|
-
|
|
59
|
-
import { tableNodeSpecWithFixedToDOM } from './nodeviews/toDOM';
|
|
60
|
-
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
61
|
-
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
62
|
-
import { insertTableWithNestingSupport, insertTableWithSize } from './pm-plugins/commands/insert';
|
|
63
|
-
import { pluginConfig } from './pm-plugins/create-plugin-config';
|
|
64
|
-
import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
|
|
65
|
-
import { createPlugin as createDragAndDropPlugin } from './pm-plugins/drag-and-drop/plugin';
|
|
66
|
-
import { pluginKey as dragAndDropPluginKey } from './pm-plugins/drag-and-drop/plugin-key';
|
|
67
|
-
import { keymapPlugin } from './pm-plugins/keymap';
|
|
68
|
-
import { createPlugin } from './pm-plugins/main';
|
|
69
|
-
import { pluginKey } from './pm-plugins/plugin-key';
|
|
70
|
-
import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
|
|
71
|
-
import { createPlugin as createStickyHeadersPlugin } from './pm-plugins/sticky-headers/plugin';
|
|
72
|
-
import { pluginKey as stickyHeadersPluginKey } from './pm-plugins/sticky-headers/plugin-key';
|
|
73
|
-
import { findStickyHeaderForTable } from './pm-plugins/sticky-headers/util';
|
|
74
|
-
import { createPlugin as createTableOverflowAnalyticsPlugin } from './pm-plugins/table-analytics';
|
|
75
|
-
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
76
|
-
import { createPlugin as createFlexiResizingPlugin } from './pm-plugins/table-resizing/plugin';
|
|
77
|
-
import { getPluginState as getFlexiResizingPlugin } from './pm-plugins/table-resizing/plugin-factory';
|
|
78
|
-
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing/plugin-key';
|
|
79
|
-
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
80
|
-
import {
|
|
81
|
-
createPlugin as createSizeSelectorPlugin,
|
|
82
|
-
pluginKey as sizeSelectorPluginKey,
|
|
83
|
-
} from './pm-plugins/table-size-selector';
|
|
84
|
-
import {
|
|
85
|
-
createPlugin as createTableWidthPlugin,
|
|
86
|
-
pluginKey as tableWidthPluginKey,
|
|
87
|
-
} from './pm-plugins/table-width';
|
|
88
|
-
import { createPlugin as createTableWidthInCommentFixPlugin } from './pm-plugins/table-width-in-comment-fix';
|
|
89
|
-
import { createTableWithWidth } from './pm-plugins/utils/create';
|
|
90
|
-
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
91
|
-
import type { TablePlugin, TablePluginOptions } from './tablePluginType';
|
|
92
|
-
import type { ColumnResizingPluginState, TableSharedStateInternal } from './types';
|
|
93
|
-
import { ContentComponent } from './ui/ContentComponent';
|
|
94
|
-
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
95
|
-
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
96
|
-
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
97
|
-
import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
98
|
-
// Ignored via go/ees005
|
|
99
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
100
|
-
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
101
|
-
import { FloatingToolbarLabel } from './ui/FloatingToolbarLabel/FloatingToolbarLabel';
|
|
102
|
-
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
103
|
-
import { SizeSelector } from './ui/SizeSelector';
|
|
104
|
-
import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
105
|
-
import { getToolbarConfig } from './ui/toolbar';
|
|
106
|
-
|
|
107
|
-
const defaultGetEditorFeatureFlags = () => ({});
|
|
108
|
-
|
|
109
|
-
const useTableSharedState = sharedPluginStateHookMigratorFactory(
|
|
110
|
-
(api: ExtractInjectionAPI<TablePlugin> | undefined) => {
|
|
111
|
-
const { mode } = useSharedPluginStateWithSelector(api, ['editorViewMode'], (states) => ({
|
|
112
|
-
mode: states.editorViewModeState?.mode,
|
|
113
|
-
}));
|
|
114
|
-
return { mode };
|
|
115
|
-
},
|
|
116
|
-
(api: ExtractInjectionAPI<TablePlugin> | undefined) => {
|
|
117
|
-
const { editorViewModeState } = useSharedPluginState(api, ['editorViewMode']);
|
|
118
|
-
return {
|
|
119
|
-
mode: editorViewModeState?.mode,
|
|
120
|
-
};
|
|
121
|
-
},
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
126
|
-
* from `@atlaskit/editor-core`.
|
|
127
|
-
*/
|
|
128
|
-
const tablePlugin: TablePlugin = ({ config: options, api }) => {
|
|
129
|
-
const editorViewRef: Record<'current', EditorView | null> = { current: null };
|
|
130
|
-
const defaultGetEditorContainerWidth: GetEditorContainerWidth = () => {
|
|
131
|
-
return (
|
|
132
|
-
api?.width?.sharedState.currentState() ?? {
|
|
133
|
-
width: document?.body?.offsetWidth ?? 500,
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
};
|
|
137
|
-
const editorAnalyticsAPI = api?.analytics?.actions;
|
|
138
|
-
const ariaNotifyPlugin = api?.accessibilityUtils?.actions.ariaNotify;
|
|
139
|
-
|
|
140
|
-
const isTableFixedColumnWidthsOptionEnabled =
|
|
141
|
-
options?.getEditorFeatureFlags?.().tableWithFixedColumnWidthsOption || false;
|
|
142
|
-
|
|
143
|
-
const shouldUseIncreasedScalingPercent =
|
|
144
|
-
options?.isTableScalingEnabled &&
|
|
145
|
-
(isTableFixedColumnWidthsOptionEnabled ||
|
|
146
|
-
// When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
147
|
-
options?.isCommentEditor);
|
|
148
|
-
|
|
149
|
-
const isTableSelectorEnabled =
|
|
150
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
151
|
-
!options?.isChromelessEditor &&
|
|
152
|
-
!options?.isCommentEditor &&
|
|
153
|
-
options?.getEditorFeatureFlags?.().tableSelector &&
|
|
154
|
-
editorExperiment('platform_editor_controls', 'variant1');
|
|
155
|
-
|
|
156
|
-
return {
|
|
157
|
-
name: 'table',
|
|
158
|
-
|
|
159
|
-
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
160
|
-
// to most up to date values - passing to createPluginState will not re-initialise the state
|
|
161
|
-
getSharedState: (editorState) => {
|
|
162
|
-
if (!editorState) {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
167
|
-
const tablePluginState = pluginKey.getState(editorState)!;
|
|
168
|
-
const tableResizingPluginState = getFlexiResizingPlugin(editorState);
|
|
169
|
-
const tableWidthResizingPluginState = tableWidthPluginKey.getState(editorState);
|
|
170
|
-
|
|
171
|
-
const stickyHeadersState = stickyHeadersPluginKey.getState(editorState);
|
|
172
|
-
const stickyHeader = stickyHeadersState
|
|
173
|
-
? findStickyHeaderForTable(stickyHeadersState, tablePluginState?.tablePos)
|
|
174
|
-
: undefined;
|
|
175
|
-
|
|
176
|
-
const dragAndDropState = dragAndDropPluginKey.getState(editorState);
|
|
177
|
-
const sizeSelectorPluginState = sizeSelectorPluginKey.getState(editorState);
|
|
178
|
-
|
|
179
|
-
const sharedStateInternal: TableSharedStateInternal = {
|
|
180
|
-
isFullWidthModeEnabled: !!options?.fullWidthEnabled,
|
|
181
|
-
wasFullWidthModeEnabled: !!options?.wasFullWidthEnabled,
|
|
182
|
-
isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
|
|
183
|
-
isHeaderColumnEnabled: tablePluginState.isHeaderColumnEnabled,
|
|
184
|
-
ordering: tablePluginState.ordering,
|
|
185
|
-
isResizing: !!(
|
|
186
|
-
tableResizingPluginState?.dragging || tableWidthResizingPluginState?.resizing
|
|
187
|
-
),
|
|
188
|
-
isTableResizing: tableWidthResizingPluginState?.resizing,
|
|
189
|
-
isInDanger: tablePluginState.isInDanger,
|
|
190
|
-
hoveredRows: tablePluginState.hoveredRows,
|
|
191
|
-
hoveredColumns: tablePluginState.hoveredColumns,
|
|
192
|
-
hoveredCell: tablePluginState.hoveredCell,
|
|
193
|
-
isTableHovered: tablePluginState.isTableHovered,
|
|
194
|
-
isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
|
|
195
|
-
// IMPORTANT: Need to continue to pass tableNode to control re-renders
|
|
196
|
-
// TableComponent listens for node attribute changes to update colgroups
|
|
197
|
-
tableNode: tablePluginState.tableNode,
|
|
198
|
-
widthToWidest: tablePluginState.widthToWidest,
|
|
199
|
-
resizingTableLocalId: tableWidthResizingPluginState?.tableLocalId,
|
|
200
|
-
tableRef: tablePluginState?.tableRef ?? undefined,
|
|
201
|
-
resizingTableRef: tableWidthResizingPluginState?.tableRef ?? undefined,
|
|
202
|
-
tablePos: tablePluginState.tablePos,
|
|
203
|
-
targetCellPosition: tablePluginState.targetCellPosition,
|
|
204
|
-
isContextualMenuOpen: tablePluginState.isContextualMenuOpen,
|
|
205
|
-
pluginConfig: tablePluginState.pluginConfig,
|
|
206
|
-
insertColumnButtonIndex: tablePluginState.insertColumnButtonIndex,
|
|
207
|
-
insertRowButtonIndex: tablePluginState.insertRowButtonIndex,
|
|
208
|
-
isDragAndDropEnabled: tablePluginState.isDragAndDropEnabled,
|
|
209
|
-
tableWrapperTarget: tablePluginState.tableWrapperTarget,
|
|
210
|
-
isCellMenuOpenByKeyboard: tablePluginState.isCellMenuOpenByKeyboard,
|
|
211
|
-
stickyHeader,
|
|
212
|
-
dragMenuDirection: dragAndDropState?.dragMenuDirection,
|
|
213
|
-
dragMenuIndex: dragAndDropState?.dragMenuIndex,
|
|
214
|
-
isDragMenuOpen: dragAndDropState?.isDragMenuOpen,
|
|
215
|
-
isSizeSelectorOpen: sizeSelectorPluginState?.isSelectorOpen,
|
|
216
|
-
sizeSelectorTargetRef: sizeSelectorPluginState?.targetRef,
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
return sharedStateInternal;
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
actions: {
|
|
223
|
-
insertTable:
|
|
224
|
-
(analyticsPayload): Command =>
|
|
225
|
-
(state, dispatch) => {
|
|
226
|
-
if (
|
|
227
|
-
options?.tableOptions?.allowNestedTables &&
|
|
228
|
-
fg('platform_editor_use_nested_table_pm_nodes')
|
|
229
|
-
) {
|
|
230
|
-
return editorCommandToPMCommand(
|
|
231
|
-
insertTableWithNestingSupport(
|
|
232
|
-
{
|
|
233
|
-
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
234
|
-
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
235
|
-
isFullWidthModeEnabled: options?.fullWidthEnabled,
|
|
236
|
-
isCommentEditor: options?.isCommentEditor,
|
|
237
|
-
isChromelessEditor: options?.isChromelessEditor,
|
|
238
|
-
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
239
|
-
},
|
|
240
|
-
api,
|
|
241
|
-
analyticsPayload,
|
|
242
|
-
),
|
|
243
|
-
)(state, dispatch);
|
|
244
|
-
} else {
|
|
245
|
-
const node = createTableWithWidth({
|
|
246
|
-
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
247
|
-
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
248
|
-
isFullWidthModeEnabled: options?.fullWidthEnabled,
|
|
249
|
-
isCommentEditor: options?.isCommentEditor,
|
|
250
|
-
isChromelessEditor: options?.isChromelessEditor,
|
|
251
|
-
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
252
|
-
})(state.schema);
|
|
253
|
-
|
|
254
|
-
return (
|
|
255
|
-
api?.contentInsertion?.actions?.insert({
|
|
256
|
-
state,
|
|
257
|
-
dispatch,
|
|
258
|
-
node,
|
|
259
|
-
options: {
|
|
260
|
-
selectNodeInserted: false,
|
|
261
|
-
analyticsPayload: {
|
|
262
|
-
...analyticsPayload,
|
|
263
|
-
attributes: {
|
|
264
|
-
...analyticsPayload.attributes,
|
|
265
|
-
localId: node.attrs.localId,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
}) ?? false
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
commands: {
|
|
276
|
-
insertTableWithSize: fg('platform_editor_use_nested_table_pm_nodes')
|
|
277
|
-
? (rowsCount, colsCount, inputMethod) =>
|
|
278
|
-
insertTableWithNestingSupport(
|
|
279
|
-
{
|
|
280
|
-
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
281
|
-
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
282
|
-
isFullWidthModeEnabled: options?.fullWidthEnabled,
|
|
283
|
-
isCommentEditor: options?.isCommentEditor,
|
|
284
|
-
isChromelessEditor: options?.isChromelessEditor,
|
|
285
|
-
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
286
|
-
createTableProps: {
|
|
287
|
-
rowsCount,
|
|
288
|
-
colsCount,
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
api,
|
|
292
|
-
{
|
|
293
|
-
action: ACTION.INSERTED,
|
|
294
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
295
|
-
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
296
|
-
attributes: {
|
|
297
|
-
inputMethod: inputMethod ?? INPUT_METHOD.PICKER,
|
|
298
|
-
totalRowCount: rowsCount,
|
|
299
|
-
totalColumnCount: colsCount,
|
|
300
|
-
},
|
|
301
|
-
eventType: EVENT_TYPE.TRACK,
|
|
302
|
-
},
|
|
303
|
-
)
|
|
304
|
-
: insertTableWithSize(
|
|
305
|
-
options?.fullWidthEnabled,
|
|
306
|
-
options?.isTableScalingEnabled,
|
|
307
|
-
options?.tableOptions.allowTableAlignment,
|
|
308
|
-
api?.analytics?.actions,
|
|
309
|
-
options?.isCommentEditor,
|
|
310
|
-
),
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
nodes() {
|
|
314
|
-
const { allowColumnResizing } = pluginConfig(options?.tableOptions);
|
|
315
|
-
// TODO: ED-25901 - We need to move this into a plugin config option so we don't accidentally enable nested nodes in Jira
|
|
316
|
-
const isNestingSupported = Boolean(options?.tableOptions?.allowNestedTables);
|
|
317
|
-
|
|
318
|
-
const isTableFixedColumnWidthsOptionEnabled =
|
|
319
|
-
options?.getEditorFeatureFlags?.().tableWithFixedColumnWidthsOption || false;
|
|
320
|
-
|
|
321
|
-
const shouldUseIncreasedScalingPercent =
|
|
322
|
-
options?.isTableScalingEnabled &&
|
|
323
|
-
(isTableFixedColumnWidthsOptionEnabled ||
|
|
324
|
-
// When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
325
|
-
options?.isCommentEditor);
|
|
326
|
-
|
|
327
|
-
const isTableScalingEnabled = options?.isTableScalingEnabled;
|
|
328
|
-
const isCommentEditor = options?.isCommentEditor;
|
|
329
|
-
const isChromelessEditor = options?.isChromelessEditor;
|
|
330
|
-
|
|
331
|
-
return isNestingSupported
|
|
332
|
-
? [
|
|
333
|
-
{
|
|
334
|
-
name: 'table',
|
|
335
|
-
node: tableNodeSpecWithFixedToDOM({
|
|
336
|
-
allowColumnResizing: Boolean(allowColumnResizing),
|
|
337
|
-
tableResizingEnabled: Boolean(options?.tableOptions.allowTableResizing),
|
|
338
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
339
|
-
isNestingSupported,
|
|
340
|
-
isTableScalingEnabled,
|
|
341
|
-
shouldUseIncreasedScalingPercent,
|
|
342
|
-
isCommentEditor,
|
|
343
|
-
isChromelessEditor,
|
|
344
|
-
}),
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
name: 'tableHeader',
|
|
348
|
-
node: fg('platform_editor_adf_with_localid')
|
|
349
|
-
? tableHeaderWithNestedTableWithLocalId
|
|
350
|
-
: tableHeaderWithNestedTable,
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
name: 'tableRow',
|
|
354
|
-
node: fg('platform_editor_adf_with_localid')
|
|
355
|
-
? tableRowWithNestedTableWithLocalId
|
|
356
|
-
: tableRowWithNestedTable,
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
name: 'tableCell',
|
|
360
|
-
node: fg('platform_editor_adf_with_localid')
|
|
361
|
-
? tableCellWithNestedTableWithLocalId
|
|
362
|
-
: tableCellWithNestedTable,
|
|
363
|
-
},
|
|
364
|
-
]
|
|
365
|
-
: [
|
|
366
|
-
{
|
|
367
|
-
name: 'table',
|
|
368
|
-
node: tableNodeSpecWithFixedToDOM({
|
|
369
|
-
allowColumnResizing: Boolean(allowColumnResizing),
|
|
370
|
-
tableResizingEnabled: Boolean(options?.tableOptions.allowTableResizing),
|
|
371
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
372
|
-
isNestingSupported,
|
|
373
|
-
isTableScalingEnabled,
|
|
374
|
-
shouldUseIncreasedScalingPercent,
|
|
375
|
-
isCommentEditor,
|
|
376
|
-
isChromelessEditor,
|
|
377
|
-
}),
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
name: 'tableHeader',
|
|
381
|
-
node: fg('platform_editor_adf_with_localid') ? tableHeaderWithLocalId : tableHeader,
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
name: 'tableRow',
|
|
385
|
-
node: fg('platform_editor_adf_with_localid') ? tableRowWithLocalId : tableRow,
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
name: 'tableCell',
|
|
389
|
-
node: fg('platform_editor_adf_with_localid') ? tableCellWithLocalId : tableCell,
|
|
390
|
-
},
|
|
391
|
-
];
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
pmPlugins() {
|
|
395
|
-
const plugins: ReturnType<NonNullable<EditorPlugin['pmPlugins']>> = [
|
|
396
|
-
{
|
|
397
|
-
name: 'table',
|
|
398
|
-
plugin: ({
|
|
399
|
-
dispatchAnalyticsEvent,
|
|
400
|
-
dispatch,
|
|
401
|
-
portalProviderAPI,
|
|
402
|
-
nodeViewPortalProviderAPI,
|
|
403
|
-
eventDispatcher,
|
|
404
|
-
getIntl,
|
|
405
|
-
}) => {
|
|
406
|
-
const {
|
|
407
|
-
fullWidthEnabled,
|
|
408
|
-
wasFullWidthEnabled,
|
|
409
|
-
tableOptions,
|
|
410
|
-
getEditorFeatureFlags,
|
|
411
|
-
dragAndDropEnabled,
|
|
412
|
-
isTableScalingEnabled,
|
|
413
|
-
isCommentEditor,
|
|
414
|
-
isChromelessEditor,
|
|
415
|
-
} = options || ({} as TablePluginOptions);
|
|
416
|
-
|
|
417
|
-
return createPlugin(
|
|
418
|
-
dispatchAnalyticsEvent,
|
|
419
|
-
dispatch,
|
|
420
|
-
portalProviderAPI,
|
|
421
|
-
nodeViewPortalProviderAPI,
|
|
422
|
-
eventDispatcher,
|
|
423
|
-
pluginConfig(tableOptions),
|
|
424
|
-
defaultGetEditorContainerWidth,
|
|
425
|
-
getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
426
|
-
getIntl,
|
|
427
|
-
fullWidthEnabled,
|
|
428
|
-
wasFullWidthEnabled,
|
|
429
|
-
dragAndDropEnabled,
|
|
430
|
-
editorAnalyticsAPI,
|
|
431
|
-
api,
|
|
432
|
-
isTableScalingEnabled,
|
|
433
|
-
shouldUseIncreasedScalingPercent,
|
|
434
|
-
isCommentEditor,
|
|
435
|
-
isChromelessEditor,
|
|
436
|
-
);
|
|
437
|
-
},
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
name: 'tablePMColResizing',
|
|
441
|
-
plugin: ({ dispatch, nodeViewPortalProviderAPI }) => {
|
|
442
|
-
const { fullWidthEnabled, tableOptions, getEditorFeatureFlags, isTableScalingEnabled } =
|
|
443
|
-
options || ({} as TablePluginOptions);
|
|
444
|
-
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
445
|
-
return allowColumnResizing
|
|
446
|
-
? createFlexiResizingPlugin(
|
|
447
|
-
dispatch,
|
|
448
|
-
{
|
|
449
|
-
lastColumnResizable: !fullWidthEnabled,
|
|
450
|
-
} as ColumnResizingPluginState,
|
|
451
|
-
defaultGetEditorContainerWidth,
|
|
452
|
-
getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
453
|
-
api,
|
|
454
|
-
nodeViewPortalProviderAPI,
|
|
455
|
-
editorAnalyticsAPI,
|
|
456
|
-
isTableScalingEnabled || false,
|
|
457
|
-
!!options?.isCommentEditor,
|
|
458
|
-
)
|
|
459
|
-
: undefined;
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
|
-
{ name: 'tableEditing', plugin: () => createDecorationsPlugin() },
|
|
463
|
-
// Needs to be lower priority than editor-tables.tableEditing
|
|
464
|
-
// plugin as it is currently swallowing backspace events inside tables
|
|
465
|
-
{
|
|
466
|
-
name: 'tableKeymap',
|
|
467
|
-
plugin: ({ getIntl, nodeViewPortalProviderAPI }) => {
|
|
468
|
-
const {
|
|
469
|
-
dragAndDropEnabled,
|
|
470
|
-
isTableScalingEnabled = false,
|
|
471
|
-
fullWidthEnabled = false,
|
|
472
|
-
isCommentEditor = false,
|
|
473
|
-
isChromelessEditor = false,
|
|
474
|
-
tableOptions,
|
|
475
|
-
} = options || ({} as TablePluginOptions);
|
|
476
|
-
|
|
477
|
-
return keymapPlugin(
|
|
478
|
-
defaultGetEditorContainerWidth,
|
|
479
|
-
api,
|
|
480
|
-
nodeViewPortalProviderAPI,
|
|
481
|
-
editorAnalyticsAPI,
|
|
482
|
-
dragAndDropEnabled,
|
|
483
|
-
isTableScalingEnabled,
|
|
484
|
-
tableOptions?.allowTableAlignment,
|
|
485
|
-
fullWidthEnabled,
|
|
486
|
-
api,
|
|
487
|
-
getIntl,
|
|
488
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
489
|
-
shouldUseIncreasedScalingPercent,
|
|
490
|
-
isCommentEditor,
|
|
491
|
-
isChromelessEditor,
|
|
492
|
-
tableOptions?.allowTableResizing,
|
|
493
|
-
);
|
|
494
|
-
},
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
name: 'tableSelectionKeymap',
|
|
498
|
-
plugin: ({ getIntl }) => tableSelectionKeymapPlugin(api, getIntl),
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
name: 'tableEditing',
|
|
502
|
-
plugin: () => {
|
|
503
|
-
const { dragAndDropEnabled } = options || ({} as TablePluginOptions);
|
|
504
|
-
|
|
505
|
-
return tableEditing({
|
|
506
|
-
reportFixedTable: ({ tr, reason }: { tr: Transaction; reason: string }) => {
|
|
507
|
-
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
508
|
-
action: TABLE_ACTION.FIXED,
|
|
509
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
510
|
-
actionSubjectId: null,
|
|
511
|
-
attributes: {
|
|
512
|
-
reason,
|
|
513
|
-
},
|
|
514
|
-
eventType: EVENT_TYPE.TRACK,
|
|
515
|
-
})(tr);
|
|
516
|
-
},
|
|
517
|
-
dragAndDropEnabled,
|
|
518
|
-
}) as SafePlugin;
|
|
519
|
-
},
|
|
520
|
-
},
|
|
521
|
-
{
|
|
522
|
-
name: 'tableStickyHeaders',
|
|
523
|
-
plugin: ({ dispatch, eventDispatcher }) =>
|
|
524
|
-
options && options.tableOptions.stickyHeaders
|
|
525
|
-
? createStickyHeadersPlugin(dispatch, () => [])
|
|
526
|
-
: undefined,
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
name: 'tableDragAndDrop',
|
|
530
|
-
plugin: ({ dispatch }) => {
|
|
531
|
-
return options?.dragAndDropEnabled
|
|
532
|
-
? createDragAndDropPlugin(
|
|
533
|
-
dispatch,
|
|
534
|
-
editorAnalyticsAPI,
|
|
535
|
-
options?.isTableScalingEnabled,
|
|
536
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
537
|
-
options.isCommentEditor,
|
|
538
|
-
)
|
|
539
|
-
: undefined;
|
|
540
|
-
},
|
|
541
|
-
},
|
|
542
|
-
{
|
|
543
|
-
name: 'tableViewModeSort',
|
|
544
|
-
plugin: ({ nodeViewPortalProviderAPI }) => {
|
|
545
|
-
return api?.editorViewMode
|
|
546
|
-
? createViewModeSortPlugin(api, nodeViewPortalProviderAPI)
|
|
547
|
-
: undefined;
|
|
548
|
-
},
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
name: 'tableLocalId',
|
|
552
|
-
plugin: ({ dispatch }) => createTableLocalIdPlugin(dispatch),
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
name: 'tableWidth',
|
|
556
|
-
plugin: ({ dispatchAnalyticsEvent, dispatch }) =>
|
|
557
|
-
options?.tableOptions.allowTableResizing
|
|
558
|
-
? createTableWidthPlugin(
|
|
559
|
-
dispatch,
|
|
560
|
-
dispatchAnalyticsEvent,
|
|
561
|
-
options.fullWidthEnabled ?? false,
|
|
562
|
-
options.isTableScalingEnabled ?? false,
|
|
563
|
-
options.tableOptions.allowTableResizing ?? false,
|
|
564
|
-
options.isCommentEditor ?? false,
|
|
565
|
-
)
|
|
566
|
-
: undefined,
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
name: 'tableWidthInCommentFix',
|
|
570
|
-
plugin: ({ dispatch }) =>
|
|
571
|
-
options?.tableOptions.allowTableResizing && options?.isCommentEditor
|
|
572
|
-
? createTableWidthInCommentFixPlugin(
|
|
573
|
-
dispatch,
|
|
574
|
-
options.tableOptions.allowTableAlignment ?? false,
|
|
575
|
-
)
|
|
576
|
-
: undefined,
|
|
577
|
-
},
|
|
578
|
-
// TODO: ED-26961 - should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
579
|
-
{
|
|
580
|
-
name: 'tableOverflowAnalyticsPlugin',
|
|
581
|
-
plugin: ({ dispatch, dispatchAnalyticsEvent }) =>
|
|
582
|
-
createTableOverflowAnalyticsPlugin(
|
|
583
|
-
dispatch,
|
|
584
|
-
dispatchAnalyticsEvent,
|
|
585
|
-
options?.tableOptions.allowTableResizing ?? false,
|
|
586
|
-
),
|
|
587
|
-
},
|
|
588
|
-
{
|
|
589
|
-
name: 'tableAnalyticsPlugin',
|
|
590
|
-
plugin: ({ dispatch, dispatchAnalyticsEvent }) =>
|
|
591
|
-
createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent),
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
name: 'tableGetEditorViewReferencePlugin',
|
|
595
|
-
plugin: () => {
|
|
596
|
-
return new SafePlugin({
|
|
597
|
-
view: (editorView) => {
|
|
598
|
-
editorViewRef.current = editorView;
|
|
599
|
-
return {
|
|
600
|
-
destroy: () => {
|
|
601
|
-
editorViewRef.current = null;
|
|
602
|
-
},
|
|
603
|
-
};
|
|
604
|
-
},
|
|
605
|
-
});
|
|
606
|
-
},
|
|
607
|
-
},
|
|
608
|
-
{
|
|
609
|
-
name: 'tableSizeSelectorPlugin',
|
|
610
|
-
plugin: ({ dispatch }) =>
|
|
611
|
-
isTableSelectorEnabled ? createSizeSelectorPlugin(dispatch) : undefined,
|
|
612
|
-
},
|
|
613
|
-
];
|
|
614
|
-
|
|
615
|
-
// Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
|
|
616
|
-
// https://github.com/ProseMirror/prosemirror/issues/934
|
|
617
|
-
if (browser.safari) {
|
|
618
|
-
plugins.push({
|
|
619
|
-
name: 'tableSafariDeleteCompositionTextIssueWorkaround',
|
|
620
|
-
plugin: () => {
|
|
621
|
-
return createTableSafariDeleteCompositionTextIssueWorkaroundPlugin();
|
|
622
|
-
},
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
return plugins;
|
|
627
|
-
},
|
|
628
|
-
|
|
629
|
-
contentComponent({
|
|
630
|
-
editorView,
|
|
631
|
-
popupsMountPoint,
|
|
632
|
-
popupsBoundariesElement,
|
|
633
|
-
popupsScrollableElement,
|
|
634
|
-
dispatchAnalyticsEvent,
|
|
635
|
-
}) {
|
|
636
|
-
if (expValEquals('platform_editor_usesharedpluginstatewithselector', 'isEnabled', true)) {
|
|
637
|
-
return (
|
|
638
|
-
<ContentComponent
|
|
639
|
-
api={api}
|
|
640
|
-
editorView={editorView}
|
|
641
|
-
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
642
|
-
options={options}
|
|
643
|
-
popupsMountPoint={popupsMountPoint}
|
|
644
|
-
popupsBoundariesElement={popupsBoundariesElement}
|
|
645
|
-
popupsScrollableElement={popupsScrollableElement}
|
|
646
|
-
defaultGetEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
647
|
-
defaultGetEditorFeatureFlags={defaultGetEditorFeatureFlags}
|
|
648
|
-
isTableSelectorEnabled={isTableSelectorEnabled}
|
|
649
|
-
/>
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
return (
|
|
654
|
-
<ErrorBoundary
|
|
655
|
-
component={ACTION_SUBJECT.TABLES_PLUGIN}
|
|
656
|
-
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
657
|
-
fallbackComponent={null}
|
|
658
|
-
>
|
|
659
|
-
<GlobalStylesWrapper
|
|
660
|
-
featureFlags={api?.featureFlags?.sharedState.currentState()}
|
|
661
|
-
isDragAndDropEnabledOption={options?.dragAndDropEnabled}
|
|
662
|
-
api={api}
|
|
663
|
-
/>
|
|
664
|
-
<WithPluginState
|
|
665
|
-
plugins={{
|
|
666
|
-
tableAnalyticsPluginState: tableAnalyticsPluginKey,
|
|
667
|
-
tablePluginState: pluginKey,
|
|
668
|
-
tableWidthPluginState: tableWidthPluginKey,
|
|
669
|
-
tableResizingPluginState: tableResizingPluginKey,
|
|
670
|
-
stickyHeadersState: stickyHeadersPluginKey,
|
|
671
|
-
dragAndDropState: dragAndDropPluginKey,
|
|
672
|
-
sizeSelectorPluginState: sizeSelectorPluginKey,
|
|
673
|
-
}}
|
|
674
|
-
render={({
|
|
675
|
-
tableResizingPluginState: resizingPluginState,
|
|
676
|
-
stickyHeadersState,
|
|
677
|
-
tablePluginState,
|
|
678
|
-
tableWidthPluginState,
|
|
679
|
-
dragAndDropState,
|
|
680
|
-
sizeSelectorPluginState,
|
|
681
|
-
}) => {
|
|
682
|
-
// Any changes made inside `<WithPluginState>` need to be reflected in the
|
|
683
|
-
// `<ContentComponent>` as well.
|
|
684
|
-
const isColumnResizing = resizingPluginState?.dragging;
|
|
685
|
-
const isTableResizing = tableWidthPluginState?.resizing;
|
|
686
|
-
const resizingTableLocalId = tableWidthPluginState?.tableLocalId;
|
|
687
|
-
const resizingTableRef = tableWidthPluginState?.tableRef;
|
|
688
|
-
const isResizing = isColumnResizing || isTableResizing;
|
|
689
|
-
const widthToWidest = tablePluginState?.widthToWidest;
|
|
690
|
-
const isSizeSelectorOpen = sizeSelectorPluginState?.isSelectorOpen;
|
|
691
|
-
|
|
692
|
-
const {
|
|
693
|
-
tableNode,
|
|
694
|
-
tablePos,
|
|
695
|
-
targetCellPosition,
|
|
696
|
-
isContextualMenuOpen,
|
|
697
|
-
tableRef,
|
|
698
|
-
pluginConfig,
|
|
699
|
-
insertColumnButtonIndex,
|
|
700
|
-
insertRowButtonIndex,
|
|
701
|
-
isHeaderColumnEnabled,
|
|
702
|
-
isHeaderRowEnabled,
|
|
703
|
-
isDragAndDropEnabled,
|
|
704
|
-
tableWrapperTarget,
|
|
705
|
-
isCellMenuOpenByKeyboard,
|
|
706
|
-
// Ignored via go/ees005
|
|
707
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
708
|
-
} = tablePluginState!;
|
|
709
|
-
|
|
710
|
-
const { allowControls } = pluginConfig;
|
|
711
|
-
|
|
712
|
-
const stickyHeader = stickyHeadersState
|
|
713
|
-
? findStickyHeaderForTable(stickyHeadersState, tablePos)
|
|
714
|
-
: undefined;
|
|
715
|
-
|
|
716
|
-
return (
|
|
717
|
-
<>
|
|
718
|
-
{targetCellPosition &&
|
|
719
|
-
(tableRef || isCellMenuOpenByKeyboard) &&
|
|
720
|
-
!isResizing &&
|
|
721
|
-
options &&
|
|
722
|
-
options.allowContextualMenu && (
|
|
723
|
-
<FloatingContextualButton
|
|
724
|
-
isNumberColumnEnabled={tableNode && tableNode.attrs.isNumberColumnEnabled}
|
|
725
|
-
editorView={editorView}
|
|
726
|
-
tableNode={tableNode}
|
|
727
|
-
mountPoint={popupsMountPoint}
|
|
728
|
-
targetCellPosition={targetCellPosition}
|
|
729
|
-
scrollableElement={popupsScrollableElement}
|
|
730
|
-
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
731
|
-
isContextualMenuOpen={isContextualMenuOpen}
|
|
732
|
-
stickyHeader={stickyHeader}
|
|
733
|
-
tableWrapper={tableWrapperTarget}
|
|
734
|
-
isCellMenuOpenByKeyboard={isCellMenuOpenByKeyboard}
|
|
735
|
-
/>
|
|
736
|
-
)}
|
|
737
|
-
{allowControls && (
|
|
738
|
-
<FloatingInsertButton
|
|
739
|
-
tableNode={tableNode}
|
|
740
|
-
tableRef={tableRef}
|
|
741
|
-
insertColumnButtonIndex={insertColumnButtonIndex}
|
|
742
|
-
insertRowButtonIndex={insertRowButtonIndex}
|
|
743
|
-
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
744
|
-
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
745
|
-
isDragAndDropEnabled={isDragAndDropEnabled}
|
|
746
|
-
isTableScalingEnabled={options?.isTableScalingEnabled}
|
|
747
|
-
editorView={editorView}
|
|
748
|
-
mountPoint={popupsMountPoint}
|
|
749
|
-
boundariesElement={popupsBoundariesElement}
|
|
750
|
-
scrollableElement={popupsScrollableElement}
|
|
751
|
-
hasStickyHeaders={stickyHeader && stickyHeader.sticky}
|
|
752
|
-
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
753
|
-
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
754
|
-
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
755
|
-
getEditorFeatureFlags={
|
|
756
|
-
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags
|
|
757
|
-
}
|
|
758
|
-
isChromelessEditor={options?.isChromelessEditor}
|
|
759
|
-
api={api}
|
|
760
|
-
isCommentEditor={options?.isCommentEditor}
|
|
761
|
-
/>
|
|
762
|
-
)}
|
|
763
|
-
{options?.allowContextualMenu && (
|
|
764
|
-
<FloatingContextualMenu
|
|
765
|
-
editorView={editorView}
|
|
766
|
-
mountPoint={popupsMountPoint}
|
|
767
|
-
boundariesElement={popupsBoundariesElement}
|
|
768
|
-
targetCellPosition={targetCellPosition}
|
|
769
|
-
isOpen={Boolean(isContextualMenuOpen) && !isResizing}
|
|
770
|
-
pluginConfig={pluginConfig}
|
|
771
|
-
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
772
|
-
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
773
|
-
getEditorFeatureFlags={
|
|
774
|
-
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags
|
|
775
|
-
}
|
|
776
|
-
isCellMenuOpenByKeyboard={isCellMenuOpenByKeyboard}
|
|
777
|
-
isCommentEditor={options?.isCommentEditor}
|
|
778
|
-
api={api}
|
|
779
|
-
/>
|
|
780
|
-
)}
|
|
781
|
-
{isDragAndDropEnabled && (
|
|
782
|
-
<FloatingDragMenu
|
|
783
|
-
editorView={editorView}
|
|
784
|
-
mountPoint={popupsMountPoint}
|
|
785
|
-
boundariesElement={popupsBoundariesElement}
|
|
786
|
-
tableRef={tableRef as HTMLTableElement}
|
|
787
|
-
tableNode={tableNode}
|
|
788
|
-
targetCellPosition={targetCellPosition}
|
|
789
|
-
direction={dragAndDropState?.dragMenuDirection}
|
|
790
|
-
index={dragAndDropState?.dragMenuIndex}
|
|
791
|
-
isOpen={!!dragAndDropState?.isDragMenuOpen && !isResizing}
|
|
792
|
-
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
793
|
-
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
794
|
-
stickyHeaders={stickyHeader}
|
|
795
|
-
pluginConfig={pluginConfig}
|
|
796
|
-
isTableScalingEnabled={options?.isTableScalingEnabled}
|
|
797
|
-
getEditorFeatureFlags={
|
|
798
|
-
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags
|
|
799
|
-
}
|
|
800
|
-
ariaNotifyPlugin={ariaNotifyPlugin}
|
|
801
|
-
api={api}
|
|
802
|
-
isCommentEditor={options?.isCommentEditor}
|
|
803
|
-
/>
|
|
804
|
-
)}
|
|
805
|
-
{allowControls && !isDragAndDropEnabled && !isResizing && (
|
|
806
|
-
<FloatingDeleteButton
|
|
807
|
-
editorView={editorView}
|
|
808
|
-
selection={editorView.state.selection}
|
|
809
|
-
tableRef={tableRef as HTMLTableElement}
|
|
810
|
-
mountPoint={popupsMountPoint}
|
|
811
|
-
boundariesElement={popupsBoundariesElement}
|
|
812
|
-
scrollableElement={popupsScrollableElement}
|
|
813
|
-
stickyHeaders={stickyHeader}
|
|
814
|
-
isNumberColumnEnabled={tableNode && tableNode.attrs.isNumberColumnEnabled}
|
|
815
|
-
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
816
|
-
api={api}
|
|
817
|
-
/>
|
|
818
|
-
)}
|
|
819
|
-
{(options?.isTableScalingEnabled ||
|
|
820
|
-
(options?.tableOptions.allowTableResizing && options.isCommentEditor)) &&
|
|
821
|
-
isTableResizing &&
|
|
822
|
-
widthToWidest &&
|
|
823
|
-
resizingTableLocalId &&
|
|
824
|
-
resizingTableRef &&
|
|
825
|
-
widthToWidest[resizingTableLocalId] && (
|
|
826
|
-
<FloatingToolbarLabel
|
|
827
|
-
target={resizingTableRef}
|
|
828
|
-
content={
|
|
829
|
-
editorExperiment('single_column_layouts', true) ? (
|
|
830
|
-
<ResizerBreakoutModeLabel layout="full-width" />
|
|
831
|
-
) : (
|
|
832
|
-
<FullWidthDisplay />
|
|
833
|
-
)
|
|
834
|
-
}
|
|
835
|
-
alignX={'center'}
|
|
836
|
-
alignY={'bottom'}
|
|
837
|
-
stick={true}
|
|
838
|
-
forcePlacement={true}
|
|
839
|
-
zIndex={akEditorFloatingPanelZIndex}
|
|
840
|
-
offset={[0, 10]}
|
|
841
|
-
/>
|
|
842
|
-
)}
|
|
843
|
-
|
|
844
|
-
{isTableSelectorEnabled && isSizeSelectorOpen && (
|
|
845
|
-
<SizeSelector
|
|
846
|
-
api={api}
|
|
847
|
-
isOpenedByKeyboard={false}
|
|
848
|
-
popupsMountPoint={popupsMountPoint}
|
|
849
|
-
target={
|
|
850
|
-
sizeSelectorPluginState?.targetRef ??
|
|
851
|
-
getDomRefFromSelection(
|
|
852
|
-
editorView,
|
|
853
|
-
ACTION_SUBJECT_ID.PICKER_TABLE_SIZE,
|
|
854
|
-
api?.analytics?.actions,
|
|
855
|
-
)
|
|
856
|
-
}
|
|
857
|
-
popupsBoundariesElement={popupsBoundariesElement}
|
|
858
|
-
popupsScrollableElement={popupsScrollableElement}
|
|
859
|
-
/>
|
|
860
|
-
)}
|
|
861
|
-
</>
|
|
862
|
-
);
|
|
863
|
-
}}
|
|
864
|
-
/>
|
|
865
|
-
</ErrorBoundary>
|
|
866
|
-
);
|
|
867
|
-
},
|
|
868
|
-
|
|
869
|
-
pluginsOptions: {
|
|
870
|
-
quickInsert: ({ formatMessage }) => [
|
|
871
|
-
{
|
|
872
|
-
id: 'table',
|
|
873
|
-
title: formatMessage(messages.table),
|
|
874
|
-
description: formatMessage(messages.tableDescription),
|
|
875
|
-
keywords: ['cell', 'table'],
|
|
876
|
-
priority: 600,
|
|
877
|
-
keyshortcut: tooltip(toggleTable),
|
|
878
|
-
icon: () => <IconTable />,
|
|
879
|
-
action(insert, state) {
|
|
880
|
-
if (isTableSelectorEnabled) {
|
|
881
|
-
const tr = insert('');
|
|
882
|
-
tr.setMeta(sizeSelectorPluginKey, {
|
|
883
|
-
isSelectorOpen: true,
|
|
884
|
-
});
|
|
885
|
-
|
|
886
|
-
return tr;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// see comment on tablesPlugin.getSharedState on usage
|
|
890
|
-
const tableState = api?.table?.sharedState.currentState();
|
|
891
|
-
const tableNodeProps = {
|
|
892
|
-
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
893
|
-
isTableAlignmentEnabled: options?.tableOptions.allowTableAlignment,
|
|
894
|
-
isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
|
|
895
|
-
isCommentEditor: options?.isCommentEditor,
|
|
896
|
-
isChromelessEditor: options?.isChromelessEditor,
|
|
897
|
-
isTableResizingEnabled: options?.tableOptions.allowTableResizing,
|
|
898
|
-
};
|
|
899
|
-
|
|
900
|
-
let tableNode = createTableWithWidth(tableNodeProps)(state.schema);
|
|
901
|
-
|
|
902
|
-
let { tr } = state;
|
|
903
|
-
// If the cursor is inside a table
|
|
904
|
-
if (
|
|
905
|
-
hasParentNodeOfType(state.schema.nodes.table)(state.selection) &&
|
|
906
|
-
options?.tableOptions?.allowNestedTables &&
|
|
907
|
-
fg('platform_editor_use_nested_table_pm_nodes')
|
|
908
|
-
) {
|
|
909
|
-
// If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
|
|
910
|
-
if (
|
|
911
|
-
editorExperiment('nested-tables-in-tables', false, { exposure: true }) ||
|
|
912
|
-
getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1
|
|
913
|
-
) {
|
|
914
|
-
// Nesting is too deep insert table after the top parent table
|
|
915
|
-
const positionAfterTopTable = getPositionAfterTopParentNodeOfType(
|
|
916
|
-
state.schema.nodes.table,
|
|
917
|
-
)(state.selection.$from);
|
|
918
|
-
tr = safeInsert(tableNode, positionAfterTopTable)(tr);
|
|
919
|
-
tr.scrollIntoView();
|
|
920
|
-
} else {
|
|
921
|
-
// Table can be nested in parent table
|
|
922
|
-
tableNode = createTableWithWidth({
|
|
923
|
-
...tableNodeProps,
|
|
924
|
-
isNestedTable: true,
|
|
925
|
-
})(state.schema);
|
|
926
|
-
tr = insert(tableNode);
|
|
927
|
-
}
|
|
928
|
-
} else {
|
|
929
|
-
tr = insert(tableNode);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
933
|
-
action: ACTION.INSERTED,
|
|
934
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
935
|
-
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
936
|
-
attributes: {
|
|
937
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT,
|
|
938
|
-
localId: tableNode.attrs.localId,
|
|
939
|
-
},
|
|
940
|
-
eventType: EVENT_TYPE.TRACK,
|
|
941
|
-
})(tr);
|
|
942
|
-
return tr;
|
|
943
|
-
},
|
|
944
|
-
},
|
|
945
|
-
],
|
|
946
|
-
floatingToolbar: getToolbarConfig(
|
|
947
|
-
defaultGetEditorContainerWidth,
|
|
948
|
-
api,
|
|
949
|
-
editorAnalyticsAPI,
|
|
950
|
-
() => editorViewRef.current,
|
|
951
|
-
options,
|
|
952
|
-
isTableFixedColumnWidthsOptionEnabled,
|
|
953
|
-
shouldUseIncreasedScalingPercent,
|
|
954
|
-
)(pluginConfig(options?.tableOptions)),
|
|
955
|
-
},
|
|
956
|
-
usePluginHook({ editorView }) {
|
|
957
|
-
const { mode } = useTableSharedState(api);
|
|
958
|
-
|
|
959
|
-
useEffect(() => {
|
|
960
|
-
const { state, dispatch } = editorView;
|
|
961
|
-
const tr = state.tr;
|
|
962
|
-
tr.setMeta('viewModeState', mode);
|
|
963
|
-
if (dispatch) {
|
|
964
|
-
dispatch(tr);
|
|
965
|
-
}
|
|
966
|
-
}, [editorView, mode]);
|
|
967
|
-
},
|
|
968
|
-
};
|
|
969
|
-
};
|
|
970
|
-
|
|
971
|
-
export default tablePlugin;
|