@atlaskit/editor-plugin-table 23.4.3 → 24.0.1
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 +38 -0
- package/dist/cjs/nodeviews/TableCell.js +4 -27
- package/dist/cjs/nodeviews/TableComponent.js +1 -1
- package/dist/cjs/nodeviews/rounded-table-edges.js +168 -0
- package/dist/cjs/nodeviews/table.js +17 -68
- package/dist/cjs/pm-plugins/table-resizing/utils/dom.js +16 -1
- package/dist/cjs/ui/FloatingContextualButton/styles.js +5 -2
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/es2019/nodeviews/TableCell.js +4 -27
- package/dist/es2019/nodeviews/TableComponent.js +2 -2
- package/dist/es2019/nodeviews/rounded-table-edges.js +150 -0
- package/dist/es2019/nodeviews/table.js +15 -62
- package/dist/es2019/pm-plugins/table-resizing/utils/dom.js +15 -0
- package/dist/es2019/ui/FloatingContextualButton/styles.js +5 -2
- package/dist/es2019/ui/common-styles.js +14 -0
- package/dist/esm/nodeviews/TableCell.js +4 -27
- package/dist/esm/nodeviews/TableComponent.js +2 -2
- package/dist/esm/nodeviews/rounded-table-edges.js +161 -0
- package/dist/esm/nodeviews/table.js +17 -68
- package/dist/esm/pm-plugins/table-resizing/utils/dom.js +15 -0
- package/dist/esm/ui/FloatingContextualButton/styles.js +5 -2
- package/dist/esm/ui/common-styles.js +1 -1
- package/dist/types/nodeviews/TableCell.d.ts +0 -5
- package/dist/types/nodeviews/rounded-table-edges.d.ts +26 -0
- package/dist/types/nodeviews/table.d.ts +1 -2
- package/dist/types/pm-plugins/table-resizing/utils/dom.d.ts +4 -0
- package/package.json +38 -46
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { contextualMenuTriggerSize } from '../consts';
|
|
4
5
|
export const tableFloatingCellButtonStyles = () => css({
|
|
5
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
6
7
|
'> div': {
|
|
7
8
|
// Sits behind button to provide surface-color background
|
|
8
9
|
background: "var(--ds-surface, #FFFFFF)",
|
|
9
|
-
|
|
10
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
11
|
+
borderRadius: expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? "var(--ds-radius-small, 4px)" : "var(--ds-radius-small, 3px)",
|
|
10
12
|
display: 'flex',
|
|
11
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
12
14
|
height: `${contextualMenuTriggerSize + 2}px`,
|
|
@@ -19,7 +21,8 @@ export const tableFloatingCellButtonStyles = () => css({
|
|
|
19
21
|
flexDirection: 'column',
|
|
20
22
|
margin: "var(--ds-space-025, 2px)",
|
|
21
23
|
outline: `2px solid ${"var(--ds-surface, #FFFFFF)"}`,
|
|
22
|
-
|
|
24
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
25
|
+
borderRadius: expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? "var(--ds-radius-xsmall, 2px)" : '1px',
|
|
23
26
|
padding: 0,
|
|
24
27
|
height: 'calc(100% - 4px)',
|
|
25
28
|
display: 'flex'
|
|
@@ -304,6 +304,20 @@ const baseTableStylesWithoutSharedStyle = props => css`
|
|
|
304
304
|
box-shadow: 0px -${stickyRowOffsetTop}px
|
|
305
305
|
${expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? `var(${akEditorTableContainerBg}, ${"var(--ds-surface, #FFFFFF)"})` : "var(--ds-surface, #FFFFFF)"};
|
|
306
306
|
border-right: 0 none;
|
|
307
|
+
${expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? `
|
|
308
|
+
width: ${akEditorTableNumberColumnWidth + 1}px;
|
|
309
|
+
border-left: 1px solid ${tableBorderColor};
|
|
310
|
+
|
|
311
|
+
/* Keep the new fixed left border in sync with the selected/danger states,
|
|
312
|
+
which would otherwise leave it the default colour (.active recolours the
|
|
313
|
+
rest of the border) or drop it entirely (delete-hover sets border-left: 0). */
|
|
314
|
+
&.active {
|
|
315
|
+
border-left-color: ${tableBorderSelectedColor};
|
|
316
|
+
}
|
|
317
|
+
&.${ClassName.HOVERED_CELL_IN_DANGER} {
|
|
318
|
+
border-left: 1px solid ${tableBorderDeleteColor};
|
|
319
|
+
}
|
|
320
|
+
` : ''}
|
|
307
321
|
/* top set by NumberColumn component */
|
|
308
322
|
}
|
|
309
323
|
|
|
@@ -51,11 +51,6 @@ var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
|
51
51
|
var _this;
|
|
52
52
|
_classCallCheck(this, TableCell);
|
|
53
53
|
_this = _callSuper(this, TableCell, [node, view, getPos, eventDispatcher]);
|
|
54
|
-
/** Cached edge state to avoid redundant DOM writes. */
|
|
55
|
-
_defineProperty(_this, "prevReachesTop", false);
|
|
56
|
-
_defineProperty(_this, "prevReachesBottom", false);
|
|
57
|
-
_defineProperty(_this, "prevReachesLeft", false);
|
|
58
|
-
_defineProperty(_this, "prevReachesRight", false);
|
|
59
54
|
_defineProperty(_this, "destroy", function () {
|
|
60
55
|
if (_this.delayHandle && typeof window !== 'undefined') {
|
|
61
56
|
var _window, _window$cancelIdleCal, _window2, _window2$cancelAnimat;
|
|
@@ -137,28 +132,10 @@ var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
|
137
132
|
var tableMap = TableMap.get(tableNode);
|
|
138
133
|
var cellStartInTable = pos - resolvedPos.start(tableDepth);
|
|
139
134
|
var cellRect = tableMap.findCell(cellStartInTable);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// Only touch DOM attributes that actually changed
|
|
146
|
-
if (reachesTop !== this.prevReachesTop) {
|
|
147
|
-
this.prevReachesTop = reachesTop;
|
|
148
|
-
this.setDataAttr('data-reaches-top', reachesTop);
|
|
149
|
-
}
|
|
150
|
-
if (reachesBottom !== this.prevReachesBottom) {
|
|
151
|
-
this.prevReachesBottom = reachesBottom;
|
|
152
|
-
this.setDataAttr('data-reaches-bottom', reachesBottom);
|
|
153
|
-
}
|
|
154
|
-
if (reachesLeft !== this.prevReachesLeft) {
|
|
155
|
-
this.prevReachesLeft = reachesLeft;
|
|
156
|
-
this.setDataAttr('data-reaches-left', reachesLeft);
|
|
157
|
-
}
|
|
158
|
-
if (reachesRight !== this.prevReachesRight) {
|
|
159
|
-
this.prevReachesRight = reachesRight;
|
|
160
|
-
this.setDataAttr('data-reaches-right', reachesRight);
|
|
161
|
-
}
|
|
135
|
+
this.setDataAttr('data-reaches-top', cellRect.top === 0);
|
|
136
|
+
this.setDataAttr('data-reaches-bottom', cellRect.bottom >= tableMap.height);
|
|
137
|
+
this.setDataAttr('data-reaches-left', cellRect.left === 0);
|
|
138
|
+
this.setDataAttr('data-reaches-right', cellRect.right >= tableMap.width);
|
|
162
139
|
} catch (_unused) {
|
|
163
140
|
// Position may be stale during document mutations; silently ignore.
|
|
164
141
|
}
|
|
@@ -35,7 +35,7 @@ import { pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-header
|
|
|
35
35
|
import { findStickyHeaderForTable } from '../pm-plugins/sticky-headers/util';
|
|
36
36
|
import { hasTableBeenResized, insertColgroupFromNode } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
37
37
|
import { COLUMN_MIN_WIDTH, TABLE_EDITOR_MARGIN, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
|
|
38
|
-
import {
|
|
38
|
+
import { syncStickyCornerMasks, updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
39
39
|
import { getLayoutSize, getScalingPercentForTableWithoutWidth, getTableScalingPercent } from '../pm-plugins/table-resizing/utils/misc';
|
|
40
40
|
import { getResizeState, updateColgroup } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
41
41
|
import { scaleTable } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
@@ -135,7 +135,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
135
135
|
header.style.marginRight = '2px';
|
|
136
136
|
}
|
|
137
137
|
if (expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
|
|
138
|
-
|
|
138
|
+
syncStickyCornerMasks(_this.table);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
|
+
var setDataAttr = function setDataAttr(cell, attr, value) {
|
|
5
|
+
var hasAttr = cell.hasAttribute(attr);
|
|
6
|
+
if (value && !hasAttr) {
|
|
7
|
+
cell.setAttribute(attr, 'true');
|
|
8
|
+
} else if (!value && hasAttr) {
|
|
9
|
+
cell.removeAttribute(attr);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Refreshes the `data-reaches-{top,bottom,left,right}` attributes used by CSS to round
|
|
15
|
+
* the table's corner cells (including merged cells that span to an edge).
|
|
16
|
+
*
|
|
17
|
+
* Edge membership is derived directly from the table map's border rows/columns: a cell
|
|
18
|
+
* reaches an edge iff its offset appears in the corresponding border slice (this naturally
|
|
19
|
+
* accounts for rowspan/colspan cells, whose offset is repeated across every grid slot they
|
|
20
|
+
* cover). This is O(cells) overall, versus O(cells^2) when calling findCell per cell.
|
|
21
|
+
*/
|
|
22
|
+
var refreshRoundedTableEdgeAttrs = function refreshRoundedTableEdgeAttrs(table, tableNode) {
|
|
23
|
+
try {
|
|
24
|
+
var tableMap = TableMap.get(tableNode);
|
|
25
|
+
var width = tableMap.width,
|
|
26
|
+
height = tableMap.height,
|
|
27
|
+
map = tableMap.map;
|
|
28
|
+
var cells = Array.from(table.rows).flatMap(function (row) {
|
|
29
|
+
return Array.from(row.cells);
|
|
30
|
+
});
|
|
31
|
+
var cellOffsets = Array.from(new Set(map));
|
|
32
|
+
var topOffsets = new Set();
|
|
33
|
+
var bottomOffsets = new Set();
|
|
34
|
+
var leftOffsets = new Set();
|
|
35
|
+
var rightOffsets = new Set();
|
|
36
|
+
for (var col = 0; col < width; col++) {
|
|
37
|
+
topOffsets.add(map[col]);
|
|
38
|
+
bottomOffsets.add(map[(height - 1) * width + col]);
|
|
39
|
+
}
|
|
40
|
+
for (var row = 0; row < height; row++) {
|
|
41
|
+
leftOffsets.add(map[row * width]);
|
|
42
|
+
rightOffsets.add(map[row * width + width - 1]);
|
|
43
|
+
}
|
|
44
|
+
cellOffsets.forEach(function (cellOffset, cellIndex) {
|
|
45
|
+
var cell = cells[cellIndex];
|
|
46
|
+
if (!cell) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
setDataAttr(cell, 'data-reaches-top', topOffsets.has(cellOffset));
|
|
50
|
+
setDataAttr(cell, 'data-reaches-bottom', bottomOffsets.has(cellOffset));
|
|
51
|
+
setDataAttr(cell, 'data-reaches-left', leftOffsets.has(cellOffset));
|
|
52
|
+
setDataAttr(cell, 'data-reaches-right', rightOffsets.has(cellOffset));
|
|
53
|
+
});
|
|
54
|
+
} catch (_unused) {
|
|
55
|
+
// Table structure can be transient while ProseMirror normalises transactions.
|
|
56
|
+
// Keep existing edge attrs if the current shape cannot be mapped safely.
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Builds a lightweight signature of the cells sitting on the table's four borders, using
|
|
62
|
+
* their (immutable) ProseMirror node references. The signature changes whenever a border
|
|
63
|
+
* cell is added, removed, merged, or moved (row/column reorder via drag-and-drop) but stays
|
|
64
|
+
* stable across pure text edits in non-edge cells. This lets the controller decide cheaply
|
|
65
|
+
* (O(rows + cols)) whether the rounded-edge attrs need a full refresh, instead of only
|
|
66
|
+
* reacting to width/height changes.
|
|
67
|
+
*/
|
|
68
|
+
var getTableEdgeSignature = function getTableEdgeSignature(tableNode) {
|
|
69
|
+
var edgeCells = [];
|
|
70
|
+
var lastRowIndex = tableNode.childCount - 1;
|
|
71
|
+
tableNode.forEach(function (row, _rowOffset, rowIndex) {
|
|
72
|
+
var isEdgeRow = rowIndex === 0 || rowIndex === lastRowIndex;
|
|
73
|
+
var lastCellIndex = row.childCount - 1;
|
|
74
|
+
row.forEach(function (cell, _cellOffset, cellIndex) {
|
|
75
|
+
if (isEdgeRow || cellIndex === 0 || cellIndex === lastCellIndex) {
|
|
76
|
+
edgeCells.push(cell);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return edgeCells;
|
|
81
|
+
};
|
|
82
|
+
var tableEdgeSignaturesDiffer = function tableEdgeSignaturesDiffer(prev, next) {
|
|
83
|
+
if (!prev || prev.length !== next.length) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
for (var i = 0; i < prev.length; i++) {
|
|
87
|
+
if (prev[i] !== next[i]) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Keeps a table's rounded-corner edge attributes in sync as its shape changes.
|
|
96
|
+
*
|
|
97
|
+
* Each TableCell node view refreshes its own edge attrs when its cell attrs change. However,
|
|
98
|
+
* when the table's shape changes (e.g. a new row is inserted below the last row) or cells are
|
|
99
|
+
* reordered (e.g. dragging a row/column to a new position), ProseMirror may reuse the existing
|
|
100
|
+
* neighbouring cells as-is, so those cells never get a chance to update their edge attrs on
|
|
101
|
+
* their own. This controller covers those cases from the table node view.
|
|
102
|
+
*
|
|
103
|
+
* Callers are responsible for feature-gating each call site.
|
|
104
|
+
*/
|
|
105
|
+
export var RoundedTableEdges = /*#__PURE__*/function () {
|
|
106
|
+
// References to the previous render's border cells (O(rows + cols), perimeter-sized, not all cells).
|
|
107
|
+
|
|
108
|
+
function RoundedTableEdges(getTableElement, node) {
|
|
109
|
+
_classCallCheck(this, RoundedTableEdges);
|
|
110
|
+
this.getTableElement = getTableElement;
|
|
111
|
+
|
|
112
|
+
// Baseline the edge signature so the first content edit doesn't trigger a spurious
|
|
113
|
+
// refresh — the cells set their own edge attrs on construction.
|
|
114
|
+
this.prevSignature = getTableEdgeSignature(node);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Call from the node view's `update()` after `super.update()`. When the border signature
|
|
119
|
+
* changes it schedules a refresh of the edge attrs on the next animation frame.
|
|
120
|
+
*/
|
|
121
|
+
return _createClass(RoundedTableEdges, [{
|
|
122
|
+
key: "handleUpdate",
|
|
123
|
+
value: function handleUpdate(node) {
|
|
124
|
+
var nextSignature = getTableEdgeSignature(node);
|
|
125
|
+
var edgesChanged = tableEdgeSignaturesDiffer(this.prevSignature, nextSignature);
|
|
126
|
+
this.prevSignature = nextSignature;
|
|
127
|
+
if (edgesChanged) {
|
|
128
|
+
this.scheduleRefresh(node);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Call from the node view's `destroy()` to cancel any pending refresh. */
|
|
133
|
+
}, {
|
|
134
|
+
key: "destroy",
|
|
135
|
+
value: function destroy() {
|
|
136
|
+
if (this.refreshHandle !== undefined) {
|
|
137
|
+
cancelAnimationFrame(this.refreshHandle);
|
|
138
|
+
this.refreshHandle = undefined;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// The refresh runs on the next animation frame because ReactNodeView.update() schedules the
|
|
143
|
+
// table's React render via the portal provider. If we read `table.rows` synchronously, we'd
|
|
144
|
+
// still see the previous DOM.
|
|
145
|
+
}, {
|
|
146
|
+
key: "scheduleRefresh",
|
|
147
|
+
value: function scheduleRefresh(node) {
|
|
148
|
+
var _this = this;
|
|
149
|
+
if (this.refreshHandle !== undefined) {
|
|
150
|
+
cancelAnimationFrame(this.refreshHandle);
|
|
151
|
+
}
|
|
152
|
+
this.refreshHandle = requestAnimationFrame(function () {
|
|
153
|
+
_this.refreshHandle = undefined;
|
|
154
|
+
var table = _this.getTableElement();
|
|
155
|
+
if (table instanceof HTMLTableElement) {
|
|
156
|
+
refreshRoundedTableEdgeAttrs(table, node);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}]);
|
|
161
|
+
}();
|
|
@@ -25,6 +25,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
|
25
25
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
26
26
|
import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/utils/nodes';
|
|
27
27
|
import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
|
|
28
|
+
import { RoundedTableEdges } from './rounded-table-edges';
|
|
28
29
|
import { TableComponentWithSharedState } from './TableComponentWithSharedState';
|
|
29
30
|
import { tableNodeSpecWithFixedToDOM } from './toDOM';
|
|
30
31
|
var tableAttributes = function tableAttributes(node) {
|
|
@@ -58,37 +59,6 @@ var handleInlineTableWidth = function handleInlineTableWidth(table, width) {
|
|
|
58
59
|
}
|
|
59
60
|
table.style.setProperty('width', "".concat(width, "px"));
|
|
60
61
|
};
|
|
61
|
-
var setDataAttr = function setDataAttr(cell, attr, value) {
|
|
62
|
-
var hasAttr = cell.hasAttribute(attr);
|
|
63
|
-
if (value && !hasAttr) {
|
|
64
|
-
cell.setAttribute(attr, 'true');
|
|
65
|
-
} else if (!value && hasAttr) {
|
|
66
|
-
cell.removeAttribute(attr);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var refreshRoundedTableEdgeAttrs = function refreshRoundedTableEdgeAttrs(table, tableNode) {
|
|
70
|
-
try {
|
|
71
|
-
var tableMap = TableMap.get(tableNode);
|
|
72
|
-
var cells = Array.from(table.rows).flatMap(function (row) {
|
|
73
|
-
return Array.from(row.cells);
|
|
74
|
-
});
|
|
75
|
-
var cellOffsets = Array.from(new Set(tableMap.map));
|
|
76
|
-
cellOffsets.forEach(function (cellOffset, cellIndex) {
|
|
77
|
-
var cell = cells[cellIndex];
|
|
78
|
-
if (!cell) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
var cellRect = tableMap.findCell(cellOffset);
|
|
82
|
-
setDataAttr(cell, 'data-reaches-top', cellRect.top === 0);
|
|
83
|
-
setDataAttr(cell, 'data-reaches-bottom', cellRect.bottom >= tableMap.height);
|
|
84
|
-
setDataAttr(cell, 'data-reaches-left', cellRect.left === 0);
|
|
85
|
-
setDataAttr(cell, 'data-reaches-right', cellRect.right >= tableMap.width);
|
|
86
|
-
});
|
|
87
|
-
} catch (_unused) {
|
|
88
|
-
// Table structure can be transient while ProseMirror normalises transactions.
|
|
89
|
-
// Keep existing edge attrs if the current shape cannot be mapped safely.
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
62
|
var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
93
63
|
function TableView(props) {
|
|
94
64
|
var _this;
|
|
@@ -104,6 +74,11 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
104
74
|
_this.eventDispatcher = props.eventDispatcher;
|
|
105
75
|
_this.options = props.options;
|
|
106
76
|
_this.getEditorFeatureFlags = props.getEditorFeatureFlags;
|
|
77
|
+
if (expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
|
|
78
|
+
_this.roundedTableEdges = new RoundedTableEdges(function () {
|
|
79
|
+
return _this.table;
|
|
80
|
+
}, props.node);
|
|
81
|
+
}
|
|
107
82
|
_this.handleRef = function (node) {
|
|
108
83
|
return _this._handleTableRef(node);
|
|
109
84
|
};
|
|
@@ -273,43 +248,17 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
273
248
|
}
|
|
274
249
|
}
|
|
275
250
|
}
|
|
276
|
-
}, {
|
|
277
|
-
key: "scheduleRoundedTableEdgeRefresh",
|
|
278
|
-
value:
|
|
279
|
-
// Each TableCell node view refreshes its own edge attrs when its cell attrs change.
|
|
280
|
-
// However, when the table's shape changes (e.g. a new row is inserted below the
|
|
281
|
-
// last row), ProseMirror may reuse the existing neighbouring cells as-is, so those
|
|
282
|
-
// cells never get a chance to update their edge attrs on their own.
|
|
283
|
-
//
|
|
284
|
-
// To cover those cases, we refresh edge attrs from the table node view here.
|
|
285
|
-
//
|
|
286
|
-
// The refresh runs on the next animation frame because ReactNodeView.update()
|
|
287
|
-
// schedules the table's React render via the portal provider. If we read
|
|
288
|
-
// `this.table.rows` synchronously, we'd still see the previous DOM.
|
|
289
|
-
function scheduleRoundedTableEdgeRefresh(node) {
|
|
290
|
-
var _this4 = this;
|
|
291
|
-
if (this.roundedTableEdgeRefreshHandle !== undefined) {
|
|
292
|
-
cancelAnimationFrame(this.roundedTableEdgeRefreshHandle);
|
|
293
|
-
}
|
|
294
|
-
this.roundedTableEdgeRefreshHandle = requestAnimationFrame(function () {
|
|
295
|
-
_this4.roundedTableEdgeRefreshHandle = undefined;
|
|
296
|
-
if (_this4.table instanceof HTMLTableElement) {
|
|
297
|
-
refreshRoundedTableEdgeAttrs(_this4.table, node);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
251
|
}, {
|
|
302
252
|
key: "update",
|
|
303
253
|
value: function update(node, decorations, innerDecorations, validUpdate) {
|
|
304
|
-
if (!expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
|
|
305
|
-
return _superPropGet(TableView, "update", this, 3)([node, decorations, innerDecorations, validUpdate]);
|
|
306
|
-
}
|
|
307
|
-
var currentTableMap = TableMap.get(this.node);
|
|
308
|
-
var nextTableMap = TableMap.get(node);
|
|
309
|
-
var tableGeometryChanged = currentTableMap.width !== nextTableMap.width || currentTableMap.height !== nextTableMap.height;
|
|
310
254
|
var didUpdate = _superPropGet(TableView, "update", this, 3)([node, decorations, innerDecorations, validUpdate]);
|
|
311
|
-
|
|
312
|
-
|
|
255
|
+
|
|
256
|
+
// Keep the rounded-corner edge attrs in sync with structural changes (rows/columns
|
|
257
|
+
// added, removed, merged, or reordered via drag-and-drop) that the cells themselves
|
|
258
|
+
// can miss.
|
|
259
|
+
if (didUpdate && expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
|
|
260
|
+
var _this$roundedTableEdg;
|
|
261
|
+
(_this$roundedTableEdg = this.roundedTableEdges) === null || _this$roundedTableEdg === void 0 || _this$roundedTableEdg.handleUpdate(node);
|
|
313
262
|
}
|
|
314
263
|
return didUpdate;
|
|
315
264
|
}
|
|
@@ -347,7 +296,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
347
296
|
if (_typeof(node.attrs) !== _typeof(nextNode.attrs)) {
|
|
348
297
|
return true;
|
|
349
298
|
}
|
|
350
|
-
if (tablesHaveDifferentColumnWidths(node, nextNode)
|
|
299
|
+
if (tablesHaveDifferentColumnWidths(node, nextNode)) {
|
|
351
300
|
return true;
|
|
352
301
|
}
|
|
353
302
|
var attrKeys = Object.keys(node.attrs);
|
|
@@ -390,9 +339,9 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
390
339
|
key: "destroy",
|
|
391
340
|
value: function destroy() {
|
|
392
341
|
var _this$eventDispatcher;
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
this.
|
|
342
|
+
if (expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
|
|
343
|
+
var _this$roundedTableEdg2;
|
|
344
|
+
(_this$roundedTableEdg2 = this.roundedTableEdges) === null || _this$roundedTableEdg2 === void 0 || _this$roundedTableEdg2.destroy();
|
|
396
345
|
}
|
|
397
346
|
if (this.resizeObserver) {
|
|
398
347
|
this.resizeObserver.disconnect();
|
|
@@ -103,6 +103,21 @@ var applyTableWidthToStickyRow = function applyTableWidthToStickyRow(tableRef, h
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Repositions only the sticky-header corner masks to match the current scroll position.
|
|
109
|
+
*/
|
|
110
|
+
export var syncStickyCornerMasks = function syncStickyCornerMasks(tableRef) {
|
|
111
|
+
if (!tableRef) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
var headerRow = tableRef.querySelector('tr[data-header-row]');
|
|
115
|
+
var wrapper = tableRef.parentElement;
|
|
116
|
+
if (!headerRow || !wrapper) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
syncCornerMasksToStickyRow(tableRef, headerRow, wrapper);
|
|
120
|
+
};
|
|
106
121
|
export var clearStickyCornerMaskPositions = function clearStickyCornerMaskPositions(tableRef) {
|
|
107
122
|
var wrapper = tableRef === null || tableRef === void 0 ? void 0 : tableRef.parentElement;
|
|
108
123
|
if (!wrapper) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { contextualMenuTriggerSize } from '../consts';
|
|
4
5
|
export var tableFloatingCellButtonStyles = function tableFloatingCellButtonStyles() {
|
|
5
6
|
return css({
|
|
@@ -7,7 +8,8 @@ export var tableFloatingCellButtonStyles = function tableFloatingCellButtonStyle
|
|
|
7
8
|
'> div': {
|
|
8
9
|
// Sits behind button to provide surface-color background
|
|
9
10
|
background: "var(--ds-surface, #FFFFFF)",
|
|
10
|
-
|
|
11
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
12
|
+
borderRadius: expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? "var(--ds-radius-small, 4px)" : "var(--ds-radius-small, 3px)",
|
|
11
13
|
display: 'flex',
|
|
12
14
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
13
15
|
height: "".concat(contextualMenuTriggerSize + 2, "px"),
|
|
@@ -20,7 +22,8 @@ export var tableFloatingCellButtonStyles = function tableFloatingCellButtonStyle
|
|
|
20
22
|
flexDirection: 'column',
|
|
21
23
|
margin: "var(--ds-space-025, 2px)",
|
|
22
24
|
outline: "2px solid ".concat("var(--ds-surface, #FFFFFF)"),
|
|
23
|
-
|
|
25
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
26
|
+
borderRadius: expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) ? "var(--ds-radius-xsmall, 2px)" : '1px',
|
|
24
27
|
padding: 0,
|
|
25
28
|
height: 'calc(100% - 4px)',
|
|
26
29
|
display: 'flex'
|