@atlaskit/editor-plugin-table 15.6.6 → 15.6.7

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 15.6.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`fe7b3f29093a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fe7b3f29093a6) -
8
+ [ux] EDITOR-2990 Disable native sticky header for tables with headers greater than 50% viewport
9
+ height
10
+ - [`b4a854535b851`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b4a854535b851) -
11
+ [ux] EDITOR-2625 Add missing left border when table controls are showing and header is sticking in
12
+ table with numbered columns
13
+ - Updated dependencies
14
+
3
15
  ## 15.6.6
4
16
 
5
17
  ### Patch Changes
@@ -20,6 +20,7 @@ var _ui = require("@atlaskit/editor-common/ui");
20
20
  var _utils = require("@atlaskit/editor-prosemirror/utils");
21
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
22
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
+ var _editorContentAreaHeight = require("../pm-plugins/editor-content-area-height");
23
24
  var _pluginFactory = require("../pm-plugins/plugin-factory");
24
25
  var _pluginKey = require("../pm-plugins/plugin-key");
25
26
  var _commands = require("../pm-plugins/sticky-headers/commands");
@@ -44,6 +45,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
44
45
  (0, _classCallCheck2.default)(this, TableRowNativeStickyWithFallback);
45
46
  _this = _callSuper(this, TableRowNativeStickyWithFallback, [node, view, getPos, eventDispatcher]);
46
47
  (0, _defineProperty2.default)(_this, "cleanup", function () {
48
+ var _this$onEditorContent, _this2;
47
49
  if (_this.isStickyHeaderEnabled) {
48
50
  _this.unsubscribe();
49
51
  _this.nodeVisibilityObserverCleanupFn && _this.nodeVisibilityObserverCleanupFn();
@@ -56,6 +58,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
56
58
  if (_this.tableContainerObserver) {
57
59
  _this.tableContainerObserver.disconnect();
58
60
  }
61
+ (_this$onEditorContent = (_this2 = _this).onEditorContentAreaHeightChange) === null || _this$onEditorContent === void 0 || _this$onEditorContent.call(_this2);
59
62
  });
60
63
  (0, _defineProperty2.default)(_this, "colControlsOffset", 0);
61
64
  (0, _defineProperty2.default)(_this, "focused", false);
@@ -76,7 +79,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
76
79
  (0, _defineProperty2.default)(_this, "listening", false);
77
80
  (0, _defineProperty2.default)(_this, "padding", 0);
78
81
  (0, _defineProperty2.default)(_this, "top", 0);
79
- (0, _defineProperty2.default)(_this, "isNativeSticky", false);
82
+ (0, _defineProperty2.default)(_this, "disableNativeSticky", false);
80
83
  /**
81
84
  * Methods
82
85
  */
@@ -92,6 +95,17 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
92
95
  _this.headerRowMouseScrollEnd();
93
96
  }
94
97
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
98
+ (0, _defineProperty2.default)(_this, "toggleDisableNativeSticky", function (headerHeight, viewportHeight) {
99
+ if (!_this.disableNativeSticky && headerHeight > viewportHeight * 0.5) {
100
+ _this.disableNativeSticky = true;
101
+ if (_this.isNativeSticky === undefined) {
102
+ _this.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
103
+ }
104
+ }
105
+ if (_this.disableNativeSticky && headerHeight <= viewportHeight * 0.5) {
106
+ _this.disableNativeSticky = false;
107
+ }
108
+ });
95
109
  _this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node);
96
110
  _this.isLegacySticky = false;
97
111
  var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
@@ -118,6 +132,17 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
118
132
  }
119
133
  });
120
134
  }
135
+ if (_this.isHeaderRow && _this.isStickyHeaderEnabled && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
136
+ var _api$table;
137
+ _this.onEditorContentAreaHeightChange = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.onChange(function (_ref2) {
138
+ var nextSharedState = _ref2.nextSharedState;
139
+ if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.editorContentAreaHeight && (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.editorContentAreaHeight) !== _this.editorContentAreaHeight) {
140
+ var _this$stickyRowHeight;
141
+ _this.editorContentAreaHeight = nextSharedState.editorContentAreaHeight;
142
+ _this.toggleDisableNativeSticky((_this$stickyRowHeight = _this.stickyRowHeight) !== null && _this$stickyRowHeight !== void 0 ? _this$stickyRowHeight : 0, nextSharedState.editorContentAreaHeight);
143
+ }
144
+ });
145
+ }
121
146
  return _this;
122
147
  }
123
148
  (0, _inherits2.default)(TableRowNativeStickyWithFallback, _ref);
@@ -181,10 +206,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
181
206
  key: "destroy",
182
207
  value: function destroy() {
183
208
  if (this.isStickyHeaderEnabled) {
209
+ var _this$nodeVisibilityO;
184
210
  this.unsubscribe();
185
211
  this.overflowObserver && this.overflowObserver.disconnect();
186
212
  this.overflowObserverEntries = undefined;
187
213
  this.stickyStateObserver && this.stickyStateObserver.disconnect();
214
+ (_this$nodeVisibilityO = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO === void 0 || _this$nodeVisibilityO.disconnect();
188
215
  this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
189
216
  var tree = (0, _dom2.getTree)(this.dom);
190
217
  if (tree) {
@@ -227,7 +254,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
227
254
  }, {
228
255
  key: "subscribe",
229
256
  value: function subscribe() {
230
- var _this2 = this;
257
+ var _this3 = this;
231
258
  // Ignored via go/ees005
232
259
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
233
260
  this.editorScrollableElement = (0, _ui.findOverflowScrollParent)(this.view.dom) || window;
@@ -240,33 +267,33 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
240
267
  return;
241
268
  }
242
269
  TableRowNativeStickyWithFallback.hasScrolledSinceLoad = true;
243
- if (!_this2.overflowObserver) {
270
+ if (!_this3.overflowObserver) {
244
271
  return;
245
272
  }
246
273
 
247
274
  // 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;
275
+ if (_this3.overflowObserver) {
276
+ var _this3$overflowObserv;
277
+ var entries = (_this3$overflowObserv = _this3.overflowObserverEntries) !== null && _this3$overflowObserv !== void 0 ? _this3$overflowObserv : _this3.overflowObserver.takeRecords();
278
+ _this3.overflowObserverEntries = undefined;
252
279
 
253
280
  /** NOTE: This logic is duplicated in the overflowObserver callback
254
281
  * to avoid conflicting with a follow up refactor where this will
255
282
  * be cleaned up.
256
283
  */
257
284
  entries.forEach(function (entry) {
258
- var tableWrapper = _this2.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
285
+ var tableWrapper = _this3.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
259
286
  if (tableWrapper && tableWrapper instanceof HTMLElement) {
260
287
  if (entry.isIntersecting) {
261
288
  tableWrapper.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
262
- _this2.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
263
- _this2.isNativeSticky = true;
289
+ _this3.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
290
+ _this3.isNativeSticky = true;
264
291
  } else {
265
292
  tableWrapper.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
266
- _this2.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
267
- _this2.isNativeSticky = false;
293
+ _this3.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
294
+ _this3.isNativeSticky = false;
268
295
  }
269
- _this2.refreshLegacyStickyState();
296
+ _this3.refreshLegacyStickyState();
270
297
  }
271
298
  });
272
299
  }
@@ -336,7 +363,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
336
363
  }, {
337
364
  key: "initOverflowObserver",
338
365
  value: function initOverflowObserver() {
339
- var _this3 = this;
366
+ var _this4 = this;
340
367
  var tableWrapper = this.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
341
368
  if (!tableWrapper) {
342
369
  return;
@@ -352,19 +379,31 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
352
379
  }
353
380
  // Only apply classes if page has scrolled since load
354
381
  if (!TableRowNativeStickyWithFallback.hasScrolledSinceLoad && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_5')) {
355
- _this3.overflowObserverEntries = entries;
382
+ _this4.overflowObserverEntries = entries;
356
383
  return;
357
384
  }
358
385
  if (entry.isIntersecting) {
359
- observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
360
- _this3.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
361
- _this3.isNativeSticky = true;
386
+ if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
387
+ observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
388
+ if (!_this4.disableNativeSticky) {
389
+ _this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
390
+ }
391
+ } else {
392
+ observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
393
+ _this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
394
+ }
395
+ _this4.isNativeSticky = true;
362
396
  } else {
363
- observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
364
- _this3.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
365
- _this3.isNativeSticky = false;
397
+ if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
398
+ observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
399
+ _this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
400
+ } else {
401
+ observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
402
+ _this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
403
+ }
404
+ _this4.isNativeSticky = false;
366
405
  }
367
- _this3.refreshLegacyStickyState();
406
+ _this4.refreshLegacyStickyState();
368
407
  });
369
408
  }, options);
370
409
  }
@@ -377,7 +416,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
377
416
  }, {
378
417
  key: "initStickyStateObserver",
379
418
  value: function initStickyStateObserver() {
380
- var _this4 = this;
419
+ var _this5 = this;
381
420
  if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
382
421
  return;
383
422
  }
@@ -389,14 +428,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
389
428
  this.stickyStateObserver = new IntersectionObserver(function (entries) {
390
429
  entries.forEach(function (entry) {
391
430
  var _entry$rootBounds;
392
- var tableContainer = _this4.dom.closest(".".concat(_types.TableCssClassName.TABLE_CONTAINER));
393
- if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top)) {
394
- _this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
431
+ var tableContainer = _this5.dom.closest(".".concat(_types.TableCssClassName.TABLE_CONTAINER));
432
+ if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top) && (!_this5.disableNativeSticky || !(0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4'))) {
433
+ _this5.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
395
434
  if (tableContainer && tableContainer instanceof HTMLElement) {
396
435
  tableContainer.dataset.tableHeaderIsStuck = 'true';
397
436
  }
398
437
  } else {
399
- _this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
438
+ _this5.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
400
439
  if (tableContainer && tableContainer instanceof HTMLElement) {
401
440
  if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_3')) {
402
441
  delete tableContainer.dataset.tableHeaderIsStuck;
@@ -413,7 +452,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
413
452
  }, {
414
453
  key: "initObservers",
415
454
  value: function initObservers() {
416
- var _this5 = this;
455
+ var _this6 = this;
417
456
  if (!this.dom || this.dom.dataset.isObserved) {
418
457
  return;
419
458
  }
@@ -430,10 +469,17 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
430
469
  this.dom.style.setProperty('anchor-name', (_this$dom$getAttribut = this.dom.getAttribute('data-node-anchor')) !== null && _this$dom$getAttribut !== void 0 ? _this$dom$getAttribut : '');
431
470
  }
432
471
  this.initOverflowObserver();
472
+ if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
473
+ this.initNodeVisibilityObserver();
474
+ }
433
475
  var closestTable = this.dom.closest('table');
434
476
  if (closestTable) {
435
477
  var _this$overflowObserve;
436
478
  (_this$overflowObserve = this.overflowObserver) === null || _this$overflowObserve === void 0 || _this$overflowObserve.observe(closestTable);
479
+ if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
480
+ var _this$nodeVisibilityO2;
481
+ (_this$nodeVisibilityO2 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO2 === void 0 || _this$nodeVisibilityO2.observe(closestTable);
482
+ }
437
483
  }
438
484
  this.initStickyStateObserver();
439
485
  (_this$stickyStateObse = this.stickyStateObserver) === null || _this$stickyStateObse === void 0 || _this$stickyStateObse.observe(this.dom);
@@ -447,7 +493,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
447
493
  window.requestAnimationFrame(function () {
448
494
  var getTableContainer = function getTableContainer() {
449
495
  var _getTree;
450
- return (_getTree = (0, _dom2.getTree)(_this5.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
496
+ return (_getTree = (0, _dom2.getTree)(_this6.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
451
497
  };
452
498
 
453
499
  // we expect tree to be defined after animation frame
@@ -473,16 +519,16 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
473
519
  return getSentinelTop() !== null && getSentinelBottom() !== null;
474
520
  };
475
521
  var observeStickySentinels = function observeStickySentinels() {
476
- _this5.sentinels.top = getSentinelTop();
477
- _this5.sentinels.bottom = getSentinelBottom();
478
- [_this5.sentinels.top, _this5.sentinels.bottom].forEach(function (el) {
522
+ _this6.sentinels.top = getSentinelTop();
523
+ _this6.sentinels.bottom = getSentinelBottom();
524
+ [_this6.sentinels.top, _this6.sentinels.bottom].forEach(function (el) {
479
525
  // skip if already observed for another row on this table
480
526
  if (el && !el.dataset.isObserved) {
481
527
  el.dataset.isObserved = 'true';
482
528
 
483
529
  // Ignored via go/ees005
484
530
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
485
- _this5.intersectionObserver.observe(el);
531
+ _this6.intersectionObserver.observe(el);
486
532
  }
487
533
  });
488
534
  };
@@ -497,7 +543,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
497
543
  // observe sentinels before they are in the DOM, use MutationObserver
498
544
  // to wait for sentinels to be added to the parent Table node DOM
499
545
  // then attach the IntersectionObserver
500
- _this5.tableContainerObserver = new MutationObserver(function () {
546
+ _this6.tableContainerObserver = new MutationObserver(function () {
501
547
  // Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
502
548
  // prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
503
549
 
@@ -505,14 +551,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
505
551
  tableContainer = getTableContainer();
506
552
  }
507
553
  if (sentinelsInDom()) {
508
- var _this5$tableContainer;
554
+ var _this6$tableContainer;
509
555
  observeStickySentinels();
510
- (_this5$tableContainer = _this5.tableContainerObserver) === null || _this5$tableContainer === void 0 || _this5$tableContainer.disconnect();
556
+ (_this6$tableContainer = _this6.tableContainerObserver) === null || _this6$tableContainer === void 0 || _this6$tableContainer.disconnect();
511
557
  }
512
558
  });
513
559
  var mutatingNode = tableContainer;
514
- if (mutatingNode && _this5.tableContainerObserver) {
515
- _this5.tableContainerObserver.observe(mutatingNode, {
560
+ if (mutatingNode && _this6.tableContainerObserver) {
561
+ _this6.tableContainerObserver.observe(mutatingNode, {
516
562
  subtree: true,
517
563
  childList: true
518
564
  });
@@ -522,39 +568,69 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
522
568
  });
523
569
  }
524
570
 
571
+ // initialise intersection observer to track whether table is in scroll area
572
+ }, {
573
+ key: "initNodeVisibilityObserver",
574
+ value: function initNodeVisibilityObserver() {
575
+ var _this7 = this;
576
+ this.nodeVisibilityObserver = new IntersectionObserver(function (entries) {
577
+ entries.forEach(function (entry) {
578
+ if (!_this7.isNativeSticky) {
579
+ return;
580
+ }
581
+ if (entry.intersectionRatio !== 0 && entry.intersectionRatio !== 1) {
582
+ return;
583
+ }
584
+ if (_this7.disableNativeSticky === true) {
585
+ _this7.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
586
+ }
587
+ if (_this7.disableNativeSticky === false) {
588
+ _this7.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
589
+ }
590
+ });
591
+ }, {
592
+ threshold: [0, 0.05, 0.95, 1]
593
+ });
594
+ }
595
+
525
596
  // updating bottom sentinel position if sticky header height changes
526
597
  // to allocate for new header height
527
598
  }, {
528
599
  key: "createResizeObserver",
529
600
  value: function createResizeObserver() {
530
- var _this6 = this;
601
+ var _this8 = this;
531
602
  this.resizeObserver = new ResizeObserver(function (entries) {
532
- var tree = (0, _dom2.getTree)(_this6.dom);
603
+ var tree = (0, _dom2.getTree)(_this8.dom);
533
604
  if (!tree) {
534
605
  return;
535
606
  }
536
607
  var table = tree.table;
537
608
  entries.forEach(function (entry) {
538
- var _this6$editorScrollab;
609
+ var _this8$editorScrollab;
539
610
  // On resize of the parent scroll element we need to adjust the width
540
611
  // of the sticky header
541
612
  // Ignored via go/ees005
542
613
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
543
- if (entry.target.className === ((_this6$editorScrollab = _this6.editorScrollableElement) === null || _this6$editorScrollab === void 0 ? void 0 : _this6$editorScrollab.className)) {
544
- _this6.updateStickyHeaderWidth();
614
+ if (entry.target.className === ((_this8$editorScrollab = _this8.editorScrollableElement) === null || _this8$editorScrollab === void 0 ? void 0 : _this8$editorScrollab.className)) {
615
+ _this8.updateStickyHeaderWidth();
545
616
  } else {
546
617
  var newHeight = entry.contentRect ? entry.contentRect.height :
547
618
  // Ignored via go/ees005
548
619
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
549
620
  entry.target.offsetHeight;
550
- if (_this6.sentinels.bottom &&
621
+ if (_this8.sentinels.bottom &&
551
622
  // When the table header is sticky, it would be taller by a 1px (border-bottom),
552
623
  // So we adding this check to allow a 1px difference.
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");
624
+ Math.abs(newHeight - (_this8.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
625
+ _this8.stickyRowHeight = newHeight;
626
+ _this8.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
556
627
  (0, _dom.updateStickyMargins)(table);
557
628
  }
629
+ if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
630
+ var _this8$editorContentA;
631
+ var viewportHeight = (_this8$editorContentA = _this8.editorContentAreaHeight) !== null && _this8$editorContentA !== void 0 ? _this8$editorContentA : _editorContentAreaHeight.INITIAL_STATIC_VIEWPORT_HEIGHT;
632
+ _this8.toggleDisableNativeSticky(newHeight, viewportHeight);
633
+ }
558
634
  }
559
635
  });
560
636
  });
@@ -562,13 +638,13 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
562
638
  }, {
563
639
  key: "createIntersectionObserver",
564
640
  value: function createIntersectionObserver() {
565
- var _this7 = this;
641
+ var _this9 = this;
566
642
  this.intersectionObserver = new IntersectionObserver(function (entries, _) {
567
- var _this7$editorScrollab, _this7$editorScrollab2;
643
+ var _this9$editorScrollab, _this9$editorScrollab2;
568
644
  // IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
569
645
  // 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
570
646
  // This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
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);
647
+ var rootBounds = (_this9$editorScrollab = _this9.editorScrollableElement) === null || _this9$editorScrollab === void 0 || (_this9$editorScrollab2 = _this9$editorScrollab.getBoundingClientRect) === null || _this9$editorScrollab2 === void 0 ? void 0 : _this9$editorScrollab2.call(_this9$editorScrollab);
572
648
  entries.forEach(function (entry) {
573
649
  var target = entry.target,
574
650
  isIntersecting = entry.isIntersecting,
@@ -576,15 +652,15 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
576
652
  // This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
577
653
  var targetKey = target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
578
654
  // Cache the latest sentinel information
579
- _this7.sentinelData[targetKey] = {
655
+ _this9.sentinelData[targetKey] = {
580
656
  isIntersecting: isIntersecting,
581
657
  boundingClientRect: boundingClientRect,
582
658
  rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
583
659
  };
584
660
  // Keep the other sentinels rootBounds in sync with this latest one
585
- _this7.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
661
+ _this9.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
586
662
  });
587
- _this7.refreshLegacyStickyState();
663
+ _this9.refreshLegacyStickyState();
588
664
  }, {
589
665
  threshold: 0,
590
666
  root: this.editorScrollableElement
@@ -643,27 +719,27 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
643
719
  value: function isHeaderSticky() {
644
720
  var _sentinelTop$rootBoun;
645
721
  /*
646
- # Overview
647
- I'm going to list all the view states associated with the sentinels and when they should trigger sticky headers.
648
- The format of the states are; {top|bottom}:{in|above|below}
649
- ie sentinel:view-position -- both "above" and "below" are equal to out of the viewport
650
- For example; "top:in" means top sentinel is within the viewport. "bottom:above" means the bottom sentinel is
651
- above and out of the viewport
652
- This will hopefully simplify things and make it easier to determine when sticky should/shouldn't be triggered.
653
- # States
654
- top:in / bottom:in - NOT sticky
655
- top:in / bottom:above - NOT sticky - NOTE: This is an inversion clause
656
- top:in / bottom:below - NOT sticky
657
- top:above / bottom:in - STICKY
658
- top:above / bottom:above - NOT sticky
659
- top:above / bottom:below - STICKY
660
- top:below / bottom:in - NOT sticky - NOTE: This is an inversion clause
661
- top:below / bottom:above - NOT sticky - NOTE: This is an inversion clause
662
- top:below / bottom:below - NOT sticky
663
- # Summary
664
- The only time the header should be sticky is when the top sentinel is above the view and the bottom sentinel
665
- is in or below it.
666
- */
722
+ # Overview
723
+ I'm going to list all the view states associated with the sentinels and when they should trigger sticky headers.
724
+ The format of the states are; {top|bottom}:{in|above|below}
725
+ ie sentinel:view-position -- both "above" and "below" are equal to out of the viewport
726
+ For example; "top:in" means top sentinel is within the viewport. "bottom:above" means the bottom sentinel is
727
+ above and out of the viewport
728
+ This will hopefully simplify things and make it easier to determine when sticky should/shouldn't be triggered.
729
+ # States
730
+ top:in / bottom:in - NOT sticky
731
+ top:in / bottom:above - NOT sticky - NOTE: This is an inversion clause
732
+ top:in / bottom:below - NOT sticky
733
+ top:above / bottom:in - STICKY
734
+ top:above / bottom:above - NOT sticky
735
+ top:above / bottom:below - STICKY
736
+ top:below / bottom:in - NOT sticky - NOTE: This is an inversion clause
737
+ top:below / bottom:above - NOT sticky - NOTE: This is an inversion clause
738
+ top:below / bottom:below - NOT sticky
739
+ # Summary
740
+ The only time the header should be sticky is when the top sentinel is above the view and the bottom sentinel
741
+ is in or below it.
742
+ */
667
743
 
668
744
  var _this$sentinelData = this.sentinelData,
669
745
  sentinelTop = _this$sentinelData.top,
@@ -759,12 +835,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
759
835
  }, {
760
836
  key: "refireIntersectionObservers",
761
837
  value: function refireIntersectionObservers() {
762
- var _this8 = this;
838
+ var _this0 = this;
763
839
  if (this.isLegacySticky) {
764
840
  [this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
765
- if (el && _this8.intersectionObserver) {
766
- _this8.intersectionObserver.unobserve(el);
767
- _this8.intersectionObserver.observe(el);
841
+ if (el && _this0.intersectionObserver) {
842
+ _this0.intersectionObserver.unobserve(el);
843
+ _this0.intersectionObserver.observe(el);
768
844
  }
769
845
  });
770
846
  }
@@ -773,7 +849,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
773
849
  key: "makeHeaderRowLegacySticky",
774
850
  value: function makeHeaderRowLegacySticky(tree, scrollTop) {
775
851
  var _tbody$firstChild,
776
- _this9 = this;
852
+ _this1 = this;
777
853
  // If header row height is more than 50% of viewport height don't do this
778
854
  if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
779
855
  return;
@@ -812,7 +888,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
812
888
  });
813
889
  var fastScrollThresholdMs = 500;
814
890
  setTimeout(function () {
815
- _this9.refireIntersectionObservers();
891
+ _this1.refireIntersectionObservers();
816
892
  }, fastScrollThresholdMs);
817
893
  }
818
894
  this.dom.style.top = "0px";
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.pluginKey = exports.createPlugin = exports.INITIAL_STATIC_VIEWPORT_HEIGHT = exports.EDITOR_CONTENT_AREA_REGION_CLASSNAME = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
+ var _state = require("@atlaskit/editor-prosemirror/state");
11
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ var pluginKey = exports.pluginKey = new _state.PluginKey('editorContentAreaHeightPlugin');
17
+ var INITIAL_STATIC_VIEWPORT_HEIGHT = exports.INITIAL_STATIC_VIEWPORT_HEIGHT = 1200;
18
+ var EDITOR_CONTENT_AREA_REGION_CLASSNAME = exports.EDITOR_CONTENT_AREA_REGION_CLASSNAME = '.ak-editor-content-area-region';
19
+ var createPlugin = exports.createPlugin = function createPlugin() {
20
+ return new _safePlugin.SafePlugin({
21
+ key: pluginKey,
22
+ state: {
23
+ init: function init() {
24
+ return {
25
+ height: INITIAL_STATIC_VIEWPORT_HEIGHT
26
+ };
27
+ },
28
+ apply: function apply(tr, pluginState) {
29
+ var meta = tr.getMeta(pluginKey);
30
+ if (meta) {
31
+ return _objectSpread(_objectSpread({}, pluginState), meta);
32
+ }
33
+ return pluginState;
34
+ }
35
+ },
36
+ view: function view(_view) {
37
+ var editorContentAreaEl = _view.dom.closest(EDITOR_CONTENT_AREA_REGION_CLASSNAME);
38
+ var resizeObserver;
39
+ if (editorContentAreaEl) {
40
+ resizeObserver = new ResizeObserver(function (entries) {
41
+ var _iterator = _createForOfIteratorHelper(entries),
42
+ _step;
43
+ try {
44
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
45
+ var entry = _step.value;
46
+ var height = entry.contentRect.height;
47
+ var tr = _view.state.tr.setMeta(pluginKey, {
48
+ height: height,
49
+ isObserved: true
50
+ });
51
+ _view.dispatch(tr);
52
+ }
53
+ } catch (err) {
54
+ _iterator.e(err);
55
+ } finally {
56
+ _iterator.f();
57
+ }
58
+ });
59
+ resizeObserver.observe(editorContentAreaEl);
60
+ }
61
+ return {
62
+ destroy: function destroy() {
63
+ var _resizeObserver;
64
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 || _resizeObserver.disconnect();
65
+ }
66
+ };
67
+ }
68
+ });
69
+ };
@@ -30,6 +30,7 @@ var _createPluginConfig = require("./pm-plugins/create-plugin-config");
30
30
  var _plugin2 = require("./pm-plugins/decorations/plugin");
31
31
  var _plugin3 = require("./pm-plugins/drag-and-drop/plugin");
32
32
  var _pluginKey = require("./pm-plugins/drag-and-drop/plugin-key");
33
+ var _editorContentAreaHeight = require("./pm-plugins/editor-content-area-height");
33
34
  var _keymap = require("./pm-plugins/keymap");
34
35
  var _main = require("./pm-plugins/main");
35
36
  var _pluginKey2 = require("./pm-plugins/plugin-key");
@@ -103,6 +104,7 @@ var tablePlugin = function tablePlugin(_ref) {
103
104
  var stickyHeader = stickyHeadersState ? (0, _util.findStickyHeaderForTable)(stickyHeadersState, tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.tablePos) : undefined;
104
105
  var dragAndDropState = _pluginKey.pluginKey.getState(editorState);
105
106
  var sizeSelectorPluginState = _tableSizeSelector.pluginKey.getState(editorState);
107
+ var editorContentAreaHeightPluginState = _editorContentAreaHeight.pluginKey.getState(editorState);
106
108
  var sharedStateInternal = {
107
109
  isFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.fullWidthEnabled),
108
110
  wasFullWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasFullWidthEnabled),
@@ -140,7 +142,8 @@ var tablePlugin = function tablePlugin(_ref) {
140
142
  dragMenuIndex: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
141
143
  isDragMenuOpen: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.isDragMenuOpen,
142
144
  isSizeSelectorOpen: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.isSelectorOpen,
143
- sizeSelectorTargetRef: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.targetRef
145
+ sizeSelectorTargetRef: sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.targetRef,
146
+ editorContentAreaHeight: (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4') ? editorContentAreaHeightPluginState === null || editorContentAreaHeightPluginState === void 0 ? void 0 : editorContentAreaHeightPluginState.height : undefined
144
147
  };
145
148
  return sharedStateInternal;
146
149
  },
@@ -363,8 +366,7 @@ var tablePlugin = function tablePlugin(_ref) {
363
366
  }, {
364
367
  name: 'tableStickyHeaders',
365
368
  plugin: function plugin(_ref1) {
366
- var dispatch = _ref1.dispatch,
367
- eventDispatcher = _ref1.eventDispatcher;
369
+ var dispatch = _ref1.dispatch;
368
370
  return options && options.tableOptions.stickyHeaders ? (0, _plugin4.createPlugin)(dispatch, function () {
369
371
  return [];
370
372
  }) : undefined;
@@ -482,8 +484,13 @@ var tablePlugin = function tablePlugin(_ref) {
482
484
  var dispatch = _ref18.dispatch;
483
485
  return isTableSelectorEnabled ? (0, _tableSizeSelector.createPlugin)(dispatch) : undefined;
484
486
  }
487
+ }, {
488
+ name: 'editorContentAreaHeightPlugin',
489
+ plugin: function plugin() {
490
+ return (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_1') ? (0, _editorContentAreaHeight.createPlugin)() : undefined;
491
+ }
485
492
  }];
486
- if (!(0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_1')) {
493
+ if (!(0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_2')) {
487
494
  plugins.push({
488
495
  name: 'tableAnchorNames',
489
496
  plugin: function plugin() {