@atlaskit/editor-plugin-table 15.6.4 → 15.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/nodeviews/TableRowNativeStickyWithFallback.js +99 -43
- package/dist/es2019/nodeviews/TableRowNativeStickyWithFallback.js +58 -3
- package/dist/esm/nodeviews/TableRowNativeStickyWithFallback.js +98 -42
- package/dist/types/nodeviews/TableRowNativeStickyWithFallback.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/TableRowNativeStickyWithFallback.d.ts +3 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 15.6.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8e7168f651cc2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8e7168f651cc2) -
|
|
8
|
+
Only set native sticky header classes if a scroll event has occurred
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 15.6.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 15.6.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -183,6 +183,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
183
183
|
if (this.isStickyHeaderEnabled) {
|
|
184
184
|
this.unsubscribe();
|
|
185
185
|
this.overflowObserver && this.overflowObserver.disconnect();
|
|
186
|
+
this.overflowObserverEntries = undefined;
|
|
186
187
|
this.stickyStateObserver && this.stickyStateObserver.disconnect();
|
|
187
188
|
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
188
189
|
var tree = (0, _dom2.getTree)(this.dom);
|
|
@@ -226,12 +227,56 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
226
227
|
}, {
|
|
227
228
|
key: "subscribe",
|
|
228
229
|
value: function subscribe() {
|
|
230
|
+
var _this2 = this;
|
|
229
231
|
// Ignored via go/ees005
|
|
230
232
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
231
233
|
this.editorScrollableElement = (0, _ui.findOverflowScrollParent)(this.view.dom) || window;
|
|
232
234
|
if (this.editorScrollableElement) {
|
|
233
235
|
this.initObservers();
|
|
234
236
|
this.topPosEditorElement = (0, _dom2.getTop)(this.editorScrollableElement);
|
|
237
|
+
if (!TableRowNativeStickyWithFallback.scrollListener && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_5')) {
|
|
238
|
+
TableRowNativeStickyWithFallback.scrollListener = function () {
|
|
239
|
+
if (TableRowNativeStickyWithFallback.hasScrolledSinceLoad) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
TableRowNativeStickyWithFallback.hasScrolledSinceLoad = true;
|
|
243
|
+
if (!_this2.overflowObserver) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Re-check intersection state now that scrolling has occurred
|
|
248
|
+
if (_this2.overflowObserver) {
|
|
249
|
+
var _this2$overflowObserv;
|
|
250
|
+
var entries = (_this2$overflowObserv = _this2.overflowObserverEntries) !== null && _this2$overflowObserv !== void 0 ? _this2$overflowObserv : _this2.overflowObserver.takeRecords();
|
|
251
|
+
_this2.overflowObserverEntries = undefined;
|
|
252
|
+
|
|
253
|
+
/** NOTE: This logic is duplicated in the overflowObserver callback
|
|
254
|
+
* to avoid conflicting with a follow up refactor where this will
|
|
255
|
+
* be cleaned up.
|
|
256
|
+
*/
|
|
257
|
+
entries.forEach(function (entry) {
|
|
258
|
+
var tableWrapper = _this2.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
|
|
259
|
+
if (tableWrapper && tableWrapper instanceof HTMLElement) {
|
|
260
|
+
if (entry.isIntersecting) {
|
|
261
|
+
tableWrapper.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
262
|
+
_this2.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
|
|
263
|
+
_this2.isNativeSticky = true;
|
|
264
|
+
} else {
|
|
265
|
+
tableWrapper.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
266
|
+
_this2.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
267
|
+
_this2.isNativeSticky = false;
|
|
268
|
+
}
|
|
269
|
+
_this2.refreshLegacyStickyState();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
275
|
+
this.editorScrollableElement.addEventListener('scroll', TableRowNativeStickyWithFallback.scrollListener, {
|
|
276
|
+
passive: true,
|
|
277
|
+
once: true
|
|
278
|
+
});
|
|
279
|
+
}
|
|
235
280
|
}
|
|
236
281
|
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
237
282
|
|
|
@@ -270,6 +315,11 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
270
315
|
if (this.resizeObserver) {
|
|
271
316
|
this.resizeObserver.disconnect();
|
|
272
317
|
}
|
|
318
|
+
if (TableRowNativeStickyWithFallback.scrollListener && this.editorScrollableElement) {
|
|
319
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
320
|
+
this.editorScrollableElement.removeEventListener('scroll', TableRowNativeStickyWithFallback.scrollListener);
|
|
321
|
+
TableRowNativeStickyWithFallback.scrollListener = undefined;
|
|
322
|
+
}
|
|
273
323
|
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
274
324
|
// Ignored via go/ees005
|
|
275
325
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -286,7 +336,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
286
336
|
}, {
|
|
287
337
|
key: "initOverflowObserver",
|
|
288
338
|
value: function initOverflowObserver() {
|
|
289
|
-
var
|
|
339
|
+
var _this3 = this;
|
|
290
340
|
var tableWrapper = this.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
|
|
291
341
|
if (!tableWrapper) {
|
|
292
342
|
return;
|
|
@@ -300,16 +350,21 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
300
350
|
if (!(observer.root instanceof HTMLElement)) {
|
|
301
351
|
return;
|
|
302
352
|
}
|
|
353
|
+
// Only apply classes if page has scrolled since load
|
|
354
|
+
if (!TableRowNativeStickyWithFallback.hasScrolledSinceLoad && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_5')) {
|
|
355
|
+
_this3.overflowObserverEntries = entries;
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
303
358
|
if (entry.isIntersecting) {
|
|
304
359
|
observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
305
|
-
|
|
306
|
-
|
|
360
|
+
_this3.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
|
|
361
|
+
_this3.isNativeSticky = true;
|
|
307
362
|
} else {
|
|
308
363
|
observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
309
|
-
|
|
310
|
-
|
|
364
|
+
_this3.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
365
|
+
_this3.isNativeSticky = false;
|
|
311
366
|
}
|
|
312
|
-
|
|
367
|
+
_this3.refreshLegacyStickyState();
|
|
313
368
|
});
|
|
314
369
|
}, options);
|
|
315
370
|
}
|
|
@@ -322,7 +377,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
322
377
|
}, {
|
|
323
378
|
key: "initStickyStateObserver",
|
|
324
379
|
value: function initStickyStateObserver() {
|
|
325
|
-
var
|
|
380
|
+
var _this4 = this;
|
|
326
381
|
if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
|
|
327
382
|
return;
|
|
328
383
|
}
|
|
@@ -334,14 +389,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
334
389
|
this.stickyStateObserver = new IntersectionObserver(function (entries) {
|
|
335
390
|
entries.forEach(function (entry) {
|
|
336
391
|
var _entry$rootBounds;
|
|
337
|
-
var tableContainer =
|
|
392
|
+
var tableContainer = _this4.dom.closest(".".concat(_types.TableCssClassName.TABLE_CONTAINER));
|
|
338
393
|
if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top)) {
|
|
339
|
-
|
|
394
|
+
_this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
|
|
340
395
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
341
396
|
tableContainer.dataset.tableHeaderIsStuck = 'true';
|
|
342
397
|
}
|
|
343
398
|
} else {
|
|
344
|
-
|
|
399
|
+
_this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
|
|
345
400
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
346
401
|
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_3')) {
|
|
347
402
|
delete tableContainer.dataset.tableHeaderIsStuck;
|
|
@@ -358,7 +413,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
358
413
|
}, {
|
|
359
414
|
key: "initObservers",
|
|
360
415
|
value: function initObservers() {
|
|
361
|
-
var
|
|
416
|
+
var _this5 = this;
|
|
362
417
|
if (!this.dom || this.dom.dataset.isObserved) {
|
|
363
418
|
return;
|
|
364
419
|
}
|
|
@@ -392,7 +447,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
392
447
|
window.requestAnimationFrame(function () {
|
|
393
448
|
var getTableContainer = function getTableContainer() {
|
|
394
449
|
var _getTree;
|
|
395
|
-
return (_getTree = (0, _dom2.getTree)(
|
|
450
|
+
return (_getTree = (0, _dom2.getTree)(_this5.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
|
|
396
451
|
};
|
|
397
452
|
|
|
398
453
|
// we expect tree to be defined after animation frame
|
|
@@ -418,16 +473,16 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
418
473
|
return getSentinelTop() !== null && getSentinelBottom() !== null;
|
|
419
474
|
};
|
|
420
475
|
var observeStickySentinels = function observeStickySentinels() {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
[
|
|
476
|
+
_this5.sentinels.top = getSentinelTop();
|
|
477
|
+
_this5.sentinels.bottom = getSentinelBottom();
|
|
478
|
+
[_this5.sentinels.top, _this5.sentinels.bottom].forEach(function (el) {
|
|
424
479
|
// skip if already observed for another row on this table
|
|
425
480
|
if (el && !el.dataset.isObserved) {
|
|
426
481
|
el.dataset.isObserved = 'true';
|
|
427
482
|
|
|
428
483
|
// Ignored via go/ees005
|
|
429
484
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
430
|
-
|
|
485
|
+
_this5.intersectionObserver.observe(el);
|
|
431
486
|
}
|
|
432
487
|
});
|
|
433
488
|
};
|
|
@@ -442,7 +497,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
442
497
|
// observe sentinels before they are in the DOM, use MutationObserver
|
|
443
498
|
// to wait for sentinels to be added to the parent Table node DOM
|
|
444
499
|
// then attach the IntersectionObserver
|
|
445
|
-
|
|
500
|
+
_this5.tableContainerObserver = new MutationObserver(function () {
|
|
446
501
|
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
447
502
|
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
448
503
|
|
|
@@ -450,14 +505,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
450
505
|
tableContainer = getTableContainer();
|
|
451
506
|
}
|
|
452
507
|
if (sentinelsInDom()) {
|
|
453
|
-
var
|
|
508
|
+
var _this5$tableContainer;
|
|
454
509
|
observeStickySentinels();
|
|
455
|
-
(
|
|
510
|
+
(_this5$tableContainer = _this5.tableContainerObserver) === null || _this5$tableContainer === void 0 || _this5$tableContainer.disconnect();
|
|
456
511
|
}
|
|
457
512
|
});
|
|
458
513
|
var mutatingNode = tableContainer;
|
|
459
|
-
if (mutatingNode &&
|
|
460
|
-
|
|
514
|
+
if (mutatingNode && _this5.tableContainerObserver) {
|
|
515
|
+
_this5.tableContainerObserver.observe(mutatingNode, {
|
|
461
516
|
subtree: true,
|
|
462
517
|
childList: true
|
|
463
518
|
});
|
|
@@ -472,32 +527,32 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
472
527
|
}, {
|
|
473
528
|
key: "createResizeObserver",
|
|
474
529
|
value: function createResizeObserver() {
|
|
475
|
-
var
|
|
530
|
+
var _this6 = this;
|
|
476
531
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
477
|
-
var tree = (0, _dom2.getTree)(
|
|
532
|
+
var tree = (0, _dom2.getTree)(_this6.dom);
|
|
478
533
|
if (!tree) {
|
|
479
534
|
return;
|
|
480
535
|
}
|
|
481
536
|
var table = tree.table;
|
|
482
537
|
entries.forEach(function (entry) {
|
|
483
|
-
var
|
|
538
|
+
var _this6$editorScrollab;
|
|
484
539
|
// On resize of the parent scroll element we need to adjust the width
|
|
485
540
|
// of the sticky header
|
|
486
541
|
// Ignored via go/ees005
|
|
487
542
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
488
|
-
if (entry.target.className === ((
|
|
489
|
-
|
|
543
|
+
if (entry.target.className === ((_this6$editorScrollab = _this6.editorScrollableElement) === null || _this6$editorScrollab === void 0 ? void 0 : _this6$editorScrollab.className)) {
|
|
544
|
+
_this6.updateStickyHeaderWidth();
|
|
490
545
|
} else {
|
|
491
546
|
var newHeight = entry.contentRect ? entry.contentRect.height :
|
|
492
547
|
// Ignored via go/ees005
|
|
493
548
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
494
549
|
entry.target.offsetHeight;
|
|
495
|
-
if (
|
|
550
|
+
if (_this6.sentinels.bottom &&
|
|
496
551
|
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
497
552
|
// So we adding this check to allow a 1px difference.
|
|
498
|
-
Math.abs(newHeight - (
|
|
499
|
-
|
|
500
|
-
|
|
553
|
+
Math.abs(newHeight - (_this6.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
|
|
554
|
+
_this6.stickyRowHeight = newHeight;
|
|
555
|
+
_this6.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
|
|
501
556
|
(0, _dom.updateStickyMargins)(table);
|
|
502
557
|
}
|
|
503
558
|
}
|
|
@@ -507,13 +562,13 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
507
562
|
}, {
|
|
508
563
|
key: "createIntersectionObserver",
|
|
509
564
|
value: function createIntersectionObserver() {
|
|
510
|
-
var
|
|
565
|
+
var _this7 = this;
|
|
511
566
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
512
|
-
var
|
|
567
|
+
var _this7$editorScrollab, _this7$editorScrollab2;
|
|
513
568
|
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
514
569
|
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
515
570
|
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
516
|
-
var rootBounds = (
|
|
571
|
+
var rootBounds = (_this7$editorScrollab = _this7.editorScrollableElement) === null || _this7$editorScrollab === void 0 || (_this7$editorScrollab2 = _this7$editorScrollab.getBoundingClientRect) === null || _this7$editorScrollab2 === void 0 ? void 0 : _this7$editorScrollab2.call(_this7$editorScrollab);
|
|
517
572
|
entries.forEach(function (entry) {
|
|
518
573
|
var target = entry.target,
|
|
519
574
|
isIntersecting = entry.isIntersecting,
|
|
@@ -521,15 +576,15 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
521
576
|
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
522
577
|
var targetKey = target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
523
578
|
// Cache the latest sentinel information
|
|
524
|
-
|
|
579
|
+
_this7.sentinelData[targetKey] = {
|
|
525
580
|
isIntersecting: isIntersecting,
|
|
526
581
|
boundingClientRect: boundingClientRect,
|
|
527
582
|
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
528
583
|
};
|
|
529
584
|
// Keep the other sentinels rootBounds in sync with this latest one
|
|
530
|
-
|
|
585
|
+
_this7.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
531
586
|
});
|
|
532
|
-
|
|
587
|
+
_this7.refreshLegacyStickyState();
|
|
533
588
|
}, {
|
|
534
589
|
threshold: 0,
|
|
535
590
|
root: this.editorScrollableElement
|
|
@@ -704,12 +759,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
704
759
|
}, {
|
|
705
760
|
key: "refireIntersectionObservers",
|
|
706
761
|
value: function refireIntersectionObservers() {
|
|
707
|
-
var
|
|
762
|
+
var _this8 = this;
|
|
708
763
|
if (this.isLegacySticky) {
|
|
709
764
|
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
710
|
-
if (el &&
|
|
711
|
-
|
|
712
|
-
|
|
765
|
+
if (el && _this8.intersectionObserver) {
|
|
766
|
+
_this8.intersectionObserver.unobserve(el);
|
|
767
|
+
_this8.intersectionObserver.observe(el);
|
|
713
768
|
}
|
|
714
769
|
});
|
|
715
770
|
}
|
|
@@ -718,7 +773,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
718
773
|
key: "makeHeaderRowLegacySticky",
|
|
719
774
|
value: function makeHeaderRowLegacySticky(tree, scrollTop) {
|
|
720
775
|
var _tbody$firstChild,
|
|
721
|
-
|
|
776
|
+
_this9 = this;
|
|
722
777
|
// If header row height is more than 50% of viewport height don't do this
|
|
723
778
|
if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
|
|
724
779
|
return;
|
|
@@ -757,7 +812,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
757
812
|
});
|
|
758
813
|
var fastScrollThresholdMs = 500;
|
|
759
814
|
setTimeout(function () {
|
|
760
|
-
|
|
815
|
+
_this9.refireIntersectionObservers();
|
|
761
816
|
}, fastScrollThresholdMs);
|
|
762
817
|
}
|
|
763
818
|
this.dom.style.top = "0px";
|
|
@@ -845,4 +900,5 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
845
900
|
}
|
|
846
901
|
}
|
|
847
902
|
}]);
|
|
848
|
-
}(_TableNodeViewBase.default);
|
|
903
|
+
}(_TableNodeViewBase.default);
|
|
904
|
+
(0, _defineProperty2.default)(TableRowNativeStickyWithFallback, "hasScrolledSinceLoad", false);
|
|
@@ -161,6 +161,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
161
161
|
if (this.isStickyHeaderEnabled) {
|
|
162
162
|
this.unsubscribe();
|
|
163
163
|
this.overflowObserver && this.overflowObserver.disconnect();
|
|
164
|
+
this.overflowObserverEntries = undefined;
|
|
164
165
|
this.stickyStateObserver && this.stickyStateObserver.disconnect();
|
|
165
166
|
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
166
167
|
const tree = getTree(this.dom);
|
|
@@ -206,6 +207,49 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
206
207
|
if (this.editorScrollableElement) {
|
|
207
208
|
this.initObservers();
|
|
208
209
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
210
|
+
if (!TableRowNativeStickyWithFallback.scrollListener && fg('platform_editor_table_sticky_header_patch_5')) {
|
|
211
|
+
TableRowNativeStickyWithFallback.scrollListener = () => {
|
|
212
|
+
if (TableRowNativeStickyWithFallback.hasScrolledSinceLoad) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
TableRowNativeStickyWithFallback.hasScrolledSinceLoad = true;
|
|
216
|
+
if (!this.overflowObserver) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Re-check intersection state now that scrolling has occurred
|
|
221
|
+
if (this.overflowObserver) {
|
|
222
|
+
var _this$overflowObserve;
|
|
223
|
+
const entries = (_this$overflowObserve = this.overflowObserverEntries) !== null && _this$overflowObserve !== void 0 ? _this$overflowObserve : this.overflowObserver.takeRecords();
|
|
224
|
+
this.overflowObserverEntries = undefined;
|
|
225
|
+
|
|
226
|
+
/** NOTE: This logic is duplicated in the overflowObserver callback
|
|
227
|
+
* to avoid conflicting with a follow up refactor where this will
|
|
228
|
+
* be cleaned up.
|
|
229
|
+
*/
|
|
230
|
+
entries.forEach(entry => {
|
|
231
|
+
const tableWrapper = this.dom.closest(`.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
232
|
+
if (tableWrapper && tableWrapper instanceof HTMLElement) {
|
|
233
|
+
if (entry.isIntersecting) {
|
|
234
|
+
tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
235
|
+
this.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
236
|
+
this.isNativeSticky = true;
|
|
237
|
+
} else {
|
|
238
|
+
tableWrapper.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
239
|
+
this.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
240
|
+
this.isNativeSticky = false;
|
|
241
|
+
}
|
|
242
|
+
this.refreshLegacyStickyState();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
248
|
+
this.editorScrollableElement.addEventListener('scroll', TableRowNativeStickyWithFallback.scrollListener, {
|
|
249
|
+
passive: true,
|
|
250
|
+
once: true
|
|
251
|
+
});
|
|
252
|
+
}
|
|
209
253
|
}
|
|
210
254
|
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
211
255
|
|
|
@@ -242,6 +286,11 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
242
286
|
if (this.resizeObserver) {
|
|
243
287
|
this.resizeObserver.disconnect();
|
|
244
288
|
}
|
|
289
|
+
if (TableRowNativeStickyWithFallback.scrollListener && this.editorScrollableElement) {
|
|
290
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
291
|
+
this.editorScrollableElement.removeEventListener('scroll', TableRowNativeStickyWithFallback.scrollListener);
|
|
292
|
+
TableRowNativeStickyWithFallback.scrollListener = undefined;
|
|
293
|
+
}
|
|
245
294
|
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
246
295
|
// Ignored via go/ees005
|
|
247
296
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -269,6 +318,11 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
269
318
|
if (!(observer.root instanceof HTMLElement)) {
|
|
270
319
|
return;
|
|
271
320
|
}
|
|
321
|
+
// Only apply classes if page has scrolled since load
|
|
322
|
+
if (!TableRowNativeStickyWithFallback.hasScrolledSinceLoad && fg('platform_editor_table_sticky_header_patch_5')) {
|
|
323
|
+
this.overflowObserverEntries = entries;
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
272
326
|
if (entry.isIntersecting) {
|
|
273
327
|
observer.root.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
274
328
|
this.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
@@ -340,8 +394,8 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
340
394
|
this.initOverflowObserver();
|
|
341
395
|
const closestTable = this.dom.closest('table');
|
|
342
396
|
if (closestTable) {
|
|
343
|
-
var _this$
|
|
344
|
-
(_this$
|
|
397
|
+
var _this$overflowObserve2;
|
|
398
|
+
(_this$overflowObserve2 = this.overflowObserver) === null || _this$overflowObserve2 === void 0 ? void 0 : _this$overflowObserve2.observe(closestTable);
|
|
345
399
|
}
|
|
346
400
|
this.initStickyStateObserver();
|
|
347
401
|
(_this$stickyStateObse = this.stickyStateObserver) === null || _this$stickyStateObse === void 0 ? void 0 : _this$stickyStateObse.observe(this.dom);
|
|
@@ -778,4 +832,5 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
778
832
|
})(this.view.state, this.view.dispatch, this.view);
|
|
779
833
|
}
|
|
780
834
|
}
|
|
781
|
-
}
|
|
835
|
+
}
|
|
836
|
+
_defineProperty(TableRowNativeStickyWithFallback, "hasScrolledSinceLoad", false);
|
|
@@ -176,6 +176,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
176
176
|
if (this.isStickyHeaderEnabled) {
|
|
177
177
|
this.unsubscribe();
|
|
178
178
|
this.overflowObserver && this.overflowObserver.disconnect();
|
|
179
|
+
this.overflowObserverEntries = undefined;
|
|
179
180
|
this.stickyStateObserver && this.stickyStateObserver.disconnect();
|
|
180
181
|
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
181
182
|
var tree = getTree(this.dom);
|
|
@@ -219,12 +220,56 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
219
220
|
}, {
|
|
220
221
|
key: "subscribe",
|
|
221
222
|
value: function subscribe() {
|
|
223
|
+
var _this2 = this;
|
|
222
224
|
// Ignored via go/ees005
|
|
223
225
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
224
226
|
this.editorScrollableElement = findOverflowScrollParent(this.view.dom) || window;
|
|
225
227
|
if (this.editorScrollableElement) {
|
|
226
228
|
this.initObservers();
|
|
227
229
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
230
|
+
if (!TableRowNativeStickyWithFallback.scrollListener && fg('platform_editor_table_sticky_header_patch_5')) {
|
|
231
|
+
TableRowNativeStickyWithFallback.scrollListener = function () {
|
|
232
|
+
if (TableRowNativeStickyWithFallback.hasScrolledSinceLoad) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
TableRowNativeStickyWithFallback.hasScrolledSinceLoad = true;
|
|
236
|
+
if (!_this2.overflowObserver) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Re-check intersection state now that scrolling has occurred
|
|
241
|
+
if (_this2.overflowObserver) {
|
|
242
|
+
var _this2$overflowObserv;
|
|
243
|
+
var entries = (_this2$overflowObserv = _this2.overflowObserverEntries) !== null && _this2$overflowObserv !== void 0 ? _this2$overflowObserv : _this2.overflowObserver.takeRecords();
|
|
244
|
+
_this2.overflowObserverEntries = undefined;
|
|
245
|
+
|
|
246
|
+
/** NOTE: This logic is duplicated in the overflowObserver callback
|
|
247
|
+
* to avoid conflicting with a follow up refactor where this will
|
|
248
|
+
* be cleaned up.
|
|
249
|
+
*/
|
|
250
|
+
entries.forEach(function (entry) {
|
|
251
|
+
var tableWrapper = _this2.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
252
|
+
if (tableWrapper && tableWrapper instanceof HTMLElement) {
|
|
253
|
+
if (entry.isIntersecting) {
|
|
254
|
+
tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
255
|
+
_this2.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
256
|
+
_this2.isNativeSticky = true;
|
|
257
|
+
} else {
|
|
258
|
+
tableWrapper.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
259
|
+
_this2.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
260
|
+
_this2.isNativeSticky = false;
|
|
261
|
+
}
|
|
262
|
+
_this2.refreshLegacyStickyState();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
268
|
+
this.editorScrollableElement.addEventListener('scroll', TableRowNativeStickyWithFallback.scrollListener, {
|
|
269
|
+
passive: true,
|
|
270
|
+
once: true
|
|
271
|
+
});
|
|
272
|
+
}
|
|
228
273
|
}
|
|
229
274
|
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
230
275
|
|
|
@@ -263,6 +308,11 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
263
308
|
if (this.resizeObserver) {
|
|
264
309
|
this.resizeObserver.disconnect();
|
|
265
310
|
}
|
|
311
|
+
if (TableRowNativeStickyWithFallback.scrollListener && this.editorScrollableElement) {
|
|
312
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
313
|
+
this.editorScrollableElement.removeEventListener('scroll', TableRowNativeStickyWithFallback.scrollListener);
|
|
314
|
+
TableRowNativeStickyWithFallback.scrollListener = undefined;
|
|
315
|
+
}
|
|
266
316
|
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
267
317
|
// Ignored via go/ees005
|
|
268
318
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -279,7 +329,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
279
329
|
}, {
|
|
280
330
|
key: "initOverflowObserver",
|
|
281
331
|
value: function initOverflowObserver() {
|
|
282
|
-
var
|
|
332
|
+
var _this3 = this;
|
|
283
333
|
var tableWrapper = this.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
284
334
|
if (!tableWrapper) {
|
|
285
335
|
return;
|
|
@@ -293,16 +343,21 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
293
343
|
if (!(observer.root instanceof HTMLElement)) {
|
|
294
344
|
return;
|
|
295
345
|
}
|
|
346
|
+
// Only apply classes if page has scrolled since load
|
|
347
|
+
if (!TableRowNativeStickyWithFallback.hasScrolledSinceLoad && fg('platform_editor_table_sticky_header_patch_5')) {
|
|
348
|
+
_this3.overflowObserverEntries = entries;
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
296
351
|
if (entry.isIntersecting) {
|
|
297
352
|
observer.root.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
298
|
-
|
|
299
|
-
|
|
353
|
+
_this3.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
354
|
+
_this3.isNativeSticky = true;
|
|
300
355
|
} else {
|
|
301
356
|
observer.root.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
302
|
-
|
|
303
|
-
|
|
357
|
+
_this3.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
358
|
+
_this3.isNativeSticky = false;
|
|
304
359
|
}
|
|
305
|
-
|
|
360
|
+
_this3.refreshLegacyStickyState();
|
|
306
361
|
});
|
|
307
362
|
}, options);
|
|
308
363
|
}
|
|
@@ -315,7 +370,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
315
370
|
}, {
|
|
316
371
|
key: "initStickyStateObserver",
|
|
317
372
|
value: function initStickyStateObserver() {
|
|
318
|
-
var
|
|
373
|
+
var _this4 = this;
|
|
319
374
|
if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
|
|
320
375
|
return;
|
|
321
376
|
}
|
|
@@ -327,14 +382,14 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
327
382
|
this.stickyStateObserver = new IntersectionObserver(function (entries) {
|
|
328
383
|
entries.forEach(function (entry) {
|
|
329
384
|
var _entry$rootBounds;
|
|
330
|
-
var tableContainer =
|
|
385
|
+
var tableContainer = _this4.dom.closest(".".concat(ClassName.TABLE_CONTAINER));
|
|
331
386
|
if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top)) {
|
|
332
|
-
|
|
387
|
+
_this4.dom.classList.add(ClassName.NATIVE_STICKY_ACTIVE);
|
|
333
388
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
334
389
|
tableContainer.dataset.tableHeaderIsStuck = 'true';
|
|
335
390
|
}
|
|
336
391
|
} else {
|
|
337
|
-
|
|
392
|
+
_this4.dom.classList.remove(ClassName.NATIVE_STICKY_ACTIVE);
|
|
338
393
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
339
394
|
if (fg('platform_editor_table_sticky_header_patch_3')) {
|
|
340
395
|
delete tableContainer.dataset.tableHeaderIsStuck;
|
|
@@ -351,7 +406,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
351
406
|
}, {
|
|
352
407
|
key: "initObservers",
|
|
353
408
|
value: function initObservers() {
|
|
354
|
-
var
|
|
409
|
+
var _this5 = this;
|
|
355
410
|
if (!this.dom || this.dom.dataset.isObserved) {
|
|
356
411
|
return;
|
|
357
412
|
}
|
|
@@ -385,7 +440,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
385
440
|
window.requestAnimationFrame(function () {
|
|
386
441
|
var getTableContainer = function getTableContainer() {
|
|
387
442
|
var _getTree;
|
|
388
|
-
return (_getTree = getTree(
|
|
443
|
+
return (_getTree = getTree(_this5.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
|
|
389
444
|
};
|
|
390
445
|
|
|
391
446
|
// we expect tree to be defined after animation frame
|
|
@@ -411,16 +466,16 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
411
466
|
return getSentinelTop() !== null && getSentinelBottom() !== null;
|
|
412
467
|
};
|
|
413
468
|
var observeStickySentinels = function observeStickySentinels() {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
[
|
|
469
|
+
_this5.sentinels.top = getSentinelTop();
|
|
470
|
+
_this5.sentinels.bottom = getSentinelBottom();
|
|
471
|
+
[_this5.sentinels.top, _this5.sentinels.bottom].forEach(function (el) {
|
|
417
472
|
// skip if already observed for another row on this table
|
|
418
473
|
if (el && !el.dataset.isObserved) {
|
|
419
474
|
el.dataset.isObserved = 'true';
|
|
420
475
|
|
|
421
476
|
// Ignored via go/ees005
|
|
422
477
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
423
|
-
|
|
478
|
+
_this5.intersectionObserver.observe(el);
|
|
424
479
|
}
|
|
425
480
|
});
|
|
426
481
|
};
|
|
@@ -435,7 +490,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
435
490
|
// observe sentinels before they are in the DOM, use MutationObserver
|
|
436
491
|
// to wait for sentinels to be added to the parent Table node DOM
|
|
437
492
|
// then attach the IntersectionObserver
|
|
438
|
-
|
|
493
|
+
_this5.tableContainerObserver = new MutationObserver(function () {
|
|
439
494
|
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
440
495
|
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
441
496
|
|
|
@@ -443,14 +498,14 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
443
498
|
tableContainer = getTableContainer();
|
|
444
499
|
}
|
|
445
500
|
if (sentinelsInDom()) {
|
|
446
|
-
var
|
|
501
|
+
var _this5$tableContainer;
|
|
447
502
|
observeStickySentinels();
|
|
448
|
-
(
|
|
503
|
+
(_this5$tableContainer = _this5.tableContainerObserver) === null || _this5$tableContainer === void 0 || _this5$tableContainer.disconnect();
|
|
449
504
|
}
|
|
450
505
|
});
|
|
451
506
|
var mutatingNode = tableContainer;
|
|
452
|
-
if (mutatingNode &&
|
|
453
|
-
|
|
507
|
+
if (mutatingNode && _this5.tableContainerObserver) {
|
|
508
|
+
_this5.tableContainerObserver.observe(mutatingNode, {
|
|
454
509
|
subtree: true,
|
|
455
510
|
childList: true
|
|
456
511
|
});
|
|
@@ -465,32 +520,32 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
465
520
|
}, {
|
|
466
521
|
key: "createResizeObserver",
|
|
467
522
|
value: function createResizeObserver() {
|
|
468
|
-
var
|
|
523
|
+
var _this6 = this;
|
|
469
524
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
470
|
-
var tree = getTree(
|
|
525
|
+
var tree = getTree(_this6.dom);
|
|
471
526
|
if (!tree) {
|
|
472
527
|
return;
|
|
473
528
|
}
|
|
474
529
|
var table = tree.table;
|
|
475
530
|
entries.forEach(function (entry) {
|
|
476
|
-
var
|
|
531
|
+
var _this6$editorScrollab;
|
|
477
532
|
// On resize of the parent scroll element we need to adjust the width
|
|
478
533
|
// of the sticky header
|
|
479
534
|
// Ignored via go/ees005
|
|
480
535
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
481
|
-
if (entry.target.className === ((
|
|
482
|
-
|
|
536
|
+
if (entry.target.className === ((_this6$editorScrollab = _this6.editorScrollableElement) === null || _this6$editorScrollab === void 0 ? void 0 : _this6$editorScrollab.className)) {
|
|
537
|
+
_this6.updateStickyHeaderWidth();
|
|
483
538
|
} else {
|
|
484
539
|
var newHeight = entry.contentRect ? entry.contentRect.height :
|
|
485
540
|
// Ignored via go/ees005
|
|
486
541
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
487
542
|
entry.target.offsetHeight;
|
|
488
|
-
if (
|
|
543
|
+
if (_this6.sentinels.bottom &&
|
|
489
544
|
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
490
545
|
// So we adding this check to allow a 1px difference.
|
|
491
|
-
Math.abs(newHeight - (
|
|
492
|
-
|
|
493
|
-
|
|
546
|
+
Math.abs(newHeight - (_this6.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
|
|
547
|
+
_this6.stickyRowHeight = newHeight;
|
|
548
|
+
_this6.sentinels.bottom.style.bottom = "".concat(tableScrollbarOffset + stickyRowOffsetTop + newHeight, "px");
|
|
494
549
|
updateTableMargin(table);
|
|
495
550
|
}
|
|
496
551
|
}
|
|
@@ -500,13 +555,13 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
500
555
|
}, {
|
|
501
556
|
key: "createIntersectionObserver",
|
|
502
557
|
value: function createIntersectionObserver() {
|
|
503
|
-
var
|
|
558
|
+
var _this7 = this;
|
|
504
559
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
505
|
-
var
|
|
560
|
+
var _this7$editorScrollab, _this7$editorScrollab2;
|
|
506
561
|
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
507
562
|
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
508
563
|
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
509
|
-
var rootBounds = (
|
|
564
|
+
var rootBounds = (_this7$editorScrollab = _this7.editorScrollableElement) === null || _this7$editorScrollab === void 0 || (_this7$editorScrollab2 = _this7$editorScrollab.getBoundingClientRect) === null || _this7$editorScrollab2 === void 0 ? void 0 : _this7$editorScrollab2.call(_this7$editorScrollab);
|
|
510
565
|
entries.forEach(function (entry) {
|
|
511
566
|
var target = entry.target,
|
|
512
567
|
isIntersecting = entry.isIntersecting,
|
|
@@ -514,15 +569,15 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
514
569
|
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
515
570
|
var targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
516
571
|
// Cache the latest sentinel information
|
|
517
|
-
|
|
572
|
+
_this7.sentinelData[targetKey] = {
|
|
518
573
|
isIntersecting: isIntersecting,
|
|
519
574
|
boundingClientRect: boundingClientRect,
|
|
520
575
|
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
521
576
|
};
|
|
522
577
|
// Keep the other sentinels rootBounds in sync with this latest one
|
|
523
|
-
|
|
578
|
+
_this7.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
524
579
|
});
|
|
525
|
-
|
|
580
|
+
_this7.refreshLegacyStickyState();
|
|
526
581
|
}, {
|
|
527
582
|
threshold: 0,
|
|
528
583
|
root: this.editorScrollableElement
|
|
@@ -697,12 +752,12 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
697
752
|
}, {
|
|
698
753
|
key: "refireIntersectionObservers",
|
|
699
754
|
value: function refireIntersectionObservers() {
|
|
700
|
-
var
|
|
755
|
+
var _this8 = this;
|
|
701
756
|
if (this.isLegacySticky) {
|
|
702
757
|
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
703
|
-
if (el &&
|
|
704
|
-
|
|
705
|
-
|
|
758
|
+
if (el && _this8.intersectionObserver) {
|
|
759
|
+
_this8.intersectionObserver.unobserve(el);
|
|
760
|
+
_this8.intersectionObserver.observe(el);
|
|
706
761
|
}
|
|
707
762
|
});
|
|
708
763
|
}
|
|
@@ -711,7 +766,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
711
766
|
key: "makeHeaderRowLegacySticky",
|
|
712
767
|
value: function makeHeaderRowLegacySticky(tree, scrollTop) {
|
|
713
768
|
var _tbody$firstChild,
|
|
714
|
-
|
|
769
|
+
_this9 = this;
|
|
715
770
|
// If header row height is more than 50% of viewport height don't do this
|
|
716
771
|
if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
|
|
717
772
|
return;
|
|
@@ -750,7 +805,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
750
805
|
});
|
|
751
806
|
var fastScrollThresholdMs = 500;
|
|
752
807
|
setTimeout(function () {
|
|
753
|
-
|
|
808
|
+
_this9.refireIntersectionObservers();
|
|
754
809
|
}, fastScrollThresholdMs);
|
|
755
810
|
}
|
|
756
811
|
this.dom.style.top = "0px";
|
|
@@ -839,4 +894,5 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
839
894
|
}
|
|
840
895
|
}]);
|
|
841
896
|
}(TableNodeView);
|
|
897
|
+
_defineProperty(TableRowNativeStickyWithFallback, "hasScrolledSinceLoad", false);
|
|
842
898
|
export { TableRowNativeStickyWithFallback as default };
|
|
@@ -4,6 +4,8 @@ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
|
4
4
|
import { type PluginInjectionAPI } from '../types';
|
|
5
5
|
import TableNodeView from './TableNodeViewBase';
|
|
6
6
|
export default class TableRowNativeStickyWithFallback extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
7
|
+
static hasScrolledSinceLoad: boolean;
|
|
8
|
+
static scrollListener?: () => void;
|
|
7
9
|
private nodeVisibilityObserverCleanupFn?;
|
|
8
10
|
cleanup: () => void;
|
|
9
11
|
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher, api?: PluginInjectionAPI);
|
|
@@ -32,6 +34,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView<HTML
|
|
|
32
34
|
private overflowObserver?;
|
|
33
35
|
private stickyStateObserver?;
|
|
34
36
|
private isNativeSticky;
|
|
37
|
+
private overflowObserverEntries?;
|
|
35
38
|
/**
|
|
36
39
|
* Methods: Nodeview Lifecycle
|
|
37
40
|
*/
|
|
@@ -4,6 +4,8 @@ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
|
4
4
|
import { type PluginInjectionAPI } from '../types';
|
|
5
5
|
import TableNodeView from './TableNodeViewBase';
|
|
6
6
|
export default class TableRowNativeStickyWithFallback extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
7
|
+
static hasScrolledSinceLoad: boolean;
|
|
8
|
+
static scrollListener?: () => void;
|
|
7
9
|
private nodeVisibilityObserverCleanupFn?;
|
|
8
10
|
cleanup: () => void;
|
|
9
11
|
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher, api?: PluginInjectionAPI);
|
|
@@ -32,6 +34,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView<HTML
|
|
|
32
34
|
private overflowObserver?;
|
|
33
35
|
private stickyStateObserver?;
|
|
34
36
|
private isNativeSticky;
|
|
37
|
+
private overflowObserverEntries?;
|
|
35
38
|
/**
|
|
36
39
|
* Methods: Nodeview Lifecycle
|
|
37
40
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "15.6.
|
|
3
|
+
"version": "15.6.6",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^6.1.0",
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^6.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
|
|
40
|
-
"@atlaskit/editor-plugin-extension": "9.
|
|
40
|
+
"@atlaskit/editor-plugin-extension": "9.3.0",
|
|
41
41
|
"@atlaskit/editor-plugin-guideline": "^6.0.0",
|
|
42
42
|
"@atlaskit/editor-plugin-interaction": "^11.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-limited-mode": "^3.1.0",
|
|
44
44
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
45
|
-
"@atlaskit/editor-plugin-toolbar": "^3.
|
|
45
|
+
"@atlaskit/editor-plugin-toolbar": "^3.5.0",
|
|
46
46
|
"@atlaskit/editor-plugin-user-intent": "^4.0.0",
|
|
47
47
|
"@atlaskit/editor-plugin-width": "^7.0.0",
|
|
48
48
|
"@atlaskit/editor-prosemirror": "^7.2.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"uuid": "^3.1.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@atlaskit/editor-common": "^110.
|
|
73
|
+
"@atlaskit/editor-common": "^110.47.0",
|
|
74
74
|
"react": "^18.2.0",
|
|
75
75
|
"react-dom": "^18.2.0",
|
|
76
76
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -160,6 +160,9 @@
|
|
|
160
160
|
},
|
|
161
161
|
"platform_editor_table_sticky_header_patch_3": {
|
|
162
162
|
"type": "boolean"
|
|
163
|
+
},
|
|
164
|
+
"platform_editor_table_sticky_header_patch_5": {
|
|
165
|
+
"type": "boolean"
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
168
|
}
|