@atlaskit/editor-plugin-table 38.0.6 → 38.0.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,14 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 38.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`52195baa604db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/52195baa604db) -
8
+ Fix table row node views leaking event listeners on destroy, behind the
9
+ `platform_editor_reduce_memory_leaks` experiment.
10
+ - Updated dependencies
11
+
3
12
  ## 38.0.6
4
13
 
5
14
  ### Patch Changes
@@ -89,6 +89,15 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
89
89
  _this.headerRowMouseScrollEnd();
90
90
  }
91
91
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
92
+ (0, _defineProperty2.default)(_this, "onWidthPluginEvent", function () {
93
+ return _this.updateStickyHeaderWidth();
94
+ });
95
+ (0, _defineProperty2.default)(_this, "onTablePluginEvent", function (state) {
96
+ return _this.onTablePluginState(state);
97
+ });
98
+ (0, _defineProperty2.default)(_this, "onScrollEnd", function () {
99
+ return _this.refireIntersectionObservers();
100
+ });
92
101
  _this.isSticky = false;
93
102
  var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
94
103
  pluginConfig = _getPluginState.pluginConfig;
@@ -215,13 +224,20 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
215
224
  value: function destroy() {
216
225
  if (this.isStickyHeaderEnabled) {
217
226
  this.unsubscribe();
218
- this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
227
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
228
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
229
+ }
219
230
  var tree = (0, _dom2.getTree)(this.dom);
220
231
  if (tree) {
221
232
  this.makeRowHeaderNotSticky(tree.table, true);
222
233
  }
223
234
  this.emitOff(true);
224
235
  }
236
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
237
+ var _this$nodeVisibilityO;
238
+ (_this$nodeVisibilityO = this.nodeVisibilityObserverCleanupFn) === null || _this$nodeVisibilityO === void 0 || _this$nodeVisibilityO.call(this);
239
+ this.nodeVisibilityObserverCleanupFn = undefined;
240
+ }
225
241
  if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_dynamic_limited_mode')) {
226
242
  var _this$limitedModeUnsu2;
227
243
  (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 || _this$limitedModeUnsu2.call(this);
@@ -269,21 +285,28 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
269
285
  this.initObservers();
270
286
  this.topPosEditorElement = (0, _dom2.getTop)(this.editorScrollableElement);
271
287
  }
272
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
273
-
274
- // Ignored via go/ees005
275
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
276
- this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginState.bind(this));
288
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
289
+ this.eventDispatcher.on('widthPlugin', this.onWidthPluginEvent);
290
+ // Ignored via go/ees005
291
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
292
+ this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginEvent);
293
+ } else {
294
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
295
+ // Ignored via go/ees005
296
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
297
+ this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginState.bind(this));
298
+ }
277
299
  this.listening = true;
300
+ var scrollHandler = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') ? this.headerRowMouseScroll : this.headerRowMouseScroll.bind(this);
278
301
 
279
302
  // Ignored via go/ees005
280
303
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
281
- this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
304
+ this.dom.addEventListener('wheel', scrollHandler, {
282
305
  passive: true
283
306
  });
284
307
  // Ignored via go/ees005
285
308
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
286
- this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this), {
309
+ this.dom.addEventListener('touchmove', scrollHandler, {
287
310
  passive: true
288
311
  });
289
312
  }
@@ -306,10 +329,20 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
306
329
  if (this.resizeObserver) {
307
330
  this.resizeObserver.disconnect();
308
331
  }
309
- this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
310
- // Ignored via go/ees005
311
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
312
- this.eventDispatcher.off(_pluginKey.pluginKey.key, this.onTablePluginState);
332
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
333
+ var _this$editorScrollabl;
334
+ this.eventDispatcher.off('widthPlugin', this.onWidthPluginEvent);
335
+ // Ignored via go/ees005
336
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
337
+ this.eventDispatcher.off(_pluginKey.pluginKey.key, this.onTablePluginEvent);
338
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
339
+ (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.removeEventListener('scrollend', this.onScrollEnd);
340
+ } else {
341
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
342
+ // Ignored via go/ees005
343
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
344
+ this.eventDispatcher.off(_pluginKey.pluginKey.key, this.onTablePluginState);
345
+ }
313
346
  this.listening = false;
314
347
 
315
348
  // Ignored via go/ees005
@@ -680,7 +713,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
680
713
  }
681
714
  var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
682
715
  if (!this.isSticky) {
683
- var _this$editorScrollabl;
716
+ var _this$editorScrollabl2;
684
717
  (0, _dom.syncStickyRowToTable)(table);
685
718
  this.dom.classList.add('sticky');
686
719
  table.classList.add(_types.TableCssClassName.TABLE_STICKY);
@@ -693,7 +726,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
693
726
  */
694
727
  // Ignored via go/ees005
695
728
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
696
- (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', this.refireIntersectionObservers, {
729
+ (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 || _this$editorScrollabl2.addEventListener('scrollend', (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') ? this.onScrollEnd : this.refireIntersectionObservers, {
697
730
  passive: true,
698
731
  once: true
699
732
  });
@@ -98,6 +98,15 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
98
98
  _this.headerRowMouseScrollEnd();
99
99
  }
100
100
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
101
+ (0, _defineProperty2.default)(_this, "onWidthPluginEvent", function () {
102
+ return _this.updateStickyHeaderWidth();
103
+ });
104
+ (0, _defineProperty2.default)(_this, "onTablePluginEvent", function (state) {
105
+ return _this.onTablePluginState(state);
106
+ });
107
+ (0, _defineProperty2.default)(_this, "onScrollEnd", function () {
108
+ return _this.refireIntersectionObservers();
109
+ });
101
110
  (0, _defineProperty2.default)(_this, "toggleDisableNativeSticky", function (headerHeight, viewportHeight) {
102
111
  if (!_this.disableNativeSticky && headerHeight > viewportHeight * 0.5) {
103
112
  _this.disableNativeSticky = true;
@@ -261,13 +270,22 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
261
270
  this.overflowObserverEntries = undefined;
262
271
  this.stickyStateObserver && this.stickyStateObserver.disconnect();
263
272
  (_this$nodeVisibilityO = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO === void 0 || _this$nodeVisibilityO.disconnect();
264
- this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
273
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
274
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
275
+ }
265
276
  var tree = (0, _dom2.getTree)(this.dom);
266
277
  if (tree) {
267
278
  this.makeRowHeaderNotLegacySticky(tree.table, true);
268
279
  }
269
280
  this.emitOff(true);
270
281
  }
282
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
283
+ var _this$nodeVisibilityO2, _this$onEditorContent2;
284
+ (_this$nodeVisibilityO2 = this.nodeVisibilityObserverCleanupFn) === null || _this$nodeVisibilityO2 === void 0 || _this$nodeVisibilityO2.call(this);
285
+ this.nodeVisibilityObserverCleanupFn = undefined;
286
+ (_this$onEditorContent2 = this.onEditorContentAreaHeightChange) === null || _this$onEditorContent2 === void 0 || _this$onEditorContent2.call(this);
287
+ this.onEditorContentAreaHeightChange = undefined;
288
+ }
271
289
  if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_dynamic_limited_mode')) {
272
290
  var _this$limitedModeUnsu2;
273
291
  (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 || _this$limitedModeUnsu2.call(this);
@@ -358,21 +376,28 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
358
376
  once: true
359
377
  });
360
378
  }
361
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
362
-
363
- // Ignored via go/ees005
364
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
365
- this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginState.bind(this));
379
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
380
+ this.eventDispatcher.on('widthPlugin', this.onWidthPluginEvent);
381
+ // Ignored via go/ees005
382
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
383
+ this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginEvent);
384
+ } else {
385
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
386
+ // Ignored via go/ees005
387
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
388
+ this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginState.bind(this));
389
+ }
366
390
  this.listening = true;
391
+ var scrollHandler = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') ? this.headerRowMouseScroll : this.headerRowMouseScroll.bind(this);
367
392
 
368
393
  // Ignored via go/ees005
369
394
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
370
- this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
395
+ this.dom.addEventListener('wheel', scrollHandler, {
371
396
  passive: true
372
397
  });
373
398
  // Ignored via go/ees005
374
399
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
375
- this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this), {
400
+ this.dom.addEventListener('touchmove', scrollHandler, {
376
401
  passive: true
377
402
  });
378
403
  }
@@ -400,10 +425,20 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
400
425
  this.editorScrollableElement.removeEventListener('scroll', this.scrollListener);
401
426
  this.scrollListener = undefined;
402
427
  }
403
- this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
404
- // Ignored via go/ees005
405
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
406
- this.eventDispatcher.off(_pluginKey.pluginKey.key, this.onTablePluginState);
428
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
429
+ var _this$editorScrollabl;
430
+ this.eventDispatcher.off('widthPlugin', this.onWidthPluginEvent);
431
+ // Ignored via go/ees005
432
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
433
+ this.eventDispatcher.off(_pluginKey.pluginKey.key, this.onTablePluginEvent);
434
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
435
+ (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.removeEventListener('scrollend', this.onScrollEnd);
436
+ } else {
437
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
438
+ // Ignored via go/ees005
439
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
440
+ this.eventDispatcher.off(_pluginKey.pluginKey.key, this.onTablePluginState);
441
+ }
407
442
  this.listening = false;
408
443
 
409
444
  // Ignored via go/ees005
@@ -527,9 +562,9 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
527
562
  this.initNodeVisibilityObserver();
528
563
  var closestTable = this.dom.closest('table');
529
564
  if (closestTable) {
530
- var _this$overflowObserve, _this$nodeVisibilityO2;
565
+ var _this$overflowObserve, _this$nodeVisibilityO3;
531
566
  (_this$overflowObserve = this.overflowObserver) === null || _this$overflowObserve === void 0 || _this$overflowObserve.observe(closestTable);
532
- (_this$nodeVisibilityO2 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO2 === void 0 || _this$nodeVisibilityO2.observe(closestTable);
567
+ (_this$nodeVisibilityO3 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO3 === void 0 || _this$nodeVisibilityO3.observe(closestTable);
533
568
  }
534
569
  this.initStickyStateObserver();
535
570
  (_this$stickyStateObse = this.stickyStateObserver) === null || _this$stickyStateObse === void 0 || _this$stickyStateObse.observe(this.dom);
@@ -949,11 +984,11 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
949
984
  var _this$stickyStateObse2, _this$stickyStateObse3;
950
985
  var table = this.dom.closest('table');
951
986
  if (table) {
952
- var _this$overflowObserve2, _this$overflowObserve3, _this$nodeVisibilityO3, _this$nodeVisibilityO4;
987
+ var _this$overflowObserve2, _this$overflowObserve3, _this$nodeVisibilityO4, _this$nodeVisibilityO5;
953
988
  (_this$overflowObserve2 = this.overflowObserver) === null || _this$overflowObserve2 === void 0 || _this$overflowObserve2.unobserve(table);
954
989
  (_this$overflowObserve3 = this.overflowObserver) === null || _this$overflowObserve3 === void 0 || _this$overflowObserve3.observe(table);
955
- (_this$nodeVisibilityO3 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO3 === void 0 || _this$nodeVisibilityO3.unobserve(table);
956
- (_this$nodeVisibilityO4 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO4 === void 0 || _this$nodeVisibilityO4.observe(table);
990
+ (_this$nodeVisibilityO4 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO4 === void 0 || _this$nodeVisibilityO4.unobserve(table);
991
+ (_this$nodeVisibilityO5 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO5 === void 0 || _this$nodeVisibilityO5.observe(table);
957
992
  }
958
993
  (_this$stickyStateObse2 = this.stickyStateObserver) === null || _this$stickyStateObse2 === void 0 || _this$stickyStateObse2.unobserve(this.dom);
959
994
  (_this$stickyStateObse3 = this.stickyStateObserver) === null || _this$stickyStateObse3 === void 0 || _this$stickyStateObse3.observe(this.dom);
@@ -982,7 +1017,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
982
1017
  }
983
1018
  var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
984
1019
  if (!this.isLegacySticky) {
985
- var _this$editorScrollabl;
1020
+ var _this$editorScrollabl2;
986
1021
  (0, _dom.syncStickyRowToTable)(table);
987
1022
  this.dom.classList.add('sticky');
988
1023
  table.classList.add(_types.TableCssClassName.TABLE_STICKY);
@@ -995,7 +1030,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
995
1030
  */
996
1031
  // Ignored via go/ees005
997
1032
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
998
- (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', this.refireIntersectionObservers, {
1033
+ (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 || _this$editorScrollabl2.addEventListener('scrollend', (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') ? this.onScrollEnd : this.refireIntersectionObservers, {
999
1034
  passive: true,
1000
1035
  once: true
1001
1036
  });
@@ -73,6 +73,9 @@ export default class TableRow extends TableNodeView {
73
73
  this.headerRowMouseScrollEnd();
74
74
  }
75
75
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
76
+ _defineProperty(this, "onWidthPluginEvent", () => this.updateStickyHeaderWidth());
77
+ _defineProperty(this, "onTablePluginEvent", state => this.onTablePluginState(state));
78
+ _defineProperty(this, "onScrollEnd", () => this.refireIntersectionObservers());
76
79
  this.isSticky = false;
77
80
  const {
78
81
  pluginConfig
@@ -194,13 +197,20 @@ export default class TableRow extends TableNodeView {
194
197
  destroy() {
195
198
  if (this.isStickyHeaderEnabled) {
196
199
  this.unsubscribe();
197
- this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
200
+ if (!isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
201
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
202
+ }
198
203
  const tree = getTree(this.dom);
199
204
  if (tree) {
200
205
  this.makeRowHeaderNotSticky(tree.table, true);
201
206
  }
202
207
  this.emitOff(true);
203
208
  }
209
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
210
+ var _this$nodeVisibilityO;
211
+ (_this$nodeVisibilityO = this.nodeVisibilityObserverCleanupFn) === null || _this$nodeVisibilityO === void 0 ? void 0 : _this$nodeVisibilityO.call(this);
212
+ this.nodeVisibilityObserverCleanupFn = undefined;
213
+ }
204
214
  if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
205
215
  var _this$limitedModeUnsu2;
206
216
  (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 ? void 0 : _this$limitedModeUnsu2.call(this);
@@ -244,21 +254,28 @@ export default class TableRow extends TableNodeView {
244
254
  this.initObservers();
245
255
  this.topPosEditorElement = getTop(this.editorScrollableElement);
246
256
  }
247
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
248
-
249
- // Ignored via go/ees005
250
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
251
- this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
257
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
258
+ this.eventDispatcher.on('widthPlugin', this.onWidthPluginEvent);
259
+ // Ignored via go/ees005
260
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
261
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginEvent);
262
+ } else {
263
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
264
+ // Ignored via go/ees005
265
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
266
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
267
+ }
252
268
  this.listening = true;
269
+ const scrollHandler = isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.headerRowMouseScroll : this.headerRowMouseScroll.bind(this);
253
270
 
254
271
  // Ignored via go/ees005
255
272
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
256
- this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
273
+ this.dom.addEventListener('wheel', scrollHandler, {
257
274
  passive: true
258
275
  });
259
276
  // Ignored via go/ees005
260
277
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
261
- this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this), {
278
+ this.dom.addEventListener('touchmove', scrollHandler, {
262
279
  passive: true
263
280
  });
264
281
  }
@@ -279,10 +296,20 @@ export default class TableRow extends TableNodeView {
279
296
  if (this.resizeObserver) {
280
297
  this.resizeObserver.disconnect();
281
298
  }
282
- this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
283
- // Ignored via go/ees005
284
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
285
- this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
299
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
300
+ var _this$editorScrollabl;
301
+ this.eventDispatcher.off('widthPlugin', this.onWidthPluginEvent);
302
+ // Ignored via go/ees005
303
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
304
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginEvent);
305
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
306
+ (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 ? void 0 : _this$editorScrollabl.removeEventListener('scrollend', this.onScrollEnd);
307
+ } else {
308
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
309
+ // Ignored via go/ees005
310
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
311
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
312
+ }
286
313
  this.listening = false;
287
314
 
288
315
  // Ignored via go/ees005
@@ -396,12 +423,12 @@ export default class TableRow extends TableNodeView {
396
423
  table
397
424
  } = tree;
398
425
  entries.forEach(entry => {
399
- var _this$editorScrollabl;
426
+ var _this$editorScrollabl2;
400
427
  // On resize of the parent scroll element we need to adjust the width
401
428
  // of the sticky header
402
429
  // Ignored via go/ees005
403
430
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
404
- if (entry.target.className === ((_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 ? void 0 : _this$editorScrollabl.className)) {
431
+ if (entry.target.className === ((_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 ? void 0 : _this$editorScrollabl2.className)) {
405
432
  this.updateStickyHeaderWidth();
406
433
  } else {
407
434
  const newHeight = entry.contentRect ? entry.contentRect.height :
@@ -422,11 +449,11 @@ export default class TableRow extends TableNodeView {
422
449
  }
423
450
  createIntersectionObserver() {
424
451
  this.intersectionObserver = new IntersectionObserver((entries, _) => {
425
- var _this$editorScrollabl2, _this$editorScrollabl3;
452
+ var _this$editorScrollabl3, _this$editorScrollabl4;
426
453
  // IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
427
454
  // 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
428
455
  // This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
429
- const rootBounds = (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 ? void 0 : (_this$editorScrollabl3 = _this$editorScrollabl2.getBoundingClientRect) === null || _this$editorScrollabl3 === void 0 ? void 0 : _this$editorScrollabl3.call(_this$editorScrollabl2);
456
+ const rootBounds = (_this$editorScrollabl3 = this.editorScrollableElement) === null || _this$editorScrollabl3 === void 0 ? void 0 : (_this$editorScrollabl4 = _this$editorScrollabl3.getBoundingClientRect) === null || _this$editorScrollabl4 === void 0 ? void 0 : _this$editorScrollabl4.call(_this$editorScrollabl3);
430
457
  entries.forEach(entry => {
431
458
  const {
432
459
  target,
@@ -636,7 +663,7 @@ export default class TableRow extends TableNodeView {
636
663
  }
637
664
  const domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
638
665
  if (!this.isSticky) {
639
- var _this$editorScrollabl4;
666
+ var _this$editorScrollabl5;
640
667
  syncStickyRowToTable(table);
641
668
  this.dom.classList.add('sticky');
642
669
  table.classList.add(ClassName.TABLE_STICKY);
@@ -649,7 +676,7 @@ export default class TableRow extends TableNodeView {
649
676
  */
650
677
  // Ignored via go/ees005
651
678
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
652
- (_this$editorScrollabl4 = this.editorScrollableElement) === null || _this$editorScrollabl4 === void 0 ? void 0 : _this$editorScrollabl4.addEventListener('scrollend', this.refireIntersectionObservers, {
679
+ (_this$editorScrollabl5 = this.editorScrollableElement) === null || _this$editorScrollabl5 === void 0 ? void 0 : _this$editorScrollabl5.addEventListener('scrollend', isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.onScrollEnd : this.refireIntersectionObservers, {
653
680
  passive: true,
654
681
  once: true
655
682
  });
@@ -82,6 +82,9 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
82
82
  this.headerRowMouseScrollEnd();
83
83
  }
84
84
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
85
+ _defineProperty(this, "onWidthPluginEvent", () => this.updateStickyHeaderWidth());
86
+ _defineProperty(this, "onTablePluginEvent", state => this.onTablePluginState(state));
87
+ _defineProperty(this, "onScrollEnd", () => this.refireIntersectionObservers());
85
88
  _defineProperty(this, "toggleDisableNativeSticky", (headerHeight, viewportHeight) => {
86
89
  if (!this.disableNativeSticky && headerHeight > viewportHeight * 0.5) {
87
90
  this.disableNativeSticky = true;
@@ -241,13 +244,22 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
241
244
  this.overflowObserverEntries = undefined;
242
245
  this.stickyStateObserver && this.stickyStateObserver.disconnect();
243
246
  (_this$nodeVisibilityO = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO === void 0 ? void 0 : _this$nodeVisibilityO.disconnect();
244
- this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
247
+ if (!isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
248
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
249
+ }
245
250
  const tree = getTree(this.dom);
246
251
  if (tree) {
247
252
  this.makeRowHeaderNotLegacySticky(tree.table, true);
248
253
  }
249
254
  this.emitOff(true);
250
255
  }
256
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
257
+ var _this$nodeVisibilityO2, _this$onEditorContent2;
258
+ (_this$nodeVisibilityO2 = this.nodeVisibilityObserverCleanupFn) === null || _this$nodeVisibilityO2 === void 0 ? void 0 : _this$nodeVisibilityO2.call(this);
259
+ this.nodeVisibilityObserverCleanupFn = undefined;
260
+ (_this$onEditorContent2 = this.onEditorContentAreaHeightChange) === null || _this$onEditorContent2 === void 0 ? void 0 : _this$onEditorContent2.call(this);
261
+ this.onEditorContentAreaHeightChange = undefined;
262
+ }
251
263
  if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
252
264
  var _this$limitedModeUnsu2;
253
265
  (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 ? void 0 : _this$limitedModeUnsu2.call(this);
@@ -333,21 +345,28 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
333
345
  once: true
334
346
  });
335
347
  }
336
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
337
-
338
- // Ignored via go/ees005
339
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
340
- this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
348
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
349
+ this.eventDispatcher.on('widthPlugin', this.onWidthPluginEvent);
350
+ // Ignored via go/ees005
351
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
352
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginEvent);
353
+ } else {
354
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
355
+ // Ignored via go/ees005
356
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
357
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
358
+ }
341
359
  this.listening = true;
360
+ const scrollHandler = isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.headerRowMouseScroll : this.headerRowMouseScroll.bind(this);
342
361
 
343
362
  // Ignored via go/ees005
344
363
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
345
- this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
364
+ this.dom.addEventListener('wheel', scrollHandler, {
346
365
  passive: true
347
366
  });
348
367
  // Ignored via go/ees005
349
368
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
350
- this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this), {
369
+ this.dom.addEventListener('touchmove', scrollHandler, {
351
370
  passive: true
352
371
  });
353
372
  }
@@ -373,10 +392,20 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
373
392
  this.editorScrollableElement.removeEventListener('scroll', this.scrollListener);
374
393
  this.scrollListener = undefined;
375
394
  }
376
- this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
377
- // Ignored via go/ees005
378
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
379
- this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
395
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
396
+ var _this$editorScrollabl;
397
+ this.eventDispatcher.off('widthPlugin', this.onWidthPluginEvent);
398
+ // Ignored via go/ees005
399
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
400
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginEvent);
401
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
402
+ (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 ? void 0 : _this$editorScrollabl.removeEventListener('scrollend', this.onScrollEnd);
403
+ } else {
404
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
405
+ // Ignored via go/ees005
406
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
407
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
408
+ }
380
409
  this.listening = false;
381
410
 
382
411
  // Ignored via go/ees005
@@ -491,9 +520,9 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
491
520
  this.initNodeVisibilityObserver();
492
521
  const closestTable = this.dom.closest('table');
493
522
  if (closestTable) {
494
- var _this$overflowObserve2, _this$nodeVisibilityO2;
523
+ var _this$overflowObserve2, _this$nodeVisibilityO3;
495
524
  (_this$overflowObserve2 = this.overflowObserver) === null || _this$overflowObserve2 === void 0 ? void 0 : _this$overflowObserve2.observe(closestTable);
496
- (_this$nodeVisibilityO2 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO2 === void 0 ? void 0 : _this$nodeVisibilityO2.observe(closestTable);
525
+ (_this$nodeVisibilityO3 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO3 === void 0 ? void 0 : _this$nodeVisibilityO3.observe(closestTable);
497
526
  }
498
527
  this.initStickyStateObserver();
499
528
  (_this$stickyStateObse = this.stickyStateObserver) === null || _this$stickyStateObse === void 0 ? void 0 : _this$stickyStateObse.observe(this.dom);
@@ -615,12 +644,12 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
615
644
  table
616
645
  } = tree;
617
646
  entries.forEach(entry => {
618
- var _this$editorScrollabl;
647
+ var _this$editorScrollabl2;
619
648
  // On resize of the parent scroll element we need to adjust the width
620
649
  // of the sticky header
621
650
  // Ignored via go/ees005
622
651
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
623
- if (entry.target.className === ((_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 ? void 0 : _this$editorScrollabl.className)) {
652
+ if (entry.target.className === ((_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 ? void 0 : _this$editorScrollabl2.className)) {
624
653
  this.updateStickyHeaderWidth();
625
654
  } else {
626
655
  var _this$editorContentAr;
@@ -644,11 +673,11 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
644
673
  }
645
674
  createIntersectionObserver() {
646
675
  this.intersectionObserver = new IntersectionObserver((entries, _) => {
647
- var _this$editorScrollabl2, _this$editorScrollabl3;
676
+ var _this$editorScrollabl3, _this$editorScrollabl4;
648
677
  // IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
649
678
  // 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
650
679
  // This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
651
- const rootBounds = (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 ? void 0 : (_this$editorScrollabl3 = _this$editorScrollabl2.getBoundingClientRect) === null || _this$editorScrollabl3 === void 0 ? void 0 : _this$editorScrollabl3.call(_this$editorScrollabl2);
680
+ const rootBounds = (_this$editorScrollabl3 = this.editorScrollableElement) === null || _this$editorScrollabl3 === void 0 ? void 0 : (_this$editorScrollabl4 = _this$editorScrollabl3.getBoundingClientRect) === null || _this$editorScrollabl4 === void 0 ? void 0 : _this$editorScrollabl4.call(_this$editorScrollabl3);
652
681
  entries.forEach(entry => {
653
682
  const {
654
683
  target,
@@ -886,11 +915,11 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
886
915
  var _this$stickyStateObse2, _this$stickyStateObse3;
887
916
  const table = this.dom.closest('table');
888
917
  if (table) {
889
- var _this$overflowObserve3, _this$overflowObserve4, _this$nodeVisibilityO3, _this$nodeVisibilityO4;
918
+ var _this$overflowObserve3, _this$overflowObserve4, _this$nodeVisibilityO4, _this$nodeVisibilityO5;
890
919
  (_this$overflowObserve3 = this.overflowObserver) === null || _this$overflowObserve3 === void 0 ? void 0 : _this$overflowObserve3.unobserve(table);
891
920
  (_this$overflowObserve4 = this.overflowObserver) === null || _this$overflowObserve4 === void 0 ? void 0 : _this$overflowObserve4.observe(table);
892
- (_this$nodeVisibilityO3 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO3 === void 0 ? void 0 : _this$nodeVisibilityO3.unobserve(table);
893
- (_this$nodeVisibilityO4 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO4 === void 0 ? void 0 : _this$nodeVisibilityO4.observe(table);
921
+ (_this$nodeVisibilityO4 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO4 === void 0 ? void 0 : _this$nodeVisibilityO4.unobserve(table);
922
+ (_this$nodeVisibilityO5 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO5 === void 0 ? void 0 : _this$nodeVisibilityO5.observe(table);
894
923
  }
895
924
  (_this$stickyStateObse2 = this.stickyStateObserver) === null || _this$stickyStateObse2 === void 0 ? void 0 : _this$stickyStateObse2.unobserve(this.dom);
896
925
  (_this$stickyStateObse3 = this.stickyStateObserver) === null || _this$stickyStateObse3 === void 0 ? void 0 : _this$stickyStateObse3.observe(this.dom);
@@ -918,7 +947,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
918
947
  }
919
948
  const domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
920
949
  if (!this.isLegacySticky) {
921
- var _this$editorScrollabl4;
950
+ var _this$editorScrollabl5;
922
951
  syncStickyRowToTable(table);
923
952
  this.dom.classList.add('sticky');
924
953
  table.classList.add(ClassName.TABLE_STICKY);
@@ -931,7 +960,7 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
931
960
  */
932
961
  // Ignored via go/ees005
933
962
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
934
- (_this$editorScrollabl4 = this.editorScrollableElement) === null || _this$editorScrollabl4 === void 0 ? void 0 : _this$editorScrollabl4.addEventListener('scrollend', this.refireIntersectionObservers, {
963
+ (_this$editorScrollabl5 = this.editorScrollableElement) === null || _this$editorScrollabl5 === void 0 ? void 0 : _this$editorScrollabl5.addEventListener('scrollend', isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.onScrollEnd : this.refireIntersectionObservers, {
935
964
  passive: true,
936
965
  once: true
937
966
  });
@@ -82,6 +82,15 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
82
82
  _this.headerRowMouseScrollEnd();
83
83
  }
84
84
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
85
+ _defineProperty(_this, "onWidthPluginEvent", function () {
86
+ return _this.updateStickyHeaderWidth();
87
+ });
88
+ _defineProperty(_this, "onTablePluginEvent", function (state) {
89
+ return _this.onTablePluginState(state);
90
+ });
91
+ _defineProperty(_this, "onScrollEnd", function () {
92
+ return _this.refireIntersectionObservers();
93
+ });
85
94
  _this.isSticky = false;
86
95
  var _getPluginState = getPluginState(view.state),
87
96
  pluginConfig = _getPluginState.pluginConfig;
@@ -208,13 +217,20 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
208
217
  value: function destroy() {
209
218
  if (this.isStickyHeaderEnabled) {
210
219
  this.unsubscribe();
211
- this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
220
+ if (!isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
221
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
222
+ }
212
223
  var tree = getTree(this.dom);
213
224
  if (tree) {
214
225
  this.makeRowHeaderNotSticky(tree.table, true);
215
226
  }
216
227
  this.emitOff(true);
217
228
  }
229
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
230
+ var _this$nodeVisibilityO;
231
+ (_this$nodeVisibilityO = this.nodeVisibilityObserverCleanupFn) === null || _this$nodeVisibilityO === void 0 || _this$nodeVisibilityO.call(this);
232
+ this.nodeVisibilityObserverCleanupFn = undefined;
233
+ }
218
234
  if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
219
235
  var _this$limitedModeUnsu2;
220
236
  (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 || _this$limitedModeUnsu2.call(this);
@@ -262,21 +278,28 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
262
278
  this.initObservers();
263
279
  this.topPosEditorElement = getTop(this.editorScrollableElement);
264
280
  }
265
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
266
-
267
- // Ignored via go/ees005
268
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
- this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
281
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
282
+ this.eventDispatcher.on('widthPlugin', this.onWidthPluginEvent);
283
+ // Ignored via go/ees005
284
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
285
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginEvent);
286
+ } else {
287
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
288
+ // Ignored via go/ees005
289
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
290
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
291
+ }
270
292
  this.listening = true;
293
+ var scrollHandler = isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.headerRowMouseScroll : this.headerRowMouseScroll.bind(this);
271
294
 
272
295
  // Ignored via go/ees005
273
296
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
274
- this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
297
+ this.dom.addEventListener('wheel', scrollHandler, {
275
298
  passive: true
276
299
  });
277
300
  // Ignored via go/ees005
278
301
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
279
- this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this), {
302
+ this.dom.addEventListener('touchmove', scrollHandler, {
280
303
  passive: true
281
304
  });
282
305
  }
@@ -299,10 +322,20 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
299
322
  if (this.resizeObserver) {
300
323
  this.resizeObserver.disconnect();
301
324
  }
302
- this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
303
- // Ignored via go/ees005
304
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
305
- this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
325
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
326
+ var _this$editorScrollabl;
327
+ this.eventDispatcher.off('widthPlugin', this.onWidthPluginEvent);
328
+ // Ignored via go/ees005
329
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginEvent);
331
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
332
+ (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.removeEventListener('scrollend', this.onScrollEnd);
333
+ } else {
334
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
335
+ // Ignored via go/ees005
336
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
337
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
338
+ }
306
339
  this.listening = false;
307
340
 
308
341
  // Ignored via go/ees005
@@ -673,7 +706,7 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
673
706
  }
674
707
  var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
675
708
  if (!this.isSticky) {
676
- var _this$editorScrollabl;
709
+ var _this$editorScrollabl2;
677
710
  syncStickyRowToTable(table);
678
711
  this.dom.classList.add('sticky');
679
712
  table.classList.add(ClassName.TABLE_STICKY);
@@ -686,7 +719,7 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
686
719
  */
687
720
  // Ignored via go/ees005
688
721
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
689
- (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', this.refireIntersectionObservers, {
722
+ (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 || _this$editorScrollabl2.addEventListener('scrollend', isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.onScrollEnd : this.refireIntersectionObservers, {
690
723
  passive: true,
691
724
  once: true
692
725
  });
@@ -91,6 +91,15 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
91
91
  _this.headerRowMouseScrollEnd();
92
92
  }
93
93
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
94
+ _defineProperty(_this, "onWidthPluginEvent", function () {
95
+ return _this.updateStickyHeaderWidth();
96
+ });
97
+ _defineProperty(_this, "onTablePluginEvent", function (state) {
98
+ return _this.onTablePluginState(state);
99
+ });
100
+ _defineProperty(_this, "onScrollEnd", function () {
101
+ return _this.refireIntersectionObservers();
102
+ });
94
103
  _defineProperty(_this, "toggleDisableNativeSticky", function (headerHeight, viewportHeight) {
95
104
  if (!_this.disableNativeSticky && headerHeight > viewportHeight * 0.5) {
96
105
  _this.disableNativeSticky = true;
@@ -254,13 +263,22 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
254
263
  this.overflowObserverEntries = undefined;
255
264
  this.stickyStateObserver && this.stickyStateObserver.disconnect();
256
265
  (_this$nodeVisibilityO = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO === void 0 || _this$nodeVisibilityO.disconnect();
257
- this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
266
+ if (!isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
267
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
268
+ }
258
269
  var tree = getTree(this.dom);
259
270
  if (tree) {
260
271
  this.makeRowHeaderNotLegacySticky(tree.table, true);
261
272
  }
262
273
  this.emitOff(true);
263
274
  }
275
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
276
+ var _this$nodeVisibilityO2, _this$onEditorContent2;
277
+ (_this$nodeVisibilityO2 = this.nodeVisibilityObserverCleanupFn) === null || _this$nodeVisibilityO2 === void 0 || _this$nodeVisibilityO2.call(this);
278
+ this.nodeVisibilityObserverCleanupFn = undefined;
279
+ (_this$onEditorContent2 = this.onEditorContentAreaHeightChange) === null || _this$onEditorContent2 === void 0 || _this$onEditorContent2.call(this);
280
+ this.onEditorContentAreaHeightChange = undefined;
281
+ }
264
282
  if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
265
283
  var _this$limitedModeUnsu2;
266
284
  (_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 || _this$limitedModeUnsu2.call(this);
@@ -351,21 +369,28 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
351
369
  once: true
352
370
  });
353
371
  }
354
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
355
-
356
- // Ignored via go/ees005
357
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
358
- this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
372
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
373
+ this.eventDispatcher.on('widthPlugin', this.onWidthPluginEvent);
374
+ // Ignored via go/ees005
375
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
376
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginEvent);
377
+ } else {
378
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
379
+ // Ignored via go/ees005
380
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
381
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
382
+ }
359
383
  this.listening = true;
384
+ var scrollHandler = isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.headerRowMouseScroll : this.headerRowMouseScroll.bind(this);
360
385
 
361
386
  // Ignored via go/ees005
362
387
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
363
- this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
388
+ this.dom.addEventListener('wheel', scrollHandler, {
364
389
  passive: true
365
390
  });
366
391
  // Ignored via go/ees005
367
392
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
368
- this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this), {
393
+ this.dom.addEventListener('touchmove', scrollHandler, {
369
394
  passive: true
370
395
  });
371
396
  }
@@ -393,10 +418,20 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
393
418
  this.editorScrollableElement.removeEventListener('scroll', this.scrollListener);
394
419
  this.scrollListener = undefined;
395
420
  }
396
- this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
397
- // Ignored via go/ees005
398
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
399
- this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
421
+ if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
422
+ var _this$editorScrollabl;
423
+ this.eventDispatcher.off('widthPlugin', this.onWidthPluginEvent);
424
+ // Ignored via go/ees005
425
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
426
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginEvent);
427
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
428
+ (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.removeEventListener('scrollend', this.onScrollEnd);
429
+ } else {
430
+ this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
431
+ // Ignored via go/ees005
432
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
433
+ this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
434
+ }
400
435
  this.listening = false;
401
436
 
402
437
  // Ignored via go/ees005
@@ -520,9 +555,9 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
520
555
  this.initNodeVisibilityObserver();
521
556
  var closestTable = this.dom.closest('table');
522
557
  if (closestTable) {
523
- var _this$overflowObserve, _this$nodeVisibilityO2;
558
+ var _this$overflowObserve, _this$nodeVisibilityO3;
524
559
  (_this$overflowObserve = this.overflowObserver) === null || _this$overflowObserve === void 0 || _this$overflowObserve.observe(closestTable);
525
- (_this$nodeVisibilityO2 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO2 === void 0 || _this$nodeVisibilityO2.observe(closestTable);
560
+ (_this$nodeVisibilityO3 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO3 === void 0 || _this$nodeVisibilityO3.observe(closestTable);
526
561
  }
527
562
  this.initStickyStateObserver();
528
563
  (_this$stickyStateObse = this.stickyStateObserver) === null || _this$stickyStateObse === void 0 || _this$stickyStateObse.observe(this.dom);
@@ -942,11 +977,11 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
942
977
  var _this$stickyStateObse2, _this$stickyStateObse3;
943
978
  var table = this.dom.closest('table');
944
979
  if (table) {
945
- var _this$overflowObserve2, _this$overflowObserve3, _this$nodeVisibilityO3, _this$nodeVisibilityO4;
980
+ var _this$overflowObserve2, _this$overflowObserve3, _this$nodeVisibilityO4, _this$nodeVisibilityO5;
946
981
  (_this$overflowObserve2 = this.overflowObserver) === null || _this$overflowObserve2 === void 0 || _this$overflowObserve2.unobserve(table);
947
982
  (_this$overflowObserve3 = this.overflowObserver) === null || _this$overflowObserve3 === void 0 || _this$overflowObserve3.observe(table);
948
- (_this$nodeVisibilityO3 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO3 === void 0 || _this$nodeVisibilityO3.unobserve(table);
949
- (_this$nodeVisibilityO4 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO4 === void 0 || _this$nodeVisibilityO4.observe(table);
983
+ (_this$nodeVisibilityO4 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO4 === void 0 || _this$nodeVisibilityO4.unobserve(table);
984
+ (_this$nodeVisibilityO5 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO5 === void 0 || _this$nodeVisibilityO5.observe(table);
950
985
  }
951
986
  (_this$stickyStateObse2 = this.stickyStateObserver) === null || _this$stickyStateObse2 === void 0 || _this$stickyStateObse2.unobserve(this.dom);
952
987
  (_this$stickyStateObse3 = this.stickyStateObserver) === null || _this$stickyStateObse3 === void 0 || _this$stickyStateObse3.observe(this.dom);
@@ -975,7 +1010,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
975
1010
  }
976
1011
  var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
977
1012
  if (!this.isLegacySticky) {
978
- var _this$editorScrollabl;
1013
+ var _this$editorScrollabl2;
979
1014
  syncStickyRowToTable(table);
980
1015
  this.dom.classList.add('sticky');
981
1016
  table.classList.add(ClassName.TABLE_STICKY);
@@ -988,7 +1023,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
988
1023
  */
989
1024
  // Ignored via go/ees005
990
1025
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
991
- (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', this.refireIntersectionObservers, {
1026
+ (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 || _this$editorScrollabl2.addEventListener('scrollend', isExperimentEnabled('platform_editor_reduce_memory_leaks') ? this.onScrollEnd : this.refireIntersectionObservers, {
992
1027
  passive: true,
993
1028
  once: true
994
1029
  });
@@ -43,6 +43,9 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
43
43
  */
44
44
  private headerRowMouseScrollEnd;
45
45
  private headerRowMouseScroll;
46
+ private onWidthPluginEvent;
47
+ private onTablePluginEvent;
48
+ private onScrollEnd;
46
49
  private subscribe;
47
50
  private unsubscribe;
48
51
  private initObservers;
@@ -56,6 +56,9 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView<HTML
56
56
  */
57
57
  private headerRowMouseScrollEnd;
58
58
  private headerRowMouseScroll;
59
+ private onWidthPluginEvent;
60
+ private onTablePluginEvent;
61
+ private onScrollEnd;
59
62
  private subscribe;
60
63
  private unsubscribe;
61
64
  private initOverflowObserver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "38.0.6",
3
+ "version": "38.0.7",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -68,7 +68,7 @@
68
68
  "uuid": "^11.1.1"
69
69
  },
70
70
  "peerDependencies": {
71
- "@atlaskit/editor-common": "^130.3.0",
71
+ "@atlaskit/editor-common": "^130.4.0",
72
72
  "react": "^18.2.0 || ^19.2.0",
73
73
  "react-dom": "^18.2.0 || ^19.2.0",
74
74
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"