@atlaskit/editor-plugin-table 2.9.1 → 2.10.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 +17 -0
- package/dist/cjs/plugins/table/event-handlers.js +52 -56
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +19 -69
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +5 -1
- package/dist/cjs/plugins/table/nodeviews/table.js +23 -30
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +3 -6
- package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +2 -40
- package/dist/cjs/plugins/table/pm-plugins/main.js +3 -3
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +3 -7
- package/dist/cjs/plugins/table/ui/common-styles.js +2 -2
- package/dist/cjs/plugins/table/utils/dom.js +5 -12
- package/dist/es2019/plugins/table/event-handlers.js +3 -6
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +18 -69
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +6 -1
- package/dist/es2019/plugins/table/nodeviews/table.js +24 -32
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -7
- package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +0 -35
- package/dist/es2019/plugins/table/pm-plugins/main.js +3 -4
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -77
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +3 -9
- package/dist/es2019/plugins/table/ui/common-styles.js +3 -3
- package/dist/es2019/plugins/table/utils/dom.js +5 -12
- package/dist/esm/plugins/table/event-handlers.js +52 -56
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +19 -69
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -1
- package/dist/esm/plugins/table/nodeviews/table.js +23 -30
- package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -6
- package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +0 -37
- package/dist/esm/plugins/table/pm-plugins/main.js +3 -3
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +3 -7
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/utils/dom.js +5 -12
- package/dist/types/plugins/table/event-handlers.d.ts +1 -2
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +0 -2
- package/dist/types/plugins/table/nodeviews/table.d.ts +0 -1
- package/dist/types/plugins/table/nodeviews/tableCell.d.ts +2 -3
- package/dist/types/plugins/table/nodeviews/types.d.ts +0 -1
- package/dist/types/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
- package/dist/types/plugins/table/types.d.ts +2 -2
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
- package/dist/types/plugins/table/utils/dom.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +0 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +2 -3
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
- package/dist/types-ts4.5/plugins/table/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +1 -1
- package/package.json +2 -2
- package/report.api.md +2 -0
- package/src/__tests__/integration/horizontal-scroll-shadows.ts +6 -9
- package/src/__tests__/integration/resize.ts +6 -16
- package/src/__tests__/unit/event-handlers.ts +1 -4
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +48 -92
- package/src/__tests__/unit/nodeviews/cell.ts +1 -3
- package/src/__tests__/unit/nodeviews/table.ts +71 -83
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +5 -9
- package/src/__tests__/unit/ui/RowControls.tsx +1 -0
- package/src/__tests__/unit/utils/dom.ts +6 -112
- package/src/plugins/table/event-handlers.ts +72 -79
- package/src/plugins/table/nodeviews/TableComponent.tsx +37 -114
- package/src/plugins/table/nodeviews/TableResizer.tsx +3 -0
- package/src/plugins/table/nodeviews/table.tsx +22 -30
- package/src/plugins/table/nodeviews/tableCell.tsx +3 -11
- package/src/plugins/table/nodeviews/types.ts +0 -1
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -54
- package/src/plugins/table/pm-plugins/main.ts +4 -22
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +1 -83
- package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -7
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +30 -48
- package/src/plugins/table/types.ts +3 -2
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +3 -15
- package/src/plugins/table/ui/common-styles.ts +1 -1
- package/src/plugins/table/utils/dom.ts +3 -11
- package/tmp/api-report-tmp.d.ts +2 -0
|
@@ -51,10 +51,8 @@ import {
|
|
|
51
51
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
52
52
|
import { TableContainer } from './TableContainer';
|
|
53
53
|
import type { TableOptions } from './types';
|
|
54
|
-
import { updateOverflowShadows } from './update-overflow-shadows';
|
|
55
54
|
|
|
56
55
|
const isIE11 = browser.ie_version === 11;
|
|
57
|
-
const NOOP = () => undefined;
|
|
58
56
|
export interface ComponentProps {
|
|
59
57
|
view: EditorView;
|
|
60
58
|
getNode: () => PmNode;
|
|
@@ -79,7 +77,6 @@ export interface ComponentProps {
|
|
|
79
77
|
interface TableState {
|
|
80
78
|
scroll: number;
|
|
81
79
|
parentWidth?: number;
|
|
82
|
-
isLoading: boolean;
|
|
83
80
|
stickyHeader?: RowStickyState;
|
|
84
81
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: boolean;
|
|
85
82
|
[ShadowEvent.SHOW_AFTER_SHADOW]: boolean;
|
|
@@ -90,7 +87,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
90
87
|
state: TableState = {
|
|
91
88
|
scroll: 0,
|
|
92
89
|
parentWidth: undefined,
|
|
93
|
-
isLoading: true,
|
|
94
90
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: false,
|
|
95
91
|
[ShadowEvent.SHOW_AFTER_SHADOW]: false,
|
|
96
92
|
};
|
|
@@ -104,7 +100,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
104
100
|
|
|
105
101
|
constructor(props: ComponentProps) {
|
|
106
102
|
super(props);
|
|
107
|
-
const { options, containerWidth, getNode
|
|
103
|
+
const { options, containerWidth, getNode } = props;
|
|
108
104
|
this.node = getNode();
|
|
109
105
|
this.containerWidth = containerWidth;
|
|
110
106
|
|
|
@@ -129,15 +125,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
129
125
|
}
|
|
130
126
|
});
|
|
131
127
|
}
|
|
132
|
-
|
|
133
|
-
const { initialRenderOptimization } = getEditorFeatureFlags();
|
|
134
|
-
|
|
135
|
-
if (!initialRenderOptimization) {
|
|
136
|
-
// @see ED-7945
|
|
137
|
-
requestAnimationFrame(() => {
|
|
138
|
-
this.setState({ isLoading: false });
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
128
|
}
|
|
142
129
|
|
|
143
130
|
componentDidMount() {
|
|
@@ -206,29 +193,22 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
206
193
|
clearHoverSelection()(view.state, view.dispatch);
|
|
207
194
|
}
|
|
208
195
|
|
|
209
|
-
|
|
210
|
-
this.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.
|
|
217
|
-
this.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
this.overflowShadowsObserver = new OverflowShadowsObserver(
|
|
221
|
-
this.updateShadowState,
|
|
222
|
-
this.table,
|
|
223
|
-
this.wrapper,
|
|
224
|
-
);
|
|
225
|
-
}
|
|
196
|
+
if (
|
|
197
|
+
this.wrapper?.parentElement &&
|
|
198
|
+
this.table &&
|
|
199
|
+
!this.overflowShadowsObserver
|
|
200
|
+
) {
|
|
201
|
+
this.overflowShadowsObserver = new OverflowShadowsObserver(
|
|
202
|
+
this.updateShadowState,
|
|
203
|
+
this.table,
|
|
204
|
+
this.wrapper,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
226
207
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
208
|
+
if (this.overflowShadowsObserver) {
|
|
209
|
+
this.overflowShadowsObserver.observeShadowSentinels(
|
|
210
|
+
this.state.stickyHeader?.sticky,
|
|
211
|
+
);
|
|
232
212
|
}
|
|
233
213
|
|
|
234
214
|
const currentTable = getNode();
|
|
@@ -248,32 +228,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
248
228
|
) {
|
|
249
229
|
const { view } = this.props;
|
|
250
230
|
recreateResizeColsByNode(this.table, currentTable);
|
|
251
|
-
updateControls(
|
|
231
|
+
updateControls()(view.state);
|
|
252
232
|
}
|
|
253
233
|
|
|
254
234
|
this.handleTableResizingDebounced();
|
|
255
235
|
}
|
|
256
236
|
}
|
|
257
237
|
|
|
258
|
-
private updateShadows() {
|
|
259
|
-
const parent = this.wrapper?.parentElement;
|
|
260
|
-
if (this.wrapper && parent) {
|
|
261
|
-
const rightShadows = parent.querySelectorAll<HTMLElement>(
|
|
262
|
-
`.${ClassName.TABLE_RIGHT_SHADOW}`,
|
|
263
|
-
);
|
|
264
|
-
const leftShadows = parent.querySelectorAll<HTMLElement>(
|
|
265
|
-
`.${ClassName.TABLE_LEFT_SHADOW}`,
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
updateOverflowShadows(this.props.getEditorFeatureFlags)(
|
|
269
|
-
this.wrapper,
|
|
270
|
-
this.table,
|
|
271
|
-
rightShadows,
|
|
272
|
-
leftShadows,
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
238
|
private updateShadowState = (shadowKey: ShadowEvent, value: boolean) => {
|
|
278
239
|
if (this.state[shadowKey] === value) {
|
|
279
240
|
return;
|
|
@@ -293,9 +254,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
293
254
|
};
|
|
294
255
|
|
|
295
256
|
onStickyState = (state: StickyPluginState) => {
|
|
296
|
-
const { tableOverflowShadowsOptimization } =
|
|
297
|
-
this.props.getEditorFeatureFlags();
|
|
298
|
-
|
|
299
257
|
const pos = this.props.getPos();
|
|
300
258
|
if (!isValidPosition(pos, this.props.view.state)) {
|
|
301
259
|
return;
|
|
@@ -303,7 +261,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
303
261
|
const stickyHeader = findStickyHeaderForTable(state, pos);
|
|
304
262
|
if (stickyHeader !== this.state.stickyHeader) {
|
|
305
263
|
this.setState({ stickyHeader });
|
|
306
|
-
if (
|
|
264
|
+
if (this.overflowShadowsObserver) {
|
|
307
265
|
this.overflowShadowsObserver.updateStickyShadows();
|
|
308
266
|
}
|
|
309
267
|
}
|
|
@@ -326,27 +284,16 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
326
284
|
getPos,
|
|
327
285
|
pluginInjectionApi,
|
|
328
286
|
} = this.props;
|
|
329
|
-
const {
|
|
287
|
+
const { showBeforeShadow, showAfterShadow } = this.state;
|
|
330
288
|
const node = getNode();
|
|
331
289
|
// doesn't work well with WithPluginState
|
|
332
290
|
const { isInDanger, hoveredRows } = getPluginState(view.state);
|
|
333
291
|
|
|
334
|
-
const {
|
|
335
|
-
stickyHeadersOptimization,
|
|
336
|
-
initialRenderOptimization,
|
|
337
|
-
tableRenderOptimization,
|
|
338
|
-
tableOverflowShadowsOptimization,
|
|
339
|
-
} = this.props.getEditorFeatureFlags();
|
|
340
|
-
|
|
341
292
|
const tableRef = this.table || undefined;
|
|
342
293
|
const headerRow = tableRef
|
|
343
294
|
? tableRef.querySelector<HTMLTableRowElement>('tr[data-header-row]')
|
|
344
295
|
: undefined;
|
|
345
296
|
|
|
346
|
-
//dont need to change tableHeight with tableRenderOptimization because it will be observed inside floating components
|
|
347
|
-
const tableHeight =
|
|
348
|
-
tableRef && !tableRenderOptimization ? tableRef.offsetHeight : undefined;
|
|
349
|
-
|
|
350
297
|
const hasHeaderRow = containsHeaderRow(node);
|
|
351
298
|
const rowControls = (
|
|
352
299
|
<div className={ClassName.ROW_CONTROLS_WRAPPER}>
|
|
@@ -364,7 +311,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
364
311
|
hasHeaderRow={hasHeaderRow}
|
|
365
312
|
// pass `selection` and `tableHeight` to control re-render
|
|
366
313
|
selection={view.state.selection}
|
|
367
|
-
tableHeight={tableHeight}
|
|
368
314
|
headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
|
|
369
315
|
stickyHeader={this.state.stickyHeader}
|
|
370
316
|
getEditorFeatureFlags={this.props.getEditorFeatureFlags}
|
|
@@ -373,16 +319,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
373
319
|
);
|
|
374
320
|
|
|
375
321
|
const shadowPadding =
|
|
376
|
-
allowControls &&
|
|
377
|
-
? -tableToolbarSize
|
|
378
|
-
: tableMarginSides;
|
|
322
|
+
allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
|
|
379
323
|
|
|
380
|
-
const shadowStyle =
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
)
|
|
385
|
-
: NOOP;
|
|
324
|
+
const shadowStyle = memoizeOne(
|
|
325
|
+
(visible) =>
|
|
326
|
+
({ visibility: visible ? 'visible' : 'hidden' } as CSSProperties),
|
|
327
|
+
);
|
|
386
328
|
|
|
387
329
|
const isNested = isTableNested(view.state, getPos());
|
|
388
330
|
|
|
@@ -404,15 +346,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
404
346
|
pluginInjectionApi={pluginInjectionApi}
|
|
405
347
|
isTableResizingEnabled={options?.isTableResizingEnabled}
|
|
406
348
|
>
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
)}
|
|
413
|
-
{allowControls &&
|
|
414
|
-
(!isLoading || initialRenderOptimization) &&
|
|
415
|
-
rowControls}
|
|
349
|
+
<div
|
|
350
|
+
className={ClassName.TABLE_STICKY_SENTINEL_TOP}
|
|
351
|
+
data-testid="sticky-sentinel-top"
|
|
352
|
+
/>
|
|
353
|
+
{allowControls && rowControls}
|
|
416
354
|
<div
|
|
417
355
|
style={shadowStyle(showBeforeShadow)}
|
|
418
356
|
className={ClassName.TABLE_LEFT_SHADOW}
|
|
@@ -421,11 +359,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
421
359
|
<div
|
|
422
360
|
className={`${ClassName.TABLE_LEFT_SHADOW} ${ClassName.TABLE_STICKY_SHADOW}`}
|
|
423
361
|
style={{
|
|
424
|
-
visibility:
|
|
425
|
-
|
|
426
|
-
? 'visible'
|
|
427
|
-
: 'hidden'
|
|
428
|
-
: undefined,
|
|
362
|
+
visibility:
|
|
363
|
+
showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
429
364
|
top: `${
|
|
430
365
|
this.state.stickyHeader.top +
|
|
431
366
|
this.state.stickyHeader.padding +
|
|
@@ -466,11 +401,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
466
401
|
<div
|
|
467
402
|
className={`${ClassName.TABLE_RIGHT_SHADOW} ${ClassName.TABLE_STICKY_SHADOW}`}
|
|
468
403
|
style={{
|
|
469
|
-
visibility:
|
|
470
|
-
|
|
471
|
-
? 'visible'
|
|
472
|
-
: 'hidden'
|
|
473
|
-
: undefined,
|
|
404
|
+
visibility:
|
|
405
|
+
showAfterShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
474
406
|
top: `${
|
|
475
407
|
this.state.stickyHeader.top +
|
|
476
408
|
this.state.stickyHeader.padding +
|
|
@@ -481,12 +413,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
481
413
|
/>
|
|
482
414
|
</div>
|
|
483
415
|
)}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
/>
|
|
489
|
-
)}
|
|
416
|
+
<div
|
|
417
|
+
className={ClassName.TABLE_STICKY_SENTINEL_BOTTOM}
|
|
418
|
+
data-testid="sticky-sentinel-bottom"
|
|
419
|
+
/>
|
|
490
420
|
</TableContainer>
|
|
491
421
|
);
|
|
492
422
|
}
|
|
@@ -507,13 +437,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
507
437
|
}
|
|
508
438
|
}
|
|
509
439
|
|
|
510
|
-
const { tableOverflowShadowsOptimization } =
|
|
511
|
-
this.props.getEditorFeatureFlags();
|
|
512
|
-
|
|
513
|
-
if (!tableOverflowShadowsOptimization) {
|
|
514
|
-
this.updateShadows();
|
|
515
|
-
}
|
|
516
|
-
|
|
517
440
|
this.setState({
|
|
518
441
|
[ShadowEvent.SHOW_BEFORE_SHADOW]: this.wrapper.scrollLeft !== 0,
|
|
519
442
|
});
|
|
@@ -17,6 +17,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
|
17
17
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
18
18
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
19
19
|
|
|
20
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
20
21
|
import {
|
|
21
22
|
COLUMN_MIN_WIDTH,
|
|
22
23
|
getColgroupChildrenLength,
|
|
@@ -126,6 +127,7 @@ export const TableResizer = ({
|
|
|
126
127
|
|
|
127
128
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
128
129
|
const handleHeightSize = getResizerHandleHeight(tableRef);
|
|
130
|
+
const { isInDanger } = getPluginState(editorView.state);
|
|
129
131
|
|
|
130
132
|
const { startMeasure, endMeasure, countFrames } = useMeasureFramerate();
|
|
131
133
|
|
|
@@ -331,6 +333,7 @@ export const TableResizer = ({
|
|
|
331
333
|
innerPadding={tableHandlePosition}
|
|
332
334
|
isHandleVisible={findTable(editorView.state?.selection)?.pos === getPos()}
|
|
333
335
|
handleComponent={handleComponent}
|
|
336
|
+
appearance={isInDanger ? 'danger' : undefined}
|
|
334
337
|
>
|
|
335
338
|
{children}
|
|
336
339
|
</ResizerNext>
|
|
@@ -95,7 +95,6 @@ const toDOM = (node: PmNode, props: Props) => {
|
|
|
95
95
|
export default class TableView extends ReactNodeView<Props> {
|
|
96
96
|
private table: HTMLElement | undefined;
|
|
97
97
|
private resizeObserver?: ResizeObserver;
|
|
98
|
-
private tableRenderOptimization?: boolean;
|
|
99
98
|
eventDispatcher?: EventDispatcher;
|
|
100
99
|
|
|
101
100
|
getPos: getPosHandlerNode;
|
|
@@ -114,7 +113,6 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
114
113
|
props.hasIntlContext,
|
|
115
114
|
);
|
|
116
115
|
this.getPos = props.getPos;
|
|
117
|
-
this.tableRenderOptimization = props.tableRenderOptimization;
|
|
118
116
|
this.eventDispatcher = props.eventDispatcher;
|
|
119
117
|
}
|
|
120
118
|
|
|
@@ -247,37 +245,33 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
247
245
|
|
|
248
246
|
private hasHoveredRows = false;
|
|
249
247
|
viewShouldUpdate(nextNode: PmNode) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const node = this.getNode();
|
|
259
|
-
if (typeof node.attrs !== typeof nextNode.attrs) {
|
|
260
|
-
return true;
|
|
261
|
-
}
|
|
262
|
-
const attrKeys = Object.keys(node.attrs);
|
|
263
|
-
const nextAttrKeys = Object.keys(nextNode.attrs);
|
|
264
|
-
if (attrKeys.length !== nextAttrKeys.length) {
|
|
265
|
-
return true;
|
|
266
|
-
}
|
|
248
|
+
const { hoveredRows } = getPluginState(this.view.state);
|
|
249
|
+
const hoveredRowsChanged = !!hoveredRows?.length !== this.hasHoveredRows;
|
|
250
|
+
if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
|
|
251
|
+
this.hasHoveredRows = !!hoveredRows?.length;
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
267
254
|
|
|
268
|
-
|
|
269
|
-
|
|
255
|
+
const node = this.getNode();
|
|
256
|
+
if (typeof node.attrs !== typeof nextNode.attrs) {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
const attrKeys = Object.keys(node.attrs);
|
|
260
|
+
const nextAttrKeys = Object.keys(nextNode.attrs);
|
|
261
|
+
if (attrKeys.length !== nextAttrKeys.length) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
270
264
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
265
|
+
const tableMap = TableMap.get(node);
|
|
266
|
+
const nextTableMap = TableMap.get(nextNode);
|
|
274
267
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
});
|
|
268
|
+
if (tableMap.width !== nextTableMap.width) {
|
|
269
|
+
return true;
|
|
278
270
|
}
|
|
279
271
|
|
|
280
|
-
return
|
|
272
|
+
return attrKeys.some((key) => {
|
|
273
|
+
return node.attrs[key] !== nextNode.attrs[key];
|
|
274
|
+
});
|
|
281
275
|
}
|
|
282
276
|
|
|
283
277
|
ignoreMutation(
|
|
@@ -335,7 +329,6 @@ export const createTableView = (
|
|
|
335
329
|
): NodeView => {
|
|
336
330
|
const { pluginConfig } = getPluginState(view.state);
|
|
337
331
|
const { allowColumnResizing } = getPluginConfig(pluginConfig);
|
|
338
|
-
const { tableRenderOptimization } = getEditorFeatureFlags();
|
|
339
332
|
const hasIntlContext = true;
|
|
340
333
|
|
|
341
334
|
return new TableView({
|
|
@@ -346,7 +339,6 @@ export const createTableView = (
|
|
|
346
339
|
eventDispatcher,
|
|
347
340
|
getPos: getPos as getPosHandlerNode,
|
|
348
341
|
options,
|
|
349
|
-
tableRenderOptimization,
|
|
350
342
|
getEditorContainerWidth,
|
|
351
343
|
getEditorFeatureFlags,
|
|
352
344
|
hasIntlContext,
|
|
@@ -6,10 +6,7 @@ import {
|
|
|
6
6
|
getCellDomAttrs,
|
|
7
7
|
} from '@atlaskit/adf-schema';
|
|
8
8
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
9
|
-
import type {
|
|
10
|
-
GetEditorFeatureFlags,
|
|
11
|
-
getPosHandler,
|
|
12
|
-
} from '@atlaskit/editor-common/types';
|
|
9
|
+
import type { getPosHandler } from '@atlaskit/editor-common/types';
|
|
13
10
|
import { DOMSerializer, Node } from '@atlaskit/editor-prosemirror/model';
|
|
14
11
|
import { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
15
12
|
|
|
@@ -24,13 +21,11 @@ export default class TableCellNodeView implements NodeView {
|
|
|
24
21
|
view: EditorView;
|
|
25
22
|
providerFactory?: ProviderFactory;
|
|
26
23
|
observer?: ResizeObserver;
|
|
27
|
-
mouseMoveOptimization?: boolean;
|
|
28
24
|
|
|
29
25
|
constructor(
|
|
30
26
|
node: Node,
|
|
31
27
|
view: EditorView,
|
|
32
28
|
getPos: any,
|
|
33
|
-
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
34
29
|
observer?: ResizeObserver,
|
|
35
30
|
) {
|
|
36
31
|
this.view = view;
|
|
@@ -45,11 +40,8 @@ export default class TableCellNodeView implements NodeView {
|
|
|
45
40
|
this.dom = dom as HTMLElement;
|
|
46
41
|
this.contentDOM = contentDOM as HTMLElement;
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (mouseMoveOptimization && observer) {
|
|
43
|
+
if (observer) {
|
|
51
44
|
this.contentDOM.id = uuid();
|
|
52
|
-
this.mouseMoveOptimization = mouseMoveOptimization;
|
|
53
45
|
this.observer = observer;
|
|
54
46
|
observer.observe(this.contentDOM);
|
|
55
47
|
}
|
|
@@ -108,7 +100,7 @@ export default class TableCellNodeView implements NodeView {
|
|
|
108
100
|
}
|
|
109
101
|
|
|
110
102
|
destroy() {
|
|
111
|
-
if (this.
|
|
103
|
+
if (this.observer) {
|
|
112
104
|
this.observer.unobserve(this.contentDOM);
|
|
113
105
|
}
|
|
114
106
|
}
|
|
@@ -25,7 +25,6 @@ export interface Props {
|
|
|
25
25
|
eventDispatcher: EventDispatcher;
|
|
26
26
|
getPos: () => number | undefined;
|
|
27
27
|
options?: TableOptions;
|
|
28
|
-
tableRenderOptimization?: boolean;
|
|
29
28
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
30
29
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
31
30
|
hasIntlContext: boolean;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
3
1
|
import { TableCssClassName as ClassName } from '../types';
|
|
4
2
|
|
|
5
3
|
export const updateShadowListForStickyStyles = (
|
|
@@ -17,55 +15,3 @@ export const updateShadowListForStickyStyles = (
|
|
|
17
15
|
}
|
|
18
16
|
});
|
|
19
17
|
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Update overflow shadows for a given wrapper & table.
|
|
23
|
-
* if `overflowShadowOptimization` is enabled, this will exit early.
|
|
24
|
-
*/
|
|
25
|
-
export const updateOverflowShadows =
|
|
26
|
-
(getEditorFeatureFlags: GetEditorFeatureFlags) =>
|
|
27
|
-
(
|
|
28
|
-
wrapper?: HTMLElement | null,
|
|
29
|
-
table?: HTMLElement | null,
|
|
30
|
-
rightShadows?: NodeListOf<HTMLElement> | null,
|
|
31
|
-
leftShadows?: NodeListOf<HTMLElement> | null,
|
|
32
|
-
) => {
|
|
33
|
-
if (getEditorFeatureFlags()?.tableOverflowShadowsOptimization === true) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
// Right shadow
|
|
37
|
-
if (table && wrapper) {
|
|
38
|
-
const stickyRow = wrapper.querySelector('tr.sticky');
|
|
39
|
-
const stickyCell = stickyRow && stickyRow.firstElementChild;
|
|
40
|
-
|
|
41
|
-
if (rightShadows) {
|
|
42
|
-
const diff = table.offsetWidth - wrapper.offsetWidth;
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < rightShadows.length; i++) {
|
|
45
|
-
const rightShadow = rightShadows[i];
|
|
46
|
-
rightShadow.style.display =
|
|
47
|
-
diff > 0 && diff > wrapper.scrollLeft ? 'block' : 'none';
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
rightShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) &&
|
|
51
|
-
stickyCell
|
|
52
|
-
) {
|
|
53
|
-
rightShadow.style.height = `${stickyCell.clientHeight + 1}px`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (leftShadows) {
|
|
58
|
-
for (let i = 0; i < leftShadows.length; i++) {
|
|
59
|
-
const leftShadow = leftShadows[i];
|
|
60
|
-
leftShadow.style.display = wrapper.scrollLeft > 0 ? 'block' : 'none';
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
leftShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) &&
|
|
64
|
-
stickyCell
|
|
65
|
-
) {
|
|
66
|
-
leftShadow.style.height = `${stickyCell.clientHeight + 1}px`;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
@@ -139,26 +139,12 @@ export const createPlugin = (
|
|
|
139
139
|
node: ProseMirrorNode,
|
|
140
140
|
view: EditorView,
|
|
141
141
|
getPos: getPosHandler,
|
|
142
|
-
) =>
|
|
143
|
-
new TableCellNodeView(
|
|
144
|
-
node,
|
|
145
|
-
view,
|
|
146
|
-
getPos,
|
|
147
|
-
getEditorFeatureFlags,
|
|
148
|
-
observer,
|
|
149
|
-
),
|
|
142
|
+
) => new TableCellNodeView(node, view, getPos, observer),
|
|
150
143
|
tableHeader: (
|
|
151
144
|
node: ProseMirrorNode,
|
|
152
145
|
view: EditorView,
|
|
153
146
|
getPos: getPosHandler,
|
|
154
|
-
) =>
|
|
155
|
-
new TableCellNodeView(
|
|
156
|
-
node,
|
|
157
|
-
view,
|
|
158
|
-
getPos,
|
|
159
|
-
getEditorFeatureFlags,
|
|
160
|
-
observer,
|
|
161
|
-
),
|
|
147
|
+
) => new TableCellNodeView(node, view, getPos, observer),
|
|
162
148
|
};
|
|
163
149
|
|
|
164
150
|
// Used to prevent invalid table cell spans being reported more than once per editor/document
|
|
@@ -367,8 +353,7 @@ export const createPlugin = (
|
|
|
367
353
|
},
|
|
368
354
|
|
|
369
355
|
nodeViews: {
|
|
370
|
-
|
|
371
|
-
...(tableCellNodeview as any),
|
|
356
|
+
...tableCellNodeview,
|
|
372
357
|
table: (node, view, getPos) =>
|
|
373
358
|
createTableView(
|
|
374
359
|
node,
|
|
@@ -395,10 +380,7 @@ export const createPlugin = (
|
|
|
395
380
|
mouseover: whenTableInFocus(handleMouseOver),
|
|
396
381
|
mouseleave: whenTableInFocus(handleMouseLeave),
|
|
397
382
|
mouseout: whenTableInFocus(handleMouseOut),
|
|
398
|
-
mousemove: whenTableInFocus(
|
|
399
|
-
handleMouseMove(getEditorFeatureFlags),
|
|
400
|
-
elementContentRects,
|
|
401
|
-
),
|
|
383
|
+
mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
|
|
402
384
|
click: whenTableInFocus(handleClick),
|
|
403
385
|
},
|
|
404
386
|
|