@atlaskit/editor-plugin-table 7.5.4 → 7.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/commands/column-resize.js +3 -3
- package/dist/cjs/commands/delete.js +2 -2
- package/dist/cjs/commands/insert.js +15 -15
- package/dist/cjs/commands-with-analytics.js +7 -7
- package/dist/cjs/event-handlers.js +27 -11
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/cjs/nodeviews/TableCell.js +5 -30
- package/dist/cjs/nodeviews/TableComponent.js +120 -83
- package/dist/cjs/nodeviews/TableContainer.js +23 -21
- package/dist/cjs/nodeviews/TableResizer.js +13 -13
- package/dist/cjs/nodeviews/table.js +9 -9
- package/dist/cjs/plugin.js +60 -59
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/cjs/pm-plugins/keymap.js +6 -8
- package/dist/cjs/pm-plugins/main.js +7 -24
- package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/cjs/pm-plugins/table-width.js +6 -2
- package/dist/cjs/toolbar.js +21 -21
- package/dist/cjs/transforms/column-width.js +4 -4
- package/dist/cjs/transforms/delete-columns.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
- package/dist/cjs/utils/column-controls.js +5 -5
- package/dist/cjs/utils/create.js +2 -5
- package/dist/cjs/utils/dom.js +13 -15
- package/dist/cjs/utils/drag-menu.js +4 -4
- package/dist/es2019/commands/column-resize.js +3 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +12 -12
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +27 -11
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/es2019/nodeviews/TableCell.js +1 -24
- package/dist/es2019/nodeviews/TableComponent.js +88 -63
- package/dist/es2019/nodeviews/TableContainer.js +20 -22
- package/dist/es2019/nodeviews/TableResizer.js +13 -13
- package/dist/es2019/nodeviews/table.js +9 -9
- package/dist/es2019/plugin.js +19 -20
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
- package/dist/es2019/pm-plugins/keymap.js +5 -8
- package/dist/es2019/pm-plugins/main.js +6 -23
- package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/es2019/pm-plugins/table-width.js +6 -2
- package/dist/es2019/toolbar.js +15 -15
- package/dist/es2019/transforms/column-width.js +5 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
- package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
- package/dist/es2019/utils/column-controls.js +6 -6
- package/dist/es2019/utils/create.js +2 -5
- package/dist/es2019/utils/dom.js +13 -15
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +3 -3
- package/dist/esm/commands/delete.js +2 -2
- package/dist/esm/commands/insert.js +15 -15
- package/dist/esm/commands-with-analytics.js +7 -7
- package/dist/esm/event-handlers.js +27 -11
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/esm/nodeviews/TableCell.js +5 -30
- package/dist/esm/nodeviews/TableComponent.js +119 -82
- package/dist/esm/nodeviews/TableContainer.js +24 -22
- package/dist/esm/nodeviews/TableResizer.js +13 -13
- package/dist/esm/nodeviews/table.js +9 -9
- package/dist/esm/plugin.js +60 -59
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/esm/pm-plugins/keymap.js +6 -8
- package/dist/esm/pm-plugins/main.js +7 -24
- package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/esm/pm-plugins/table-width.js +6 -2
- package/dist/esm/toolbar.js +21 -21
- package/dist/esm/transforms/column-width.js +5 -5
- package/dist/esm/transforms/delete-columns.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
- package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/esm/ui/TableFloatingControls/index.js +113 -224
- package/dist/esm/utils/column-controls.js +6 -6
- package/dist/esm/utils/create.js +2 -5
- package/dist/esm/utils/dom.js +13 -15
- package/dist/esm/utils/drag-menu.js +4 -4
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +7 -7
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +4 -5
- package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types/nodeviews/TableCell.d.ts +1 -5
- package/dist/types/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/pm-plugins/table-width.d.ts +1 -2
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/types.d.ts +1 -3
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types/utils/create.d.ts +1 -2
- package/dist/types/utils/dom.d.ts +10 -2
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +7 -7
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +4 -5
- package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -3
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types-ts4.5/utils/create.d.ts +1 -2
- package/dist/types-ts4.5/utils/dom.d.ts +10 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -4
- package/src/commands/column-resize.ts +4 -3
- package/src/commands/delete.ts +2 -2
- package/src/commands/insert.ts +15 -27
- package/src/commands-with-analytics.ts +6 -9
- package/src/event-handlers.ts +107 -105
- package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
- package/src/nodeviews/TableCell.ts +0 -26
- package/src/nodeviews/TableComponent.tsx +107 -78
- package/src/nodeviews/TableContainer.tsx +26 -32
- package/src/nodeviews/TableResizer.tsx +15 -18
- package/src/nodeviews/table.tsx +6 -5
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +17 -32
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
- package/src/pm-plugins/keymap.ts +6 -13
- package/src/pm-plugins/main.ts +6 -25
- package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
- package/src/pm-plugins/table-width.ts +4 -6
- package/src/toolbar.tsx +16 -19
- package/src/transforms/column-width.ts +7 -6
- package/src/transforms/delete-columns.ts +2 -2
- package/src/types.ts +1 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
- package/src/ui/FloatingContextualMenu/index.tsx +0 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
- package/src/ui/FloatingDragMenu/index.tsx +4 -8
- package/src/ui/FloatingInsertButton/index.tsx +11 -22
- package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
- package/src/ui/TableFloatingControls/index.tsx +155 -241
- package/src/utils/column-controls.ts +5 -6
- package/src/utils/create.ts +2 -5
- package/src/utils/dom.ts +12 -19
- package/src/utils/drag-menu.ts +7 -12
|
@@ -22,11 +22,7 @@ import type {
|
|
|
22
22
|
EditorContainerWidth,
|
|
23
23
|
GetEditorFeatureFlags,
|
|
24
24
|
} from '@atlaskit/editor-common/types';
|
|
25
|
-
import {
|
|
26
|
-
browser,
|
|
27
|
-
calcTableColumnWidths,
|
|
28
|
-
isValidPosition,
|
|
29
|
-
} from '@atlaskit/editor-common/utils';
|
|
25
|
+
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
30
26
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
31
27
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
32
28
|
import {
|
|
@@ -59,6 +55,7 @@ import {
|
|
|
59
55
|
updateColgroup,
|
|
60
56
|
} from '../pm-plugins/table-resizing/utils';
|
|
61
57
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
58
|
+
import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
|
|
62
59
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
63
60
|
import type { PluginInjectionAPI } from '../types';
|
|
64
61
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
@@ -87,6 +84,12 @@ const isIE11 = browser.ie_version === 11;
|
|
|
87
84
|
// To make sure we capture the last update, we use setTimeout.
|
|
88
85
|
const initialOverflowCaptureTimeroutDelay = 300;
|
|
89
86
|
|
|
87
|
+
// This is a hard switch for controlling whether the overflow analytics should be dispatched. There has been 6months of data
|
|
88
|
+
// already collected which we could use but have not. This has been disabled rather then removed entirely in the event that
|
|
89
|
+
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
90
|
+
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
91
|
+
const isOverflowAnalyticsEnabled = false;
|
|
92
|
+
|
|
90
93
|
export interface ComponentProps {
|
|
91
94
|
view: EditorView;
|
|
92
95
|
getNode: () => PmNode;
|
|
@@ -102,13 +105,13 @@ export interface ComponentProps {
|
|
|
102
105
|
isHeaderColumnEnabled: boolean;
|
|
103
106
|
isMediaFullscreen?: boolean;
|
|
104
107
|
isDragAndDropEnabled?: boolean;
|
|
108
|
+
isTableScalingEnabled?: boolean;
|
|
105
109
|
tableActive: boolean;
|
|
106
110
|
ordering: TableColumnOrdering;
|
|
107
111
|
isResizing?: boolean;
|
|
108
112
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
109
113
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
110
114
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
111
|
-
tableRef?: HTMLElement | undefined;
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
interface TableState {
|
|
@@ -117,6 +120,8 @@ interface TableState {
|
|
|
117
120
|
stickyHeader?: RowStickyState;
|
|
118
121
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: boolean;
|
|
119
122
|
[ShadowEvent.SHOW_AFTER_SHADOW]: boolean;
|
|
123
|
+
tableWrapperWidth?: number;
|
|
124
|
+
tableWrapperHeight?: number;
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
@@ -127,6 +132,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
127
132
|
parentWidth: undefined,
|
|
128
133
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: false,
|
|
129
134
|
[ShadowEvent.SHOW_AFTER_SHADOW]: false,
|
|
135
|
+
tableWrapperWidth: undefined,
|
|
136
|
+
tableWrapperHeight: undefined,
|
|
130
137
|
};
|
|
131
138
|
|
|
132
139
|
private wrapper?: HTMLDivElement | null;
|
|
@@ -139,11 +146,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
139
146
|
|
|
140
147
|
private isInitialOverflowSent: boolean;
|
|
141
148
|
private initialOverflowCaptureTimerId?: ReturnType<typeof setTimeout>;
|
|
149
|
+
private resizeObserver?: ResizeObserver;
|
|
142
150
|
|
|
143
151
|
private dragAndDropCleanupFn?: CleanupFn;
|
|
144
152
|
|
|
145
|
-
private tableColumnWidths?: number[];
|
|
146
|
-
|
|
147
153
|
constructor(props: ComponentProps) {
|
|
148
154
|
super(props);
|
|
149
155
|
const { options, containerWidth, getNode } = props;
|
|
@@ -163,6 +169,21 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
163
169
|
},
|
|
164
170
|
);
|
|
165
171
|
|
|
172
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
173
|
+
for (let entry of entries) {
|
|
174
|
+
this.setState((prev) => {
|
|
175
|
+
return prev?.tableWrapperWidth === entry.contentRect?.width &&
|
|
176
|
+
prev?.tableWrapperHeight === entry.contentRect?.height
|
|
177
|
+
? prev
|
|
178
|
+
: {
|
|
179
|
+
...prev,
|
|
180
|
+
tableWrapperWidth: entry.contentRect.width,
|
|
181
|
+
tableWrapperHeight: entry.contentRect.height,
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
166
187
|
// Disable inline table editing and resizing controls in Firefox
|
|
167
188
|
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
168
189
|
if ('execCommand' in document) {
|
|
@@ -182,8 +203,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
182
203
|
isDragAndDropEnabled,
|
|
183
204
|
getNode,
|
|
184
205
|
getEditorFeatureFlags,
|
|
206
|
+
isTableScalingEnabled,
|
|
185
207
|
} = this.props;
|
|
186
208
|
|
|
209
|
+
if (isTableScalingEnabled) {
|
|
210
|
+
this.handleColgroupUpdates(true);
|
|
211
|
+
}
|
|
212
|
+
|
|
187
213
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
188
214
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
189
215
|
passive: true,
|
|
@@ -231,11 +257,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
231
257
|
|
|
232
258
|
eventDispatcher.on((stickyHeadersPluginKey as any).key, this.onStickyState);
|
|
233
259
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
260
|
+
if (isOverflowAnalyticsEnabled) {
|
|
261
|
+
const initialIsOveflowing =
|
|
262
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
263
|
+
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
237
264
|
|
|
238
|
-
|
|
265
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
266
|
+
}
|
|
239
267
|
}
|
|
240
268
|
|
|
241
269
|
componentWillUnmount() {
|
|
@@ -254,6 +282,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
254
282
|
this.dragAndDropCleanupFn();
|
|
255
283
|
}
|
|
256
284
|
|
|
285
|
+
this.resizeObserver?.disconnect();
|
|
286
|
+
|
|
257
287
|
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
258
288
|
|
|
259
289
|
if (stickyScrollbar) {
|
|
@@ -288,20 +318,17 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
288
318
|
}
|
|
289
319
|
}
|
|
290
320
|
|
|
291
|
-
handleColgroupUpdates() {
|
|
292
|
-
const { getNode, containerWidth, isResizing, view, getPos
|
|
293
|
-
this.props;
|
|
321
|
+
handleColgroupUpdates(force = false) {
|
|
322
|
+
const { getNode, containerWidth, isResizing, view, getPos } = this.props;
|
|
294
323
|
|
|
295
|
-
if (!
|
|
324
|
+
if (!this.table) {
|
|
296
325
|
return;
|
|
297
326
|
}
|
|
298
327
|
|
|
299
|
-
const TABLE_MARGIN = 76;
|
|
300
|
-
|
|
301
328
|
// Remove any widths styles after resizing preview is completed
|
|
302
|
-
|
|
329
|
+
this.table.style.width = '';
|
|
303
330
|
|
|
304
|
-
const tableRenderWidth = containerWidth.width -
|
|
331
|
+
const tableRenderWidth = containerWidth.width - TABLE_EDITOR_MARGIN;
|
|
305
332
|
const tableNode = getNode();
|
|
306
333
|
const start = getPos() || 0;
|
|
307
334
|
const depth = view.state.doc.resolve(start).depth;
|
|
@@ -312,39 +339,25 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
312
339
|
}
|
|
313
340
|
|
|
314
341
|
const { width: tableNodeWidth } = tableNode.attrs;
|
|
315
|
-
const tableColumnWidths = calcTableColumnWidths(tableNode);
|
|
316
342
|
const shouldTableScale = tableRenderWidth < tableNodeWidth;
|
|
317
|
-
|
|
318
|
-
if (this.tableColumnWidths) {
|
|
319
|
-
isTableColumnWidthsSame = tableColumnWidths?.every(
|
|
320
|
-
(width, index) => width === this.tableColumnWidths![index],
|
|
321
|
-
);
|
|
322
|
-
}
|
|
343
|
+
|
|
323
344
|
const { width: containerWidthValue } = containerWidth;
|
|
324
345
|
const isWidthChanged = this.containerWidth?.width !== containerWidthValue;
|
|
325
346
|
|
|
326
|
-
if (
|
|
327
|
-
shouldTableScale &&
|
|
328
|
-
!isResizing &&
|
|
329
|
-
(!isTableColumnWidthsSame || isWidthChanged)
|
|
330
|
-
) {
|
|
347
|
+
if (force || (shouldTableScale && !isResizing && isWidthChanged)) {
|
|
331
348
|
const resizeState = getResizeState({
|
|
332
349
|
minWidth: COLUMN_MIN_WIDTH,
|
|
333
350
|
maxSize: tableRenderWidth,
|
|
334
351
|
table: tableNode,
|
|
335
|
-
tableRef: this.table
|
|
352
|
+
tableRef: this.table,
|
|
336
353
|
start,
|
|
337
354
|
domAtPos: view.domAtPos,
|
|
338
|
-
|
|
355
|
+
isTableScalingEnabled: true,
|
|
339
356
|
});
|
|
340
357
|
|
|
341
|
-
|
|
342
|
-
updateColgroup(resizeState, this.table!, true);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
this.tableColumnWidths = tableColumnWidths;
|
|
346
|
-
this.containerWidth = containerWidth;
|
|
358
|
+
updateColgroup(resizeState, this.table!, tableNode, true);
|
|
347
359
|
}
|
|
360
|
+
this.containerWidth = containerWidth;
|
|
348
361
|
}
|
|
349
362
|
|
|
350
363
|
componentDidUpdate(_: any, prevState: TableState) {
|
|
@@ -355,13 +368,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
355
368
|
allowColumnResizing,
|
|
356
369
|
isResizing,
|
|
357
370
|
options,
|
|
358
|
-
|
|
371
|
+
isTableScalingEnabled,
|
|
359
372
|
} = this.props;
|
|
360
373
|
const { isInDanger } = getPluginState(view.state);
|
|
361
|
-
const { tablePreserveWidth = false } = getEditorFeatureFlags();
|
|
362
374
|
const table = findTable(view.state.selection);
|
|
363
375
|
|
|
364
|
-
if (
|
|
376
|
+
if (isTableScalingEnabled) {
|
|
365
377
|
this.handleColgroupUpdates();
|
|
366
378
|
}
|
|
367
379
|
|
|
@@ -424,7 +436,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
424
436
|
isResizing);
|
|
425
437
|
|
|
426
438
|
if (shouldRecreateResizeCols) {
|
|
427
|
-
insertColgroupFromNode(
|
|
439
|
+
insertColgroupFromNode(
|
|
440
|
+
this.table,
|
|
441
|
+
currentTable,
|
|
442
|
+
isTableScalingEnabled,
|
|
443
|
+
);
|
|
428
444
|
}
|
|
429
445
|
|
|
430
446
|
updateControls()(view.state);
|
|
@@ -432,38 +448,42 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
432
448
|
|
|
433
449
|
this.handleTableResizingDebounced();
|
|
434
450
|
}
|
|
451
|
+
if (isOverflowAnalyticsEnabled) {
|
|
452
|
+
const newIsOverflowing =
|
|
453
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
454
|
+
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
435
455
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
456
|
+
const prevIsOverflowing =
|
|
457
|
+
prevState[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
458
|
+
prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
439
459
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
if (this.initialOverflowCaptureTimerId) {
|
|
445
|
-
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
if (!this.isInitialOverflowSent) {
|
|
449
|
-
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
450
|
-
}
|
|
460
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
461
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
462
|
+
}
|
|
451
463
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
state: { tr },
|
|
456
|
-
} = this.props.view;
|
|
464
|
+
if (!this.isInitialOverflowSent) {
|
|
465
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
466
|
+
}
|
|
457
467
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
468
|
+
if (
|
|
469
|
+
this.isInitialOverflowSent &&
|
|
470
|
+
prevIsOverflowing !== newIsOverflowing
|
|
471
|
+
) {
|
|
472
|
+
const {
|
|
473
|
+
dispatch,
|
|
474
|
+
state: { tr },
|
|
475
|
+
} = this.props.view;
|
|
476
|
+
|
|
477
|
+
dispatch(
|
|
478
|
+
tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
479
|
+
isOverflowing: newIsOverflowing,
|
|
480
|
+
wasOverflowing: prevIsOverflowing,
|
|
481
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
482
|
+
width: this.node.attrs.width || 0,
|
|
483
|
+
parentWidth: this.state?.parentWidth || 0,
|
|
484
|
+
}),
|
|
485
|
+
);
|
|
486
|
+
}
|
|
467
487
|
}
|
|
468
488
|
}
|
|
469
489
|
|
|
@@ -485,6 +505,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
485
505
|
}
|
|
486
506
|
};
|
|
487
507
|
|
|
508
|
+
private observeTable(table: HTMLTableElement | null) {
|
|
509
|
+
if (table) {
|
|
510
|
+
this.resizeObserver?.observe(table);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
488
514
|
onStickyState = (state: StickyPluginState) => {
|
|
489
515
|
const pos = this.props.getPos();
|
|
490
516
|
if (!isValidPosition(pos, this.props.view.state)) {
|
|
@@ -517,6 +543,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
517
543
|
pluginInjectionApi,
|
|
518
544
|
isDragAndDropEnabled,
|
|
519
545
|
getEditorFeatureFlags,
|
|
546
|
+
isTableScalingEnabled,
|
|
520
547
|
} = this.props;
|
|
521
548
|
|
|
522
549
|
const { showBeforeShadow, showAfterShadow } = this.state;
|
|
@@ -552,6 +579,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
552
579
|
selection={view.state.selection}
|
|
553
580
|
headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
|
|
554
581
|
stickyHeader={this.state.stickyHeader}
|
|
582
|
+
tableWrapperWidth={this.state.tableWrapperWidth}
|
|
555
583
|
/>
|
|
556
584
|
);
|
|
557
585
|
const tableContainerWidth = getTableContainerWidth(node);
|
|
@@ -576,6 +604,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
576
604
|
tableContainerWidth={tableContainerWidth}
|
|
577
605
|
isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
|
|
578
606
|
getScrollOffset={() => this.wrapper?.scrollLeft || 0}
|
|
607
|
+
tableWrapperHeight={this.state.tableWrapperHeight}
|
|
579
608
|
/>
|
|
580
609
|
) : null;
|
|
581
610
|
|
|
@@ -610,7 +639,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
610
639
|
shadowPadding +
|
|
611
640
|
2;
|
|
612
641
|
|
|
613
|
-
const { stickyScrollbar
|
|
642
|
+
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
614
643
|
|
|
615
644
|
return (
|
|
616
645
|
<TableContainer
|
|
@@ -628,9 +657,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
628
657
|
isBreakoutEnabled={options?.isBreakoutEnabled}
|
|
629
658
|
isNested={isNested}
|
|
630
659
|
pluginInjectionApi={pluginInjectionApi}
|
|
660
|
+
tableWrapperHeight={this.state.tableWrapperHeight}
|
|
631
661
|
isTableResizingEnabled={options?.isTableResizingEnabled}
|
|
632
662
|
isResizing={isResizing}
|
|
633
|
-
|
|
663
|
+
isTableScalingEnabled={isTableScalingEnabled}
|
|
634
664
|
>
|
|
635
665
|
<div
|
|
636
666
|
className={ClassName.TABLE_STICKY_SENTINEL_TOP}
|
|
@@ -681,6 +711,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
681
711
|
if (tableElement !== this.table) {
|
|
682
712
|
this.table = tableElement;
|
|
683
713
|
this.createShadowSentinels(this.table);
|
|
714
|
+
this.observeTable(this.table);
|
|
684
715
|
}
|
|
685
716
|
}
|
|
686
717
|
}}
|
|
@@ -860,7 +891,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
860
891
|
getPos,
|
|
861
892
|
containerWidth,
|
|
862
893
|
options,
|
|
863
|
-
|
|
894
|
+
isTableScalingEnabled,
|
|
864
895
|
} = this.props;
|
|
865
896
|
const node = getNode();
|
|
866
897
|
const { state, dispatch } = view;
|
|
@@ -874,8 +905,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
874
905
|
|
|
875
906
|
this.scaleTableDebounced.cancel();
|
|
876
907
|
|
|
877
|
-
const { tablePreserveWidth = false } = getEditorFeatureFlags();
|
|
878
|
-
|
|
879
908
|
const tr = scaleTable(
|
|
880
909
|
this.table,
|
|
881
910
|
{
|
|
@@ -888,7 +917,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
888
917
|
...options,
|
|
889
918
|
},
|
|
890
919
|
domAtPos,
|
|
891
|
-
|
|
920
|
+
isTableScalingEnabled,
|
|
892
921
|
)(state.tr);
|
|
893
922
|
|
|
894
923
|
dispatch(tr);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useCallback, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
|
|
@@ -77,7 +77,8 @@ type ResizableTableContainerProps = {
|
|
|
77
77
|
tableRef: HTMLTableElement;
|
|
78
78
|
isResizing?: boolean;
|
|
79
79
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
80
|
-
|
|
80
|
+
isTableScalingEnabled?: boolean;
|
|
81
|
+
tableWrapperHeight?: number;
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
export const ResizableTableContainer = React.memo(
|
|
@@ -91,10 +92,12 @@ export const ResizableTableContainer = React.memo(
|
|
|
91
92
|
tableRef,
|
|
92
93
|
isResizing,
|
|
93
94
|
pluginInjectionApi,
|
|
94
|
-
|
|
95
|
+
isTableScalingEnabled,
|
|
96
|
+
tableWrapperHeight,
|
|
95
97
|
}: PropsWithChildren<ResizableTableContainerProps>) => {
|
|
96
98
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
97
99
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
100
|
+
const [resizing, setIsResizing] = useState(false);
|
|
98
101
|
|
|
99
102
|
const updateContainerHeight = useCallback((height: number | 'auto') => {
|
|
100
103
|
// current StickyHeader State is not stable to be fetch.
|
|
@@ -108,41 +111,26 @@ export const ResizableTableContainer = React.memo(
|
|
|
108
111
|
// 1px is border width but collapse make it 0.5.
|
|
109
112
|
// -- When sticky header appear, we should add first row height but reduce
|
|
110
113
|
// collapsed border
|
|
111
|
-
|
|
112
|
-
'height',
|
|
113
|
-
typeof height === 'number' ? `${height + 40.5}px` : 'auto',
|
|
114
|
-
);
|
|
114
|
+
return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
|
|
115
115
|
} else {
|
|
116
116
|
const stickyHeaderHeight =
|
|
117
117
|
containerRef.current
|
|
118
118
|
?.getElementsByTagName('th')[0]
|
|
119
119
|
.getBoundingClientRect().height || 0;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
: 'auto',
|
|
125
|
-
);
|
|
120
|
+
|
|
121
|
+
return typeof height === 'number'
|
|
122
|
+
? `${height + stickyHeaderHeight + 39.5}px`
|
|
123
|
+
: 'auto';
|
|
126
124
|
}
|
|
127
125
|
}, []);
|
|
128
126
|
|
|
129
|
-
const resizeObserverRef = useRef(
|
|
130
|
-
new ResizeObserver((entries) => {
|
|
131
|
-
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
132
|
-
}),
|
|
133
|
-
);
|
|
134
|
-
|
|
135
127
|
const onResizeStart = useCallback(() => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
}, [tableRef]);
|
|
128
|
+
setIsResizing(true);
|
|
129
|
+
}, []);
|
|
140
130
|
|
|
141
131
|
const onResizeStop = useCallback(() => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
resizeObserverRef.current.disconnect();
|
|
145
|
-
}, [updateContainerHeight]);
|
|
132
|
+
setIsResizing(false);
|
|
133
|
+
}, []);
|
|
146
134
|
|
|
147
135
|
const updateWidth = useCallback((width: number) => {
|
|
148
136
|
if (!containerRef.current) {
|
|
@@ -191,7 +179,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
191
179
|
|
|
192
180
|
const tableWidth = getTableContainerWidth(node);
|
|
193
181
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
194
|
-
const responsiveContainerWidth =
|
|
182
|
+
const responsiveContainerWidth = isTableScalingEnabled
|
|
195
183
|
? containerWidth -
|
|
196
184
|
akEditorGutterPadding * 2 -
|
|
197
185
|
akEditorMediaResizeHandlerPaddingWide / 2
|
|
@@ -218,7 +206,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
218
206
|
displayGuideline,
|
|
219
207
|
attachAnalyticsEvent,
|
|
220
208
|
displayGapCursor,
|
|
221
|
-
|
|
209
|
+
isTableScalingEnabled,
|
|
222
210
|
};
|
|
223
211
|
|
|
224
212
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
@@ -239,6 +227,9 @@ export const ResizableTableContainer = React.memo(
|
|
|
239
227
|
<div
|
|
240
228
|
style={{
|
|
241
229
|
width: tableWidthRef.current,
|
|
230
|
+
height: resizing
|
|
231
|
+
? updateContainerHeight(tableWrapperHeight ?? 'auto')
|
|
232
|
+
: 'auto',
|
|
242
233
|
}}
|
|
243
234
|
className={ClassName.TABLE_RESIZER_CONTAINER}
|
|
244
235
|
ref={containerRef}
|
|
@@ -266,7 +257,8 @@ type TableContainerProps = {
|
|
|
266
257
|
isNested: boolean;
|
|
267
258
|
isResizing?: boolean;
|
|
268
259
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
269
|
-
|
|
260
|
+
isTableScalingEnabled?: boolean;
|
|
261
|
+
tableWrapperHeight?: number;
|
|
270
262
|
};
|
|
271
263
|
|
|
272
264
|
export const TableContainer = ({
|
|
@@ -280,9 +272,10 @@ export const TableContainer = ({
|
|
|
280
272
|
getPos,
|
|
281
273
|
tableRef,
|
|
282
274
|
isNested,
|
|
275
|
+
tableWrapperHeight,
|
|
283
276
|
isResizing,
|
|
284
277
|
pluginInjectionApi,
|
|
285
|
-
|
|
278
|
+
isTableScalingEnabled,
|
|
286
279
|
}: PropsWithChildren<TableContainerProps>) => {
|
|
287
280
|
if (isTableResizingEnabled && !isNested) {
|
|
288
281
|
return (
|
|
@@ -293,9 +286,10 @@ export const TableContainer = ({
|
|
|
293
286
|
editorView={editorView}
|
|
294
287
|
getPos={getPos}
|
|
295
288
|
tableRef={tableRef}
|
|
289
|
+
tableWrapperHeight={tableWrapperHeight}
|
|
296
290
|
isResizing={isResizing}
|
|
297
291
|
pluginInjectionApi={pluginInjectionApi}
|
|
298
|
-
|
|
292
|
+
isTableScalingEnabled={isTableScalingEnabled}
|
|
299
293
|
>
|
|
300
294
|
{children}
|
|
301
295
|
</ResizableTableContainer>
|
|
@@ -75,7 +75,7 @@ interface TableResizerProps {
|
|
|
75
75
|
payload: TableEventPayload,
|
|
76
76
|
) => ((tr: Transaction) => boolean) | undefined;
|
|
77
77
|
displayGapCursor: (toggle: boolean) => boolean;
|
|
78
|
-
|
|
78
|
+
isTableScalingEnabled?: boolean;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export interface TableResizerImprovementProps extends TableResizerProps {
|
|
@@ -125,10 +125,7 @@ const getResizerHandleHeight = (
|
|
|
125
125
|
|
|
126
126
|
const getResizerMinWidth = (node: PMNode) => {
|
|
127
127
|
const currentColumnCount = getColgroupChildrenLength(node);
|
|
128
|
-
const minColumnWidth =
|
|
129
|
-
currentColumnCount <= 3
|
|
130
|
-
? currentColumnCount * COLUMN_MIN_WIDTH
|
|
131
|
-
: 3 * COLUMN_MIN_WIDTH;
|
|
128
|
+
const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
|
|
132
129
|
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
133
130
|
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
134
131
|
return minColumnWidth + 1;
|
|
@@ -170,7 +167,7 @@ export const TableResizer = ({
|
|
|
170
167
|
displayGuideline,
|
|
171
168
|
attachAnalyticsEvent,
|
|
172
169
|
displayGapCursor,
|
|
173
|
-
|
|
170
|
+
isTableScalingEnabled,
|
|
174
171
|
}: PropsWithChildren<TableResizerImprovementProps>) => {
|
|
175
172
|
const currentGap = useRef(0);
|
|
176
173
|
// track resizing state - use ref over state to avoid re-render
|
|
@@ -218,7 +215,7 @@ export const TableResizer = ({
|
|
|
218
215
|
if (gap !== currentGap.current) {
|
|
219
216
|
currentGap.current = gap;
|
|
220
217
|
const visibleGuidelines = getVisibleGuidelines(
|
|
221
|
-
|
|
218
|
+
isTableScalingEnabled
|
|
222
219
|
? defaultGuidelinesForPreserveTable(containerWidth)
|
|
223
220
|
: defaultGuidelines,
|
|
224
221
|
containerWidth,
|
|
@@ -234,19 +231,19 @@ export const TableResizer = ({
|
|
|
234
231
|
);
|
|
235
232
|
}
|
|
236
233
|
},
|
|
237
|
-
[
|
|
234
|
+
[isTableScalingEnabled, containerWidth, displayGuideline],
|
|
238
235
|
);
|
|
239
236
|
|
|
240
237
|
const guidelineSnaps = useMemo(
|
|
241
238
|
() =>
|
|
242
239
|
snappingEnabled
|
|
243
240
|
? {
|
|
244
|
-
x:
|
|
241
|
+
x: isTableScalingEnabled
|
|
245
242
|
? defaultTablePreserveSnappingWidths(containerWidth)
|
|
246
243
|
: defaultSnappingWidths,
|
|
247
244
|
}
|
|
248
245
|
: undefined,
|
|
249
|
-
[snappingEnabled,
|
|
246
|
+
[snappingEnabled, isTableScalingEnabled, containerWidth],
|
|
250
247
|
);
|
|
251
248
|
|
|
252
249
|
useEffect(() => {
|
|
@@ -282,7 +279,7 @@ export const TableResizer = ({
|
|
|
282
279
|
dispatch(tr);
|
|
283
280
|
|
|
284
281
|
const visibleGuidelines = getVisibleGuidelines(
|
|
285
|
-
|
|
282
|
+
isTableScalingEnabled
|
|
286
283
|
? defaultGuidelinesForPreserveTable(containerWidth)
|
|
287
284
|
: defaultGuidelines,
|
|
288
285
|
containerWidth,
|
|
@@ -299,7 +296,7 @@ export const TableResizer = ({
|
|
|
299
296
|
startMeasure,
|
|
300
297
|
editorView,
|
|
301
298
|
displayGapCursor,
|
|
302
|
-
|
|
299
|
+
isTableScalingEnabled,
|
|
303
300
|
containerWidth,
|
|
304
301
|
displayGuideline,
|
|
305
302
|
onResizeStart,
|
|
@@ -328,16 +325,16 @@ export const TableResizer = ({
|
|
|
328
325
|
parentWidth: newWidth,
|
|
329
326
|
},
|
|
330
327
|
editorView.domAtPos.bind(editorView),
|
|
331
|
-
|
|
328
|
+
isTableScalingEnabled,
|
|
332
329
|
);
|
|
333
330
|
|
|
334
331
|
updateActiveGuidelines(
|
|
335
332
|
findClosestSnap(
|
|
336
333
|
newWidth,
|
|
337
|
-
|
|
334
|
+
isTableScalingEnabled
|
|
338
335
|
? defaultTablePreserveSnappingWidths(containerWidth)
|
|
339
336
|
: defaultSnappingWidths,
|
|
340
|
-
|
|
337
|
+
isTableScalingEnabled
|
|
341
338
|
? defaultGuidelinesForPreserveTable(containerWidth)
|
|
342
339
|
: defaultGuidelines,
|
|
343
340
|
TABLE_HIGHLIGHT_GAP,
|
|
@@ -350,7 +347,7 @@ export const TableResizer = ({
|
|
|
350
347
|
},
|
|
351
348
|
[
|
|
352
349
|
countFrames,
|
|
353
|
-
|
|
350
|
+
isTableScalingEnabled,
|
|
354
351
|
tableRef,
|
|
355
352
|
node,
|
|
356
353
|
editorView,
|
|
@@ -400,7 +397,7 @@ export const TableResizer = ({
|
|
|
400
397
|
parentWidth: newWidth,
|
|
401
398
|
},
|
|
402
399
|
editorView.domAtPos.bind(editorView),
|
|
403
|
-
|
|
400
|
+
isTableScalingEnabled,
|
|
404
401
|
)(tr);
|
|
405
402
|
|
|
406
403
|
const scaledNode = tr.doc.nodeAt(pos)!;
|
|
@@ -441,7 +438,7 @@ export const TableResizer = ({
|
|
|
441
438
|
attachAnalyticsEvent,
|
|
442
439
|
endMeasure,
|
|
443
440
|
onResizeStop,
|
|
444
|
-
|
|
441
|
+
isTableScalingEnabled,
|
|
445
442
|
],
|
|
446
443
|
);
|
|
447
444
|
|