@atlaskit/editor-plugin-table 22.1.3 → 22.2.0
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 +20 -0
- package/dist/cjs/nodeviews/TableComponent.js +6 -5
- package/dist/cjs/nodeviews/table-node-views.js +1 -2
- package/dist/cjs/pm-plugins/commands/column-resize.js +2 -3
- package/dist/cjs/pm-plugins/commands/hover.js +6 -14
- package/dist/cjs/pm-plugins/commands/misc.js +13 -17
- package/dist/cjs/pm-plugins/decorations/plugin.js +2 -10
- package/dist/cjs/pm-plugins/decorations/utils/column-controls.js +9 -26
- package/dist/cjs/pm-plugins/utils/decoration.js +6 -10
- package/dist/cjs/pm-plugins/utils/sticky-header.js +2 -2
- package/dist/cjs/pm-plugins/utils/tableMode.js +52 -20
- package/dist/cjs/tablePlugin.js +1 -2
- package/dist/cjs/ui/FloatingContextualButton/index.js +1 -2
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -15
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/es2019/nodeviews/TableComponent.js +6 -5
- package/dist/es2019/nodeviews/table-node-views.js +1 -2
- package/dist/es2019/pm-plugins/commands/column-resize.js +2 -3
- package/dist/es2019/pm-plugins/commands/hover.js +4 -16
- package/dist/es2019/pm-plugins/commands/misc.js +1 -6
- package/dist/es2019/pm-plugins/decorations/plugin.js +2 -9
- package/dist/es2019/pm-plugins/decorations/utils/column-controls.js +3 -21
- package/dist/es2019/pm-plugins/utils/decoration.js +6 -10
- package/dist/es2019/pm-plugins/utils/sticky-header.js +2 -2
- package/dist/es2019/pm-plugins/utils/tableMode.js +46 -18
- package/dist/es2019/tablePlugin.js +1 -2
- package/dist/es2019/ui/FloatingContextualButton/index.js +1 -2
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -15
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +6 -5
- package/dist/esm/nodeviews/table-node-views.js +1 -2
- package/dist/esm/pm-plugins/commands/column-resize.js +2 -3
- package/dist/esm/pm-plugins/commands/hover.js +6 -14
- package/dist/esm/pm-plugins/commands/misc.js +14 -18
- package/dist/esm/pm-plugins/decorations/plugin.js +2 -10
- package/dist/esm/pm-plugins/decorations/utils/column-controls.js +10 -27
- package/dist/esm/pm-plugins/utils/decoration.js +6 -10
- package/dist/esm/pm-plugins/utils/sticky-header.js +2 -2
- package/dist/esm/pm-plugins/utils/tableMode.js +51 -19
- package/dist/esm/tablePlugin.js +1 -2
- package/dist/esm/ui/FloatingContextualButton/index.js +1 -2
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -15
- package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/types/pm-plugins/decorations/utils/column-controls.d.ts +2 -2
- package/dist/types/pm-plugins/decorations/utils/types.d.ts +1 -7
- package/dist/types/pm-plugins/utils/decoration.d.ts +2 -2
- package/dist/types/pm-plugins/utils/sticky-header.d.ts +1 -1
- package/dist/types/pm-plugins/utils/tableMode.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/decorations/utils/column-controls.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/decorations/utils/types.d.ts +1 -7
- package/dist/types-ts4.5/pm-plugins/utils/decoration.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/utils/sticky-header.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +7 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 22.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`e5cdd96dcf4f9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e5cdd96dcf4f9) -
|
|
8
|
+
Clean up platform_editor_hydratable_ui experiment (shipped as enabled)
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [`d2c265eaaf495`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d2c265eaaf495) -
|
|
13
|
+
Remove isDragAndDropEnabled dead code from pm-plugins - always true (EDITOR-6290)
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 22.1.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`af869bf30a1e1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/af869bf30a1e1) -
|
|
21
|
+
Fix table-layout: auto inline style persisting after fit-to-content measurement
|
|
22
|
+
|
|
3
23
|
## 22.1.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -140,18 +140,19 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
140
140
|
var prevNode = _this.node;
|
|
141
141
|
var node = getNode();
|
|
142
142
|
var prevAttrs = prevNode.attrs;
|
|
143
|
-
var isNested = (0, _nodes.isTableNested)(_this.props.view.state, _this.props.getPos());
|
|
144
143
|
var tablePos = _this.props.getPos();
|
|
144
|
+
var isNested = (0, _nodes.isTableNested)(_this.props.view.state, tablePos);
|
|
145
145
|
var parentWidth = _this.getParentNodeWidth();
|
|
146
146
|
var useMeasuredWidthForBodiedSyncBlock = isNested && typeof tablePos === 'number' && (0, _nodes.isTableNestedUnderBodiedSyncBlock)(_this.props.view.state, tablePos) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_9');
|
|
147
147
|
if (useMeasuredWidthForBodiedSyncBlock) {
|
|
148
148
|
// Prefer the live DOM measurement (`clientWidth`) over the ResizeObserver-cached
|
|
149
149
|
// value (`wrapperWidth`) because clientWidth is synchronous and more up-to-date
|
|
150
150
|
// at the time this handler runs. Fall back to `wrapperWidth` if the wrapper ref
|
|
151
|
-
// is not yet available.
|
|
152
|
-
//
|
|
151
|
+
// is not yet available.
|
|
152
|
+
// The clientWidth > 0 since DOM clientWidth is 0 before layout
|
|
153
|
+
// The > 1 guard for wrapperWidth was intentional to filter out the degenerate value of 1 that ResizeObserver reports during element unmounting.
|
|
153
154
|
var measuredWrapperWidth;
|
|
154
|
-
if (_this.wrapper && _this.wrapper.clientWidth >
|
|
155
|
+
if (_this.wrapper && _this.wrapper.clientWidth > 0) {
|
|
155
156
|
measuredWrapperWidth = _this.wrapper.clientWidth;
|
|
156
157
|
} else if (_this.wrapperWidth && _this.wrapperWidth > 1) {
|
|
157
158
|
measuredWrapperWidth = _this.wrapperWidth;
|
|
@@ -162,7 +163,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
162
163
|
parentWidth = measuredWrapperWidth;
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
|
-
if (!useMeasuredWidthForBodiedSyncBlock && isNested && (0, _nodes.isTableNestedInMoreThanOneNode)(_this.props.view.state,
|
|
166
|
+
if (!useMeasuredWidthForBodiedSyncBlock && isNested && (0, _nodes.isTableNestedInMoreThanOneNode)(_this.props.view.state, tablePos)) {
|
|
166
167
|
var resizeObsWrapperWidth = _this.wrapperWidth || 0;
|
|
167
168
|
var wrapperWidthDiffBetweenRerenders = Math.abs(resizeObsWrapperWidth - (_this.state.parentWidth || 0));
|
|
168
169
|
var isOusideOfThreshold = wrapperWidthDiffBetweenRerenders <= NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD || wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
|
|
@@ -32,8 +32,7 @@ var tableHeaderView = exports.tableHeaderView = function tableHeaderView(options
|
|
|
32
32
|
};
|
|
33
33
|
var tableRowView = exports.tableRowView = function tableRowView(options) {
|
|
34
34
|
return function (node, view, getPos) {
|
|
35
|
-
|
|
36
|
-
if ((0, _stickyHeader.isNativeStickySupported)((_options$isDragAndDro = options.isDragAndDropEnabled) !== null && _options$isDragAndDro !== void 0 ? _options$isDragAndDro : false) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
35
|
+
if ((0, _stickyHeader.isNativeStickySupported)() && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
37
36
|
return new _TableRowNativeStickyWithFallback.default(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
|
|
38
37
|
} else {
|
|
39
38
|
return new _TableRow.default(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
|
|
@@ -33,8 +33,7 @@ var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosi
|
|
|
33
33
|
var customTr = state.tr;
|
|
34
34
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
35
35
|
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
|
|
36
|
-
getIntl = _getPluginState.getIntl
|
|
37
|
-
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
36
|
+
getIntl = _getPluginState.getIntl;
|
|
38
37
|
var fakeDispatch = function fakeDispatch(tr) {
|
|
39
38
|
customTr = tr;
|
|
40
39
|
};
|
|
@@ -47,7 +46,7 @@ var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosi
|
|
|
47
46
|
});
|
|
48
47
|
var decorationsWithWidgetAndHandle = (0, _decoration.updateDecorations)(customTr.doc, decorationsWithWidget, (0, _decoration.createColumnLineResize)(state.selection, {
|
|
49
48
|
right: columnIndex
|
|
50
|
-
}
|
|
49
|
+
}), _types.TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
|
|
51
50
|
getTablePluginCommand({
|
|
52
51
|
type: 'START_KEYBOARD_COLUMN_RESIZE',
|
|
53
52
|
data: {
|
|
@@ -49,12 +49,10 @@ var hoverMergedCells = exports.hoverMergedCells = function hoverMergedCells() {
|
|
|
49
49
|
var hoverColumns = exports.hoverColumns = function hoverColumns(hoveredColumns, isInDanger) {
|
|
50
50
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
51
51
|
var cells = (0, _utils.getCellsInColumn)(hoveredColumns)(state.tr.selection);
|
|
52
|
-
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
53
|
-
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
54
52
|
if (!cells) {
|
|
55
53
|
return false;
|
|
56
54
|
}
|
|
57
|
-
var decorations = (0, _decoration.createControlsHoverDecoration)(cells, 'column', state.tr,
|
|
55
|
+
var decorations = (0, _decoration.createControlsHoverDecoration)(cells, 'column', state.tr, hoveredColumns, isInDanger);
|
|
58
56
|
return {
|
|
59
57
|
type: 'HOVER_COLUMNS',
|
|
60
58
|
data: {
|
|
@@ -73,9 +71,7 @@ var hoverRows = exports.hoverRows = function hoverRows(hoveredRows, isInDanger)
|
|
|
73
71
|
if (!cells) {
|
|
74
72
|
return false;
|
|
75
73
|
}
|
|
76
|
-
var
|
|
77
|
-
isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
|
|
78
|
-
var decorations = (0, _decoration.createControlsHoverDecoration)(cells, 'row', state.tr, isDragAndDropEnabled, hoveredRows, isInDanger);
|
|
74
|
+
var decorations = (0, _decoration.createControlsHoverDecoration)(cells, 'row', state.tr, hoveredRows, isInDanger);
|
|
79
75
|
return {
|
|
80
76
|
type: 'HOVER_ROWS',
|
|
81
77
|
data: {
|
|
@@ -101,9 +97,7 @@ var hoverTable = exports.hoverTable = function hoverTable(isInDanger, isSelected
|
|
|
101
97
|
if (!cells) {
|
|
102
98
|
return false;
|
|
103
99
|
}
|
|
104
|
-
var
|
|
105
|
-
isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
|
|
106
|
-
var decorations = (0, _decoration.createControlsHoverDecoration)(cells, 'table', state.tr, isDragAndDropEnabled, [], isInDanger, isSelected);
|
|
100
|
+
var decorations = (0, _decoration.createControlsHoverDecoration)(cells, 'table', state.tr, [], isInDanger, isSelected);
|
|
107
101
|
return {
|
|
108
102
|
type: 'HOVER_TABLE',
|
|
109
103
|
data: {
|
|
@@ -132,12 +126,10 @@ var clearHoverSelection = exports.clearHoverSelection = function clearHoverSelec
|
|
|
132
126
|
};
|
|
133
127
|
var showResizeHandleLine = exports.showResizeHandleLine = function showResizeHandleLine(cellColumnPositioning) {
|
|
134
128
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
135
|
-
var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
|
|
136
|
-
isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
|
|
137
129
|
return {
|
|
138
130
|
type: 'SHOW_RESIZE_HANDLE_LINE',
|
|
139
131
|
data: {
|
|
140
|
-
decorationSet: (0, _updatePluginStateDecorations.updatePluginStateDecorations)(state, (0, _decoration.createColumnLineResize)(state.selection, cellColumnPositioning
|
|
132
|
+
decorationSet: (0, _updatePluginStateDecorations.updatePluginStateDecorations)(state, (0, _decoration.createColumnLineResize)(state.selection, cellColumnPositioning), _types.TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
|
|
141
133
|
}
|
|
142
134
|
};
|
|
143
135
|
});
|
|
@@ -166,8 +158,8 @@ var setTableHovered = exports.setTableHovered = function setTableHovered(hovered
|
|
|
166
158
|
};
|
|
167
159
|
var hoverCell = exports.hoverCell = function hoverCell(rowIndex, colIndex) {
|
|
168
160
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
169
|
-
var
|
|
170
|
-
prevHoveredCell =
|
|
161
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
162
|
+
prevHoveredCell = _getPluginState.hoveredCell;
|
|
171
163
|
|
|
172
164
|
// If no arguments have been passed then the intention it to reset the hover cell data
|
|
173
165
|
var clear = rowIndex === undefined && colIndex === undefined;
|
|
@@ -41,8 +41,6 @@ var setTableRef = exports.setTableRef = function setTableRef(ref) {
|
|
|
41
41
|
var tableNode = ref && foundTable ? foundTable.node : undefined;
|
|
42
42
|
var tablePos = ref && foundTable ? foundTable.pos : undefined;
|
|
43
43
|
var tableWrapperTarget = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
44
|
-
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
45
|
-
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
46
44
|
return {
|
|
47
45
|
type: 'SET_TABLE_REF',
|
|
48
46
|
data: {
|
|
@@ -53,8 +51,6 @@ var setTableRef = exports.setTableRef = function setTableRef(ref) {
|
|
|
53
51
|
isNumberColumnEnabled: (0, _nodes.checkIfNumberColumnEnabled)(state.selection),
|
|
54
52
|
isHeaderRowEnabled: (0, _nodes.checkIfHeaderRowEnabled)(state.selection),
|
|
55
53
|
isHeaderColumnEnabled: (0, _nodes.checkIfHeaderColumnEnabled)(state.selection),
|
|
56
|
-
// decoration set is drawn by the decoration plugin, skip this for DnD as all controls are floating
|
|
57
|
-
decorationSet: !isDragAndDropEnabled ? (0, _updatePluginStateDecorations.updatePluginStateDecorations)(state, (0, _decoration.createColumnControlsDecoration)(state.selection), _types.TableDecorations.COLUMN_CONTROLS_DECORATIONS) : undefined,
|
|
58
54
|
resizeHandleRowIndex: undefined,
|
|
59
55
|
resizeHandleColumnIndex: undefined
|
|
60
56
|
}
|
|
@@ -339,8 +335,8 @@ var setMultipleCellAttrs = exports.setMultipleCellAttrs = function setMultipleCe
|
|
|
339
335
|
return function (state, dispatch) {
|
|
340
336
|
var cursorPos;
|
|
341
337
|
var tr = state.tr;
|
|
342
|
-
var
|
|
343
|
-
targetCellPosition =
|
|
338
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
339
|
+
targetCellPosition = _getPluginState.targetCellPosition;
|
|
344
340
|
if ((0, _utils2.isSelectionType)(tr.selection, 'cell')) {
|
|
345
341
|
// Ignored via go/ees005
|
|
346
342
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -501,9 +497,9 @@ var hideInsertColumnOrRowButton = exports.hideInsertColumnOrRowButton = function
|
|
|
501
497
|
var addResizeHandleDecorations = exports.addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip, nodeViewPortalProviderAPI, isKeyboardResize) {
|
|
502
498
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
503
499
|
var tableNode = (0, _utils2.findTable)(state.selection);
|
|
504
|
-
var
|
|
505
|
-
allowColumnResizing =
|
|
506
|
-
getIntl =
|
|
500
|
+
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
501
|
+
allowColumnResizing = _getPluginState2.pluginConfig.allowColumnResizing,
|
|
502
|
+
getIntl = _getPluginState2.getIntl;
|
|
507
503
|
if (!tableNode || !allowColumnResizing) {
|
|
508
504
|
return false;
|
|
509
505
|
}
|
|
@@ -527,12 +523,12 @@ var addResizeHandleDecorations = exports.addResizeHandleDecorations = function a
|
|
|
527
523
|
var updateResizeHandleDecorations = exports.updateResizeHandleDecorations = function updateResizeHandleDecorations(nodeViewPortalProviderAPI, rowIndex, columnIndex, includeTooltip) {
|
|
528
524
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
529
525
|
var tableNode = (0, _utils2.findTable)(state.selection);
|
|
530
|
-
var
|
|
531
|
-
resizeHandleRowIndex =
|
|
532
|
-
resizeHandleColumnIndex =
|
|
533
|
-
resizeHandleIncludeTooltip =
|
|
534
|
-
allowColumnResizing =
|
|
535
|
-
getIntl =
|
|
526
|
+
var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
527
|
+
resizeHandleRowIndex = _getPluginState3.resizeHandleRowIndex,
|
|
528
|
+
resizeHandleColumnIndex = _getPluginState3.resizeHandleColumnIndex,
|
|
529
|
+
resizeHandleIncludeTooltip = _getPluginState3.resizeHandleIncludeTooltip,
|
|
530
|
+
allowColumnResizing = _getPluginState3.pluginConfig.allowColumnResizing,
|
|
531
|
+
getIntl = _getPluginState3.getIntl;
|
|
536
532
|
if (!tableNode || !allowColumnResizing) {
|
|
537
533
|
return false;
|
|
538
534
|
}
|
|
@@ -606,8 +602,8 @@ var addBoldInEmptyHeaderCells = exports.addBoldInEmptyHeaderCells = function add
|
|
|
606
602
|
};
|
|
607
603
|
var updateWidthToWidest = exports.updateWidthToWidest = function updateWidthToWidest(widthToWidest) {
|
|
608
604
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
609
|
-
var
|
|
610
|
-
prevWidthToWidest =
|
|
605
|
+
var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
|
|
606
|
+
prevWidthToWidest = _getPluginState4.widthToWidest;
|
|
611
607
|
if ((0, _isEqual.default)(widthToWidest, prevWidthToWidest)) {
|
|
612
608
|
return false;
|
|
613
609
|
}
|
|
@@ -22,8 +22,6 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
|
|
|
22
22
|
var isResizing = (_tableWidthPluginKey$ = _tableWidth.pluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
23
23
|
var wasResizing = (_tableWidthPluginKey$2 = _tableWidth.pluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
24
24
|
var _ref = _pluginKey.pluginKey.getState(newState) || {},
|
|
25
|
-
_ref$isDragAndDropEna = _ref.isDragAndDropEnabled,
|
|
26
|
-
isDragAndDropEnabled = _ref$isDragAndDropEna === void 0 ? false : _ref$isDragAndDropEna,
|
|
27
25
|
isInDanger = _ref.isInDanger,
|
|
28
26
|
isTableHovered = _ref.isTableHovered;
|
|
29
27
|
var changedResizing = isResizing !== wasResizing;
|
|
@@ -34,10 +32,7 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
|
|
|
34
32
|
} else if (tr.docChanged || tr.selection instanceof _cellSelection.CellSelection || changedResizing) {
|
|
35
33
|
return (0, _columnControls.buildColumnControlsDecorations)({
|
|
36
34
|
decorationSet: decorationSet,
|
|
37
|
-
tr: tr
|
|
38
|
-
options: {
|
|
39
|
-
isDragAndDropEnabled: isDragAndDropEnabled
|
|
40
|
-
}
|
|
35
|
+
tr: tr
|
|
41
36
|
});
|
|
42
37
|
} else if (tr.selectionSet) {
|
|
43
38
|
var _findTable, _findTable2;
|
|
@@ -52,10 +47,7 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
|
|
|
52
47
|
if ((isInDanger || isTableHovered) && (!(0, _coreUtils.insideTable)(newState) || ((_findTable = (0, _utils.findTable)(newState.selection)) === null || _findTable === void 0 ? void 0 : _findTable.node) !== ((_findTable2 = (0, _utils.findTable)(oldState.selection)) === null || _findTable2 === void 0 ? void 0 : _findTable2.node))) {
|
|
53
48
|
return (0, _columnControls.buildColumnControlsDecorations)({
|
|
54
49
|
decorationSet: decorationSet,
|
|
55
|
-
tr: tr
|
|
56
|
-
options: {
|
|
57
|
-
isDragAndDropEnabled: isDragAndDropEnabled
|
|
58
|
-
}
|
|
50
|
+
tr: tr
|
|
59
51
|
});
|
|
60
52
|
}
|
|
61
53
|
}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.maybeUpdateColumnControlsSelectedDecoration = exports.buildColumnControlsDecorations = void 0;
|
|
7
7
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
8
|
-
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
8
|
var _types = require("../../../types");
|
|
10
9
|
var _decoration = require("../../utils/decoration");
|
|
11
10
|
var _composeDecorations = require("./compose-decorations");
|
|
@@ -28,27 +27,18 @@ var maybeUpdateColumnSelectedDecoration = function maybeUpdateColumnSelectedDeco
|
|
|
28
27
|
}
|
|
29
28
|
return (0, _decoration.updateDecorations)(tr.doc, decorationSet, (0, _decoration.createColumnSelectedDecoration)(tr), _types.TableDecorations.COLUMN_SELECTED);
|
|
30
29
|
};
|
|
31
|
-
var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDecoration(_ref3) {
|
|
32
|
-
var decorationSet = _ref3.decorationSet,
|
|
33
|
-
tr = _ref3.tr;
|
|
34
|
-
var table = (0, _utils.findTable)(tr.selection);
|
|
35
|
-
if (!table) {
|
|
36
|
-
return decorationSet;
|
|
37
|
-
}
|
|
38
|
-
return (0, _decoration.updateDecorations)(tr.doc, decorationSet, (0, _decoration.createColumnControlsDecoration)(tr.selection), _types.TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
39
|
-
};
|
|
40
30
|
|
|
41
31
|
// @see: https://product-fabric.atlassian.net/browse/ED-7304
|
|
42
|
-
var removeColumnControlsSelectedDecoration = function removeColumnControlsSelectedDecoration(
|
|
43
|
-
var decorationSet =
|
|
32
|
+
var removeColumnControlsSelectedDecoration = function removeColumnControlsSelectedDecoration(_ref3) {
|
|
33
|
+
var decorationSet = _ref3.decorationSet;
|
|
44
34
|
return decorationSet.remove((0, _decoration.findColumnControlSelectedDecoration)(decorationSet));
|
|
45
35
|
};
|
|
46
36
|
var hasColumnSelectedDecorations = function hasColumnSelectedDecorations(decorationSet) {
|
|
47
37
|
return !!(0, _decoration.findColumnControlSelectedDecoration)(decorationSet).length;
|
|
48
38
|
};
|
|
49
|
-
var maybeUpdateColumnControlsSelectedDecoration = exports.maybeUpdateColumnControlsSelectedDecoration = function maybeUpdateColumnControlsSelectedDecoration(
|
|
50
|
-
var decorationSet =
|
|
51
|
-
tr =
|
|
39
|
+
var maybeUpdateColumnControlsSelectedDecoration = exports.maybeUpdateColumnControlsSelectedDecoration = function maybeUpdateColumnControlsSelectedDecoration(_ref4) {
|
|
40
|
+
var decorationSet = _ref4.decorationSet,
|
|
41
|
+
tr = _ref4.tr;
|
|
52
42
|
if (!hasColumnSelectedDecorations(decorationSet)) {
|
|
53
43
|
return decorationSet;
|
|
54
44
|
}
|
|
@@ -57,17 +47,10 @@ var maybeUpdateColumnControlsSelectedDecoration = exports.maybeUpdateColumnContr
|
|
|
57
47
|
tr: tr
|
|
58
48
|
});
|
|
59
49
|
};
|
|
60
|
-
var buildColumnControlsDecorations = exports.buildColumnControlsDecorations = function buildColumnControlsDecorations(
|
|
61
|
-
var decorationSet =
|
|
62
|
-
tr =
|
|
63
|
-
|
|
64
|
-
if (options.isDragAndDropEnabled) {
|
|
65
|
-
return (0, _composeDecorations.composeDecorations)([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration])({
|
|
66
|
-
decorationSet: decorationSet,
|
|
67
|
-
tr: tr
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return (0, _composeDecorations.composeDecorations)([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration, maybeUpdateColumnControlsDecoration])({
|
|
50
|
+
var buildColumnControlsDecorations = exports.buildColumnControlsDecorations = function buildColumnControlsDecorations(_ref5) {
|
|
51
|
+
var decorationSet = _ref5.decorationSet,
|
|
52
|
+
tr = _ref5.tr;
|
|
53
|
+
return (0, _composeDecorations.composeDecorations)([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration])({
|
|
71
54
|
decorationSet: decorationSet,
|
|
72
55
|
tr: tr
|
|
73
56
|
});
|
|
@@ -40,7 +40,7 @@ var createCellHoverDecoration = exports.createCellHoverDecoration = function cre
|
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
|
-
var createControlsHoverDecoration = exports.createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr,
|
|
43
|
+
var createControlsHoverDecoration = exports.createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr, hoveredIndexes, danger, selected) {
|
|
44
44
|
var table = (0, _utils2.findTable)(tr.selection);
|
|
45
45
|
if (!table) {
|
|
46
46
|
return [];
|
|
@@ -92,13 +92,9 @@ var createControlsHoverDecoration = exports.createControlsHoverDecoration = func
|
|
|
92
92
|
if (selected) {
|
|
93
93
|
classes.push(_types.TableCssClassName.SELECTED_CELL);
|
|
94
94
|
}
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
classes.push(_types.TableCssClassName.HOVERED_NO_HIGHLIGHT);
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
classes.push(type === 'column' ? _types.TableCssClassName.HOVERED_COLUMN : type === 'row' ? _types.TableCssClassName.HOVERED_ROW : _types.TableCssClassName.HOVERED_TABLE);
|
|
95
|
+
if (type === 'column' || type === 'row') {
|
|
96
|
+
classes.pop();
|
|
97
|
+
classes.push(_types.TableCssClassName.HOVERED_NO_HIGHLIGHT);
|
|
102
98
|
}
|
|
103
99
|
var key;
|
|
104
100
|
switch (type) {
|
|
@@ -399,7 +395,7 @@ var createResizeHandleDecoration = exports.createResizeHandleDecoration = functi
|
|
|
399
395
|
* this function will return two decorations applying a new class `ClassName.WITH_RESIZE_LINE`
|
|
400
396
|
* only on the cells: `C1` and `D1`.
|
|
401
397
|
*/
|
|
402
|
-
var createColumnLineResize = exports.createColumnLineResize = function createColumnLineResize(selection, cellColumnPositioning
|
|
398
|
+
var createColumnLineResize = exports.createColumnLineResize = function createColumnLineResize(selection, cellColumnPositioning) {
|
|
403
399
|
var table = (0, _utils2.findTable)(selection);
|
|
404
400
|
if (!table || cellColumnPositioning.right === null) {
|
|
405
401
|
return [];
|
|
@@ -410,7 +406,7 @@ var createColumnLineResize = exports.createColumnLineResize = function createCol
|
|
|
410
406
|
if (isLastColumn) {
|
|
411
407
|
columnIndex -= 1;
|
|
412
408
|
}
|
|
413
|
-
var decorationClassName =
|
|
409
|
+
var decorationClassName = isLastColumn ? _types.TableCssClassName.WITH_DRAG_RESIZE_LINE_LAST_COLUMN : _types.TableCssClassName.WITH_DRAG_RESIZE_LINE;
|
|
414
410
|
var cellPositions = makeArray(map.height).map(function (rowIndex) {
|
|
415
411
|
return map.map[map.width * rowIndex + columnIndex];
|
|
416
412
|
}).filter(function (cellPosition, rowIndex) {
|
|
@@ -13,11 +13,11 @@ var isAnchorSupported = exports.isAnchorSupported = (0, _memoizeOne.default)(fun
|
|
|
13
13
|
}
|
|
14
14
|
return false;
|
|
15
15
|
});
|
|
16
|
-
var isNativeStickySupported = exports.isNativeStickySupported = function isNativeStickySupported(
|
|
16
|
+
var isNativeStickySupported = exports.isNativeStickySupported = function isNativeStickySupported() {
|
|
17
17
|
var safariVersion = (0, _browser.getBrowserInfo)().safari_version;
|
|
18
18
|
var isBrowserSafari = !Number.isNaN(safariVersion);
|
|
19
19
|
return (
|
|
20
20
|
// Safari has a bug with position: sticky and content editable, so we don't support it
|
|
21
|
-
!isBrowserSafari && isAnchorSupported()
|
|
21
|
+
!isBrowserSafari && isAnchorSupported()
|
|
22
22
|
);
|
|
23
23
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isContentModeSupported = exports.applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToAllTables = void 0;
|
|
6
|
+
exports.measureTableWithAutoLayout = exports.isContentModeSupported = exports.applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToAllTables = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
9
|
var _table = require("@atlaskit/editor-common/table");
|
|
@@ -78,42 +78,74 @@ var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = func
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
82
|
+
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
83
|
+
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
82
84
|
*/
|
|
83
|
-
var
|
|
84
|
-
var _api$analytics, _api$width$sharedStat, _api$width;
|
|
85
|
-
var tableObject = (0, _utils.findTable)(view.state.selection);
|
|
86
|
-
if (!tableObject) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
var node = tableObject.node,
|
|
90
|
-
pos = tableObject.pos;
|
|
91
|
-
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
92
|
-
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
var tableRef = tableState.tableRef;
|
|
96
|
-
|
|
97
|
-
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
98
|
-
// for a rAF to measure natural column widths, instea directly update the DOM elements and
|
|
99
|
-
// take a measurement.
|
|
85
|
+
var measureTableWithAutoLayout = exports.measureTableWithAutoLayout = function measureTableWithAutoLayout(tableRef) {
|
|
100
86
|
var cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
101
87
|
var contentWrap = tableRef.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP));
|
|
102
88
|
var resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(".".concat(_styles.TableSharedCssClassName.TABLE_RESIZER_CONTAINER));
|
|
103
89
|
var resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
|
|
90
|
+
|
|
91
|
+
// Capture current inline styles so we can restore them after measurement
|
|
92
|
+
var prevTableWidth = tableRef.style.width;
|
|
93
|
+
var prevTableLayout = tableRef.style.tableLayout;
|
|
94
|
+
var prevColWidths = cols.map(function (col) {
|
|
95
|
+
return col.style.width;
|
|
96
|
+
});
|
|
97
|
+
var prevResizerItemWidth = resizerItem === null || resizerItem === void 0 ? void 0 : resizerItem.style.width;
|
|
98
|
+
|
|
99
|
+
// Apply temporary styles for content-based measurement
|
|
104
100
|
tableRef.style.width = '';
|
|
105
101
|
tableRef.style.tableLayout = 'auto';
|
|
106
102
|
cols.forEach(function (col) {
|
|
107
103
|
return col.style.width = '';
|
|
108
104
|
});
|
|
109
105
|
if (resizerContainer) {
|
|
110
|
-
|
|
106
|
+
// favour CSS var to align with the table first render state, which gets reset
|
|
107
|
+
// once resized by user. By doing this we avoid the need to any 'reset' work after
|
|
108
|
+
// measurement and ensures it works if the table has been resized or not in the session.
|
|
109
|
+
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
111
110
|
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
112
111
|
}
|
|
113
112
|
if (resizerItem) {
|
|
114
113
|
resizerItem.style.width = 'max-content';
|
|
115
114
|
}
|
|
116
115
|
var measurement = (0, _contentMode.getTableMeasurement)(tableRef);
|
|
116
|
+
|
|
117
|
+
// Reset all inline styles back to their previous values
|
|
118
|
+
tableRef.style.width = prevTableWidth;
|
|
119
|
+
tableRef.style.tableLayout = prevTableLayout;
|
|
120
|
+
cols.forEach(function (col, i) {
|
|
121
|
+
return col.style.width = prevColWidths[i];
|
|
122
|
+
});
|
|
123
|
+
if (resizerItem) {
|
|
124
|
+
resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
|
|
125
|
+
}
|
|
126
|
+
return measurement;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
131
|
+
*/
|
|
132
|
+
var applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
|
|
133
|
+
var _api$analytics, _api$width$sharedStat, _api$width;
|
|
134
|
+
var tableObject = (0, _utils.findTable)(view.state.selection);
|
|
135
|
+
if (!tableObject) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
var node = tableObject.node,
|
|
139
|
+
pos = tableObject.pos;
|
|
140
|
+
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
141
|
+
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
146
|
+
// for a rAF to measure natural column widths, directly update the DOM elements,
|
|
147
|
+
// take a measurement, and reset styles so no temporary overrides persist.
|
|
148
|
+
var measurement = measureTableWithAutoLayout(tableState.tableRef);
|
|
117
149
|
var tr = (0, _contentMode.applyTableMeasurement)(view.state.tr, node, measurement, pos);
|
|
118
150
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
|
|
119
151
|
action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
package/dist/cjs/tablePlugin.js
CHANGED
|
@@ -52,7 +52,6 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
52
52
|
tableWrapper = props.tableWrapper,
|
|
53
53
|
targetCellPosition = props.targetCellPosition,
|
|
54
54
|
isCellMenuOpenByKeyboard = props.isCellMenuOpenByKeyboard,
|
|
55
|
-
isDragAndDropEnabled = props.isDragAndDropEnabled,
|
|
56
55
|
formatMessage = props.intl.formatMessage; // : Props & WrappedComponentProps
|
|
57
56
|
|
|
58
57
|
var handleClick = function handleClick() {
|
|
@@ -105,7 +104,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
105
104
|
}));
|
|
106
105
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
107
106
|
var parentStickyNative = targetCellRef.parentElement && ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4') ? tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.classList.contains(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW) : targetCellRef.parentElement.classList.contains(_types.TableCssClassName.NATIVE_STICKY));
|
|
108
|
-
if (parentStickyNative && targetCellRef.nodeName === 'TH' && (0, _stickyHeader.isNativeStickySupported)(
|
|
107
|
+
if (parentStickyNative && targetCellRef.nodeName === 'TH' && (0, _stickyHeader.isNativeStickySupported)() && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
109
108
|
var _targetCellRef$parent;
|
|
110
109
|
/* We need to default to checking the anchor style because there may be a conflict with the block controls
|
|
111
110
|
plugin not using the data attribute value and setting the `anchor-name` style property independently of the data attribute.
|
|
@@ -10,7 +10,6 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
11
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
12
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
13
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
13
|
var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
15
14
|
var _consts = require("../consts");
|
|
16
15
|
var _ContextualMenu = _interopRequireDefault(require("./ContextualMenu"));
|
|
@@ -38,24 +37,17 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
38
37
|
isCommentEditor = _ref.isCommentEditor,
|
|
39
38
|
api = _ref.api,
|
|
40
39
|
isDragMenuOpen = _ref.isDragMenuOpen;
|
|
41
|
-
if (
|
|
40
|
+
if (!editorView) {
|
|
42
41
|
return null;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
46
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
48
45
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
49
46
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
50
47
|
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
51
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
48
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
54
49
|
return null;
|
|
55
50
|
}
|
|
56
|
-
|
|
57
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
51
|
var selection = editorView.state.selection;
|
|
60
52
|
var selectionRect = (0, _utils2.isSelectionType)(selection, 'cell') ?
|
|
61
53
|
// Ignored via go/ees005
|
|
@@ -64,8 +56,6 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
64
56
|
if (!selectionRect) {
|
|
65
57
|
return null;
|
|
66
58
|
}
|
|
67
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
59
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
70
60
|
var targetCellRef = (0, _utils.findDomRefAtPos)(targetCellPosition, domAtPos);
|
|
71
61
|
if (!targetCellRef) {
|
|
@@ -95,10 +85,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
95
85
|
stick: true
|
|
96
86
|
}, (0, _react.jsx)("div", {
|
|
97
87
|
css: (0, _styles.tablePopupStyles)(isDragAndDropEnabled)
|
|
98
|
-
}, (0, _react.jsx)(_ContextualMenu.default
|
|
99
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
101
|
-
, {
|
|
88
|
+
}, (0, _react.jsx)(_ContextualMenu.default, {
|
|
102
89
|
editorView: editorView
|
|
103
90
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
104
91
|
,
|
|
@@ -84,7 +84,7 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
|
|
|
84
84
|
containerRef === null || containerRef === void 0 || (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 || _containerRef$current2.style.removeProperty('top');
|
|
85
85
|
}
|
|
86
86
|
var anchorStyles = {};
|
|
87
|
-
if ((0, _stickyHeader.isNativeStickySupported)(
|
|
87
|
+
if ((0, _stickyHeader.isNativeStickySupported)() && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
88
88
|
var _tableRef$querySelect, _tableRef$querySelect2;
|
|
89
89
|
var rowAnchorName = (_tableRef$querySelect = tableRef.querySelector('tr')) === null || _tableRef$querySelect === void 0 ? void 0 : _tableRef$querySelect.style.getPropertyValue('anchor-name');
|
|
90
90
|
// cast here is due to CSSProperties missing valid positionAnchor property
|
|
@@ -120,18 +120,19 @@ class TableComponent extends React.Component {
|
|
|
120
120
|
const prevNode = this.node;
|
|
121
121
|
const node = getNode();
|
|
122
122
|
const prevAttrs = prevNode.attrs;
|
|
123
|
-
const isNested = isTableNested(this.props.view.state, this.props.getPos());
|
|
124
123
|
const tablePos = this.props.getPos();
|
|
124
|
+
const isNested = isTableNested(this.props.view.state, tablePos);
|
|
125
125
|
let parentWidth = this.getParentNodeWidth();
|
|
126
126
|
const useMeasuredWidthForBodiedSyncBlock = isNested && typeof tablePos === 'number' && isTableNestedUnderBodiedSyncBlock(this.props.view.state, tablePos) && fg('platform_synced_block_patch_9');
|
|
127
127
|
if (useMeasuredWidthForBodiedSyncBlock) {
|
|
128
128
|
// Prefer the live DOM measurement (`clientWidth`) over the ResizeObserver-cached
|
|
129
129
|
// value (`wrapperWidth`) because clientWidth is synchronous and more up-to-date
|
|
130
130
|
// at the time this handler runs. Fall back to `wrapperWidth` if the wrapper ref
|
|
131
|
-
// is not yet available.
|
|
132
|
-
//
|
|
131
|
+
// is not yet available.
|
|
132
|
+
// The clientWidth > 0 since DOM clientWidth is 0 before layout
|
|
133
|
+
// The > 1 guard for wrapperWidth was intentional to filter out the degenerate value of 1 that ResizeObserver reports during element unmounting.
|
|
133
134
|
let measuredWrapperWidth;
|
|
134
|
-
if (this.wrapper && this.wrapper.clientWidth >
|
|
135
|
+
if (this.wrapper && this.wrapper.clientWidth > 0) {
|
|
135
136
|
measuredWrapperWidth = this.wrapper.clientWidth;
|
|
136
137
|
} else if (this.wrapperWidth && this.wrapperWidth > 1) {
|
|
137
138
|
measuredWrapperWidth = this.wrapperWidth;
|
|
@@ -142,7 +143,7 @@ class TableComponent extends React.Component {
|
|
|
142
143
|
parentWidth = measuredWrapperWidth;
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
|
-
if (!useMeasuredWidthForBodiedSyncBlock && isNested && isTableNestedInMoreThanOneNode(this.props.view.state,
|
|
146
|
+
if (!useMeasuredWidthForBodiedSyncBlock && isNested && isTableNestedInMoreThanOneNode(this.props.view.state, tablePos)) {
|
|
146
147
|
const resizeObsWrapperWidth = this.wrapperWidth || 0;
|
|
147
148
|
const wrapperWidthDiffBetweenRerenders = Math.abs(resizeObsWrapperWidth - (this.state.parentWidth || 0));
|
|
148
149
|
const isOusideOfThreshold = wrapperWidthDiffBetweenRerenders <= NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD || wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
|
|
@@ -24,8 +24,7 @@ export const tableHeaderView = options => {
|
|
|
24
24
|
};
|
|
25
25
|
export const tableRowView = options => {
|
|
26
26
|
return (node, view, getPos) => {
|
|
27
|
-
|
|
28
|
-
if (isNativeStickySupported((_options$isDragAndDro = options.isDragAndDropEnabled) !== null && _options$isDragAndDro !== void 0 ? _options$isDragAndDro : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
27
|
+
if (isNativeStickySupported() && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
29
28
|
return new TableRowNativeStickyWithFallback(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
|
|
30
29
|
} else {
|
|
31
30
|
return new TableRow(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
|