@atlaskit/editor-plugin-table 7.16.11 → 7.16.13
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/.eslintrc.js +3 -3
- package/CHANGELOG.md +16 -0
- package/dist/cjs/commands/misc.js +3 -3
- package/dist/cjs/nodeviews/TableCell.js +10 -10
- package/dist/cjs/nodeviews/TableContainer.js +83 -27
- package/dist/cjs/nodeviews/TableResizer.js +40 -19
- package/dist/cjs/nodeviews/TableRow.js +23 -23
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +4 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +3 -3
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +1 -1
- package/dist/cjs/ui/FloatingDragMenu/styles.js +1 -1
- package/dist/cjs/ui/common-styles.js +13 -13
- package/dist/cjs/ui/ui-styles.js +25 -25
- package/dist/cjs/utils/guidelines.js +7 -4
- package/dist/cjs/utils/merged-cells.js +3 -3
- package/dist/cjs/utils/snapping.js +7 -8
- package/dist/es2019/commands/misc.js +3 -3
- package/dist/es2019/nodeviews/TableContainer.js +70 -9
- package/dist/es2019/nodeviews/TableResizer.js +42 -21
- package/dist/es2019/nodeviews/TableRow.js +21 -21
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +3 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +4 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +3 -3
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +47 -47
- package/dist/es2019/ui/FloatingDragMenu/styles.js +30 -30
- package/dist/es2019/ui/common-styles.js +802 -816
- package/dist/es2019/ui/ui-styles.js +665 -678
- package/dist/es2019/utils/guidelines.js +5 -2
- package/dist/es2019/utils/merged-cells.js +3 -3
- package/dist/es2019/utils/snapping.js +5 -6
- package/dist/esm/commands/misc.js +3 -3
- package/dist/esm/nodeviews/TableCell.js +10 -10
- package/dist/esm/nodeviews/TableContainer.js +85 -29
- package/dist/esm/nodeviews/TableResizer.js +42 -21
- package/dist/esm/nodeviews/TableRow.js +23 -23
- package/dist/esm/pm-plugins/table-resizing/plugin.js +3 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +4 -4
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +3 -3
- package/dist/esm/ui/FloatingContextualMenu/styles.js +1 -1
- package/dist/esm/ui/FloatingDragMenu/styles.js +1 -1
- package/dist/esm/ui/common-styles.js +13 -13
- package/dist/esm/ui/ui-styles.js +25 -25
- package/dist/esm/utils/guidelines.js +6 -3
- package/dist/esm/utils/merged-cells.js +3 -3
- package/dist/esm/utils/snapping.js +6 -7
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +1 -1
- package/dist/types/pm-plugins/drag-and-drop/utils/getDragBehaviour.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +1 -1
- package/dist/types/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.d.ts +1 -1
- package/dist/types/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +1 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +1 -1
- package/dist/types/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types/ui/icons/DragHandleDisabledIcon.d.ts +1 -1
- package/dist/types/utils/guidelines.d.ts +2 -1
- package/dist/types/utils/snapping.d.ts +3 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/getDragBehaviour.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/DragHandleDisabledIcon.d.ts +1 -1
- package/dist/types-ts4.5/utils/guidelines.d.ts +2 -1
- package/dist/types-ts4.5/utils/snapping.d.ts +3 -2
- package/docs/0-intro.tsx +9 -7
- package/package.json +3 -3
- package/report.api.md +67 -66
- package/src/commands/clear.ts +36 -44
- package/src/commands/collapse.ts +8 -8
- package/src/commands/column-resize.ts +412 -452
- package/src/commands/delete.ts +14 -14
- package/src/commands/display-mode.ts +10 -11
- package/src/commands/go-to-next-cell.ts +48 -54
- package/src/commands/hover.ts +210 -227
- package/src/commands/index.ts +35 -35
- package/src/commands/insert.ts +208 -235
- package/src/commands/misc.ts +655 -748
- package/src/commands/referentiality.ts +9 -9
- package/src/commands/selection.ts +433 -563
- package/src/commands/sort.ts +68 -86
- package/src/commands/split-cell.ts +14 -14
- package/src/commands/toggle.ts +69 -67
- package/src/commands-with-analytics.ts +570 -639
- package/src/create-plugin-config.ts +13 -13
- package/src/event-handlers.ts +513 -612
- package/src/handlers.ts +120 -133
- package/src/nodeviews/ExternalDropTargets.tsx +68 -73
- package/src/nodeviews/OverflowShadowsObserver.ts +148 -157
- package/src/nodeviews/TableCell.ts +47 -54
- package/src/nodeviews/TableComponent.tsx +1018 -1112
- package/src/nodeviews/TableComponentWithSharedState.tsx +91 -94
- package/src/nodeviews/TableContainer.tsx +384 -340
- package/src/nodeviews/TableNodeViewBase.ts +19 -24
- package/src/nodeviews/TableResizer.tsx +642 -653
- package/src/nodeviews/TableRow.ts +580 -629
- package/src/nodeviews/TableStickyScrollbar.ts +173 -190
- package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +8 -8
- package/src/nodeviews/__mocks__/OverridableMock.ts +14 -15
- package/src/nodeviews/table.tsx +345 -375
- package/src/nodeviews/types.ts +21 -24
- package/src/nodeviews/update-overflow-shadows.ts +8 -14
- package/src/plugin.tsx +578 -603
- package/src/pm-plugins/analytics/actions.ts +10 -12
- package/src/pm-plugins/analytics/commands.ts +31 -37
- package/src/pm-plugins/analytics/plugin-factory.ts +4 -2
- package/src/pm-plugins/analytics/plugin-key.ts +1 -3
- package/src/pm-plugins/analytics/plugin.ts +60 -70
- package/src/pm-plugins/analytics/reducer.ts +19 -19
- package/src/pm-plugins/analytics/types.ts +10 -10
- package/src/pm-plugins/analytics/utils/moved-event.ts +38 -38
- package/src/pm-plugins/decorations/plugin.ts +58 -77
- package/src/pm-plugins/decorations/utils/column-controls.ts +59 -71
- package/src/pm-plugins/decorations/utils/column-resizing.ts +50 -57
- package/src/pm-plugins/decorations/utils/compose-decorations.ts +6 -6
- package/src/pm-plugins/decorations/utils/index.ts +3 -6
- package/src/pm-plugins/decorations/utils/types.ts +7 -12
- package/src/pm-plugins/default-table-selection.ts +3 -3
- package/src/pm-plugins/drag-and-drop/actions.ts +25 -25
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +158 -190
- package/src/pm-plugins/drag-and-drop/commands.ts +154 -170
- package/src/pm-plugins/drag-and-drop/consts.ts +4 -5
- package/src/pm-plugins/drag-and-drop/plugin-factory.ts +23 -20
- package/src/pm-plugins/drag-and-drop/plugin-key.ts +1 -3
- package/src/pm-plugins/drag-and-drop/plugin.ts +329 -383
- package/src/pm-plugins/drag-and-drop/reducer.ts +30 -30
- package/src/pm-plugins/drag-and-drop/types.ts +8 -8
- package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +38 -41
- package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +3 -6
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +57 -70
- package/src/pm-plugins/keymap.ts +208 -220
- package/src/pm-plugins/main.ts +348 -400
- package/src/pm-plugins/plugin-factory.ts +32 -34
- package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +83 -97
- package/src/pm-plugins/sticky-headers/commands.ts +2 -6
- package/src/pm-plugins/sticky-headers/plugin-key.ts +1 -3
- package/src/pm-plugins/sticky-headers/plugin-state.ts +41 -44
- package/src/pm-plugins/sticky-headers/plugin.ts +4 -4
- package/src/pm-plugins/sticky-headers/types.ts +8 -8
- package/src/pm-plugins/sticky-headers/util.ts +10 -10
- package/src/pm-plugins/table-analytics.ts +70 -72
- package/src/pm-plugins/table-local-id.ts +180 -184
- package/src/pm-plugins/table-resizing/commands.ts +72 -85
- package/src/pm-plugins/table-resizing/event-handlers.ts +298 -317
- package/src/pm-plugins/table-resizing/plugin-factory.ts +10 -10
- package/src/pm-plugins/table-resizing/plugin-key.ts +1 -3
- package/src/pm-plugins/table-resizing/plugin.ts +61 -68
- package/src/pm-plugins/table-resizing/reducer.ts +30 -33
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +84 -84
- package/src/pm-plugins/table-resizing/utils/column-state.ts +78 -81
- package/src/pm-plugins/table-resizing/utils/content-width.ts +94 -114
- package/src/pm-plugins/table-resizing/utils/dom.ts +93 -110
- package/src/pm-plugins/table-resizing/utils/index.ts +29 -34
- package/src/pm-plugins/table-resizing/utils/misc.ts +94 -119
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +93 -106
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +240 -257
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +343 -372
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +202 -207
- package/src/pm-plugins/table-resizing/utils/types.ts +17 -17
- package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +1 -2
- package/src/pm-plugins/table-selection-keymap.ts +25 -51
- package/src/pm-plugins/table-width.ts +191 -204
- package/src/pm-plugins/view-mode-sort/index.ts +223 -227
- package/src/pm-plugins/view-mode-sort/plugin-key.ts +3 -2
- package/src/pm-plugins/view-mode-sort/types.ts +12 -12
- package/src/pm-plugins/view-mode-sort/utils.ts +108 -117
- package/src/reducer.ts +139 -155
- package/src/toolbar.tsx +815 -905
- package/src/transforms/column-width.ts +186 -213
- package/src/transforms/delete-columns.ts +208 -222
- package/src/transforms/delete-rows.ts +117 -121
- package/src/transforms/fix-tables.ts +190 -215
- package/src/transforms/merge.ts +263 -269
- package/src/transforms/replace-table.ts +27 -43
- package/src/transforms/split.ts +65 -75
- package/src/types.ts +421 -427
- package/src/ui/ColumnResizeWidget/index.tsx +40 -47
- package/src/ui/DragHandle/HandleIconComponent.tsx +9 -13
- package/src/ui/DragHandle/index.tsx +221 -250
- package/src/ui/DragPreview/index.tsx +35 -35
- package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +33 -41
- package/src/ui/FloatingContextualButton/FixedButton.tsx +154 -157
- package/src/ui/FloatingContextualButton/index.tsx +109 -115
- package/src/ui/FloatingContextualButton/styles.ts +43 -46
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +634 -694
- package/src/ui/FloatingContextualMenu/index.tsx +83 -101
- package/src/ui/FloatingContextualMenu/styles.ts +57 -65
- package/src/ui/FloatingDeleteButton/DeleteButton.tsx +37 -37
- package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +47 -57
- package/src/ui/FloatingDeleteButton/index.tsx +319 -350
- package/src/ui/FloatingDragMenu/DragMenu.tsx +555 -596
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +152 -162
- package/src/ui/FloatingDragMenu/index.tsx +88 -102
- package/src/ui/FloatingDragMenu/styles.ts +51 -54
- package/src/ui/FloatingInsertButton/InsertButton.tsx +204 -217
- package/src/ui/FloatingInsertButton/getPopupOptions.ts +100 -115
- package/src/ui/FloatingInsertButton/index.tsx +248 -292
- package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +24 -29
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +308 -329
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +85 -94
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +46 -46
- package/src/ui/TableFloatingColumnControls/index.tsx +116 -136
- package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +79 -91
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +95 -102
- package/src/ui/TableFloatingControls/CornerControls/index.tsx +1 -4
- package/src/ui/TableFloatingControls/CornerControls/types.ts +8 -8
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +50 -50
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +111 -124
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +86 -105
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +305 -341
- package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +72 -75
- package/src/ui/TableFloatingControls/index.tsx +191 -193
- package/src/ui/TableFullWidthLabel/index.tsx +20 -20
- package/src/ui/common-styles.ts +880 -912
- package/src/ui/consts.ts +29 -74
- package/src/ui/icons/AddColLeftIcon.tsx +33 -39
- package/src/ui/icons/AddColRightIcon.tsx +33 -39
- package/src/ui/icons/AddRowAboveIcon.tsx +16 -22
- package/src/ui/icons/AddRowBelowIcon.tsx +33 -39
- package/src/ui/icons/DisplayModeIcon.tsx +31 -31
- package/src/ui/icons/DragHandleDisabledIcon.tsx +19 -21
- package/src/ui/icons/DragHandleIcon.tsx +12 -12
- package/src/ui/icons/DragInMotionIcon.tsx +45 -52
- package/src/ui/icons/MergeCellsIcon.tsx +22 -28
- package/src/ui/icons/MinimisedHandle.tsx +9 -9
- package/src/ui/icons/SplitCellIcon.tsx +30 -36
- package/src/ui/ui-styles.ts +769 -798
- package/src/utils/alignment.ts +1 -1
- package/src/utils/analytics.ts +192 -208
- package/src/utils/collapse.ts +55 -64
- package/src/utils/column-controls.ts +237 -254
- package/src/utils/create.ts +30 -30
- package/src/utils/decoration.ts +482 -502
- package/src/utils/dom.ts +127 -134
- package/src/utils/drag-menu.ts +322 -373
- package/src/utils/get-allow-add-column-custom-step.ts +4 -5
- package/src/utils/guidelines.ts +16 -21
- package/src/utils/index.ts +68 -68
- package/src/utils/merged-cells.ts +245 -254
- package/src/utils/nodes.ts +91 -106
- package/src/utils/paste.ts +119 -135
- package/src/utils/row-controls.ts +199 -213
- package/src/utils/selection.ts +77 -87
- package/src/utils/snapping.ts +87 -100
- package/src/utils/table.ts +44 -44
- package/src/utils/transforms.ts +5 -5
- package/src/utils/update-plugin-state-decorations.ts +5 -9
package/src/plugin.tsx
CHANGED
|
@@ -3,12 +3,12 @@ import React from 'react';
|
|
|
3
3
|
import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
4
4
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
ACTION,
|
|
7
|
+
ACTION_SUBJECT,
|
|
8
|
+
ACTION_SUBJECT_ID,
|
|
9
|
+
EVENT_TYPE,
|
|
10
|
+
INPUT_METHOD,
|
|
11
|
+
TABLE_ACTION,
|
|
12
12
|
} from '@atlaskit/editor-common/analytics';
|
|
13
13
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
14
14
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
@@ -16,13 +16,13 @@ import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
|
16
16
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
17
17
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
18
18
|
import type {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
Command,
|
|
20
|
+
EditorCommand,
|
|
21
|
+
EditorPlugin,
|
|
22
|
+
GetEditorContainerWidth,
|
|
23
|
+
GetEditorFeatureFlags,
|
|
24
|
+
NextEditorPlugin,
|
|
25
|
+
OptionalPlugin,
|
|
26
26
|
} from '@atlaskit/editor-common/types';
|
|
27
27
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
28
28
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
@@ -45,8 +45,8 @@ import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analyti
|
|
|
45
45
|
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
46
46
|
import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
|
|
47
47
|
import {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
createPlugin as createDragAndDropPlugin,
|
|
49
|
+
pluginKey as dragAndDropPluginKey,
|
|
50
50
|
} from './pm-plugins/drag-and-drop';
|
|
51
51
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
52
52
|
import { createPlugin } from './pm-plugins/main';
|
|
@@ -54,29 +54,25 @@ import { getPluginState } from './pm-plugins/plugin-factory';
|
|
|
54
54
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
55
55
|
import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
|
|
56
56
|
import {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
createPlugin as createStickyHeadersPlugin,
|
|
58
|
+
findStickyHeaderForTable,
|
|
59
|
+
pluginKey as stickyHeadersPluginKey,
|
|
60
60
|
} from './pm-plugins/sticky-headers';
|
|
61
61
|
import { createPlugin as createTableOverflowAnalyticsPlugin } from './pm-plugins/table-analytics';
|
|
62
62
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
63
63
|
import {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
createPlugin as createFlexiResizingPlugin,
|
|
65
|
+
getPluginState as getFlexiResizingPlugin,
|
|
66
|
+
pluginKey as tableResizingPluginKey,
|
|
67
67
|
} from './pm-plugins/table-resizing';
|
|
68
68
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
69
69
|
import {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
createPlugin as createTableWidthPlugin,
|
|
71
|
+
pluginKey as tableWidthPluginKey,
|
|
72
72
|
} from './pm-plugins/table-width';
|
|
73
73
|
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
74
74
|
import { getToolbarConfig } from './toolbar';
|
|
75
|
-
import type {
|
|
76
|
-
ColumnResizingPluginState,
|
|
77
|
-
PluginConfig,
|
|
78
|
-
TableSharedState,
|
|
79
|
-
} from './types';
|
|
75
|
+
import type { ColumnResizingPluginState, PluginConfig, TableSharedState } from './types';
|
|
80
76
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
81
77
|
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
82
78
|
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
@@ -87,16 +83,16 @@ import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
|
87
83
|
import { createTableWithWidth } from './utils';
|
|
88
84
|
|
|
89
85
|
export interface TablePluginOptions {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
tableOptions: PluginConfig;
|
|
87
|
+
tableResizingEnabled?: boolean;
|
|
88
|
+
dragAndDropEnabled?: boolean;
|
|
89
|
+
allowContextualMenu?: boolean;
|
|
90
|
+
// TODO these two need to be rethought
|
|
91
|
+
fullWidthEnabled?: boolean;
|
|
92
|
+
wasFullWidthEnabled?: boolean;
|
|
93
|
+
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
94
|
+
isTableScalingEnabled?: boolean;
|
|
95
|
+
isTableAlignmentEnabled?: boolean;
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
|
|
@@ -105,41 +101,41 @@ const defaultGetEditorFeatureFlags = () => ({});
|
|
|
105
101
|
|
|
106
102
|
// TODO: duplicating type instead of importing media plugin causing a circular dependency
|
|
107
103
|
type MediaPlugin = NextEditorPlugin<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
'media',
|
|
105
|
+
{
|
|
106
|
+
pluginConfiguration: any;
|
|
107
|
+
dependencies: any;
|
|
108
|
+
sharedState: any;
|
|
109
|
+
actions: any;
|
|
110
|
+
}
|
|
115
111
|
>;
|
|
116
112
|
|
|
117
113
|
export type TablePlugin = NextEditorPlugin<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
114
|
+
'table',
|
|
115
|
+
{
|
|
116
|
+
pluginConfiguration: TablePluginOptions | undefined;
|
|
117
|
+
actions: {
|
|
118
|
+
insertTable: InsertTableAction;
|
|
119
|
+
};
|
|
120
|
+
sharedState?: TableSharedState;
|
|
121
|
+
commands: {
|
|
122
|
+
insertTableWithSize: (
|
|
123
|
+
rowsCount: number,
|
|
124
|
+
colsCount: number,
|
|
125
|
+
inputMethod?: INPUT_METHOD.PICKER,
|
|
126
|
+
) => EditorCommand;
|
|
127
|
+
};
|
|
128
|
+
dependencies: [
|
|
129
|
+
AnalyticsPlugin,
|
|
130
|
+
ContentInsertionPlugin,
|
|
131
|
+
WidthPlugin,
|
|
132
|
+
GuidelinePlugin,
|
|
133
|
+
SelectionPlugin,
|
|
134
|
+
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
135
|
+
OptionalPlugin<MediaPlugin>,
|
|
136
|
+
OptionalPlugin<EditorViewModePlugin>,
|
|
137
|
+
];
|
|
138
|
+
}
|
|
143
139
|
>;
|
|
144
140
|
|
|
145
141
|
/**
|
|
@@ -147,539 +143,518 @@ export type TablePlugin = NextEditorPlugin<
|
|
|
147
143
|
* from `@atlaskit/editor-core`.
|
|
148
144
|
*/
|
|
149
145
|
const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
663
|
-
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
664
|
-
attributes: {
|
|
665
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT,
|
|
666
|
-
localId: tableNode.attrs.localId,
|
|
667
|
-
},
|
|
668
|
-
eventType: EVENT_TYPE.TRACK,
|
|
669
|
-
})(tr);
|
|
670
|
-
return tr;
|
|
671
|
-
},
|
|
672
|
-
},
|
|
673
|
-
],
|
|
674
|
-
floatingToolbar: getToolbarConfig(
|
|
675
|
-
defaultGetEditorContainerWidth,
|
|
676
|
-
editorAnalyticsAPI,
|
|
677
|
-
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
678
|
-
() => editorViewRef.current,
|
|
679
|
-
options,
|
|
680
|
-
)(pluginConfig(options?.tableOptions)),
|
|
681
|
-
},
|
|
682
|
-
};
|
|
146
|
+
const editorViewRef: Record<'current', EditorView | null> = { current: null };
|
|
147
|
+
const defaultGetEditorContainerWidth: GetEditorContainerWidth = () => {
|
|
148
|
+
return (
|
|
149
|
+
api?.width?.sharedState.currentState() ?? {
|
|
150
|
+
width: document?.body?.offsetWidth ?? 500,
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
const editorAnalyticsAPI = api?.analytics?.actions;
|
|
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
|
+
const tablePluginState = getPluginState(editorState);
|
|
167
|
+
const tableResizingPluginState = getFlexiResizingPlugin(editorState);
|
|
168
|
+
const tableWidthResizingPluginState = tableWidthPluginKey.getState(editorState);
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
isFullWidthModeEnabled: !!options?.fullWidthEnabled,
|
|
172
|
+
wasFullWidthModeEnabled: !!options?.wasFullWidthEnabled,
|
|
173
|
+
isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
|
|
174
|
+
isHeaderColumnEnabled: tablePluginState.isHeaderColumnEnabled,
|
|
175
|
+
ordering: tablePluginState.ordering,
|
|
176
|
+
isResizing: !!(
|
|
177
|
+
tableResizingPluginState?.dragging || tableWidthResizingPluginState?.resizing
|
|
178
|
+
),
|
|
179
|
+
isTableResizing: tableWidthResizingPluginState?.resizing,
|
|
180
|
+
isInDanger: tablePluginState.isInDanger,
|
|
181
|
+
hoveredRows: tablePluginState.hoveredRows,
|
|
182
|
+
hoveredCell: tablePluginState.hoveredCell,
|
|
183
|
+
isTableHovered: tablePluginState.isTableHovered,
|
|
184
|
+
isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
|
|
185
|
+
// IMPORTANT: Need to continue to pass tableNode to control re-renders
|
|
186
|
+
// TableComponent listens for node attribute changes to update colgroups
|
|
187
|
+
tableNode: tablePluginState.tableNode,
|
|
188
|
+
widthToWidest: tablePluginState.widthToWidest,
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
actions: {
|
|
193
|
+
insertTable:
|
|
194
|
+
(analyticsPayload): Command =>
|
|
195
|
+
(state, dispatch) => {
|
|
196
|
+
const node = createTableWithWidth({
|
|
197
|
+
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
198
|
+
isTableAlignmentEnabled: options?.isTableAlignmentEnabled,
|
|
199
|
+
isFullWidthModeEnabled: options?.fullWidthEnabled,
|
|
200
|
+
})(state.schema);
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
api?.contentInsertion?.actions?.insert({
|
|
204
|
+
state,
|
|
205
|
+
dispatch,
|
|
206
|
+
node,
|
|
207
|
+
|
|
208
|
+
options: {
|
|
209
|
+
selectNodeInserted: false,
|
|
210
|
+
analyticsPayload: {
|
|
211
|
+
...analyticsPayload,
|
|
212
|
+
attributes: {
|
|
213
|
+
...analyticsPayload.attributes,
|
|
214
|
+
localId: node.attrs.localId,
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
}) ?? false
|
|
219
|
+
);
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
commands: {
|
|
224
|
+
insertTableWithSize: insertTableWithSize(
|
|
225
|
+
options?.fullWidthEnabled,
|
|
226
|
+
options?.isTableScalingEnabled,
|
|
227
|
+
options?.isTableAlignmentEnabled,
|
|
228
|
+
api?.analytics?.actions,
|
|
229
|
+
),
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
nodes() {
|
|
233
|
+
return [
|
|
234
|
+
{ name: 'table', node: table },
|
|
235
|
+
{ name: 'tableHeader', node: tableHeader },
|
|
236
|
+
{ name: 'tableRow', node: tableRow },
|
|
237
|
+
{ name: 'tableCell', node: tableCell },
|
|
238
|
+
];
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
pmPlugins() {
|
|
242
|
+
const plugins: ReturnType<NonNullable<EditorPlugin['pmPlugins']>> = [
|
|
243
|
+
{
|
|
244
|
+
name: 'table',
|
|
245
|
+
plugin: ({
|
|
246
|
+
dispatchAnalyticsEvent,
|
|
247
|
+
dispatch,
|
|
248
|
+
portalProviderAPI,
|
|
249
|
+
eventDispatcher,
|
|
250
|
+
getIntl,
|
|
251
|
+
}) => {
|
|
252
|
+
const {
|
|
253
|
+
fullWidthEnabled,
|
|
254
|
+
wasFullWidthEnabled,
|
|
255
|
+
tableResizingEnabled,
|
|
256
|
+
|
|
257
|
+
tableOptions,
|
|
258
|
+
getEditorFeatureFlags,
|
|
259
|
+
dragAndDropEnabled,
|
|
260
|
+
isTableScalingEnabled,
|
|
261
|
+
isTableAlignmentEnabled,
|
|
262
|
+
} = options || ({} as TablePluginOptions);
|
|
263
|
+
|
|
264
|
+
return createPlugin(
|
|
265
|
+
dispatchAnalyticsEvent,
|
|
266
|
+
dispatch,
|
|
267
|
+
portalProviderAPI,
|
|
268
|
+
eventDispatcher,
|
|
269
|
+
pluginConfig(tableOptions),
|
|
270
|
+
defaultGetEditorContainerWidth,
|
|
271
|
+
getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
272
|
+
getIntl,
|
|
273
|
+
tableResizingEnabled,
|
|
274
|
+
fullWidthEnabled,
|
|
275
|
+
wasFullWidthEnabled,
|
|
276
|
+
dragAndDropEnabled,
|
|
277
|
+
editorAnalyticsAPI,
|
|
278
|
+
api,
|
|
279
|
+
isTableScalingEnabled,
|
|
280
|
+
isTableAlignmentEnabled,
|
|
281
|
+
);
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: 'tablePMColResizing',
|
|
286
|
+
plugin: ({ dispatch }) => {
|
|
287
|
+
const { fullWidthEnabled, tableOptions, getEditorFeatureFlags, isTableScalingEnabled } =
|
|
288
|
+
options || ({} as TablePluginOptions);
|
|
289
|
+
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
290
|
+
return allowColumnResizing
|
|
291
|
+
? createFlexiResizingPlugin(
|
|
292
|
+
dispatch,
|
|
293
|
+
{
|
|
294
|
+
lastColumnResizable: !fullWidthEnabled,
|
|
295
|
+
} as ColumnResizingPluginState,
|
|
296
|
+
defaultGetEditorContainerWidth,
|
|
297
|
+
getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
298
|
+
editorAnalyticsAPI,
|
|
299
|
+
isTableScalingEnabled || false,
|
|
300
|
+
)
|
|
301
|
+
: undefined;
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
{ name: 'tableEditing', plugin: () => createDecorationsPlugin() },
|
|
305
|
+
// Needs to be lower priority than editor-tables.tableEditing
|
|
306
|
+
// plugin as it is currently swallowing backspace events inside tables
|
|
307
|
+
{
|
|
308
|
+
name: 'tableKeymap',
|
|
309
|
+
plugin: ({ getIntl }) => {
|
|
310
|
+
const {
|
|
311
|
+
dragAndDropEnabled,
|
|
312
|
+
isTableScalingEnabled = false,
|
|
313
|
+
isTableAlignmentEnabled = false,
|
|
314
|
+
fullWidthEnabled = false,
|
|
315
|
+
} = options || ({} as TablePluginOptions);
|
|
316
|
+
return keymapPlugin(
|
|
317
|
+
defaultGetEditorContainerWidth,
|
|
318
|
+
editorAnalyticsAPI,
|
|
319
|
+
dragAndDropEnabled,
|
|
320
|
+
isTableScalingEnabled,
|
|
321
|
+
isTableAlignmentEnabled,
|
|
322
|
+
fullWidthEnabled,
|
|
323
|
+
api,
|
|
324
|
+
getIntl,
|
|
325
|
+
);
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: 'tableSelectionKeymap',
|
|
330
|
+
plugin: () => tableSelectionKeymapPlugin(api?.selection),
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: 'tableEditing',
|
|
334
|
+
plugin: () => {
|
|
335
|
+
const { dragAndDropEnabled } = options || ({} as TablePluginOptions);
|
|
336
|
+
|
|
337
|
+
return tableEditing({
|
|
338
|
+
reportFixedTable: ({ tr, reason }: { tr: Transaction; reason: string }) => {
|
|
339
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
340
|
+
action: TABLE_ACTION.FIXED,
|
|
341
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
342
|
+
actionSubjectId: null,
|
|
343
|
+
attributes: {
|
|
344
|
+
reason,
|
|
345
|
+
},
|
|
346
|
+
eventType: EVENT_TYPE.TRACK,
|
|
347
|
+
})(tr);
|
|
348
|
+
},
|
|
349
|
+
dragAndDropEnabled,
|
|
350
|
+
}) as SafePlugin;
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: 'tableStickyHeaders',
|
|
355
|
+
plugin: ({ dispatch, eventDispatcher }) =>
|
|
356
|
+
options && options.tableOptions.stickyHeaders
|
|
357
|
+
? createStickyHeadersPlugin(dispatch, () => [])
|
|
358
|
+
: undefined,
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: 'tableDragAndDrop',
|
|
362
|
+
plugin: ({ dispatch }) => {
|
|
363
|
+
return options?.dragAndDropEnabled
|
|
364
|
+
? createDragAndDropPlugin(dispatch, editorAnalyticsAPI)
|
|
365
|
+
: undefined;
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: 'tableViewModeSort',
|
|
370
|
+
plugin: () => {
|
|
371
|
+
return getBooleanFF('platform.editor.table.live-pages-sorting_4malx') &&
|
|
372
|
+
api?.editorViewMode
|
|
373
|
+
? createViewModeSortPlugin(api.editorViewMode)
|
|
374
|
+
: undefined;
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: 'tableLocalId',
|
|
379
|
+
plugin: ({ dispatch }) => createTableLocalIdPlugin(dispatch),
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
name: 'tableWidth',
|
|
383
|
+
plugin: ({ dispatchAnalyticsEvent, dispatch }) =>
|
|
384
|
+
options?.tableResizingEnabled
|
|
385
|
+
? createTableWidthPlugin(
|
|
386
|
+
dispatch,
|
|
387
|
+
dispatchAnalyticsEvent,
|
|
388
|
+
options?.fullWidthEnabled ?? false,
|
|
389
|
+
options?.isTableScalingEnabled ?? false,
|
|
390
|
+
options?.isTableAlignmentEnabled ?? false,
|
|
391
|
+
)
|
|
392
|
+
: undefined,
|
|
393
|
+
},
|
|
394
|
+
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
395
|
+
{
|
|
396
|
+
name: 'tableOverflowAnalyticsPlugin',
|
|
397
|
+
plugin: ({ dispatch, dispatchAnalyticsEvent }) =>
|
|
398
|
+
createTableOverflowAnalyticsPlugin(
|
|
399
|
+
dispatch,
|
|
400
|
+
dispatchAnalyticsEvent,
|
|
401
|
+
options?.tableResizingEnabled ?? false,
|
|
402
|
+
),
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: 'tableAnalyticsPlugin',
|
|
406
|
+
plugin: ({ dispatch, dispatchAnalyticsEvent }) =>
|
|
407
|
+
createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent),
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: 'tableGetEditorViewReferencePlugin',
|
|
411
|
+
plugin: () => {
|
|
412
|
+
return new SafePlugin({
|
|
413
|
+
view: (editorView) => {
|
|
414
|
+
editorViewRef.current = editorView;
|
|
415
|
+
return {
|
|
416
|
+
destroy: () => {
|
|
417
|
+
editorViewRef.current = null;
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
},
|
|
421
|
+
});
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
];
|
|
425
|
+
|
|
426
|
+
// Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
|
|
427
|
+
// https://github.com/ProseMirror/prosemirror/issues/934
|
|
428
|
+
if (browser.safari) {
|
|
429
|
+
plugins.push({
|
|
430
|
+
name: 'tableSafariDeleteCompositionTextIssueWorkaround',
|
|
431
|
+
plugin: () => {
|
|
432
|
+
return createTableSafariDeleteCompositionTextIssueWorkaroundPlugin();
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return plugins;
|
|
438
|
+
},
|
|
439
|
+
|
|
440
|
+
contentComponent({
|
|
441
|
+
editorView,
|
|
442
|
+
popupsMountPoint,
|
|
443
|
+
popupsBoundariesElement,
|
|
444
|
+
popupsScrollableElement,
|
|
445
|
+
dispatchAnalyticsEvent,
|
|
446
|
+
}) {
|
|
447
|
+
return (
|
|
448
|
+
<ErrorBoundary
|
|
449
|
+
component={ACTION_SUBJECT.TABLES_PLUGIN}
|
|
450
|
+
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
451
|
+
fallbackComponent={null}
|
|
452
|
+
>
|
|
453
|
+
<WithPluginState
|
|
454
|
+
plugins={{
|
|
455
|
+
tableAnalyticsPluginState: tableAnalyticsPluginKey,
|
|
456
|
+
tablePluginState: pluginKey,
|
|
457
|
+
tableWidthPluginState: tableWidthPluginKey,
|
|
458
|
+
tableResizingPluginState: tableResizingPluginKey,
|
|
459
|
+
stickyHeadersState: stickyHeadersPluginKey,
|
|
460
|
+
dragAndDropState: dragAndDropPluginKey,
|
|
461
|
+
}}
|
|
462
|
+
render={({
|
|
463
|
+
tableResizingPluginState: resizingPluginState,
|
|
464
|
+
stickyHeadersState,
|
|
465
|
+
tablePluginState,
|
|
466
|
+
tableWidthPluginState,
|
|
467
|
+
dragAndDropState,
|
|
468
|
+
}) => {
|
|
469
|
+
const isColumnResizing = resizingPluginState?.dragging;
|
|
470
|
+
const isTableResizing = tableWidthPluginState?.resizing;
|
|
471
|
+
const resizingTableLocalId = tableWidthPluginState?.tableLocalId;
|
|
472
|
+
const resizingTableRef = tableWidthPluginState?.tableRef;
|
|
473
|
+
const isResizing = isColumnResizing || isTableResizing;
|
|
474
|
+
const widthToWidest = tablePluginState?.widthToWidest;
|
|
475
|
+
|
|
476
|
+
const {
|
|
477
|
+
tableNode,
|
|
478
|
+
tablePos,
|
|
479
|
+
targetCellPosition,
|
|
480
|
+
isContextualMenuOpen,
|
|
481
|
+
tableRef,
|
|
482
|
+
pluginConfig,
|
|
483
|
+
insertColumnButtonIndex,
|
|
484
|
+
insertRowButtonIndex,
|
|
485
|
+
isHeaderColumnEnabled,
|
|
486
|
+
isHeaderRowEnabled,
|
|
487
|
+
isDragAndDropEnabled,
|
|
488
|
+
tableWrapperTarget,
|
|
489
|
+
} = tablePluginState!;
|
|
490
|
+
|
|
491
|
+
const { allowControls } = pluginConfig;
|
|
492
|
+
|
|
493
|
+
const stickyHeader = stickyHeadersState
|
|
494
|
+
? findStickyHeaderForTable(stickyHeadersState, tablePos)
|
|
495
|
+
: undefined;
|
|
496
|
+
|
|
497
|
+
return (
|
|
498
|
+
<>
|
|
499
|
+
{targetCellPosition &&
|
|
500
|
+
tableRef &&
|
|
501
|
+
!isResizing &&
|
|
502
|
+
options &&
|
|
503
|
+
options.allowContextualMenu && (
|
|
504
|
+
<FloatingContextualButton
|
|
505
|
+
isNumberColumnEnabled={tableNode && tableNode.attrs.isNumberColumnEnabled}
|
|
506
|
+
editorView={editorView}
|
|
507
|
+
tableNode={tableNode}
|
|
508
|
+
mountPoint={popupsMountPoint}
|
|
509
|
+
targetCellPosition={targetCellPosition}
|
|
510
|
+
scrollableElement={popupsScrollableElement}
|
|
511
|
+
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
512
|
+
isContextualMenuOpen={isContextualMenuOpen}
|
|
513
|
+
stickyHeader={stickyHeader}
|
|
514
|
+
tableWrapper={tableWrapperTarget}
|
|
515
|
+
/>
|
|
516
|
+
)}
|
|
517
|
+
{allowControls && (
|
|
518
|
+
<FloatingInsertButton
|
|
519
|
+
tableNode={tableNode}
|
|
520
|
+
tableRef={tableRef}
|
|
521
|
+
insertColumnButtonIndex={insertColumnButtonIndex}
|
|
522
|
+
insertRowButtonIndex={insertRowButtonIndex}
|
|
523
|
+
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
524
|
+
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
525
|
+
isDragAndDropEnabled={isDragAndDropEnabled}
|
|
526
|
+
editorView={editorView}
|
|
527
|
+
mountPoint={popupsMountPoint}
|
|
528
|
+
boundariesElement={popupsBoundariesElement}
|
|
529
|
+
scrollableElement={popupsScrollableElement}
|
|
530
|
+
hasStickyHeaders={stickyHeader && stickyHeader.sticky}
|
|
531
|
+
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
532
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
533
|
+
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
534
|
+
getEditorFeatureFlags={
|
|
535
|
+
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags
|
|
536
|
+
}
|
|
537
|
+
/>
|
|
538
|
+
)}
|
|
539
|
+
{options?.allowContextualMenu && (
|
|
540
|
+
<FloatingContextualMenu
|
|
541
|
+
editorView={editorView}
|
|
542
|
+
mountPoint={popupsMountPoint}
|
|
543
|
+
boundariesElement={popupsBoundariesElement}
|
|
544
|
+
targetCellPosition={targetCellPosition}
|
|
545
|
+
isOpen={Boolean(isContextualMenuOpen) && !isResizing}
|
|
546
|
+
pluginConfig={pluginConfig}
|
|
547
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
548
|
+
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
549
|
+
getEditorFeatureFlags={
|
|
550
|
+
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags
|
|
551
|
+
}
|
|
552
|
+
/>
|
|
553
|
+
)}
|
|
554
|
+
{isDragAndDropEnabled && (
|
|
555
|
+
<FloatingDragMenu
|
|
556
|
+
editorView={editorView}
|
|
557
|
+
mountPoint={popupsMountPoint}
|
|
558
|
+
boundariesElement={popupsBoundariesElement}
|
|
559
|
+
tableRef={tableRef as HTMLTableElement}
|
|
560
|
+
tableNode={tableNode}
|
|
561
|
+
targetCellPosition={targetCellPosition}
|
|
562
|
+
direction={dragAndDropState?.dragMenuDirection}
|
|
563
|
+
index={dragAndDropState?.dragMenuIndex}
|
|
564
|
+
isOpen={!!dragAndDropState?.isDragMenuOpen && !isResizing}
|
|
565
|
+
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
566
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
567
|
+
stickyHeaders={stickyHeader}
|
|
568
|
+
pluginConfig={pluginConfig}
|
|
569
|
+
isTableScalingEnabled={options?.isTableScalingEnabled}
|
|
570
|
+
getEditorFeatureFlags={
|
|
571
|
+
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags
|
|
572
|
+
}
|
|
573
|
+
/>
|
|
574
|
+
)}
|
|
575
|
+
{allowControls && !isDragAndDropEnabled && !isResizing && (
|
|
576
|
+
<FloatingDeleteButton
|
|
577
|
+
editorView={editorView}
|
|
578
|
+
selection={editorView.state.selection}
|
|
579
|
+
tableRef={tableRef as HTMLTableElement}
|
|
580
|
+
mountPoint={popupsMountPoint}
|
|
581
|
+
boundariesElement={popupsBoundariesElement}
|
|
582
|
+
scrollableElement={popupsScrollableElement}
|
|
583
|
+
stickyHeaders={stickyHeader}
|
|
584
|
+
isNumberColumnEnabled={tableNode && tableNode.attrs.isNumberColumnEnabled}
|
|
585
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
586
|
+
/>
|
|
587
|
+
)}
|
|
588
|
+
{options?.isTableScalingEnabled &&
|
|
589
|
+
isTableResizing &&
|
|
590
|
+
widthToWidest &&
|
|
591
|
+
resizingTableLocalId &&
|
|
592
|
+
resizingTableRef &&
|
|
593
|
+
widthToWidest[resizingTableLocalId] && (
|
|
594
|
+
<FloatingToolbarLabel
|
|
595
|
+
target={resizingTableRef}
|
|
596
|
+
content={<FullWidthDisplay />}
|
|
597
|
+
alignX={'center'}
|
|
598
|
+
alignY={'bottom'}
|
|
599
|
+
stick={true}
|
|
600
|
+
forcePlacement={true}
|
|
601
|
+
zIndex={akEditorFloatingPanelZIndex}
|
|
602
|
+
offset={[0, 10]}
|
|
603
|
+
/>
|
|
604
|
+
)}
|
|
605
|
+
</>
|
|
606
|
+
);
|
|
607
|
+
}}
|
|
608
|
+
/>
|
|
609
|
+
</ErrorBoundary>
|
|
610
|
+
);
|
|
611
|
+
},
|
|
612
|
+
|
|
613
|
+
pluginsOptions: {
|
|
614
|
+
quickInsert: ({ formatMessage }) => [
|
|
615
|
+
{
|
|
616
|
+
id: 'table',
|
|
617
|
+
title: formatMessage(messages.table),
|
|
618
|
+
description: formatMessage(messages.tableDescription),
|
|
619
|
+
keywords: ['cell', 'table'],
|
|
620
|
+
priority: 600,
|
|
621
|
+
keyshortcut: tooltip(toggleTable),
|
|
622
|
+
icon: () => <IconTable />,
|
|
623
|
+
action(insert, state) {
|
|
624
|
+
// see comment on tablesPlugin.getSharedState on usage
|
|
625
|
+
const tableState = api?.table?.sharedState.currentState();
|
|
626
|
+
|
|
627
|
+
const tableNode = createTableWithWidth({
|
|
628
|
+
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
629
|
+
isTableAlignmentEnabled: options?.isTableAlignmentEnabled,
|
|
630
|
+
isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
|
|
631
|
+
})(state.schema);
|
|
632
|
+
|
|
633
|
+
const tr = insert(tableNode);
|
|
634
|
+
|
|
635
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
636
|
+
action: ACTION.INSERTED,
|
|
637
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
638
|
+
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
639
|
+
attributes: {
|
|
640
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT,
|
|
641
|
+
localId: tableNode.attrs.localId,
|
|
642
|
+
},
|
|
643
|
+
eventType: EVENT_TYPE.TRACK,
|
|
644
|
+
})(tr);
|
|
645
|
+
return tr;
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
],
|
|
649
|
+
floatingToolbar: getToolbarConfig(
|
|
650
|
+
defaultGetEditorContainerWidth,
|
|
651
|
+
editorAnalyticsAPI,
|
|
652
|
+
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
653
|
+
() => editorViewRef.current,
|
|
654
|
+
options,
|
|
655
|
+
)(pluginConfig(options?.tableOptions)),
|
|
656
|
+
},
|
|
657
|
+
};
|
|
683
658
|
};
|
|
684
659
|
|
|
685
660
|
export default tablesPlugin;
|