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