@atlaskit/editor-plugin-table 15.6.2 → 15.6.3
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/TableRowNativeStickyWithFallback.js +94 -42
- package/dist/es2019/nodeviews/TableRowNativeStickyWithFallback.js +53 -2
- package/dist/esm/nodeviews/TableRowNativeStickyWithFallback.js +94 -42
- package/dist/types/nodeviews/TableRowNativeStickyWithFallback.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/TableRowNativeStickyWithFallback.d.ts +3 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 15.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`dbe5bb7c0221c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dbe5bb7c0221c) -
|
|
8
|
+
Only set native sticky header classes if a scroll event has occurred
|
|
9
|
+
- [`dbe5bb7c0221c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dbe5bb7c0221c) -
|
|
10
|
+
Remove top margin change when native table sticky headers are enabled
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 15.6.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -18,6 +18,7 @@ var _nodeVisibility = require("@atlaskit/editor-common/node-visibility");
|
|
|
18
18
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
19
19
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
20
20
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
21
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
22
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
22
23
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
23
24
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
@@ -76,6 +77,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
76
77
|
(0, _defineProperty2.default)(_this, "padding", 0);
|
|
77
78
|
(0, _defineProperty2.default)(_this, "top", 0);
|
|
78
79
|
(0, _defineProperty2.default)(_this, "isNativeSticky", false);
|
|
80
|
+
(0, _defineProperty2.default)(_this, "hasScrolledSinceLoad", false);
|
|
79
81
|
/**
|
|
80
82
|
* Methods
|
|
81
83
|
*/
|
|
@@ -182,6 +184,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
182
184
|
if (this.isStickyHeaderEnabled) {
|
|
183
185
|
this.unsubscribe();
|
|
184
186
|
this.overflowObserver && this.overflowObserver.disconnect();
|
|
187
|
+
this.overflowObserverEntries = undefined;
|
|
185
188
|
this.stickyStateObserver && this.stickyStateObserver.disconnect();
|
|
186
189
|
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
187
190
|
var tree = (0, _dom2.getTree)(this.dom);
|
|
@@ -225,12 +228,51 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
225
228
|
}, {
|
|
226
229
|
key: "subscribe",
|
|
227
230
|
value: function subscribe() {
|
|
231
|
+
var _this2 = this;
|
|
228
232
|
// Ignored via go/ees005
|
|
229
233
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
230
234
|
this.editorScrollableElement = (0, _ui.findOverflowScrollParent)(this.view.dom) || window;
|
|
231
235
|
if (this.editorScrollableElement) {
|
|
232
236
|
this.initObservers();
|
|
233
237
|
this.topPosEditorElement = (0, _dom2.getTop)(this.editorScrollableElement);
|
|
238
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_3')) {
|
|
239
|
+
this.scrollListener = function () {
|
|
240
|
+
if (!_this2.hasScrolledSinceLoad) {
|
|
241
|
+
_this2.hasScrolledSinceLoad = true;
|
|
242
|
+
// Re-check intersection state now that scrolling has occurred
|
|
243
|
+
if (_this2.overflowObserver) {
|
|
244
|
+
var _this2$overflowObserv;
|
|
245
|
+
var entries = (_this2$overflowObserv = _this2.overflowObserverEntries) !== null && _this2$overflowObserv !== void 0 ? _this2$overflowObserv : _this2.overflowObserver.takeRecords();
|
|
246
|
+
_this2.overflowObserverEntries = undefined;
|
|
247
|
+
|
|
248
|
+
/** NOTE: This logic is duplicated in the overflowObserver callback
|
|
249
|
+
* to avoid conflicting with a follow up refactor where this will
|
|
250
|
+
* be cleaned up.
|
|
251
|
+
*/
|
|
252
|
+
entries.forEach(function (entry) {
|
|
253
|
+
var tableWrapper = _this2.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
|
|
254
|
+
if (tableWrapper && tableWrapper instanceof HTMLElement) {
|
|
255
|
+
if (entry.isIntersecting) {
|
|
256
|
+
tableWrapper.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
257
|
+
_this2.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
|
|
258
|
+
_this2.isNativeSticky = true;
|
|
259
|
+
} else {
|
|
260
|
+
tableWrapper.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
261
|
+
_this2.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
262
|
+
_this2.isNativeSticky = false;
|
|
263
|
+
}
|
|
264
|
+
_this2.refreshLegacyStickyState();
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
271
|
+
this.editorScrollableElement.addEventListener('scroll', this.scrollListener, {
|
|
272
|
+
passive: true,
|
|
273
|
+
once: true
|
|
274
|
+
});
|
|
275
|
+
}
|
|
234
276
|
}
|
|
235
277
|
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
236
278
|
|
|
@@ -269,6 +311,11 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
269
311
|
if (this.resizeObserver) {
|
|
270
312
|
this.resizeObserver.disconnect();
|
|
271
313
|
}
|
|
314
|
+
if (this.scrollListener && this.editorScrollableElement) {
|
|
315
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
316
|
+
this.editorScrollableElement.removeEventListener('scroll', this.scrollListener);
|
|
317
|
+
this.scrollListener = undefined;
|
|
318
|
+
}
|
|
272
319
|
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
273
320
|
// Ignored via go/ees005
|
|
274
321
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -285,7 +332,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
285
332
|
}, {
|
|
286
333
|
key: "initOverflowObserver",
|
|
287
334
|
value: function initOverflowObserver() {
|
|
288
|
-
var
|
|
335
|
+
var _this3 = this;
|
|
289
336
|
var tableWrapper = this.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
|
|
290
337
|
if (!tableWrapper) {
|
|
291
338
|
return;
|
|
@@ -299,16 +346,21 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
299
346
|
if (!(observer.root instanceof HTMLElement)) {
|
|
300
347
|
return;
|
|
301
348
|
}
|
|
349
|
+
// Only apply classes if page has scrolled since load
|
|
350
|
+
if (!_this3.hasScrolledSinceLoad && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_3')) {
|
|
351
|
+
_this3.overflowObserverEntries = entries;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
302
354
|
if (entry.isIntersecting) {
|
|
303
355
|
observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
304
|
-
|
|
305
|
-
|
|
356
|
+
_this3.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
|
|
357
|
+
_this3.isNativeSticky = true;
|
|
306
358
|
} else {
|
|
307
359
|
observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
308
|
-
|
|
309
|
-
|
|
360
|
+
_this3.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
361
|
+
_this3.isNativeSticky = false;
|
|
310
362
|
}
|
|
311
|
-
|
|
363
|
+
_this3.refreshLegacyStickyState();
|
|
312
364
|
});
|
|
313
365
|
}, options);
|
|
314
366
|
}
|
|
@@ -321,7 +373,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
321
373
|
}, {
|
|
322
374
|
key: "initStickyStateObserver",
|
|
323
375
|
value: function initStickyStateObserver() {
|
|
324
|
-
var
|
|
376
|
+
var _this4 = this;
|
|
325
377
|
if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
|
|
326
378
|
return;
|
|
327
379
|
}
|
|
@@ -333,14 +385,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
333
385
|
this.stickyStateObserver = new IntersectionObserver(function (entries) {
|
|
334
386
|
entries.forEach(function (entry) {
|
|
335
387
|
var _entry$rootBounds;
|
|
336
|
-
var tableContainer =
|
|
388
|
+
var tableContainer = _this4.dom.closest(".".concat(_types.TableCssClassName.TABLE_CONTAINER));
|
|
337
389
|
if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top)) {
|
|
338
|
-
|
|
390
|
+
_this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
|
|
339
391
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
340
392
|
tableContainer.dataset.tableHeaderIsStuck = 'true';
|
|
341
393
|
}
|
|
342
394
|
} else {
|
|
343
|
-
|
|
395
|
+
_this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
|
|
344
396
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
345
397
|
tableContainer.dataset.tableHeaderIsStuck = 'false';
|
|
346
398
|
}
|
|
@@ -353,7 +405,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
353
405
|
}, {
|
|
354
406
|
key: "initObservers",
|
|
355
407
|
value: function initObservers() {
|
|
356
|
-
var
|
|
408
|
+
var _this5 = this;
|
|
357
409
|
if (!this.dom || this.dom.dataset.isObserved) {
|
|
358
410
|
return;
|
|
359
411
|
}
|
|
@@ -387,7 +439,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
387
439
|
window.requestAnimationFrame(function () {
|
|
388
440
|
var getTableContainer = function getTableContainer() {
|
|
389
441
|
var _getTree;
|
|
390
|
-
return (_getTree = (0, _dom2.getTree)(
|
|
442
|
+
return (_getTree = (0, _dom2.getTree)(_this5.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
|
|
391
443
|
};
|
|
392
444
|
|
|
393
445
|
// we expect tree to be defined after animation frame
|
|
@@ -413,16 +465,16 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
413
465
|
return getSentinelTop() !== null && getSentinelBottom() !== null;
|
|
414
466
|
};
|
|
415
467
|
var observeStickySentinels = function observeStickySentinels() {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
[
|
|
468
|
+
_this5.sentinels.top = getSentinelTop();
|
|
469
|
+
_this5.sentinels.bottom = getSentinelBottom();
|
|
470
|
+
[_this5.sentinels.top, _this5.sentinels.bottom].forEach(function (el) {
|
|
419
471
|
// skip if already observed for another row on this table
|
|
420
472
|
if (el && !el.dataset.isObserved) {
|
|
421
473
|
el.dataset.isObserved = 'true';
|
|
422
474
|
|
|
423
475
|
// Ignored via go/ees005
|
|
424
476
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
425
|
-
|
|
477
|
+
_this5.intersectionObserver.observe(el);
|
|
426
478
|
}
|
|
427
479
|
});
|
|
428
480
|
};
|
|
@@ -437,7 +489,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
437
489
|
// observe sentinels before they are in the DOM, use MutationObserver
|
|
438
490
|
// to wait for sentinels to be added to the parent Table node DOM
|
|
439
491
|
// then attach the IntersectionObserver
|
|
440
|
-
|
|
492
|
+
_this5.tableContainerObserver = new MutationObserver(function () {
|
|
441
493
|
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
442
494
|
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
443
495
|
|
|
@@ -445,14 +497,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
445
497
|
tableContainer = getTableContainer();
|
|
446
498
|
}
|
|
447
499
|
if (sentinelsInDom()) {
|
|
448
|
-
var
|
|
500
|
+
var _this5$tableContainer;
|
|
449
501
|
observeStickySentinels();
|
|
450
|
-
(
|
|
502
|
+
(_this5$tableContainer = _this5.tableContainerObserver) === null || _this5$tableContainer === void 0 || _this5$tableContainer.disconnect();
|
|
451
503
|
}
|
|
452
504
|
});
|
|
453
505
|
var mutatingNode = tableContainer;
|
|
454
|
-
if (mutatingNode &&
|
|
455
|
-
|
|
506
|
+
if (mutatingNode && _this5.tableContainerObserver) {
|
|
507
|
+
_this5.tableContainerObserver.observe(mutatingNode, {
|
|
456
508
|
subtree: true,
|
|
457
509
|
childList: true
|
|
458
510
|
});
|
|
@@ -467,32 +519,32 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
467
519
|
}, {
|
|
468
520
|
key: "createResizeObserver",
|
|
469
521
|
value: function createResizeObserver() {
|
|
470
|
-
var
|
|
522
|
+
var _this6 = this;
|
|
471
523
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
472
|
-
var tree = (0, _dom2.getTree)(
|
|
524
|
+
var tree = (0, _dom2.getTree)(_this6.dom);
|
|
473
525
|
if (!tree) {
|
|
474
526
|
return;
|
|
475
527
|
}
|
|
476
528
|
var table = tree.table;
|
|
477
529
|
entries.forEach(function (entry) {
|
|
478
|
-
var
|
|
530
|
+
var _this6$editorScrollab;
|
|
479
531
|
// On resize of the parent scroll element we need to adjust the width
|
|
480
532
|
// of the sticky header
|
|
481
533
|
// Ignored via go/ees005
|
|
482
534
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
483
|
-
if (entry.target.className === ((
|
|
484
|
-
|
|
535
|
+
if (entry.target.className === ((_this6$editorScrollab = _this6.editorScrollableElement) === null || _this6$editorScrollab === void 0 ? void 0 : _this6$editorScrollab.className)) {
|
|
536
|
+
_this6.updateStickyHeaderWidth();
|
|
485
537
|
} else {
|
|
486
538
|
var newHeight = entry.contentRect ? entry.contentRect.height :
|
|
487
539
|
// Ignored via go/ees005
|
|
488
540
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
489
541
|
entry.target.offsetHeight;
|
|
490
|
-
if (
|
|
542
|
+
if (_this6.sentinels.bottom &&
|
|
491
543
|
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
492
544
|
// So we adding this check to allow a 1px difference.
|
|
493
|
-
Math.abs(newHeight - (
|
|
494
|
-
|
|
495
|
-
|
|
545
|
+
Math.abs(newHeight - (_this6.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
|
|
546
|
+
_this6.stickyRowHeight = newHeight;
|
|
547
|
+
_this6.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
|
|
496
548
|
(0, _dom.updateStickyMargins)(table);
|
|
497
549
|
}
|
|
498
550
|
}
|
|
@@ -502,13 +554,13 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
502
554
|
}, {
|
|
503
555
|
key: "createIntersectionObserver",
|
|
504
556
|
value: function createIntersectionObserver() {
|
|
505
|
-
var
|
|
557
|
+
var _this7 = this;
|
|
506
558
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
507
|
-
var
|
|
559
|
+
var _this7$editorScrollab, _this7$editorScrollab2;
|
|
508
560
|
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
509
561
|
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
510
562
|
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
511
|
-
var rootBounds = (
|
|
563
|
+
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);
|
|
512
564
|
entries.forEach(function (entry) {
|
|
513
565
|
var target = entry.target,
|
|
514
566
|
isIntersecting = entry.isIntersecting,
|
|
@@ -516,15 +568,15 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
516
568
|
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
517
569
|
var targetKey = target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
518
570
|
// Cache the latest sentinel information
|
|
519
|
-
|
|
571
|
+
_this7.sentinelData[targetKey] = {
|
|
520
572
|
isIntersecting: isIntersecting,
|
|
521
573
|
boundingClientRect: boundingClientRect,
|
|
522
574
|
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
523
575
|
};
|
|
524
576
|
// Keep the other sentinels rootBounds in sync with this latest one
|
|
525
|
-
|
|
577
|
+
_this7.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
526
578
|
});
|
|
527
|
-
|
|
579
|
+
_this7.refreshLegacyStickyState();
|
|
528
580
|
}, {
|
|
529
581
|
threshold: 0,
|
|
530
582
|
root: this.editorScrollableElement
|
|
@@ -699,12 +751,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
699
751
|
}, {
|
|
700
752
|
key: "refireIntersectionObservers",
|
|
701
753
|
value: function refireIntersectionObservers() {
|
|
702
|
-
var
|
|
754
|
+
var _this8 = this;
|
|
703
755
|
if (this.isLegacySticky) {
|
|
704
756
|
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
705
|
-
if (el &&
|
|
706
|
-
|
|
707
|
-
|
|
757
|
+
if (el && _this8.intersectionObserver) {
|
|
758
|
+
_this8.intersectionObserver.unobserve(el);
|
|
759
|
+
_this8.intersectionObserver.observe(el);
|
|
708
760
|
}
|
|
709
761
|
});
|
|
710
762
|
}
|
|
@@ -713,7 +765,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
713
765
|
key: "makeHeaderRowLegacySticky",
|
|
714
766
|
value: function makeHeaderRowLegacySticky(tree, scrollTop) {
|
|
715
767
|
var _tbody$firstChild,
|
|
716
|
-
|
|
768
|
+
_this9 = this;
|
|
717
769
|
// If header row height is more than 50% of viewport height don't do this
|
|
718
770
|
if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
|
|
719
771
|
return;
|
|
@@ -752,7 +804,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
752
804
|
});
|
|
753
805
|
var fastScrollThresholdMs = 500;
|
|
754
806
|
setTimeout(function () {
|
|
755
|
-
|
|
807
|
+
_this9.refireIntersectionObservers();
|
|
756
808
|
}, fastScrollThresholdMs);
|
|
757
809
|
}
|
|
758
810
|
this.dom.style.top = "0px";
|
|
@@ -6,6 +6,7 @@ import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
|
6
6
|
import { tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
7
7
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
8
8
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
11
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
11
12
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -60,6 +61,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
60
61
|
_defineProperty(this, "padding", 0);
|
|
61
62
|
_defineProperty(this, "top", 0);
|
|
62
63
|
_defineProperty(this, "isNativeSticky", false);
|
|
64
|
+
_defineProperty(this, "hasScrolledSinceLoad", false);
|
|
63
65
|
/**
|
|
64
66
|
* Methods
|
|
65
67
|
*/
|
|
@@ -160,6 +162,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
160
162
|
if (this.isStickyHeaderEnabled) {
|
|
161
163
|
this.unsubscribe();
|
|
162
164
|
this.overflowObserver && this.overflowObserver.disconnect();
|
|
165
|
+
this.overflowObserverEntries = undefined;
|
|
163
166
|
this.stickyStateObserver && this.stickyStateObserver.disconnect();
|
|
164
167
|
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
165
168
|
const tree = getTree(this.dom);
|
|
@@ -205,6 +208,44 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
205
208
|
if (this.editorScrollableElement) {
|
|
206
209
|
this.initObservers();
|
|
207
210
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
211
|
+
if (fg('platform_editor_table_sticky_header_patch_3')) {
|
|
212
|
+
this.scrollListener = () => {
|
|
213
|
+
if (!this.hasScrolledSinceLoad) {
|
|
214
|
+
this.hasScrolledSinceLoad = true;
|
|
215
|
+
// Re-check intersection state now that scrolling has occurred
|
|
216
|
+
if (this.overflowObserver) {
|
|
217
|
+
var _this$overflowObserve;
|
|
218
|
+
const entries = (_this$overflowObserve = this.overflowObserverEntries) !== null && _this$overflowObserve !== void 0 ? _this$overflowObserve : this.overflowObserver.takeRecords();
|
|
219
|
+
this.overflowObserverEntries = undefined;
|
|
220
|
+
|
|
221
|
+
/** NOTE: This logic is duplicated in the overflowObserver callback
|
|
222
|
+
* to avoid conflicting with a follow up refactor where this will
|
|
223
|
+
* be cleaned up.
|
|
224
|
+
*/
|
|
225
|
+
entries.forEach(entry => {
|
|
226
|
+
const tableWrapper = this.dom.closest(`.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
227
|
+
if (tableWrapper && tableWrapper instanceof HTMLElement) {
|
|
228
|
+
if (entry.isIntersecting) {
|
|
229
|
+
tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
230
|
+
this.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
231
|
+
this.isNativeSticky = true;
|
|
232
|
+
} else {
|
|
233
|
+
tableWrapper.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
234
|
+
this.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
235
|
+
this.isNativeSticky = false;
|
|
236
|
+
}
|
|
237
|
+
this.refreshLegacyStickyState();
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
244
|
+
this.editorScrollableElement.addEventListener('scroll', this.scrollListener, {
|
|
245
|
+
passive: true,
|
|
246
|
+
once: true
|
|
247
|
+
});
|
|
248
|
+
}
|
|
208
249
|
}
|
|
209
250
|
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
210
251
|
|
|
@@ -241,6 +282,11 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
241
282
|
if (this.resizeObserver) {
|
|
242
283
|
this.resizeObserver.disconnect();
|
|
243
284
|
}
|
|
285
|
+
if (this.scrollListener && this.editorScrollableElement) {
|
|
286
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
287
|
+
this.editorScrollableElement.removeEventListener('scroll', this.scrollListener);
|
|
288
|
+
this.scrollListener = undefined;
|
|
289
|
+
}
|
|
244
290
|
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
245
291
|
// Ignored via go/ees005
|
|
246
292
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -268,6 +314,11 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
268
314
|
if (!(observer.root instanceof HTMLElement)) {
|
|
269
315
|
return;
|
|
270
316
|
}
|
|
317
|
+
// Only apply classes if page has scrolled since load
|
|
318
|
+
if (!this.hasScrolledSinceLoad && fg('platform_editor_table_sticky_header_patch_3')) {
|
|
319
|
+
this.overflowObserverEntries = entries;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
271
322
|
if (entry.isIntersecting) {
|
|
272
323
|
observer.root.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
273
324
|
this.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
@@ -335,8 +386,8 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
335
386
|
this.initOverflowObserver();
|
|
336
387
|
const closestTable = this.dom.closest('table');
|
|
337
388
|
if (closestTable) {
|
|
338
|
-
var _this$
|
|
339
|
-
(_this$
|
|
389
|
+
var _this$overflowObserve2;
|
|
390
|
+
(_this$overflowObserve2 = this.overflowObserver) === null || _this$overflowObserve2 === void 0 ? void 0 : _this$overflowObserve2.observe(closestTable);
|
|
340
391
|
}
|
|
341
392
|
this.initStickyStateObserver();
|
|
342
393
|
(_this$stickyStateObse = this.stickyStateObserver) === null || _this$stickyStateObse === void 0 ? void 0 : _this$stickyStateObse.observe(this.dom);
|
|
@@ -13,6 +13,7 @@ import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
|
13
13
|
import { tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
14
14
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
15
15
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
18
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
18
19
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -69,6 +70,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
69
70
|
_defineProperty(_this, "padding", 0);
|
|
70
71
|
_defineProperty(_this, "top", 0);
|
|
71
72
|
_defineProperty(_this, "isNativeSticky", false);
|
|
73
|
+
_defineProperty(_this, "hasScrolledSinceLoad", false);
|
|
72
74
|
/**
|
|
73
75
|
* Methods
|
|
74
76
|
*/
|
|
@@ -175,6 +177,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
175
177
|
if (this.isStickyHeaderEnabled) {
|
|
176
178
|
this.unsubscribe();
|
|
177
179
|
this.overflowObserver && this.overflowObserver.disconnect();
|
|
180
|
+
this.overflowObserverEntries = undefined;
|
|
178
181
|
this.stickyStateObserver && this.stickyStateObserver.disconnect();
|
|
179
182
|
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
180
183
|
var tree = getTree(this.dom);
|
|
@@ -218,12 +221,51 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
218
221
|
}, {
|
|
219
222
|
key: "subscribe",
|
|
220
223
|
value: function subscribe() {
|
|
224
|
+
var _this2 = this;
|
|
221
225
|
// Ignored via go/ees005
|
|
222
226
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
223
227
|
this.editorScrollableElement = findOverflowScrollParent(this.view.dom) || window;
|
|
224
228
|
if (this.editorScrollableElement) {
|
|
225
229
|
this.initObservers();
|
|
226
230
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
231
|
+
if (fg('platform_editor_table_sticky_header_patch_3')) {
|
|
232
|
+
this.scrollListener = function () {
|
|
233
|
+
if (!_this2.hasScrolledSinceLoad) {
|
|
234
|
+
_this2.hasScrolledSinceLoad = true;
|
|
235
|
+
// Re-check intersection state now that scrolling has occurred
|
|
236
|
+
if (_this2.overflowObserver) {
|
|
237
|
+
var _this2$overflowObserv;
|
|
238
|
+
var entries = (_this2$overflowObserv = _this2.overflowObserverEntries) !== null && _this2$overflowObserv !== void 0 ? _this2$overflowObserv : _this2.overflowObserver.takeRecords();
|
|
239
|
+
_this2.overflowObserverEntries = undefined;
|
|
240
|
+
|
|
241
|
+
/** NOTE: This logic is duplicated in the overflowObserver callback
|
|
242
|
+
* to avoid conflicting with a follow up refactor where this will
|
|
243
|
+
* be cleaned up.
|
|
244
|
+
*/
|
|
245
|
+
entries.forEach(function (entry) {
|
|
246
|
+
var tableWrapper = _this2.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
247
|
+
if (tableWrapper && tableWrapper instanceof HTMLElement) {
|
|
248
|
+
if (entry.isIntersecting) {
|
|
249
|
+
tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
250
|
+
_this2.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
251
|
+
_this2.isNativeSticky = true;
|
|
252
|
+
} else {
|
|
253
|
+
tableWrapper.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
254
|
+
_this2.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
255
|
+
_this2.isNativeSticky = false;
|
|
256
|
+
}
|
|
257
|
+
_this2.refreshLegacyStickyState();
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
264
|
+
this.editorScrollableElement.addEventListener('scroll', this.scrollListener, {
|
|
265
|
+
passive: true,
|
|
266
|
+
once: true
|
|
267
|
+
});
|
|
268
|
+
}
|
|
227
269
|
}
|
|
228
270
|
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
229
271
|
|
|
@@ -262,6 +304,11 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
262
304
|
if (this.resizeObserver) {
|
|
263
305
|
this.resizeObserver.disconnect();
|
|
264
306
|
}
|
|
307
|
+
if (this.scrollListener && this.editorScrollableElement) {
|
|
308
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
309
|
+
this.editorScrollableElement.removeEventListener('scroll', this.scrollListener);
|
|
310
|
+
this.scrollListener = undefined;
|
|
311
|
+
}
|
|
265
312
|
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
266
313
|
// Ignored via go/ees005
|
|
267
314
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -278,7 +325,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
278
325
|
}, {
|
|
279
326
|
key: "initOverflowObserver",
|
|
280
327
|
value: function initOverflowObserver() {
|
|
281
|
-
var
|
|
328
|
+
var _this3 = this;
|
|
282
329
|
var tableWrapper = this.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
283
330
|
if (!tableWrapper) {
|
|
284
331
|
return;
|
|
@@ -292,16 +339,21 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
292
339
|
if (!(observer.root instanceof HTMLElement)) {
|
|
293
340
|
return;
|
|
294
341
|
}
|
|
342
|
+
// Only apply classes if page has scrolled since load
|
|
343
|
+
if (!_this3.hasScrolledSinceLoad && fg('platform_editor_table_sticky_header_patch_3')) {
|
|
344
|
+
_this3.overflowObserverEntries = entries;
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
295
347
|
if (entry.isIntersecting) {
|
|
296
348
|
observer.root.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
297
|
-
|
|
298
|
-
|
|
349
|
+
_this3.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
350
|
+
_this3.isNativeSticky = true;
|
|
299
351
|
} else {
|
|
300
352
|
observer.root.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
301
|
-
|
|
302
|
-
|
|
353
|
+
_this3.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
354
|
+
_this3.isNativeSticky = false;
|
|
303
355
|
}
|
|
304
|
-
|
|
356
|
+
_this3.refreshLegacyStickyState();
|
|
305
357
|
});
|
|
306
358
|
}, options);
|
|
307
359
|
}
|
|
@@ -314,7 +366,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
314
366
|
}, {
|
|
315
367
|
key: "initStickyStateObserver",
|
|
316
368
|
value: function initStickyStateObserver() {
|
|
317
|
-
var
|
|
369
|
+
var _this4 = this;
|
|
318
370
|
if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
|
|
319
371
|
return;
|
|
320
372
|
}
|
|
@@ -326,14 +378,14 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
326
378
|
this.stickyStateObserver = new IntersectionObserver(function (entries) {
|
|
327
379
|
entries.forEach(function (entry) {
|
|
328
380
|
var _entry$rootBounds;
|
|
329
|
-
var tableContainer =
|
|
381
|
+
var tableContainer = _this4.dom.closest(".".concat(ClassName.TABLE_CONTAINER));
|
|
330
382
|
if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top)) {
|
|
331
|
-
|
|
383
|
+
_this4.dom.classList.add(ClassName.NATIVE_STICKY_ACTIVE);
|
|
332
384
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
333
385
|
tableContainer.dataset.tableHeaderIsStuck = 'true';
|
|
334
386
|
}
|
|
335
387
|
} else {
|
|
336
|
-
|
|
388
|
+
_this4.dom.classList.remove(ClassName.NATIVE_STICKY_ACTIVE);
|
|
337
389
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
338
390
|
tableContainer.dataset.tableHeaderIsStuck = 'false';
|
|
339
391
|
}
|
|
@@ -346,7 +398,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
346
398
|
}, {
|
|
347
399
|
key: "initObservers",
|
|
348
400
|
value: function initObservers() {
|
|
349
|
-
var
|
|
401
|
+
var _this5 = this;
|
|
350
402
|
if (!this.dom || this.dom.dataset.isObserved) {
|
|
351
403
|
return;
|
|
352
404
|
}
|
|
@@ -380,7 +432,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
380
432
|
window.requestAnimationFrame(function () {
|
|
381
433
|
var getTableContainer = function getTableContainer() {
|
|
382
434
|
var _getTree;
|
|
383
|
-
return (_getTree = getTree(
|
|
435
|
+
return (_getTree = getTree(_this5.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
|
|
384
436
|
};
|
|
385
437
|
|
|
386
438
|
// we expect tree to be defined after animation frame
|
|
@@ -406,16 +458,16 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
406
458
|
return getSentinelTop() !== null && getSentinelBottom() !== null;
|
|
407
459
|
};
|
|
408
460
|
var observeStickySentinels = function observeStickySentinels() {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
[
|
|
461
|
+
_this5.sentinels.top = getSentinelTop();
|
|
462
|
+
_this5.sentinels.bottom = getSentinelBottom();
|
|
463
|
+
[_this5.sentinels.top, _this5.sentinels.bottom].forEach(function (el) {
|
|
412
464
|
// skip if already observed for another row on this table
|
|
413
465
|
if (el && !el.dataset.isObserved) {
|
|
414
466
|
el.dataset.isObserved = 'true';
|
|
415
467
|
|
|
416
468
|
// Ignored via go/ees005
|
|
417
469
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
418
|
-
|
|
470
|
+
_this5.intersectionObserver.observe(el);
|
|
419
471
|
}
|
|
420
472
|
});
|
|
421
473
|
};
|
|
@@ -430,7 +482,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
430
482
|
// observe sentinels before they are in the DOM, use MutationObserver
|
|
431
483
|
// to wait for sentinels to be added to the parent Table node DOM
|
|
432
484
|
// then attach the IntersectionObserver
|
|
433
|
-
|
|
485
|
+
_this5.tableContainerObserver = new MutationObserver(function () {
|
|
434
486
|
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
435
487
|
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
436
488
|
|
|
@@ -438,14 +490,14 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
438
490
|
tableContainer = getTableContainer();
|
|
439
491
|
}
|
|
440
492
|
if (sentinelsInDom()) {
|
|
441
|
-
var
|
|
493
|
+
var _this5$tableContainer;
|
|
442
494
|
observeStickySentinels();
|
|
443
|
-
(
|
|
495
|
+
(_this5$tableContainer = _this5.tableContainerObserver) === null || _this5$tableContainer === void 0 || _this5$tableContainer.disconnect();
|
|
444
496
|
}
|
|
445
497
|
});
|
|
446
498
|
var mutatingNode = tableContainer;
|
|
447
|
-
if (mutatingNode &&
|
|
448
|
-
|
|
499
|
+
if (mutatingNode && _this5.tableContainerObserver) {
|
|
500
|
+
_this5.tableContainerObserver.observe(mutatingNode, {
|
|
449
501
|
subtree: true,
|
|
450
502
|
childList: true
|
|
451
503
|
});
|
|
@@ -460,32 +512,32 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
460
512
|
}, {
|
|
461
513
|
key: "createResizeObserver",
|
|
462
514
|
value: function createResizeObserver() {
|
|
463
|
-
var
|
|
515
|
+
var _this6 = this;
|
|
464
516
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
465
|
-
var tree = getTree(
|
|
517
|
+
var tree = getTree(_this6.dom);
|
|
466
518
|
if (!tree) {
|
|
467
519
|
return;
|
|
468
520
|
}
|
|
469
521
|
var table = tree.table;
|
|
470
522
|
entries.forEach(function (entry) {
|
|
471
|
-
var
|
|
523
|
+
var _this6$editorScrollab;
|
|
472
524
|
// On resize of the parent scroll element we need to adjust the width
|
|
473
525
|
// of the sticky header
|
|
474
526
|
// Ignored via go/ees005
|
|
475
527
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
476
|
-
if (entry.target.className === ((
|
|
477
|
-
|
|
528
|
+
if (entry.target.className === ((_this6$editorScrollab = _this6.editorScrollableElement) === null || _this6$editorScrollab === void 0 ? void 0 : _this6$editorScrollab.className)) {
|
|
529
|
+
_this6.updateStickyHeaderWidth();
|
|
478
530
|
} else {
|
|
479
531
|
var newHeight = entry.contentRect ? entry.contentRect.height :
|
|
480
532
|
// Ignored via go/ees005
|
|
481
533
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
482
534
|
entry.target.offsetHeight;
|
|
483
|
-
if (
|
|
535
|
+
if (_this6.sentinels.bottom &&
|
|
484
536
|
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
485
537
|
// So we adding this check to allow a 1px difference.
|
|
486
|
-
Math.abs(newHeight - (
|
|
487
|
-
|
|
488
|
-
|
|
538
|
+
Math.abs(newHeight - (_this6.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
|
|
539
|
+
_this6.stickyRowHeight = newHeight;
|
|
540
|
+
_this6.sentinels.bottom.style.bottom = "".concat(tableScrollbarOffset + stickyRowOffsetTop + newHeight, "px");
|
|
489
541
|
updateTableMargin(table);
|
|
490
542
|
}
|
|
491
543
|
}
|
|
@@ -495,13 +547,13 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
495
547
|
}, {
|
|
496
548
|
key: "createIntersectionObserver",
|
|
497
549
|
value: function createIntersectionObserver() {
|
|
498
|
-
var
|
|
550
|
+
var _this7 = this;
|
|
499
551
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
500
|
-
var
|
|
552
|
+
var _this7$editorScrollab, _this7$editorScrollab2;
|
|
501
553
|
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
502
554
|
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
503
555
|
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
504
|
-
var rootBounds = (
|
|
556
|
+
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);
|
|
505
557
|
entries.forEach(function (entry) {
|
|
506
558
|
var target = entry.target,
|
|
507
559
|
isIntersecting = entry.isIntersecting,
|
|
@@ -509,15 +561,15 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
509
561
|
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
510
562
|
var targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
511
563
|
// Cache the latest sentinel information
|
|
512
|
-
|
|
564
|
+
_this7.sentinelData[targetKey] = {
|
|
513
565
|
isIntersecting: isIntersecting,
|
|
514
566
|
boundingClientRect: boundingClientRect,
|
|
515
567
|
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
516
568
|
};
|
|
517
569
|
// Keep the other sentinels rootBounds in sync with this latest one
|
|
518
|
-
|
|
570
|
+
_this7.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
519
571
|
});
|
|
520
|
-
|
|
572
|
+
_this7.refreshLegacyStickyState();
|
|
521
573
|
}, {
|
|
522
574
|
threshold: 0,
|
|
523
575
|
root: this.editorScrollableElement
|
|
@@ -692,12 +744,12 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
692
744
|
}, {
|
|
693
745
|
key: "refireIntersectionObservers",
|
|
694
746
|
value: function refireIntersectionObservers() {
|
|
695
|
-
var
|
|
747
|
+
var _this8 = this;
|
|
696
748
|
if (this.isLegacySticky) {
|
|
697
749
|
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
698
|
-
if (el &&
|
|
699
|
-
|
|
700
|
-
|
|
750
|
+
if (el && _this8.intersectionObserver) {
|
|
751
|
+
_this8.intersectionObserver.unobserve(el);
|
|
752
|
+
_this8.intersectionObserver.observe(el);
|
|
701
753
|
}
|
|
702
754
|
});
|
|
703
755
|
}
|
|
@@ -706,7 +758,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
706
758
|
key: "makeHeaderRowLegacySticky",
|
|
707
759
|
value: function makeHeaderRowLegacySticky(tree, scrollTop) {
|
|
708
760
|
var _tbody$firstChild,
|
|
709
|
-
|
|
761
|
+
_this9 = this;
|
|
710
762
|
// If header row height is more than 50% of viewport height don't do this
|
|
711
763
|
if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
|
|
712
764
|
return;
|
|
@@ -745,7 +797,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_ref) {
|
|
|
745
797
|
});
|
|
746
798
|
var fastScrollThresholdMs = 500;
|
|
747
799
|
setTimeout(function () {
|
|
748
|
-
|
|
800
|
+
_this9.refireIntersectionObservers();
|
|
749
801
|
}, fastScrollThresholdMs);
|
|
750
802
|
}
|
|
751
803
|
this.dom.style.top = "0px";
|
|
@@ -32,6 +32,9 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView<HTML
|
|
|
32
32
|
private overflowObserver?;
|
|
33
33
|
private stickyStateObserver?;
|
|
34
34
|
private isNativeSticky;
|
|
35
|
+
private hasScrolledSinceLoad;
|
|
36
|
+
private scrollListener?;
|
|
37
|
+
private overflowObserverEntries?;
|
|
35
38
|
/**
|
|
36
39
|
* Methods: Nodeview Lifecycle
|
|
37
40
|
*/
|
|
@@ -32,6 +32,9 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView<HTML
|
|
|
32
32
|
private overflowObserver?;
|
|
33
33
|
private stickyStateObserver?;
|
|
34
34
|
private isNativeSticky;
|
|
35
|
+
private hasScrolledSinceLoad;
|
|
36
|
+
private scrollListener?;
|
|
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.3",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -37,9 +37,9 @@
|
|
|
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.2.
|
|
40
|
+
"@atlaskit/editor-plugin-extension": "9.2.15",
|
|
41
41
|
"@atlaskit/editor-plugin-guideline": "^6.0.0",
|
|
42
|
-
"@atlaskit/editor-plugin-interaction": "^
|
|
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
45
|
"@atlaskit/editor-plugin-toolbar": "^3.4.0",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
56
56
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
57
57
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
58
|
-
"@atlaskit/primitives": "^
|
|
58
|
+
"@atlaskit/primitives": "^17.0.0",
|
|
59
59
|
"@atlaskit/theme": "^21.0.0",
|
|
60
60
|
"@atlaskit/tmp-editor-statsig": "^16.0.0",
|
|
61
61
|
"@atlaskit/toggle": "^15.2.0",
|
|
62
|
-
"@atlaskit/tokens": "^
|
|
62
|
+
"@atlaskit/tokens": "^9.0.0",
|
|
63
63
|
"@atlaskit/tooltip": "^20.11.0",
|
|
64
64
|
"@babel/runtime": "^7.0.0",
|
|
65
65
|
"@emotion/react": "^11.7.1",
|
|
@@ -157,6 +157,9 @@
|
|
|
157
157
|
},
|
|
158
158
|
"platform_editor_change_table_nesting_check": {
|
|
159
159
|
"type": "boolean"
|
|
160
|
+
},
|
|
161
|
+
"platform_editor_table_sticky_header_patch_3": {
|
|
162
|
+
"type": "boolean"
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
}
|