@atlaskit/editor-plugin-table 29.0.0 → 29.1.0

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.
@@ -19,6 +19,7 @@ var _nodeVisibility = require("@atlaskit/editor-common/node-visibility");
19
19
  var _styles = require("@atlaskit/editor-common/styles");
20
20
  var _ui = require("@atlaskit/editor-common/ui");
21
21
  var _utils = require("@atlaskit/editor-prosemirror/utils");
22
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
22
23
  var _fg = require("@atlaskit/platform-feature-flags/fg");
23
24
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
24
25
  var _editorContentAreaHeight = require("../pm-plugins/editor-content-area-height");
@@ -41,7 +42,6 @@ var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
41
42
  var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
42
43
  var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (_TableNodeView) {
43
44
  function TableRowNativeStickyWithFallback(node, view, getPos, eventDispatcher, api) {
44
- var _api$limitedMode;
45
45
  var _this;
46
46
  (0, _classCallCheck2.default)(this, TableRowNativeStickyWithFallback);
47
47
  _this = _callSuper(this, TableRowNativeStickyWithFallback, [node, view, getPos, eventDispatcher]);
@@ -119,10 +119,38 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
119
119
  pluginConfig = _getPluginState.pluginConfig;
120
120
  _this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
121
121
  _this.api = api;
122
- if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode !== void 0 && _api$limitedMode.documentSizeBreachesThreshold) {
123
- _this.isStickyHeaderEnabled = false;
124
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
125
- document.addEventListener('limited-mode-activated', _this.cleanup);
122
+
123
+ // Sticky headers are the only thing limited mode turns off here, so there is nothing to read
124
+ // or subscribe to when they were never enabled for this editor.
125
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_dynamic_limited_mode')) {
126
+ var _api$limitedMode, _limitedMode$currentS;
127
+ var limitedMode = _this.isStickyHeaderEnabled ? api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.sharedState : undefined;
128
+ if (limitedMode !== null && limitedMode !== void 0 && (_limitedMode$currentS = limitedMode.currentState()) !== null && _limitedMode$currentS !== void 0 && _limitedMode$currentS.enabled) {
129
+ _this.isStickyHeaderEnabled = false;
130
+ } else {
131
+ _this.limitedModeUnsubscribe = limitedMode === null || limitedMode === void 0 ? void 0 : limitedMode.onChange(function (_ref) {
132
+ var _this$limitedModeUnsu, _this3;
133
+ var nextSharedState = _ref.nextSharedState;
134
+ if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.enabled)) {
135
+ return;
136
+ }
137
+
138
+ // Order matters: cleanup() short-circuits unless sticky headers are still marked enabled.
139
+ _this.cleanup();
140
+ _this.isStickyHeaderEnabled = false;
141
+
142
+ // Limited mode never turns back off, so this listener has done its job.
143
+ (_this$limitedModeUnsu = (_this3 = _this).limitedModeUnsubscribe) === null || _this$limitedModeUnsu === void 0 || _this$limitedModeUnsu.call(_this3);
144
+ _this.limitedModeUnsubscribe = undefined;
145
+ });
146
+ }
147
+ } else {
148
+ var _api$limitedMode2;
149
+ if (api !== null && api !== void 0 && (_api$limitedMode2 = api.limitedMode) !== null && _api$limitedMode2 !== void 0 && (_api$limitedMode2 = _api$limitedMode2.sharedState.currentState()) !== null && _api$limitedMode2 !== void 0 && (_api$limitedMode2 = _api$limitedMode2.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode2 !== void 0 && _api$limitedMode2.documentSizeBreachesThreshold) {
150
+ _this.isStickyHeaderEnabled = false;
151
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
152
+ document.addEventListener('limited-mode-activated', _this.cleanup);
153
+ }
126
154
  }
127
155
  var pos = _this.getPos();
128
156
  _this.isInNestedTable = false;
@@ -156,8 +184,8 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
156
184
  }
157
185
  if (_this.isHeaderRow && _this.isStickyHeaderEnabled) {
158
186
  var _api$table;
159
- _this.onEditorContentAreaHeightChange = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.onChange(function (_ref) {
160
- var nextSharedState = _ref.nextSharedState;
187
+ _this.onEditorContentAreaHeightChange = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.onChange(function (_ref2) {
188
+ var nextSharedState = _ref2.nextSharedState;
161
189
  if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.editorContentAreaHeight && (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.editorContentAreaHeight) !== _this.editorContentAreaHeight) {
162
190
  var _this$stickyRowHeight;
163
191
  _this.editorContentAreaHeight = nextSharedState.editorContentAreaHeight;
@@ -246,9 +274,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
246
274
  }
247
275
  this.emitOff(true);
248
276
  }
249
-
250
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
251
- document.removeEventListener('limited-mode-activated', this.cleanup);
277
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_dynamic_limited_mode')) {
278
+ var _this$limitedModeUnsu2;
279
+ (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 || _this$limitedModeUnsu2.call(this);
280
+ this.limitedModeUnsubscribe = undefined;
281
+ } else {
282
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
283
+ document.removeEventListener('limited-mode-activated', this.cleanup);
284
+ }
252
285
  if (this.tableContainerObserver) {
253
286
  this.tableContainerObserver.disconnect();
254
287
  }
@@ -281,7 +314,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
281
314
  }, {
282
315
  key: "subscribe",
283
316
  value: function subscribe() {
284
- var _this3 = this;
317
+ var _this4 = this;
285
318
  // Ignored via go/ees005
286
319
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
287
320
  this.editorScrollableElement = (0, _ui.findOverflowScrollParent)(this.view.dom) || window;
@@ -289,39 +322,39 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
289
322
  this.initObservers();
290
323
  this.topPosEditorElement = (0, _dom2.getTop)(this.editorScrollableElement);
291
324
  this.scrollListener = function () {
292
- var _this3$overflowObserv;
293
- if (_this3.hasScrolledSinceLoad) {
325
+ var _this4$overflowObserv;
326
+ if (_this4.hasScrolledSinceLoad) {
294
327
  return;
295
328
  }
296
- _this3.hasScrolledSinceLoad = true;
297
- if (!_this3.overflowObserver) {
329
+ _this4.hasScrolledSinceLoad = true;
330
+ if (!_this4.overflowObserver) {
298
331
  return;
299
332
  }
300
333
 
301
334
  // Re-check intersection state now that scrolling has occurred
302
- var entries = (_this3$overflowObserv = _this3.overflowObserverEntries) !== null && _this3$overflowObserv !== void 0 ? _this3$overflowObserv : _this3.overflowObserver.takeRecords();
303
- _this3.overflowObserverEntries = undefined;
335
+ var entries = (_this4$overflowObserv = _this4.overflowObserverEntries) !== null && _this4$overflowObserv !== void 0 ? _this4$overflowObserv : _this4.overflowObserver.takeRecords();
336
+ _this4.overflowObserverEntries = undefined;
304
337
 
305
338
  /** NOTE: This logic is duplicated in the overflowObserver callback
306
339
  * to avoid conflicting with a follow up refactor where this will
307
340
  * be cleaned up.
308
341
  */
309
342
  entries.forEach(function (entry) {
310
- if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this3.updateSingleRowTableStickyHeaderState()) {
343
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this4.updateSingleRowTableStickyHeaderState()) {
311
344
  return;
312
345
  }
313
- var tableWrapper = _this3.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
346
+ var tableWrapper = _this4.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
314
347
  if (tableWrapper && tableWrapper instanceof HTMLElement && !(0, _dom2.areAllRectsZero)(entry)) {
315
348
  if (entry.isIntersecting) {
316
349
  tableWrapper.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
317
- _this3.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
318
- _this3.isNativeSticky = true;
350
+ _this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
351
+ _this4.isNativeSticky = true;
319
352
  } else {
320
353
  tableWrapper.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
321
- _this3.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
322
- _this3.isNativeSticky = false;
354
+ _this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
355
+ _this4.isNativeSticky = false;
323
356
  }
324
- _this3.refreshLegacyStickyState();
357
+ _this4.refreshLegacyStickyState();
325
358
  }
326
359
  });
327
360
  };
@@ -389,7 +422,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
389
422
  }, {
390
423
  key: "initOverflowObserver",
391
424
  value: function initOverflowObserver() {
392
- var _this4 = this;
425
+ var _this5 = this;
393
426
  var tableWrapper = this.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
394
427
  if (!tableWrapper) {
395
428
  return;
@@ -400,31 +433,31 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
400
433
  };
401
434
  this.overflowObserver = new IntersectionObserver(function (entries, observer) {
402
435
  entries.forEach(function (entry) {
403
- var _this4$api;
436
+ var _this5$api;
404
437
  if (!(observer.root instanceof HTMLElement)) {
405
438
  return;
406
439
  }
407
- if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this4.updateSingleRowTableStickyHeaderState()) {
440
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this5.updateSingleRowTableStickyHeaderState()) {
408
441
  return;
409
442
  }
410
443
  // Only apply classes if page has scrolled since load
411
- if (!_this4.hasScrolledSinceLoad) {
412
- _this4.overflowObserverEntries = entries;
444
+ if (!_this5.hasScrolledSinceLoad) {
445
+ _this5.overflowObserverEntries = entries;
413
446
  return;
414
447
  }
415
448
  if (entry.isIntersecting) {
416
449
  observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
417
- if (!_this4.disableNativeSticky) {
418
- _this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
450
+ if (!_this5.disableNativeSticky) {
451
+ _this5.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
419
452
  }
420
- _this4.isNativeSticky = true;
453
+ _this5.isNativeSticky = true;
421
454
  } else {
422
455
  observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
423
- _this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
424
- _this4.isNativeSticky = false;
456
+ _this5.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
457
+ _this5.isNativeSticky = false;
425
458
  }
426
- _this4.refreshLegacyStickyState();
427
- (_this4$api = _this4.api) === null || _this4$api === void 0 || (_this4$api = _this4$api.analytics) === null || _this4$api === void 0 || (_this4$api = _this4$api.actions) === null || _this4$api === void 0 || _this4$api.fireAnalyticsEvent({
459
+ _this5.refreshLegacyStickyState();
460
+ (_this5$api = _this5.api) === null || _this5$api === void 0 || (_this5$api = _this5$api.analytics) === null || _this5$api === void 0 || (_this5$api = _this5$api.actions) === null || _this5$api === void 0 || _this5$api.fireAnalyticsEvent({
428
461
  action: _analytics.TABLE_ACTION.STICKY_HEADER_METHOD_TOGGLED,
429
462
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
430
463
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE_STICKY_HEADER,
@@ -445,7 +478,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
445
478
  }, {
446
479
  key: "initStickyStateObserver",
447
480
  value: function initStickyStateObserver() {
448
- var _this5 = this;
481
+ var _this6 = this;
449
482
  if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
450
483
  return;
451
484
  }
@@ -457,17 +490,17 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
457
490
  this.stickyStateObserver = new IntersectionObserver(function (entries) {
458
491
  entries.forEach(function (entry) {
459
492
  var _entry$rootBounds;
460
- if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this5.updateSingleRowTableStickyHeaderState()) {
493
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this6.updateSingleRowTableStickyHeaderState()) {
461
494
  return;
462
495
  }
463
- var tableContainer = _this5.dom.closest(".".concat(_types.TableCssClassName.TABLE_CONTAINER));
464
- if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top) && !_this5.disableNativeSticky) {
465
- _this5.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
496
+ var tableContainer = _this6.dom.closest(".".concat(_types.TableCssClassName.TABLE_CONTAINER));
497
+ if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top) && !_this6.disableNativeSticky) {
498
+ _this6.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
466
499
  if (tableContainer && tableContainer instanceof HTMLElement) {
467
500
  tableContainer.dataset.tableHeaderIsStuck = 'true';
468
501
  }
469
502
  } else {
470
- _this5.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
503
+ _this6.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
471
504
  if (tableContainer && tableContainer instanceof HTMLElement) {
472
505
  delete tableContainer.dataset.tableHeaderIsStuck;
473
506
  }
@@ -480,7 +513,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
480
513
  }, {
481
514
  key: "initObservers",
482
515
  value: function initObservers() {
483
- var _this6 = this;
516
+ var _this7 = this;
484
517
  if (!this.dom || this.dom.dataset.isObserved) {
485
518
  return;
486
519
  }
@@ -516,7 +549,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
516
549
  window.requestAnimationFrame(function () {
517
550
  var getTableContainer = function getTableContainer() {
518
551
  var _getTree;
519
- return (_getTree = (0, _dom2.getTree)(_this6.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
552
+ return (_getTree = (0, _dom2.getTree)(_this7.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
520
553
  };
521
554
 
522
555
  // we expect tree to be defined after animation frame
@@ -542,16 +575,16 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
542
575
  return getSentinelTop() !== null && getSentinelBottom() !== null;
543
576
  };
544
577
  var observeStickySentinels = function observeStickySentinels() {
545
- _this6.sentinels.top = getSentinelTop();
546
- _this6.sentinels.bottom = getSentinelBottom();
547
- [_this6.sentinels.top, _this6.sentinels.bottom].forEach(function (el) {
578
+ _this7.sentinels.top = getSentinelTop();
579
+ _this7.sentinels.bottom = getSentinelBottom();
580
+ [_this7.sentinels.top, _this7.sentinels.bottom].forEach(function (el) {
548
581
  // skip if already observed for another row on this table
549
582
  if (el && !el.dataset.isObserved) {
550
583
  el.dataset.isObserved = 'true';
551
584
 
552
585
  // Ignored via go/ees005
553
586
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
554
- _this6.intersectionObserver.observe(el);
587
+ _this7.intersectionObserver.observe(el);
555
588
  }
556
589
  });
557
590
  };
@@ -566,7 +599,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
566
599
  // observe sentinels before they are in the DOM, use MutationObserver
567
600
  // to wait for sentinels to be added to the parent Table node DOM
568
601
  // then attach the IntersectionObserver
569
- _this6.tableContainerObserver = new MutationObserver(function () {
602
+ _this7.tableContainerObserver = new MutationObserver(function () {
570
603
  // Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
571
604
  // prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
572
605
 
@@ -574,14 +607,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
574
607
  tableContainer = getTableContainer();
575
608
  }
576
609
  if (sentinelsInDom()) {
577
- var _this6$tableContainer;
610
+ var _this7$tableContainer;
578
611
  observeStickySentinels();
579
- (_this6$tableContainer = _this6.tableContainerObserver) === null || _this6$tableContainer === void 0 || _this6$tableContainer.disconnect();
612
+ (_this7$tableContainer = _this7.tableContainerObserver) === null || _this7$tableContainer === void 0 || _this7$tableContainer.disconnect();
580
613
  }
581
614
  });
582
615
  var mutatingNode = tableContainer;
583
- if (mutatingNode && _this6.tableContainerObserver) {
584
- _this6.tableContainerObserver.observe(mutatingNode, {
616
+ if (mutatingNode && _this7.tableContainerObserver) {
617
+ _this7.tableContainerObserver.observe(mutatingNode, {
585
618
  subtree: true,
586
619
  childList: true
587
620
  });
@@ -595,23 +628,23 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
595
628
  }, {
596
629
  key: "initNodeVisibilityObserver",
597
630
  value: function initNodeVisibilityObserver() {
598
- var _this7 = this;
631
+ var _this8 = this;
599
632
  this.nodeVisibilityObserver = new IntersectionObserver(function (entries) {
600
633
  entries.forEach(function (entry) {
601
- if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this7.updateSingleRowTableStickyHeaderState()) {
634
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this8.updateSingleRowTableStickyHeaderState()) {
602
635
  return;
603
636
  }
604
- if (!_this7.isNativeSticky) {
637
+ if (!_this8.isNativeSticky) {
605
638
  return;
606
639
  }
607
640
  if (entry.intersectionRatio !== 0 && entry.intersectionRatio !== 1) {
608
641
  return;
609
642
  }
610
- if (_this7.disableNativeSticky === true) {
611
- _this7.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
643
+ if (_this8.disableNativeSticky === true) {
644
+ _this8.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
612
645
  }
613
- if (_this7.disableNativeSticky === false) {
614
- _this7.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
646
+ if (_this8.disableNativeSticky === false) {
647
+ _this8.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
615
648
  }
616
649
  });
617
650
  }, {
@@ -624,37 +657,37 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
624
657
  }, {
625
658
  key: "createResizeObserver",
626
659
  value: function createResizeObserver() {
627
- var _this8 = this;
660
+ var _this9 = this;
628
661
  this.resizeObserver = new ResizeObserver(function (entries) {
629
- var tree = (0, _dom2.getTree)(_this8.dom);
662
+ var tree = (0, _dom2.getTree)(_this9.dom);
630
663
  if (!tree) {
631
664
  return;
632
665
  }
633
666
  var table = tree.table;
634
667
  entries.forEach(function (entry) {
635
- var _this8$editorScrollab;
668
+ var _this9$editorScrollab;
636
669
  // On resize of the parent scroll element we need to adjust the width
637
670
  // of the sticky header
638
671
  // Ignored via go/ees005
639
672
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
640
- if (entry.target.className === ((_this8$editorScrollab = _this8.editorScrollableElement) === null || _this8$editorScrollab === void 0 ? void 0 : _this8$editorScrollab.className)) {
641
- _this8.updateStickyHeaderWidth();
673
+ if (entry.target.className === ((_this9$editorScrollab = _this9.editorScrollableElement) === null || _this9$editorScrollab === void 0 ? void 0 : _this9$editorScrollab.className)) {
674
+ _this9.updateStickyHeaderWidth();
642
675
  } else {
643
- var _this8$editorContentA;
676
+ var _this9$editorContentA;
644
677
  var newHeight = entry.contentRect ? entry.contentRect.height :
645
678
  // Ignored via go/ees005
646
679
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
647
680
  entry.target.offsetHeight;
648
- if (_this8.sentinels.bottom &&
681
+ if (_this9.sentinels.bottom &&
649
682
  // When the table header is sticky, it would be taller by a 1px (border-bottom),
650
683
  // So we adding this check to allow a 1px difference.
651
- Math.abs(newHeight - (_this8.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
652
- _this8.stickyRowHeight = newHeight;
653
- _this8.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
684
+ Math.abs(newHeight - (_this9.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
685
+ _this9.stickyRowHeight = newHeight;
686
+ _this9.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
654
687
  (0, _dom.updateStickyMargins)(table);
655
688
  }
656
- var viewportHeight = (_this8$editorContentA = _this8.editorContentAreaHeight) !== null && _this8$editorContentA !== void 0 ? _this8$editorContentA : _editorContentAreaHeight.INITIAL_STATIC_VIEWPORT_HEIGHT;
657
- _this8.toggleDisableNativeSticky(newHeight, viewportHeight);
689
+ var viewportHeight = (_this9$editorContentA = _this9.editorContentAreaHeight) !== null && _this9$editorContentA !== void 0 ? _this9$editorContentA : _editorContentAreaHeight.INITIAL_STATIC_VIEWPORT_HEIGHT;
690
+ _this9.toggleDisableNativeSticky(newHeight, viewportHeight);
658
691
  }
659
692
  });
660
693
  });
@@ -662,13 +695,13 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
662
695
  }, {
663
696
  key: "createIntersectionObserver",
664
697
  value: function createIntersectionObserver() {
665
- var _this9 = this;
698
+ var _this0 = this;
666
699
  this.intersectionObserver = new IntersectionObserver(function (entries, _) {
667
- var _this9$editorScrollab, _this9$editorScrollab2;
700
+ var _this0$editorScrollab, _this0$editorScrollab2;
668
701
  // IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
669
702
  // 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
670
703
  // This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
671
- 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);
704
+ var rootBounds = (_this0$editorScrollab = _this0.editorScrollableElement) === null || _this0$editorScrollab === void 0 || (_this0$editorScrollab2 = _this0$editorScrollab.getBoundingClientRect) === null || _this0$editorScrollab2 === void 0 ? void 0 : _this0$editorScrollab2.call(_this0$editorScrollab);
672
705
  entries.forEach(function (entry) {
673
706
  var target = entry.target,
674
707
  isIntersecting = entry.isIntersecting,
@@ -676,15 +709,15 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
676
709
  // This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
677
710
  var targetKey = target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
678
711
  // Cache the latest sentinel information
679
- _this9.sentinelData[targetKey] = {
712
+ _this0.sentinelData[targetKey] = {
680
713
  isIntersecting: isIntersecting,
681
714
  boundingClientRect: boundingClientRect,
682
715
  rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
683
716
  };
684
717
  // Keep the other sentinels rootBounds in sync with this latest one
685
- _this9.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
718
+ _this0.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
686
719
  });
687
- _this9.refreshLegacyStickyState();
720
+ _this0.refreshLegacyStickyState();
688
721
  }, {
689
722
  threshold: 0,
690
723
  root: this.editorScrollableElement
@@ -895,12 +928,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
895
928
  }, {
896
929
  key: "refireIntersectionObservers",
897
930
  value: function refireIntersectionObservers() {
898
- var _this0 = this;
931
+ var _this1 = this;
899
932
  if (this.isLegacySticky) {
900
933
  [this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
901
- if (el && _this0.intersectionObserver) {
902
- _this0.intersectionObserver.unobserve(el);
903
- _this0.intersectionObserver.observe(el);
934
+ if (el && _this1.intersectionObserver) {
935
+ _this1.intersectionObserver.unobserve(el);
936
+ _this1.intersectionObserver.observe(el);
904
937
  }
905
938
  });
906
939
  }
@@ -908,7 +941,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
908
941
  }, {
909
942
  key: "checkIsSingleRowTable",
910
943
  value: function checkIsSingleRowTable() {
911
- var _this1 = this;
944
+ var _this10 = this;
912
945
  var pos = this.getPos();
913
946
  if (typeof pos !== 'number') {
914
947
  return false;
@@ -917,7 +950,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
917
950
  var _findParentNodeCloses3;
918
951
  var $tableRowPos = this.view.state.doc.resolve(pos);
919
952
  var tableNode = (_findParentNodeCloses3 = (0, _utils.findParentNodeClosestToPos)($tableRowPos, function (node) {
920
- return node.type === _this1.view.state.schema.nodes.table;
953
+ return node.type === _this10.view.state.schema.nodes.table;
921
954
  })) === null || _findParentNodeCloses3 === void 0 ? void 0 : _findParentNodeCloses3.node;
922
955
  return (tableNode === null || tableNode === void 0 ? void 0 : tableNode.childCount) === 1;
923
956
  } catch (_unused3) {
@@ -973,7 +1006,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
973
1006
  key: "makeHeaderRowLegacySticky",
974
1007
  value: function makeHeaderRowLegacySticky(tree, scrollTop) {
975
1008
  var _tbody$firstChild,
976
- _this10 = this;
1009
+ _this11 = this;
977
1010
  // If header row height is more than 50% of viewport height don't do this
978
1011
  if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
979
1012
  return;
@@ -1012,7 +1045,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
1012
1045
  });
1013
1046
  var fastScrollThresholdMs = 500;
1014
1047
  setTimeout(function () {
1015
- _this10.refireIntersectionObservers();
1048
+ _this11.refireIntersectionObservers();
1016
1049
  }, fastScrollThresholdMs);
1017
1050
  }
1018
1051
  this.dom.style.top = "0px";
@@ -280,8 +280,10 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
280
280
  // Read limited mode from the nodeView's own `this.view.state` via the plugin key exposed on
281
281
  // the (already-typed) shared state, NOT `currentState().enabled`: during initial EditorView
282
282
  // construction the injection API's editor state is undefined, so `.enabled` reads a stale false.
283
+ //
284
+ // Reads the plugin's derived `enabled`, so this covers every reason limited mode can be on.
283
285
  var limitedMode = (_this$reactComponentP9 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP9 === void 0 ? void 0 : _this$reactComponentP9.limitedMode;
284
- var enabled = Boolean(limitedMode === null || limitedMode === void 0 || (_limitedMode$sharedSt = limitedMode.sharedState.currentState()) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.limitedModePluginKey) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.getState(this.view.state)) === null || _limitedMode$sharedSt === void 0 ? void 0 : _limitedMode$sharedSt.documentSizeBreachesThreshold);
286
+ var enabled = Boolean(limitedMode === null || limitedMode === void 0 || (_limitedMode$sharedSt = limitedMode.sharedState.currentState()) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.limitedModePluginKey) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.getState(this.view.state)) === null || _limitedMode$sharedSt === void 0 ? void 0 : _limitedMode$sharedSt.enabled);
285
287
  var applied = (0, _contentVisibility.applyContentVisibility)(this.table, enabled, function () {
286
288
  return {
287
289
  // The `<table>` is content-sized (`display: table`), so it needs an explicit intrinsic
@@ -41,9 +41,10 @@ export const TableComponentWithSharedState = ({
41
41
  lineLength,
42
42
  mode,
43
43
  selection,
44
- width
45
- } = useSharedPluginStateWithSelector(api, ['table', 'width', 'media', 'selection', 'editorViewMode', 'interaction'], states => {
46
- var _states$tableState, _states$tableState2, _states$tableState3, _states$tableState4, _states$tableState5, _states$tableState6, _states$tableState7, _states$tableState8, _states$tableState9, _states$tableState0, _states$tableState1, _states$mediaState, _states$selectionStat, _states$editorViewMod, _states$widthState, _states$widthState2, _states$interactionSt;
44
+ width,
45
+ limitedModeEnabled
46
+ } = useSharedPluginStateWithSelector(api, ['table', 'width', 'media', 'selection', 'editorViewMode', 'interaction', 'limitedMode'], states => {
47
+ var _states$tableState, _states$tableState2, _states$tableState3, _states$tableState4, _states$tableState5, _states$tableState6, _states$tableState7, _states$tableState8, _states$tableState9, _states$tableState0, _states$tableState1, _states$mediaState, _states$selectionStat, _states$editorViewMod, _states$widthState, _states$widthState2, _states$interactionSt, _states$limitedModeSt;
47
48
  return {
48
49
  // tableState
49
50
  isTableResizing: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.isTableResizing,
@@ -68,7 +69,10 @@ export const TableComponentWithSharedState = ({
68
69
  width: (_states$widthState = states.widthState) === null || _states$widthState === void 0 ? void 0 : _states$widthState.width,
69
70
  lineLength: (_states$widthState2 = states.widthState) === null || _states$widthState2 === void 0 ? void 0 : _states$widthState2.lineLength,
70
71
  // interactionState
71
- interaction: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState
72
+ interaction: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
73
+ // limitedModeState — selected (rather than read once) so sticky headers stop when limited
74
+ // mode latches mid-session, not only when it was already on as the table mounted.
75
+ limitedModeEnabled: (_states$limitedModeSt = states.limitedModeState) === null || _states$limitedModeSt === void 0 ? void 0 : _states$limitedModeSt.enabled
72
76
  };
73
77
  });
74
78
  const isLivePageViewMode = mode === 'view';
@@ -122,6 +126,7 @@ export const TableComponentWithSharedState = ({
122
126
  hoveredCell: hoveredCell,
123
127
  isTableHovered: isTableHovered,
124
128
  isWholeTableInDanger: isWholeTableInDanger,
125
- selection: selection
129
+ selection: selection,
130
+ limitedMode: limitedModeEnabled
126
131
  });
127
132
  };
@@ -5,6 +5,7 @@ import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
5
5
  import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
6
6
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
7
7
  import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
8
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
9
  import { fg } from '@atlaskit/platform-feature-flags/fg';
9
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -24,7 +25,6 @@ const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
24
25
  const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
25
26
  export default class TableRow extends TableNodeView {
26
27
  constructor(node, view, getPos, eventDispatcher, api) {
27
- var _api$limitedMode, _api$limitedMode$shar, _api$limitedMode$shar2;
28
28
  super(node, view, getPos, eventDispatcher);
29
29
  _defineProperty(this, "cleanup", () => {
30
30
  if (this.isStickyHeaderEnabled) {
@@ -79,10 +79,39 @@ export default class TableRow extends TableNodeView {
79
79
  pluginConfig
80
80
  } = getPluginState(view.state);
81
81
  this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
82
- if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode$shar = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode$shar !== void 0 && (_api$limitedMode$shar2 = _api$limitedMode$shar.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode$shar2 !== void 0 && _api$limitedMode$shar2.documentSizeBreachesThreshold) {
83
- this.isStickyHeaderEnabled = false;
84
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
85
- document.addEventListener('limited-mode-activated', this.cleanup);
82
+
83
+ // Sticky headers are the only thing limited mode turns off here, so there is nothing to read
84
+ // or subscribe to when they were never enabled for this editor.
85
+ if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
86
+ var _api$limitedMode, _limitedMode$currentS;
87
+ const limitedMode = this.isStickyHeaderEnabled ? api === null || api === void 0 ? void 0 : (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.sharedState : undefined;
88
+ if (limitedMode !== null && limitedMode !== void 0 && (_limitedMode$currentS = limitedMode.currentState()) !== null && _limitedMode$currentS !== void 0 && _limitedMode$currentS.enabled) {
89
+ this.isStickyHeaderEnabled = false;
90
+ } else {
91
+ this.limitedModeUnsubscribe = limitedMode === null || limitedMode === void 0 ? void 0 : limitedMode.onChange(({
92
+ nextSharedState
93
+ }) => {
94
+ var _this$limitedModeUnsu;
95
+ if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.enabled)) {
96
+ return;
97
+ }
98
+
99
+ // Order matters: cleanup() short-circuits unless sticky headers are still marked enabled.
100
+ this.cleanup();
101
+ this.isStickyHeaderEnabled = false;
102
+
103
+ // Limited mode never turns back off, so this listener has done its job.
104
+ (_this$limitedModeUnsu = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu === void 0 ? void 0 : _this$limitedModeUnsu.call(this);
105
+ this.limitedModeUnsubscribe = undefined;
106
+ });
107
+ }
108
+ } else {
109
+ var _api$limitedMode2, _api$limitedMode2$sha, _api$limitedMode2$sha2;
110
+ if (api !== null && api !== void 0 && (_api$limitedMode2 = api.limitedMode) !== null && _api$limitedMode2 !== void 0 && (_api$limitedMode2$sha = _api$limitedMode2.sharedState.currentState()) !== null && _api$limitedMode2$sha !== void 0 && (_api$limitedMode2$sha2 = _api$limitedMode2$sha.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode2$sha2 !== void 0 && _api$limitedMode2$sha2.documentSizeBreachesThreshold) {
111
+ this.isStickyHeaderEnabled = false;
112
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
113
+ document.addEventListener('limited-mode-activated', this.cleanup);
114
+ }
86
115
  }
87
116
  const pos = this.getPos();
88
117
  this.isInNestedTable = false;
@@ -173,9 +202,14 @@ export default class TableRow extends TableNodeView {
173
202
  }
174
203
  this.emitOff(true);
175
204
  }
176
-
177
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
178
- document.removeEventListener('limited-mode-activated', this.cleanup);
205
+ if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
206
+ var _this$limitedModeUnsu2;
207
+ (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 ? void 0 : _this$limitedModeUnsu2.call(this);
208
+ this.limitedModeUnsubscribe = undefined;
209
+ } else {
210
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
211
+ document.removeEventListener('limited-mode-activated', this.cleanup);
212
+ }
179
213
  if (this.tableContainerObserver) {
180
214
  this.tableContainerObserver.disconnect();
181
215
  }