@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
|
@@ -6,7 +6,7 @@ import rafSchedule from 'raf-schd';
|
|
|
6
6
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
8
8
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
9
|
-
import { browser,
|
|
9
|
+
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
11
11
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
12
12
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -18,6 +18,7 @@ import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '.
|
|
|
18
18
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
19
19
|
import { COLUMN_MIN_WIDTH, getLayoutSize, getResizeState, insertColgroupFromNode, scaleTable, updateColgroup } from '../pm-plugins/table-resizing/utils';
|
|
20
20
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
21
|
+
import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
|
|
21
22
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
22
23
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
23
24
|
import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
|
|
@@ -33,6 +34,12 @@ const isIE11 = browser.ie_version === 11;
|
|
|
33
34
|
// componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
|
|
34
35
|
// To make sure we capture the last update, we use setTimeout.
|
|
35
36
|
const initialOverflowCaptureTimeroutDelay = 300;
|
|
37
|
+
|
|
38
|
+
// This is a hard switch for controlling whether the overflow analytics should be dispatched. There has been 6months of data
|
|
39
|
+
// already collected which we could use but have not. This has been disabled rather then removed entirely in the event that
|
|
40
|
+
// the current collected data becomes stale and we want to start collecting fresh data again in future.
|
|
41
|
+
// PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
|
|
42
|
+
const isOverflowAnalyticsEnabled = false;
|
|
36
43
|
class TableComponent extends React.Component {
|
|
37
44
|
constructor(props) {
|
|
38
45
|
super(props);
|
|
@@ -40,7 +47,9 @@ class TableComponent extends React.Component {
|
|
|
40
47
|
scroll: 0,
|
|
41
48
|
parentWidth: undefined,
|
|
42
49
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: false,
|
|
43
|
-
[ShadowEvent.SHOW_AFTER_SHADOW]: false
|
|
50
|
+
[ShadowEvent.SHOW_AFTER_SHADOW]: false,
|
|
51
|
+
tableWrapperWidth: undefined,
|
|
52
|
+
tableWrapperHeight: undefined
|
|
44
53
|
});
|
|
45
54
|
_defineProperty(this, "updateShadowState", (shadowKey, value) => {
|
|
46
55
|
if (this.state[shadowKey] === value) {
|
|
@@ -161,7 +170,7 @@ class TableComponent extends React.Component {
|
|
|
161
170
|
getPos,
|
|
162
171
|
containerWidth,
|
|
163
172
|
options,
|
|
164
|
-
|
|
173
|
+
isTableScalingEnabled
|
|
165
174
|
} = this.props;
|
|
166
175
|
const node = getNode();
|
|
167
176
|
const {
|
|
@@ -177,9 +186,6 @@ class TableComponent extends React.Component {
|
|
|
177
186
|
width
|
|
178
187
|
} = containerWidth;
|
|
179
188
|
this.scaleTableDebounced.cancel();
|
|
180
|
-
const {
|
|
181
|
-
tablePreserveWidth = false
|
|
182
|
-
} = getEditorFeatureFlags();
|
|
183
189
|
const tr = scaleTable(this.table, {
|
|
184
190
|
...scaleOptions,
|
|
185
191
|
node,
|
|
@@ -188,7 +194,7 @@ class TableComponent extends React.Component {
|
|
|
188
194
|
containerWidth: width,
|
|
189
195
|
previousContainerWidth: this.containerWidth.width || width,
|
|
190
196
|
...options
|
|
191
|
-
}, domAtPos,
|
|
197
|
+
}, domAtPos, isTableScalingEnabled)(state.tr);
|
|
192
198
|
dispatch(tr);
|
|
193
199
|
});
|
|
194
200
|
_defineProperty(this, "setTimerToSendInitialOverflowCaptured", isOverflowing => {
|
|
@@ -295,6 +301,18 @@ class TableComponent extends React.Component {
|
|
|
295
301
|
this.layoutSize = this.tableNodeLayoutSize(this.node, _containerWidth.width, {
|
|
296
302
|
isFullWidthModeEnabled
|
|
297
303
|
});
|
|
304
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
305
|
+
for (let entry of entries) {
|
|
306
|
+
this.setState(prev => {
|
|
307
|
+
var _entry$contentRect, _entry$contentRect2;
|
|
308
|
+
return (prev === null || prev === void 0 ? void 0 : prev.tableWrapperWidth) === ((_entry$contentRect = entry.contentRect) === null || _entry$contentRect === void 0 ? void 0 : _entry$contentRect.width) && (prev === null || prev === void 0 ? void 0 : prev.tableWrapperHeight) === ((_entry$contentRect2 = entry.contentRect) === null || _entry$contentRect2 === void 0 ? void 0 : _entry$contentRect2.height) ? prev : {
|
|
309
|
+
...prev,
|
|
310
|
+
tableWrapperWidth: entry.contentRect.width,
|
|
311
|
+
tableWrapperHeight: entry.contentRect.height
|
|
312
|
+
};
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
});
|
|
298
316
|
|
|
299
317
|
// Disable inline table editing and resizing controls in Firefox
|
|
300
318
|
// https://github.com/ProseMirror/prosemirror/issues/432
|
|
@@ -313,8 +331,12 @@ class TableComponent extends React.Component {
|
|
|
313
331
|
options,
|
|
314
332
|
isDragAndDropEnabled,
|
|
315
333
|
getNode,
|
|
316
|
-
getEditorFeatureFlags
|
|
334
|
+
getEditorFeatureFlags,
|
|
335
|
+
isTableScalingEnabled
|
|
317
336
|
} = this.props;
|
|
337
|
+
if (isTableScalingEnabled) {
|
|
338
|
+
this.handleColgroupUpdates(true);
|
|
339
|
+
}
|
|
318
340
|
if (allowColumnResizing && this.wrapper && !isIE11) {
|
|
319
341
|
this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
|
|
320
342
|
passive: true
|
|
@@ -349,10 +371,13 @@ class TableComponent extends React.Component {
|
|
|
349
371
|
this.onStickyState(currentStickyState);
|
|
350
372
|
}
|
|
351
373
|
eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
|
|
352
|
-
|
|
353
|
-
|
|
374
|
+
if (isOverflowAnalyticsEnabled) {
|
|
375
|
+
const initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
376
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
377
|
+
}
|
|
354
378
|
}
|
|
355
379
|
componentWillUnmount() {
|
|
380
|
+
var _this$resizeObserver;
|
|
356
381
|
const {
|
|
357
382
|
allowColumnResizing,
|
|
358
383
|
eventDispatcher,
|
|
@@ -366,6 +391,7 @@ class TableComponent extends React.Component {
|
|
|
366
391
|
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
367
392
|
this.dragAndDropCleanupFn();
|
|
368
393
|
}
|
|
394
|
+
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 ? void 0 : _this$resizeObserver.disconnect();
|
|
369
395
|
const {
|
|
370
396
|
stickyScrollbar
|
|
371
397
|
} = getEditorFeatureFlags();
|
|
@@ -392,24 +418,22 @@ class TableComponent extends React.Component {
|
|
|
392
418
|
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
393
419
|
}
|
|
394
420
|
}
|
|
395
|
-
handleColgroupUpdates() {
|
|
421
|
+
handleColgroupUpdates(force = false) {
|
|
396
422
|
var _this$containerWidth;
|
|
397
423
|
const {
|
|
398
424
|
getNode,
|
|
399
425
|
containerWidth,
|
|
400
426
|
isResizing,
|
|
401
427
|
view,
|
|
402
|
-
getPos
|
|
403
|
-
tableRef
|
|
428
|
+
getPos
|
|
404
429
|
} = this.props;
|
|
405
|
-
if (!
|
|
430
|
+
if (!this.table) {
|
|
406
431
|
return;
|
|
407
432
|
}
|
|
408
|
-
const TABLE_MARGIN = 76;
|
|
409
433
|
|
|
410
434
|
// Remove any widths styles after resizing preview is completed
|
|
411
|
-
|
|
412
|
-
const tableRenderWidth = containerWidth.width -
|
|
435
|
+
this.table.style.width = '';
|
|
436
|
+
const tableRenderWidth = containerWidth.width - TABLE_EDITOR_MARGIN;
|
|
413
437
|
const tableNode = getNode();
|
|
414
438
|
const start = getPos() || 0;
|
|
415
439
|
const depth = view.state.doc.resolve(start).depth;
|
|
@@ -421,17 +445,12 @@ class TableComponent extends React.Component {
|
|
|
421
445
|
const {
|
|
422
446
|
width: tableNodeWidth
|
|
423
447
|
} = tableNode.attrs;
|
|
424
|
-
const tableColumnWidths = calcTableColumnWidths(tableNode);
|
|
425
448
|
const shouldTableScale = tableRenderWidth < tableNodeWidth;
|
|
426
|
-
let isTableColumnWidthsSame = false;
|
|
427
|
-
if (this.tableColumnWidths) {
|
|
428
|
-
isTableColumnWidthsSame = tableColumnWidths === null || tableColumnWidths === void 0 ? void 0 : tableColumnWidths.every((width, index) => width === this.tableColumnWidths[index]);
|
|
429
|
-
}
|
|
430
449
|
const {
|
|
431
450
|
width: containerWidthValue
|
|
432
451
|
} = containerWidth;
|
|
433
452
|
const isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
|
|
434
|
-
if (shouldTableScale && !isResizing &&
|
|
453
|
+
if (force || shouldTableScale && !isResizing && isWidthChanged) {
|
|
435
454
|
const resizeState = getResizeState({
|
|
436
455
|
minWidth: COLUMN_MIN_WIDTH,
|
|
437
456
|
maxSize: tableRenderWidth,
|
|
@@ -439,14 +458,11 @@ class TableComponent extends React.Component {
|
|
|
439
458
|
tableRef: this.table,
|
|
440
459
|
start,
|
|
441
460
|
domAtPos: view.domAtPos,
|
|
442
|
-
|
|
461
|
+
isTableScalingEnabled: true
|
|
443
462
|
});
|
|
444
|
-
|
|
445
|
-
updateColgroup(resizeState, this.table, true);
|
|
446
|
-
});
|
|
447
|
-
this.tableColumnWidths = tableColumnWidths;
|
|
448
|
-
this.containerWidth = containerWidth;
|
|
463
|
+
updateColgroup(resizeState, this.table, tableNode, true);
|
|
449
464
|
}
|
|
465
|
+
this.containerWidth = containerWidth;
|
|
450
466
|
}
|
|
451
467
|
componentDidUpdate(_, prevState) {
|
|
452
468
|
var _this$wrapper;
|
|
@@ -457,16 +473,13 @@ class TableComponent extends React.Component {
|
|
|
457
473
|
allowColumnResizing,
|
|
458
474
|
isResizing,
|
|
459
475
|
options,
|
|
460
|
-
|
|
476
|
+
isTableScalingEnabled
|
|
461
477
|
} = this.props;
|
|
462
478
|
const {
|
|
463
479
|
isInDanger
|
|
464
480
|
} = getPluginState(view.state);
|
|
465
|
-
const {
|
|
466
|
-
tablePreserveWidth = false
|
|
467
|
-
} = getEditorFeatureFlags();
|
|
468
481
|
const table = findTable(view.state.selection);
|
|
469
|
-
if (
|
|
482
|
+
if (isTableScalingEnabled) {
|
|
470
483
|
this.handleColgroupUpdates();
|
|
471
484
|
}
|
|
472
485
|
if (isInDanger && !table) {
|
|
@@ -505,35 +518,43 @@ class TableComponent extends React.Component {
|
|
|
505
518
|
} = this.props;
|
|
506
519
|
const shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
|
|
507
520
|
if (shouldRecreateResizeCols) {
|
|
508
|
-
insertColgroupFromNode(this.table, currentTable,
|
|
521
|
+
insertColgroupFromNode(this.table, currentTable, isTableScalingEnabled);
|
|
509
522
|
}
|
|
510
523
|
updateControls()(view.state);
|
|
511
524
|
}
|
|
512
525
|
this.handleTableResizingDebounced();
|
|
513
526
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
this.
|
|
527
|
+
if (isOverflowAnalyticsEnabled) {
|
|
528
|
+
const newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
529
|
+
const prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
530
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
531
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
532
|
+
}
|
|
533
|
+
if (!this.isInitialOverflowSent) {
|
|
534
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
535
|
+
}
|
|
536
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
537
|
+
var _this$state2;
|
|
538
|
+
const {
|
|
539
|
+
dispatch,
|
|
540
|
+
state: {
|
|
541
|
+
tr
|
|
542
|
+
}
|
|
543
|
+
} = this.props.view;
|
|
544
|
+
dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
545
|
+
isOverflowing: newIsOverflowing,
|
|
546
|
+
wasOverflowing: prevIsOverflowing,
|
|
547
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
548
|
+
width: this.node.attrs.width || 0,
|
|
549
|
+
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
550
|
+
}));
|
|
551
|
+
}
|
|
521
552
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
tr
|
|
528
|
-
}
|
|
529
|
-
} = this.props.view;
|
|
530
|
-
dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
531
|
-
isOverflowing: newIsOverflowing,
|
|
532
|
-
wasOverflowing: prevIsOverflowing,
|
|
533
|
-
editorWidth: this.props.containerWidth.width || 0,
|
|
534
|
-
width: this.node.attrs.width || 0,
|
|
535
|
-
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
536
|
-
}));
|
|
553
|
+
}
|
|
554
|
+
observeTable(table) {
|
|
555
|
+
if (table) {
|
|
556
|
+
var _this$resizeObserver2;
|
|
557
|
+
(_this$resizeObserver2 = this.resizeObserver) === null || _this$resizeObserver2 === void 0 ? void 0 : _this$resizeObserver2.observe(table);
|
|
537
558
|
}
|
|
538
559
|
}
|
|
539
560
|
render() {
|
|
@@ -551,7 +572,8 @@ class TableComponent extends React.Component {
|
|
|
551
572
|
getPos,
|
|
552
573
|
pluginInjectionApi,
|
|
553
574
|
isDragAndDropEnabled,
|
|
554
|
-
getEditorFeatureFlags
|
|
575
|
+
getEditorFeatureFlags,
|
|
576
|
+
isTableScalingEnabled
|
|
555
577
|
} = this.props;
|
|
556
578
|
const {
|
|
557
579
|
showBeforeShadow,
|
|
@@ -588,7 +610,8 @@ class TableComponent extends React.Component {
|
|
|
588
610
|
,
|
|
589
611
|
selection: view.state.selection,
|
|
590
612
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
591
|
-
stickyHeader: this.state.stickyHeader
|
|
613
|
+
stickyHeader: this.state.stickyHeader,
|
|
614
|
+
tableWrapperWidth: this.state.tableWrapperWidth
|
|
592
615
|
});
|
|
593
616
|
const tableContainerWidth = getTableContainerWidth(node);
|
|
594
617
|
const colControls = isDragAndDropEnabled ? /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
|
|
@@ -614,7 +637,8 @@ class TableComponent extends React.Component {
|
|
|
614
637
|
getScrollOffset: () => {
|
|
615
638
|
var _this$wrapper2;
|
|
616
639
|
return ((_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.scrollLeft) || 0;
|
|
617
|
-
}
|
|
640
|
+
},
|
|
641
|
+
tableWrapperHeight: this.state.tableWrapperHeight
|
|
618
642
|
}) : null;
|
|
619
643
|
const shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
|
|
620
644
|
const shadowStyle = memoizeOne(visible => ({
|
|
@@ -635,8 +659,7 @@ class TableComponent extends React.Component {
|
|
|
635
659
|
const isNested = isTableNested(view.state, tablePos);
|
|
636
660
|
const topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
|
|
637
661
|
const {
|
|
638
|
-
stickyScrollbar
|
|
639
|
-
tablePreserveWidth
|
|
662
|
+
stickyScrollbar
|
|
640
663
|
} = getEditorFeatureFlags();
|
|
641
664
|
return /*#__PURE__*/React.createElement(TableContainer, {
|
|
642
665
|
className: classnames(ClassName.TABLE_CONTAINER, {
|
|
@@ -653,9 +676,10 @@ class TableComponent extends React.Component {
|
|
|
653
676
|
isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
|
|
654
677
|
isNested: isNested,
|
|
655
678
|
pluginInjectionApi: pluginInjectionApi,
|
|
679
|
+
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
656
680
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
657
681
|
isResizing: isResizing,
|
|
658
|
-
|
|
682
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
659
683
|
}, /*#__PURE__*/React.createElement("div", {
|
|
660
684
|
className: ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
661
685
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -693,6 +717,7 @@ class TableComponent extends React.Component {
|
|
|
693
717
|
if (tableElement !== this.table) {
|
|
694
718
|
this.table = tableElement;
|
|
695
719
|
this.createShadowSentinels(this.table);
|
|
720
|
+
this.observeTable(this.table);
|
|
696
721
|
}
|
|
697
722
|
}
|
|
698
723
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useCallback, useRef, useState } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
4
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
@@ -42,10 +42,12 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
42
42
|
tableRef,
|
|
43
43
|
isResizing,
|
|
44
44
|
pluginInjectionApi,
|
|
45
|
-
|
|
45
|
+
isTableScalingEnabled,
|
|
46
|
+
tableWrapperHeight
|
|
46
47
|
}) => {
|
|
47
48
|
const containerRef = useRef(null);
|
|
48
49
|
const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
50
|
+
const [resizing, setIsResizing] = useState(false);
|
|
49
51
|
const updateContainerHeight = useCallback(height => {
|
|
50
52
|
var _containerRef$current;
|
|
51
53
|
// current StickyHeader State is not stable to be fetch.
|
|
@@ -53,31 +55,24 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
53
55
|
// consistently fetch and refactor below
|
|
54
56
|
const stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
|
|
55
57
|
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
56
|
-
var _containerRef$current2;
|
|
57
58
|
// when starting to drag, we need to keep the original space,
|
|
58
59
|
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
59
60
|
// 1px is border width but collapse make it 0.5.
|
|
60
61
|
// -- When sticky header appear, we should add first row height but reduce
|
|
61
62
|
// collapsed border
|
|
62
|
-
|
|
63
|
+
return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
|
|
63
64
|
} else {
|
|
64
|
-
var _containerRef$
|
|
65
|
-
const stickyHeaderHeight = ((_containerRef$
|
|
66
|
-
|
|
65
|
+
var _containerRef$current2;
|
|
66
|
+
const stickyHeaderHeight = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
67
|
+
return typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto';
|
|
67
68
|
}
|
|
68
69
|
}, []);
|
|
69
|
-
const resizeObserverRef = useRef(new ResizeObserver(entries => {
|
|
70
|
-
updateContainerHeight(entries[entries.length - 1].contentRect.height);
|
|
71
|
-
}));
|
|
72
70
|
const onResizeStart = useCallback(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
}, [tableRef]);
|
|
71
|
+
setIsResizing(true);
|
|
72
|
+
}, []);
|
|
77
73
|
const onResizeStop = useCallback(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, [updateContainerHeight]);
|
|
74
|
+
setIsResizing(false);
|
|
75
|
+
}, []);
|
|
81
76
|
const updateWidth = useCallback(width => {
|
|
82
77
|
if (!containerRef.current) {
|
|
83
78
|
return;
|
|
@@ -107,7 +102,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
107
102
|
}, [pluginInjectionApi]);
|
|
108
103
|
const tableWidth = getTableContainerWidth(node);
|
|
109
104
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
110
|
-
const responsiveContainerWidth =
|
|
105
|
+
const responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
111
106
|
const width = Math.min(tableWidth, responsiveContainerWidth);
|
|
112
107
|
if (!isResizing) {
|
|
113
108
|
tableWidthRef.current = width;
|
|
@@ -125,7 +120,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
125
120
|
displayGuideline,
|
|
126
121
|
attachAnalyticsEvent,
|
|
127
122
|
displayGapCursor,
|
|
128
|
-
|
|
123
|
+
isTableScalingEnabled
|
|
129
124
|
};
|
|
130
125
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
|
|
131
126
|
tableResizerProps = {
|
|
@@ -141,7 +136,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
141
136
|
}
|
|
142
137
|
}, /*#__PURE__*/React.createElement("div", {
|
|
143
138
|
style: {
|
|
144
|
-
width: tableWidthRef.current
|
|
139
|
+
width: tableWidthRef.current,
|
|
140
|
+
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto'
|
|
145
141
|
},
|
|
146
142
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
147
143
|
ref: containerRef
|
|
@@ -164,9 +160,10 @@ export const TableContainer = ({
|
|
|
164
160
|
getPos,
|
|
165
161
|
tableRef,
|
|
166
162
|
isNested,
|
|
163
|
+
tableWrapperHeight,
|
|
167
164
|
isResizing,
|
|
168
165
|
pluginInjectionApi,
|
|
169
|
-
|
|
166
|
+
isTableScalingEnabled
|
|
170
167
|
}) => {
|
|
171
168
|
if (isTableResizingEnabled && !isNested) {
|
|
172
169
|
return /*#__PURE__*/React.createElement(ResizableTableContainer, {
|
|
@@ -176,9 +173,10 @@ export const TableContainer = ({
|
|
|
176
173
|
editorView: editorView,
|
|
177
174
|
getPos: getPos,
|
|
178
175
|
tableRef: tableRef,
|
|
176
|
+
tableWrapperHeight: tableWrapperHeight,
|
|
179
177
|
isResizing: isResizing,
|
|
180
178
|
pluginInjectionApi: pluginInjectionApi,
|
|
181
|
-
|
|
179
|
+
isTableScalingEnabled: isTableScalingEnabled
|
|
182
180
|
}, children);
|
|
183
181
|
}
|
|
184
182
|
const tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
|
|
@@ -51,7 +51,7 @@ const getResizerHandleHeight = tableRef => {
|
|
|
51
51
|
};
|
|
52
52
|
const getResizerMinWidth = node => {
|
|
53
53
|
const currentColumnCount = getColgroupChildrenLength(node);
|
|
54
|
-
const minColumnWidth =
|
|
54
|
+
const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
|
|
55
55
|
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
56
56
|
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
57
57
|
return minColumnWidth + 1;
|
|
@@ -83,7 +83,7 @@ export const TableResizer = ({
|
|
|
83
83
|
displayGuideline,
|
|
84
84
|
attachAnalyticsEvent,
|
|
85
85
|
displayGapCursor,
|
|
86
|
-
|
|
86
|
+
isTableScalingEnabled
|
|
87
87
|
}) => {
|
|
88
88
|
var _findTable, _editorView$state;
|
|
89
89
|
const currentGap = useRef(0);
|
|
@@ -130,13 +130,13 @@ export const TableResizer = ({
|
|
|
130
130
|
}) => {
|
|
131
131
|
if (gap !== currentGap.current) {
|
|
132
132
|
currentGap.current = gap;
|
|
133
|
-
const visibleGuidelines = getVisibleGuidelines(
|
|
133
|
+
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
134
134
|
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
135
135
|
}
|
|
136
|
-
}, [
|
|
136
|
+
}, [isTableScalingEnabled, containerWidth, displayGuideline]);
|
|
137
137
|
const guidelineSnaps = useMemo(() => snappingEnabled ? {
|
|
138
|
-
x:
|
|
139
|
-
} : undefined, [snappingEnabled,
|
|
138
|
+
x: isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
|
|
139
|
+
} : undefined, [snappingEnabled, isTableScalingEnabled, containerWidth]);
|
|
140
140
|
useEffect(() => {
|
|
141
141
|
return () => {
|
|
142
142
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -174,12 +174,12 @@ export const TableResizer = ({
|
|
|
174
174
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
175
175
|
});
|
|
176
176
|
dispatch(tr);
|
|
177
|
-
const visibleGuidelines = getVisibleGuidelines(
|
|
177
|
+
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
178
178
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
179
179
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
180
180
|
onResizeStart();
|
|
181
181
|
}
|
|
182
|
-
}, [startMeasure, editorView, displayGapCursor,
|
|
182
|
+
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
183
183
|
const handleResize = useCallback((originalState, delta) => {
|
|
184
184
|
countFrames();
|
|
185
185
|
const newWidth = originalState.width + delta.width;
|
|
@@ -197,11 +197,11 @@ export const TableResizer = ({
|
|
|
197
197
|
prevNode: node,
|
|
198
198
|
start: pos + 1,
|
|
199
199
|
parentWidth: newWidth
|
|
200
|
-
}, editorView.domAtPos.bind(editorView),
|
|
201
|
-
updateActiveGuidelines(findClosestSnap(newWidth,
|
|
200
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
|
|
201
|
+
updateActiveGuidelines(findClosestSnap(newWidth, isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
202
202
|
updateWidth(newWidth);
|
|
203
203
|
return newWidth;
|
|
204
|
-
}, [countFrames,
|
|
204
|
+
}, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
205
205
|
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
206
206
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
207
207
|
isResizing.current = false;
|
|
@@ -238,7 +238,7 @@ export const TableResizer = ({
|
|
|
238
238
|
prevNode: node,
|
|
239
239
|
start: pos + 1,
|
|
240
240
|
parentWidth: newWidth
|
|
241
|
-
}, editorView.domAtPos.bind(editorView),
|
|
241
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled)(tr);
|
|
242
242
|
const scaledNode = tr.doc.nodeAt(pos);
|
|
243
243
|
(_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
|
|
244
244
|
originalNode: node,
|
|
@@ -256,7 +256,7 @@ export const TableResizer = ({
|
|
|
256
256
|
onResizeStop();
|
|
257
257
|
}
|
|
258
258
|
return newWidth;
|
|
259
|
-
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop,
|
|
259
|
+
}, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
|
|
260
260
|
const handleTableSizeChangeOnKeypress = useCallback(step => {
|
|
261
261
|
const newWidth = width + step;
|
|
262
262
|
if (newWidth > maxWidth || newWidth < resizerMinWidth) {
|
|
@@ -57,17 +57,15 @@ export default class TableView extends ReactNodeView {
|
|
|
57
57
|
_defineProperty(this, "hasHoveredRows", false);
|
|
58
58
|
this.getPos = props.getPos;
|
|
59
59
|
this.eventDispatcher = props.eventDispatcher;
|
|
60
|
-
this.
|
|
60
|
+
this.options = props.options;
|
|
61
61
|
}
|
|
62
62
|
getContentDOM() {
|
|
63
63
|
const rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
|
|
64
64
|
if (rendered.dom) {
|
|
65
|
+
var _this$options;
|
|
65
66
|
this.table = rendered.dom;
|
|
66
|
-
const {
|
|
67
|
-
tablePreserveWidth = false
|
|
68
|
-
} = this.getEditorFeatureFlags();
|
|
69
67
|
// Preserve Table Width cannot have inline width set on the table
|
|
70
|
-
if (!
|
|
68
|
+
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled)) {
|
|
71
69
|
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
72
70
|
if (tableInlineWidth) {
|
|
73
71
|
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
@@ -157,6 +155,7 @@ export default class TableView extends ReactNodeView {
|
|
|
157
155
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
158
156
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
159
157
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
158
|
+
isTableScalingEnabled: pluginState.isTableScalingEnabled,
|
|
160
159
|
tableActive: tableActive,
|
|
161
160
|
ordering: pluginState.ordering,
|
|
162
161
|
isResizing: isResizing,
|
|
@@ -165,8 +164,7 @@ export default class TableView extends ReactNodeView {
|
|
|
165
164
|
contentDOM: forwardRef,
|
|
166
165
|
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
167
166
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
168
|
-
pluginInjectionApi: props.pluginInjectionApi
|
|
169
|
-
tableRef: this.table
|
|
167
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
170
168
|
});
|
|
171
169
|
}
|
|
172
170
|
});
|
|
@@ -234,7 +232,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
234
232
|
isFullWidthModeEnabled,
|
|
235
233
|
wasFullWidthModeEnabled,
|
|
236
234
|
isTableResizingEnabled,
|
|
237
|
-
isDragAndDropEnabled
|
|
235
|
+
isDragAndDropEnabled,
|
|
236
|
+
isTableScalingEnabled
|
|
238
237
|
} = getPluginState(view.state);
|
|
239
238
|
const {
|
|
240
239
|
allowColumnResizing
|
|
@@ -252,7 +251,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
252
251
|
isFullWidthModeEnabled,
|
|
253
252
|
wasFullWidthModeEnabled,
|
|
254
253
|
isTableResizingEnabled,
|
|
255
|
-
isDragAndDropEnabled
|
|
254
|
+
isDragAndDropEnabled,
|
|
255
|
+
isTableScalingEnabled
|
|
256
256
|
},
|
|
257
257
|
getEditorContainerWidth,
|
|
258
258
|
getEditorFeatureFlags,
|