@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
|
@@ -8,22 +8,12 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
8
8
|
import { injectIntl } from 'react-intl-next';
|
|
9
9
|
|
|
10
10
|
import type { TableColumnOrdering } from '@atlaskit/custom-steps';
|
|
11
|
-
import {
|
|
12
|
-
ACTION_SUBJECT,
|
|
13
|
-
EVENT_TYPE,
|
|
14
|
-
TABLE_ACTION,
|
|
15
|
-
} from '@atlaskit/editor-common/analytics';
|
|
11
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
16
12
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
17
13
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
18
|
-
import {
|
|
19
|
-
getParentNodeWidth,
|
|
20
|
-
getTableContainerWidth,
|
|
21
|
-
} from '@atlaskit/editor-common/node-width';
|
|
14
|
+
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
22
15
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
23
|
-
import type {
|
|
24
|
-
EditorContainerWidth,
|
|
25
|
-
GetEditorFeatureFlags,
|
|
26
|
-
} from '@atlaskit/editor-common/types';
|
|
16
|
+
import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
27
17
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
28
18
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
29
19
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -37,22 +27,19 @@ import { token } from '@atlaskit/tokens';
|
|
|
37
27
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
38
28
|
import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils';
|
|
39
29
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
40
|
-
import type {
|
|
41
|
-
RowStickyState,
|
|
42
|
-
StickyPluginState,
|
|
43
|
-
} from '../pm-plugins/sticky-headers';
|
|
30
|
+
import type { RowStickyState, StickyPluginState } from '../pm-plugins/sticky-headers';
|
|
44
31
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
findStickyHeaderForTable,
|
|
33
|
+
pluginKey as stickyHeadersPluginKey,
|
|
47
34
|
} from '../pm-plugins/sticky-headers';
|
|
48
35
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
49
36
|
import {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
COLUMN_MIN_WIDTH,
|
|
38
|
+
getLayoutSize,
|
|
39
|
+
getResizeState,
|
|
40
|
+
insertColgroupFromNode,
|
|
41
|
+
scaleTable,
|
|
42
|
+
updateColgroup,
|
|
56
43
|
} from '../pm-plugins/table-resizing/utils';
|
|
57
44
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
58
45
|
import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
|
|
@@ -62,12 +49,12 @@ import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
|
62
49
|
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
63
50
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
64
51
|
import {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
containsHeaderRow,
|
|
53
|
+
getAssistiveMessage,
|
|
54
|
+
isTableNested,
|
|
55
|
+
tablesHaveDifferentColumnWidths,
|
|
56
|
+
tablesHaveDifferentNoOfColumns,
|
|
57
|
+
tablesHaveDifferentNoOfRows,
|
|
71
58
|
} from '../utils';
|
|
72
59
|
|
|
73
60
|
import { ExternalDropTargets } from './ExternalDropTargets';
|
|
@@ -89,1093 +76,1012 @@ const initialOverflowCaptureTimeroutDelay = 300;
|
|
|
89
76
|
const isOverflowAnalyticsEnabled = false;
|
|
90
77
|
|
|
91
78
|
export interface ComponentProps {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
79
|
+
view: EditorView;
|
|
80
|
+
getNode: () => PmNode;
|
|
81
|
+
allowColumnResizing?: boolean;
|
|
82
|
+
eventDispatcher: EventDispatcher;
|
|
83
|
+
getPos: () => number | undefined;
|
|
84
|
+
options?: TableOptions;
|
|
85
|
+
|
|
86
|
+
contentDOM: (node: HTMLElement | null) => void;
|
|
87
|
+
containerWidth: EditorContainerWidth;
|
|
88
|
+
allowControls: boolean;
|
|
89
|
+
isHeaderRowEnabled: boolean;
|
|
90
|
+
isHeaderColumnEnabled: boolean;
|
|
91
|
+
isMediaFullscreen?: boolean;
|
|
92
|
+
isDragAndDropEnabled?: boolean;
|
|
93
|
+
isTableScalingEnabled?: boolean;
|
|
94
|
+
isTableAlignmentEnabled?: boolean;
|
|
95
|
+
tableActive: boolean;
|
|
96
|
+
ordering?: TableColumnOrdering;
|
|
97
|
+
isResizing?: boolean;
|
|
98
|
+
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
99
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
100
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
101
|
+
intl: IntlShape;
|
|
102
|
+
|
|
103
|
+
// marking props as option to ensure backward compatibility when platform.editor.table.use-shared-state-hook disabled
|
|
104
|
+
isInDanger?: boolean;
|
|
105
|
+
hoveredRows?: number[];
|
|
106
|
+
hoveredCell?: CellHoverMeta;
|
|
107
|
+
isTableHovered?: boolean;
|
|
108
|
+
isWholeTableInDanger?: boolean;
|
|
122
109
|
}
|
|
123
110
|
|
|
124
111
|
interface TableState {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
112
|
+
scroll: number;
|
|
113
|
+
parentWidth?: number;
|
|
114
|
+
stickyHeader?: RowStickyState;
|
|
115
|
+
[ShadowEvent.SHOW_BEFORE_SHADOW]: boolean;
|
|
116
|
+
[ShadowEvent.SHOW_AFTER_SHADOW]: boolean;
|
|
117
|
+
tableWrapperWidth?: number;
|
|
118
|
+
tableWrapperHeight?: number;
|
|
132
119
|
}
|
|
133
120
|
|
|
134
121
|
class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
isOverflowing,
|
|
1099
|
-
tableResizingEnabled: options?.isTableResizingEnabled || false,
|
|
1100
|
-
width: this.node.attrs.width || 0,
|
|
1101
|
-
parentWidth,
|
|
1102
|
-
},
|
|
1103
|
-
});
|
|
1104
|
-
|
|
1105
|
-
this.isInitialOverflowSent = true;
|
|
1106
|
-
}, initialOverflowCaptureTimeroutDelay);
|
|
1107
|
-
};
|
|
1108
|
-
|
|
1109
|
-
private handleAutoSize = () => {
|
|
1110
|
-
if (this.table) {
|
|
1111
|
-
const { view, getNode, getPos, containerWidth } = this.props;
|
|
1112
|
-
const node = getNode();
|
|
1113
|
-
const pos = getPos();
|
|
1114
|
-
if (!isValidPosition(pos, view.state)) {
|
|
1115
|
-
return;
|
|
1116
|
-
}
|
|
1117
|
-
autoSizeTable(view, node, this.table, pos, {
|
|
1118
|
-
containerWidth: containerWidth.width,
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
};
|
|
1122
|
-
|
|
1123
|
-
private handleWindowResize = () => {
|
|
1124
|
-
const { getNode, containerWidth } = this.props;
|
|
1125
|
-
const node = getNode();
|
|
1126
|
-
const layoutSize = this.tableNodeLayoutSize(node);
|
|
1127
|
-
|
|
1128
|
-
if (containerWidth.width > layoutSize) {
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
const parentWidth = this.getParentNodeWidth();
|
|
1133
|
-
this.scaleTableDebounced({
|
|
1134
|
-
parentWidth: parentWidth,
|
|
1135
|
-
});
|
|
1136
|
-
};
|
|
1137
|
-
|
|
1138
|
-
private getParentNodeWidth = () => {
|
|
1139
|
-
const {
|
|
1140
|
-
getPos,
|
|
1141
|
-
containerWidth,
|
|
1142
|
-
options,
|
|
1143
|
-
view: { state },
|
|
1144
|
-
} = this.props;
|
|
1145
|
-
const pos = getPos();
|
|
1146
|
-
if (!isValidPosition(pos, state)) {
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
const parentNodeWith = getParentNodeWidth(
|
|
1150
|
-
pos,
|
|
1151
|
-
state,
|
|
1152
|
-
containerWidth,
|
|
1153
|
-
options && options.isFullWidthModeEnabled,
|
|
1154
|
-
);
|
|
1155
|
-
|
|
1156
|
-
return parentNodeWith;
|
|
1157
|
-
};
|
|
1158
|
-
|
|
1159
|
-
private updateParentWidth = (width?: number) => {
|
|
1160
|
-
this.setState({ parentWidth: width });
|
|
1161
|
-
};
|
|
1162
|
-
|
|
1163
|
-
private tableNodeLayoutSize = (
|
|
1164
|
-
node: PmNode,
|
|
1165
|
-
containerWidth?: number,
|
|
1166
|
-
options?: TableOptions,
|
|
1167
|
-
) =>
|
|
1168
|
-
getLayoutSize(
|
|
1169
|
-
node.attrs.layout,
|
|
1170
|
-
containerWidth || this.props.containerWidth.width,
|
|
1171
|
-
options || this.props.options || {},
|
|
1172
|
-
);
|
|
1173
|
-
|
|
1174
|
-
private scaleTableDebounced = rafSchedule(this.scaleTable);
|
|
1175
|
-
private handleTableResizingDebounced = rafSchedule(this.handleTableResizing);
|
|
1176
|
-
private handleScrollDebounced = rafSchedule(this.handleScroll);
|
|
1177
|
-
private handleAutoSizeDebounced = rafSchedule(this.handleAutoSize);
|
|
1178
|
-
private handleWindowResizeDebounced = rafSchedule(this.handleWindowResize);
|
|
122
|
+
static displayName = 'TableComponent';
|
|
123
|
+
|
|
124
|
+
state: TableState = {
|
|
125
|
+
scroll: 0,
|
|
126
|
+
parentWidth: undefined,
|
|
127
|
+
[ShadowEvent.SHOW_BEFORE_SHADOW]: false,
|
|
128
|
+
[ShadowEvent.SHOW_AFTER_SHADOW]: false,
|
|
129
|
+
tableWrapperWidth: undefined,
|
|
130
|
+
tableWrapperHeight: undefined,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
private wrapper?: HTMLDivElement | null;
|
|
134
|
+
private table?: HTMLTableElement | null;
|
|
135
|
+
private node: PmNode;
|
|
136
|
+
private containerWidth?: EditorContainerWidth;
|
|
137
|
+
private wasResizing?: boolean;
|
|
138
|
+
private tableNodeWidth?: number;
|
|
139
|
+
private layoutSize?: number;
|
|
140
|
+
private overflowShadowsObserver?: OverflowShadowsObserver;
|
|
141
|
+
private stickyScrollbar?: TableStickyScrollbar;
|
|
142
|
+
|
|
143
|
+
private isInitialOverflowSent: boolean;
|
|
144
|
+
private initialOverflowCaptureTimerId?: ReturnType<typeof setTimeout>;
|
|
145
|
+
private resizeObserver?: ResizeObserver;
|
|
146
|
+
|
|
147
|
+
private dragAndDropCleanupFn?: CleanupFn;
|
|
148
|
+
|
|
149
|
+
constructor(props: ComponentProps) {
|
|
150
|
+
super(props);
|
|
151
|
+
const { options, containerWidth, getNode } = props;
|
|
152
|
+
this.node = getNode();
|
|
153
|
+
this.containerWidth = containerWidth;
|
|
154
|
+
this.isInitialOverflowSent = false;
|
|
155
|
+
|
|
156
|
+
// store table size using previous full-width mode so can detect if it has changed.
|
|
157
|
+
const isFullWidthModeEnabled = options ? options.wasFullWidthModeEnabled : false;
|
|
158
|
+
this.layoutSize = this.tableNodeLayoutSize(this.node, containerWidth.width, {
|
|
159
|
+
isFullWidthModeEnabled,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
163
|
+
for (let entry of entries) {
|
|
164
|
+
this.setState((prev) => {
|
|
165
|
+
return prev?.tableWrapperWidth === entry.contentRect?.width &&
|
|
166
|
+
prev?.tableWrapperHeight === entry.contentRect?.height
|
|
167
|
+
? prev
|
|
168
|
+
: {
|
|
169
|
+
...prev,
|
|
170
|
+
tableWrapperWidth: entry.contentRect.width,
|
|
171
|
+
tableWrapperHeight: entry.contentRect.height,
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Disable inline table editing and resizing controls in Firefox
|
|
178
|
+
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
179
|
+
if ('execCommand' in document) {
|
|
180
|
+
['enableObjectResizing', 'enableInlineTableEditing'].forEach((cmd) => {
|
|
181
|
+
if (document.queryCommandSupported(cmd)) {
|
|
182
|
+
document.execCommand(cmd, false, 'false');
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
componentDidMount() {
|
|
189
|
+
const {
|
|
190
|
+
allowColumnResizing,
|
|
191
|
+
eventDispatcher,
|
|
192
|
+
options,
|
|
193
|
+
isDragAndDropEnabled,
|
|
194
|
+
getNode,
|
|
195
|
+
getEditorFeatureFlags,
|
|
196
|
+
isTableScalingEnabled,
|
|
197
|
+
} = this.props;
|
|
198
|
+
|
|
199
|
+
if (getBooleanFF('platform.editor.table.live-pages-sorting_4malx')) {
|
|
200
|
+
const { mode } =
|
|
201
|
+
this.props.pluginInjectionApi?.editorViewMode?.sharedState.currentState() || {};
|
|
202
|
+
if (mode === 'view') {
|
|
203
|
+
this?.table?.addEventListener('mouseenter', this.handleMouseEnter);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (
|
|
208
|
+
isTableScalingEnabled &&
|
|
209
|
+
!getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
210
|
+
) {
|
|
211
|
+
this.handleColgroupUpdates(true);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (
|
|
215
|
+
isTableScalingEnabled &&
|
|
216
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
|
|
217
|
+
getNode().attrs.displayMode !== 'fixed'
|
|
218
|
+
) {
|
|
219
|
+
this.handleColgroupUpdates(true);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
223
|
+
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
224
|
+
passive: true,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
228
|
+
|
|
229
|
+
if (stickyScrollbar) {
|
|
230
|
+
if (this.table) {
|
|
231
|
+
this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (isDragAndDropEnabled) {
|
|
236
|
+
this.dragAndDropCleanupFn = combine(
|
|
237
|
+
...autoScrollerFactory({
|
|
238
|
+
tableWrapper: this.wrapper,
|
|
239
|
+
getNode,
|
|
240
|
+
}),
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (allowColumnResizing) {
|
|
246
|
+
/**
|
|
247
|
+
* We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
|
|
248
|
+
* Instead we use the resize event to only trigger updates when necessary.
|
|
249
|
+
*/
|
|
250
|
+
if (!options?.isTableResizingEnabled) {
|
|
251
|
+
window.addEventListener('resize', this.handleWindowResizeDebounced);
|
|
252
|
+
}
|
|
253
|
+
this.handleTableResizingDebounced();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const currentStickyState = stickyHeadersPluginKey.getState(this.props.view.state);
|
|
257
|
+
|
|
258
|
+
if (currentStickyState) {
|
|
259
|
+
this.onStickyState(currentStickyState);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
eventDispatcher.on((stickyHeadersPluginKey as any).key, this.onStickyState);
|
|
263
|
+
|
|
264
|
+
if (isOverflowAnalyticsEnabled) {
|
|
265
|
+
const initialIsOveflowing =
|
|
266
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
267
|
+
|
|
268
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
componentWillUnmount() {
|
|
273
|
+
const {
|
|
274
|
+
allowColumnResizing,
|
|
275
|
+
eventDispatcher,
|
|
276
|
+
options,
|
|
277
|
+
isDragAndDropEnabled,
|
|
278
|
+
getEditorFeatureFlags,
|
|
279
|
+
} = this.props;
|
|
280
|
+
if (this.wrapper && !isIE11) {
|
|
281
|
+
this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
285
|
+
this.dragAndDropCleanupFn();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
this.resizeObserver?.disconnect();
|
|
289
|
+
|
|
290
|
+
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
291
|
+
|
|
292
|
+
if (stickyScrollbar) {
|
|
293
|
+
if (this.stickyScrollbar) {
|
|
294
|
+
this.stickyScrollbar.dispose();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
this.handleScrollDebounced.cancel();
|
|
299
|
+
this.scaleTableDebounced.cancel();
|
|
300
|
+
this.handleTableResizingDebounced.cancel();
|
|
301
|
+
this.handleAutoSizeDebounced.cancel();
|
|
302
|
+
if (!options?.isTableResizingEnabled) {
|
|
303
|
+
this.handleWindowResizeDebounced.cancel();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!options?.isTableResizingEnabled && allowColumnResizing) {
|
|
307
|
+
window.removeEventListener('resize', this.handleWindowResizeDebounced);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (getBooleanFF('platform.editor.table.live-pages-sorting_4malx')) {
|
|
311
|
+
this?.table?.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (this.overflowShadowsObserver) {
|
|
315
|
+
this.overflowShadowsObserver.dispose();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
eventDispatcher.off((stickyHeadersPluginKey as any).key, this.onStickyState);
|
|
319
|
+
|
|
320
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
321
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
handleMouseEnter = () => {
|
|
326
|
+
const node = this.props.getNode();
|
|
327
|
+
const pos = this.props.getPos();
|
|
328
|
+
const tr = this.props.view.state.tr;
|
|
329
|
+
const tableId = node.attrs.localId;
|
|
330
|
+
tr.setMeta('mouseEnterTable', [tableId, node, pos]);
|
|
331
|
+
this.props.view.dispatch(tr);
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
handleColgroupUpdates(force = false) {
|
|
335
|
+
const { getNode, containerWidth, isResizing, view, getPos } = this.props;
|
|
336
|
+
|
|
337
|
+
if (!this.table) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Remove any widths styles after resizing preview is completed
|
|
342
|
+
this.table.style.width = '';
|
|
343
|
+
|
|
344
|
+
const tableRenderWidth = containerWidth.width - TABLE_EDITOR_MARGIN;
|
|
345
|
+
const tableNode = getNode();
|
|
346
|
+
const start = getPos() || 0;
|
|
347
|
+
const depth = view.state.doc.resolve(start).depth;
|
|
348
|
+
|
|
349
|
+
if (depth !== 0) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const tableNodeWidth = getTableContainerWidth(tableNode);
|
|
354
|
+
const isTableResizedFullWidth = tableNodeWidth === 1800 && this.wasResizing && !isResizing;
|
|
355
|
+
// Needed for undo / redo
|
|
356
|
+
const isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
357
|
+
const isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
358
|
+
const isNumberColumnChanged =
|
|
359
|
+
tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
360
|
+
const isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(tableNode, this.node);
|
|
361
|
+
|
|
362
|
+
const maybeScale =
|
|
363
|
+
isTableSquashed ||
|
|
364
|
+
isTableWidthChanged ||
|
|
365
|
+
isTableResizedFullWidth ||
|
|
366
|
+
isNumberColumnChanged ||
|
|
367
|
+
isNumberOfColumnsChanged;
|
|
368
|
+
|
|
369
|
+
if (force || maybeScale) {
|
|
370
|
+
const { width: containerWidthValue } = containerWidth;
|
|
371
|
+
const isWidthChanged = this.containerWidth?.width !== containerWidthValue;
|
|
372
|
+
const wasTableResized = hasTableBeenResized(this.node);
|
|
373
|
+
const isTableResized = hasTableBeenResized(tableNode);
|
|
374
|
+
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
375
|
+
const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
376
|
+
|
|
377
|
+
const shouldUpdateColgroup =
|
|
378
|
+
isWidthChanged ||
|
|
379
|
+
isColumnsDistributed ||
|
|
380
|
+
isTableResizedFullWidth ||
|
|
381
|
+
isTableWidthChanged ||
|
|
382
|
+
isTableDisplayModeChanged ||
|
|
383
|
+
isNumberColumnChanged ||
|
|
384
|
+
isNumberOfColumnsChanged;
|
|
385
|
+
|
|
386
|
+
if (force || (!isResizing && shouldUpdateColgroup)) {
|
|
387
|
+
const resizeState = getResizeState({
|
|
388
|
+
minWidth: COLUMN_MIN_WIDTH,
|
|
389
|
+
maxSize: tableRenderWidth,
|
|
390
|
+
table: tableNode,
|
|
391
|
+
tableRef: this.table,
|
|
392
|
+
start,
|
|
393
|
+
domAtPos: view.domAtPos.bind(view),
|
|
394
|
+
isTableScalingEnabled: true,
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
let shouldScaleOnColgroupUpdate = false;
|
|
398
|
+
if (
|
|
399
|
+
this.props.options?.isTableScalingEnabled &&
|
|
400
|
+
!getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
401
|
+
) {
|
|
402
|
+
shouldScaleOnColgroupUpdate = true;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (
|
|
406
|
+
this.props.options?.isTableScalingEnabled &&
|
|
407
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
|
|
408
|
+
tableNode.attrs.displayMode !== 'fixed'
|
|
409
|
+
) {
|
|
410
|
+
shouldScaleOnColgroupUpdate = true;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Request animation frame required for Firefox
|
|
414
|
+
requestAnimationFrame(() => {
|
|
415
|
+
updateColgroup(resizeState, this.table!, tableNode, shouldScaleOnColgroupUpdate);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
this.tableNodeWidth = tableNodeWidth;
|
|
420
|
+
this.wasResizing = isResizing;
|
|
421
|
+
this.containerWidth = containerWidth;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
componentDidUpdate(_: any, prevState: TableState) {
|
|
425
|
+
const {
|
|
426
|
+
view,
|
|
427
|
+
getNode,
|
|
428
|
+
isMediaFullscreen,
|
|
429
|
+
allowColumnResizing,
|
|
430
|
+
isResizing,
|
|
431
|
+
options,
|
|
432
|
+
isTableScalingEnabled, // we could use options.isTableScalingEnabled here
|
|
433
|
+
getPos,
|
|
434
|
+
} = this.props;
|
|
435
|
+
let { isInDanger } = this.props;
|
|
436
|
+
|
|
437
|
+
const table = findTable(view.state.selection);
|
|
438
|
+
|
|
439
|
+
if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
|
|
440
|
+
const pluginState = getPluginState(view.state);
|
|
441
|
+
isInDanger = pluginState.isInDanger;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let shouldScale = false;
|
|
445
|
+
let shouldHandleColgroupUpdates = false;
|
|
446
|
+
|
|
447
|
+
if (
|
|
448
|
+
isTableScalingEnabled &&
|
|
449
|
+
!getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
|
|
450
|
+
) {
|
|
451
|
+
shouldScale = true;
|
|
452
|
+
shouldHandleColgroupUpdates = true;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (
|
|
456
|
+
isTableScalingEnabled &&
|
|
457
|
+
getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
|
|
458
|
+
getNode().attrs.displayMode !== 'fixed'
|
|
459
|
+
) {
|
|
460
|
+
shouldScale = true;
|
|
461
|
+
shouldHandleColgroupUpdates = true;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (shouldHandleColgroupUpdates) {
|
|
465
|
+
this.handleColgroupUpdates();
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (isInDanger && !table) {
|
|
469
|
+
clearHoverSelection()(view.state, view.dispatch);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (this.wrapper?.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
473
|
+
if (this.props.isDragAndDropEnabled) {
|
|
474
|
+
// requestAnimationFrame is used here to fix a race condition issue
|
|
475
|
+
// that happens when a table is nested in expand and expand's width is
|
|
476
|
+
// changed via breakout button
|
|
477
|
+
window.requestAnimationFrame(() => {
|
|
478
|
+
this.overflowShadowsObserver = new OverflowShadowsObserver(
|
|
479
|
+
this.updateShadowState,
|
|
480
|
+
this.table as HTMLElement,
|
|
481
|
+
this.wrapper as HTMLDivElement,
|
|
482
|
+
);
|
|
483
|
+
});
|
|
484
|
+
} else {
|
|
485
|
+
this.overflowShadowsObserver = new OverflowShadowsObserver(
|
|
486
|
+
this.updateShadowState,
|
|
487
|
+
this.table,
|
|
488
|
+
this.wrapper,
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (this.overflowShadowsObserver) {
|
|
494
|
+
this.overflowShadowsObserver.observeShadowSentinels(this.state.stickyHeader?.sticky);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const currentTable = getNode();
|
|
498
|
+
const previousTable = this.node;
|
|
499
|
+
const isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
|
|
500
|
+
const isNoOfRowsChanged = tablesHaveDifferentNoOfRows(currentTable, previousTable);
|
|
501
|
+
if (isNoOfColumnsChanged || isNoOfRowsChanged) {
|
|
502
|
+
this.props.pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify(
|
|
503
|
+
getAssistiveMessage(previousTable, currentTable, this.props.intl),
|
|
504
|
+
{ priority: 'important' },
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
if (currentTable.attrs.__autoSize) {
|
|
508
|
+
// Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
|
|
509
|
+
this.handleAutoSizeDebounced();
|
|
510
|
+
}
|
|
511
|
+
// re-drawing will cause media component get unmounted that will exit fullscreen mode if media is in fullscreen mode
|
|
512
|
+
// see https://product-fabric.atlassian.net/browse/MEX-1290
|
|
513
|
+
else if (allowColumnResizing && this.table && !isMediaFullscreen) {
|
|
514
|
+
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
515
|
+
// re-draw colgroup.
|
|
516
|
+
if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
517
|
+
const { view } = this.props;
|
|
518
|
+
const shouldRecreateResizeCols =
|
|
519
|
+
!options?.isTableResizingEnabled || !isResizing || (isNoOfColumnsChanged && isResizing);
|
|
520
|
+
|
|
521
|
+
if (shouldRecreateResizeCols) {
|
|
522
|
+
const start = getPos() || 0;
|
|
523
|
+
const depth = view.state.doc.resolve(start).depth;
|
|
524
|
+
shouldScale = depth === 0 && shouldScale;
|
|
525
|
+
|
|
526
|
+
insertColgroupFromNode(this.table, currentTable, shouldScale);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
updateControls()(view.state);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
this.handleTableResizingDebounced();
|
|
533
|
+
}
|
|
534
|
+
if (isOverflowAnalyticsEnabled) {
|
|
535
|
+
const newIsOverflowing =
|
|
536
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
537
|
+
|
|
538
|
+
const prevIsOverflowing =
|
|
539
|
+
prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
540
|
+
|
|
541
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
542
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (!this.isInitialOverflowSent) {
|
|
546
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
550
|
+
const {
|
|
551
|
+
dispatch,
|
|
552
|
+
state: { tr },
|
|
553
|
+
} = this.props.view;
|
|
554
|
+
|
|
555
|
+
dispatch(
|
|
556
|
+
tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
557
|
+
isOverflowing: newIsOverflowing,
|
|
558
|
+
wasOverflowing: prevIsOverflowing,
|
|
559
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
560
|
+
width: this.node.attrs.width || 0,
|
|
561
|
+
parentWidth: this.state?.parentWidth || 0,
|
|
562
|
+
}),
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
private updateShadowState = (shadowKey: ShadowEvent, value: boolean) => {
|
|
569
|
+
if (this.state[shadowKey] === value) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
this.setState({ [shadowKey]: value } as Pick<TableState, typeof shadowKey>);
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
private createShadowSentinels = (table: HTMLTableElement | null) => {
|
|
576
|
+
if (table) {
|
|
577
|
+
const shadowSentinelLeft = document.createElement('span');
|
|
578
|
+
shadowSentinelLeft.className = ClassName.TABLE_SHADOW_SENTINEL_LEFT;
|
|
579
|
+
const shadowSentinelRight = document.createElement('span');
|
|
580
|
+
shadowSentinelRight.className = ClassName.TABLE_SHADOW_SENTINEL_RIGHT;
|
|
581
|
+
table.prepend(shadowSentinelLeft);
|
|
582
|
+
table.prepend(shadowSentinelRight);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
private observeTable(table: HTMLTableElement | null) {
|
|
587
|
+
if (table) {
|
|
588
|
+
this.resizeObserver?.observe(table);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
onStickyState = (state: StickyPluginState) => {
|
|
593
|
+
const pos = this.props.getPos();
|
|
594
|
+
if (!isValidPosition(pos, this.props.view.state)) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
const stickyHeader = findStickyHeaderForTable(state, pos);
|
|
598
|
+
if (stickyHeader !== this.state.stickyHeader) {
|
|
599
|
+
this.setState({ stickyHeader });
|
|
600
|
+
if (this.overflowShadowsObserver) {
|
|
601
|
+
this.overflowShadowsObserver.updateStickyShadows();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
prevTableState: any = null;
|
|
607
|
+
|
|
608
|
+
render() {
|
|
609
|
+
const {
|
|
610
|
+
view,
|
|
611
|
+
getNode,
|
|
612
|
+
isResizing,
|
|
613
|
+
allowControls = true,
|
|
614
|
+
isHeaderRowEnabled,
|
|
615
|
+
ordering,
|
|
616
|
+
isHeaderColumnEnabled,
|
|
617
|
+
tableActive,
|
|
618
|
+
containerWidth,
|
|
619
|
+
options,
|
|
620
|
+
getPos,
|
|
621
|
+
pluginInjectionApi,
|
|
622
|
+
isDragAndDropEnabled,
|
|
623
|
+
getEditorFeatureFlags,
|
|
624
|
+
isTableScalingEnabled, // here we can use options.isTableScalingEnabled
|
|
625
|
+
isTableAlignmentEnabled,
|
|
626
|
+
} = this.props;
|
|
627
|
+
|
|
628
|
+
let { isInDanger, hoveredRows, hoveredCell, isTableHovered, isWholeTableInDanger } = this.props;
|
|
629
|
+
|
|
630
|
+
const { showBeforeShadow, showAfterShadow } = this.state;
|
|
631
|
+
const node = getNode();
|
|
632
|
+
|
|
633
|
+
if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
|
|
634
|
+
const pluginState = getPluginState(view.state);
|
|
635
|
+
isInDanger = pluginState.isInDanger;
|
|
636
|
+
hoveredRows = pluginState.hoveredRows;
|
|
637
|
+
hoveredCell = pluginState.hoveredCell;
|
|
638
|
+
isTableHovered = pluginState.isTableHovered;
|
|
639
|
+
isWholeTableInDanger = pluginState.isWholeTableInDanger;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const tableRef = this.table || undefined;
|
|
643
|
+
const headerRow = tableRef
|
|
644
|
+
? tableRef.querySelector<HTMLTableRowElement>('tr[data-header-row]')
|
|
645
|
+
: undefined;
|
|
646
|
+
|
|
647
|
+
const hasHeaderRow = containsHeaderRow(node);
|
|
648
|
+
const rowControls = (
|
|
649
|
+
<TableFloatingControls
|
|
650
|
+
editorView={view}
|
|
651
|
+
tableRef={tableRef}
|
|
652
|
+
tableNode={node}
|
|
653
|
+
tableActive={tableActive}
|
|
654
|
+
hoveredRows={hoveredRows}
|
|
655
|
+
hoveredCell={hoveredCell}
|
|
656
|
+
isTableHovered={isTableHovered}
|
|
657
|
+
isInDanger={isInDanger}
|
|
658
|
+
isResizing={isResizing}
|
|
659
|
+
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
|
660
|
+
isHeaderRowEnabled={isHeaderRowEnabled}
|
|
661
|
+
isDragAndDropEnabled={isDragAndDropEnabled}
|
|
662
|
+
ordering={ordering}
|
|
663
|
+
isHeaderColumnEnabled={isHeaderColumnEnabled}
|
|
664
|
+
hasHeaderRow={hasHeaderRow}
|
|
665
|
+
// pass `selection` and `tableHeight` to control re-render
|
|
666
|
+
selection={view.state.selection}
|
|
667
|
+
headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
|
|
668
|
+
stickyHeader={this.state.stickyHeader}
|
|
669
|
+
tableWrapperWidth={this.state.tableWrapperWidth}
|
|
670
|
+
api={pluginInjectionApi}
|
|
671
|
+
/>
|
|
672
|
+
);
|
|
673
|
+
const tableContainerWidth = getTableContainerWidth(node);
|
|
674
|
+
const colControls = isDragAndDropEnabled ? (
|
|
675
|
+
<TableFloatingColumnControls
|
|
676
|
+
editorView={view}
|
|
677
|
+
tableRef={tableRef}
|
|
678
|
+
getNode={getNode}
|
|
679
|
+
tableActive={tableActive}
|
|
680
|
+
isInDanger={isInDanger}
|
|
681
|
+
hoveredRows={hoveredRows}
|
|
682
|
+
hoveredCell={hoveredCell}
|
|
683
|
+
isTableHovered={isTableHovered}
|
|
684
|
+
isResizing={isResizing}
|
|
685
|
+
ordering={ordering}
|
|
686
|
+
hasHeaderRow={hasHeaderRow}
|
|
687
|
+
// pass `selection` to control re-render
|
|
688
|
+
selection={view.state.selection}
|
|
689
|
+
headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
|
|
690
|
+
stickyHeader={this.state.stickyHeader}
|
|
691
|
+
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
692
|
+
tableContainerWidth={tableContainerWidth}
|
|
693
|
+
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
|
694
|
+
getScrollOffset={() => this.wrapper?.scrollLeft || 0}
|
|
695
|
+
tableWrapperHeight={this.state.tableWrapperHeight}
|
|
696
|
+
api={pluginInjectionApi}
|
|
697
|
+
/>
|
|
698
|
+
) : null;
|
|
699
|
+
|
|
700
|
+
const shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
|
|
701
|
+
|
|
702
|
+
const shadowStyle = memoizeOne(
|
|
703
|
+
(visible) => ({ visibility: visible ? 'visible' : 'hidden' }) as CSSProperties,
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* ED-19838
|
|
708
|
+
* There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
|
|
709
|
+
* before CR6 lands in production
|
|
710
|
+
*/
|
|
711
|
+
let tablePos: number | undefined;
|
|
712
|
+
try {
|
|
713
|
+
tablePos = getPos ? getPos() : undefined;
|
|
714
|
+
} catch (e) {
|
|
715
|
+
tablePos = undefined;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const isNested = isTableNested(view.state, tablePos);
|
|
719
|
+
|
|
720
|
+
const topStickyShadowPosition = isDragAndDropEnabled
|
|
721
|
+
? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2
|
|
722
|
+
: this.state.stickyHeader &&
|
|
723
|
+
this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
|
|
724
|
+
|
|
725
|
+
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
726
|
+
|
|
727
|
+
return (
|
|
728
|
+
<TableContainer
|
|
729
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
730
|
+
className={classnames(ClassName.TABLE_CONTAINER, {
|
|
731
|
+
[ClassName.WITH_CONTROLS]: allowControls && tableActive,
|
|
732
|
+
[ClassName.TABLE_STICKY]: this.state.stickyHeader && hasHeaderRow,
|
|
733
|
+
[ClassName.HOVERED_DELETE_BUTTON]: isInDanger,
|
|
734
|
+
[ClassName.TABLE_SELECTED]: isTableSelected(view.state.selection),
|
|
735
|
+
})}
|
|
736
|
+
editorView={view}
|
|
737
|
+
getPos={getPos}
|
|
738
|
+
node={node}
|
|
739
|
+
tableRef={tableRef!}
|
|
740
|
+
containerWidth={containerWidth}
|
|
741
|
+
isNested={isNested}
|
|
742
|
+
pluginInjectionApi={pluginInjectionApi}
|
|
743
|
+
tableWrapperHeight={this.state.tableWrapperHeight}
|
|
744
|
+
isTableResizingEnabled={options?.isTableResizingEnabled}
|
|
745
|
+
isResizing={isResizing}
|
|
746
|
+
isTableScalingEnabled={isTableScalingEnabled}
|
|
747
|
+
isWholeTableInDanger={isWholeTableInDanger}
|
|
748
|
+
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
749
|
+
>
|
|
750
|
+
<div
|
|
751
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
752
|
+
className={ClassName.TABLE_STICKY_SENTINEL_TOP}
|
|
753
|
+
data-testid="sticky-sentinel-top"
|
|
754
|
+
/>
|
|
755
|
+
{stickyScrollbar && (
|
|
756
|
+
<div
|
|
757
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
758
|
+
className={ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP}
|
|
759
|
+
data-testid="sticky-scrollbar-sentinel-top"
|
|
760
|
+
/>
|
|
761
|
+
)}
|
|
762
|
+
|
|
763
|
+
{allowControls && rowControls}
|
|
764
|
+
{isDragAndDropEnabled && (
|
|
765
|
+
<ExternalDropTargets
|
|
766
|
+
editorView={view}
|
|
767
|
+
node={node}
|
|
768
|
+
getScrollOffset={() => {
|
|
769
|
+
return this.wrapper?.scrollLeft || 0;
|
|
770
|
+
}}
|
|
771
|
+
getTableWrapperWidth={() => {
|
|
772
|
+
return this.wrapper?.clientWidth || 760;
|
|
773
|
+
}}
|
|
774
|
+
/>
|
|
775
|
+
)}
|
|
776
|
+
<div
|
|
777
|
+
contentEditable={false}
|
|
778
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
779
|
+
style={shadowStyle(showBeforeShadow)}
|
|
780
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
781
|
+
className={ClassName.TABLE_LEFT_SHADOW}
|
|
782
|
+
/>
|
|
783
|
+
{this.state.stickyHeader && (
|
|
784
|
+
<div
|
|
785
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
786
|
+
className={`${ClassName.TABLE_LEFT_SHADOW} ${ClassName.TABLE_STICKY_SHADOW}`}
|
|
787
|
+
style={{
|
|
788
|
+
visibility: showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
789
|
+
top: `${topStickyShadowPosition}px`,
|
|
790
|
+
paddingBottom: `${isDragAndDropEnabled && token('space.025', '2px')}`,
|
|
791
|
+
}}
|
|
792
|
+
/>
|
|
793
|
+
)}
|
|
794
|
+
<div
|
|
795
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
796
|
+
className={classnames(ClassName.TABLE_NODE_WRAPPER)}
|
|
797
|
+
ref={(elem) => {
|
|
798
|
+
this.wrapper = elem;
|
|
799
|
+
if (elem) {
|
|
800
|
+
this.props.contentDOM(elem);
|
|
801
|
+
const tableElement = elem.querySelector('table');
|
|
802
|
+
if (tableElement !== this.table) {
|
|
803
|
+
this.table = tableElement;
|
|
804
|
+
this.createShadowSentinels(this.table);
|
|
805
|
+
this.observeTable(this.table);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}}
|
|
809
|
+
>
|
|
810
|
+
{allowControls && colControls}
|
|
811
|
+
</div>
|
|
812
|
+
{stickyScrollbar && (
|
|
813
|
+
<div
|
|
814
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
815
|
+
className={ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER}
|
|
816
|
+
style={{
|
|
817
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
818
|
+
height: token('space.250', '20px'), // MAX_BROWSER_SCROLLBAR_HEIGHT
|
|
819
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
820
|
+
display: 'none',
|
|
821
|
+
// prevent unwanted scroll during table resize without removing scrollbar container from the dom
|
|
822
|
+
width: isResizing ? token('space.0', '0px') : '100%',
|
|
823
|
+
}}
|
|
824
|
+
>
|
|
825
|
+
<div
|
|
826
|
+
style={{
|
|
827
|
+
width: tableRef?.clientWidth,
|
|
828
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
829
|
+
height: '100%',
|
|
830
|
+
}}
|
|
831
|
+
></div>
|
|
832
|
+
</div>
|
|
833
|
+
)}
|
|
834
|
+
<div
|
|
835
|
+
contentEditable={false}
|
|
836
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
837
|
+
style={shadowStyle(showAfterShadow)}
|
|
838
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
839
|
+
className={ClassName.TABLE_RIGHT_SHADOW}
|
|
840
|
+
/>
|
|
841
|
+
{this.state.stickyHeader && (
|
|
842
|
+
<div
|
|
843
|
+
style={{
|
|
844
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
845
|
+
position: 'absolute',
|
|
846
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
847
|
+
right: token('space.400', '32px'), // tableOverflowShadowWidthWide
|
|
848
|
+
}}
|
|
849
|
+
>
|
|
850
|
+
<div
|
|
851
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
852
|
+
className={`${ClassName.TABLE_RIGHT_SHADOW} ${ClassName.TABLE_STICKY_SHADOW}`}
|
|
853
|
+
style={{
|
|
854
|
+
visibility: showAfterShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
855
|
+
top: `${topStickyShadowPosition}px`,
|
|
856
|
+
paddingBottom: `${isDragAndDropEnabled && token('space.025', '2px')}`,
|
|
857
|
+
}}
|
|
858
|
+
/>
|
|
859
|
+
</div>
|
|
860
|
+
)}
|
|
861
|
+
<div
|
|
862
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
863
|
+
className={ClassName.TABLE_STICKY_SENTINEL_BOTTOM}
|
|
864
|
+
data-testid="sticky-sentinel-bottom"
|
|
865
|
+
/>
|
|
866
|
+
{stickyScrollbar && (
|
|
867
|
+
<div
|
|
868
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
869
|
+
className={ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM}
|
|
870
|
+
data-testid="sticky-scrollbar-sentinel-bottom"
|
|
871
|
+
/>
|
|
872
|
+
)}
|
|
873
|
+
</TableContainer>
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
private handleScroll = (event: Event) => {
|
|
878
|
+
if (!this.wrapper || event.target !== this.wrapper) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
const { stickyScrollbar } = this.props.getEditorFeatureFlags();
|
|
883
|
+
|
|
884
|
+
if (stickyScrollbar) {
|
|
885
|
+
if (this.stickyScrollbar) {
|
|
886
|
+
this.stickyScrollbar.scrollLeft(this.wrapper.scrollLeft);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
if (this.table) {
|
|
891
|
+
// sync sticky header row to table scroll
|
|
892
|
+
const headers = this.table.querySelectorAll('tr[data-header-row]');
|
|
893
|
+
for (let i = 0; i < headers.length; i++) {
|
|
894
|
+
const header = headers[i] as HTMLElement;
|
|
895
|
+
|
|
896
|
+
header.scrollLeft = this.wrapper.scrollLeft;
|
|
897
|
+
header.style.marginRight = '2px';
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
this.setState({
|
|
902
|
+
[ShadowEvent.SHOW_BEFORE_SHADOW]: this.wrapper.scrollLeft !== 0,
|
|
903
|
+
});
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
private handleTableResizing = () => {
|
|
907
|
+
const { getNode, containerWidth, options } = this.props;
|
|
908
|
+
const prevNode = this.node!;
|
|
909
|
+
const node = getNode();
|
|
910
|
+
const prevAttrs = prevNode.attrs;
|
|
911
|
+
|
|
912
|
+
const isNested = isTableNested(this.props.view.state, this.props.getPos());
|
|
913
|
+
|
|
914
|
+
const parentWidth = this.getParentNodeWidth();
|
|
915
|
+
const parentWidthChanged = parentWidth && parentWidth !== this.state.parentWidth;
|
|
916
|
+
|
|
917
|
+
const layoutSize = this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
918
|
+
|
|
919
|
+
const hasNumberedColumnChanged =
|
|
920
|
+
prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
921
|
+
|
|
922
|
+
const noOfColumnsChanged = tablesHaveDifferentNoOfColumns(node, prevNode);
|
|
923
|
+
|
|
924
|
+
if (
|
|
925
|
+
// We need to react if our parent changes
|
|
926
|
+
// Scales the cols widths relative to the new parent width.
|
|
927
|
+
parentWidthChanged ||
|
|
928
|
+
// Enabling / disabling this feature reduces or adds size to the table.
|
|
929
|
+
hasNumberedColumnChanged ||
|
|
930
|
+
// This last check is also to cater for dynamic text sizing changing the 'default' layout width
|
|
931
|
+
// Usually happens on window resize.
|
|
932
|
+
layoutSize !== this.layoutSize ||
|
|
933
|
+
noOfColumnsChanged
|
|
934
|
+
) {
|
|
935
|
+
const shouldScaleTable =
|
|
936
|
+
(!options?.isTableResizingEnabled || (options?.isTableResizingEnabled && isNested)) &&
|
|
937
|
+
!hasNumberedColumnChanged &&
|
|
938
|
+
!noOfColumnsChanged;
|
|
939
|
+
|
|
940
|
+
// If column has been inserted/deleted avoid multi dispatch
|
|
941
|
+
if (shouldScaleTable) {
|
|
942
|
+
this.scaleTable({
|
|
943
|
+
parentWidth,
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
948
|
+
if (options?.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
949
|
+
if (!hasTableBeenResized(prevNode)) {
|
|
950
|
+
this.scaleTable({
|
|
951
|
+
parentWidth: node.attrs.width,
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
this.updateParentWidth(parentWidth);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
this.node = node;
|
|
960
|
+
this.containerWidth = containerWidth;
|
|
961
|
+
this.layoutSize = layoutSize;
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
private scaleTable = (scaleOptions: { parentWidth?: number }) => {
|
|
965
|
+
const { view, getNode, getPos, containerWidth, options } = this.props;
|
|
966
|
+
const node = getNode();
|
|
967
|
+
const { state, dispatch } = view;
|
|
968
|
+
const pos = getPos();
|
|
969
|
+
|
|
970
|
+
if (typeof pos !== 'number' || !isValidPosition(pos, state)) {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
const domAtPos = view.domAtPos.bind(view);
|
|
974
|
+
const { width } = containerWidth;
|
|
975
|
+
|
|
976
|
+
this.scaleTableDebounced.cancel();
|
|
977
|
+
|
|
978
|
+
const tr = scaleTable(
|
|
979
|
+
this.table,
|
|
980
|
+
{
|
|
981
|
+
...scaleOptions,
|
|
982
|
+
node,
|
|
983
|
+
prevNode: this.node || node,
|
|
984
|
+
start: pos + 1,
|
|
985
|
+
containerWidth: width,
|
|
986
|
+
previousContainerWidth: this.containerWidth!.width || width,
|
|
987
|
+
...options,
|
|
988
|
+
},
|
|
989
|
+
domAtPos,
|
|
990
|
+
false,
|
|
991
|
+
)(state.tr);
|
|
992
|
+
|
|
993
|
+
dispatch(tr);
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
private setTimerToSendInitialOverflowCaptured = (isOverflowing: boolean) => {
|
|
997
|
+
const { dispatchAnalyticsEvent, containerWidth, options } = this.props;
|
|
998
|
+
const parentWidth = this.state?.parentWidth || 0;
|
|
999
|
+
|
|
1000
|
+
this.initialOverflowCaptureTimerId = setTimeout(() => {
|
|
1001
|
+
dispatchAnalyticsEvent({
|
|
1002
|
+
action: TABLE_ACTION.INITIAL_OVERFLOW_CAPTURED,
|
|
1003
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
1004
|
+
actionSubjectId: null,
|
|
1005
|
+
eventType: EVENT_TYPE.TRACK,
|
|
1006
|
+
attributes: {
|
|
1007
|
+
editorWidth: containerWidth.width || 0,
|
|
1008
|
+
isOverflowing,
|
|
1009
|
+
tableResizingEnabled: options?.isTableResizingEnabled || false,
|
|
1010
|
+
width: this.node.attrs.width || 0,
|
|
1011
|
+
parentWidth,
|
|
1012
|
+
},
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
this.isInitialOverflowSent = true;
|
|
1016
|
+
}, initialOverflowCaptureTimeroutDelay);
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
private handleAutoSize = () => {
|
|
1020
|
+
if (this.table) {
|
|
1021
|
+
const { view, getNode, getPos, containerWidth } = this.props;
|
|
1022
|
+
const node = getNode();
|
|
1023
|
+
const pos = getPos();
|
|
1024
|
+
if (!isValidPosition(pos, view.state)) {
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
autoSizeTable(view, node, this.table, pos, {
|
|
1028
|
+
containerWidth: containerWidth.width,
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
private handleWindowResize = () => {
|
|
1034
|
+
const { getNode, containerWidth } = this.props;
|
|
1035
|
+
const node = getNode();
|
|
1036
|
+
const layoutSize = this.tableNodeLayoutSize(node);
|
|
1037
|
+
|
|
1038
|
+
if (containerWidth.width > layoutSize) {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
const parentWidth = this.getParentNodeWidth();
|
|
1043
|
+
this.scaleTableDebounced({
|
|
1044
|
+
parentWidth: parentWidth,
|
|
1045
|
+
});
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
private getParentNodeWidth = () => {
|
|
1049
|
+
const {
|
|
1050
|
+
getPos,
|
|
1051
|
+
containerWidth,
|
|
1052
|
+
options,
|
|
1053
|
+
view: { state },
|
|
1054
|
+
} = this.props;
|
|
1055
|
+
const pos = getPos();
|
|
1056
|
+
if (!isValidPosition(pos, state)) {
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
const parentNodeWith = getParentNodeWidth(
|
|
1060
|
+
pos,
|
|
1061
|
+
state,
|
|
1062
|
+
containerWidth,
|
|
1063
|
+
options && options.isFullWidthModeEnabled,
|
|
1064
|
+
);
|
|
1065
|
+
|
|
1066
|
+
return parentNodeWith;
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
private updateParentWidth = (width?: number) => {
|
|
1070
|
+
this.setState({ parentWidth: width });
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
private tableNodeLayoutSize = (node: PmNode, containerWidth?: number, options?: TableOptions) =>
|
|
1074
|
+
getLayoutSize(
|
|
1075
|
+
node.attrs.layout,
|
|
1076
|
+
containerWidth || this.props.containerWidth.width,
|
|
1077
|
+
options || this.props.options || {},
|
|
1078
|
+
);
|
|
1079
|
+
|
|
1080
|
+
private scaleTableDebounced = rafSchedule(this.scaleTable);
|
|
1081
|
+
private handleTableResizingDebounced = rafSchedule(this.handleTableResizing);
|
|
1082
|
+
private handleScrollDebounced = rafSchedule(this.handleScroll);
|
|
1083
|
+
private handleAutoSizeDebounced = rafSchedule(this.handleAutoSize);
|
|
1084
|
+
private handleWindowResizeDebounced = rafSchedule(this.handleWindowResize);
|
|
1179
1085
|
}
|
|
1180
1086
|
|
|
1181
1087
|
export default injectIntl(TableComponent);
|