@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.
- package/CHANGELOG.md +36 -0
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +10 -5
- package/dist/cjs/nodeviews/TableRow.js +73 -40
- package/dist/cjs/nodeviews/TableRowNativeStickyWithFallback.js +119 -86
- package/dist/cjs/nodeviews/table.js +3 -1
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +10 -5
- package/dist/es2019/nodeviews/TableRow.js +42 -8
- package/dist/es2019/nodeviews/TableRowNativeStickyWithFallback.js +42 -8
- package/dist/es2019/nodeviews/table.js +3 -1
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +10 -5
- package/dist/esm/nodeviews/TableRow.js +73 -40
- package/dist/esm/nodeviews/TableRowNativeStickyWithFallback.js +119 -86
- package/dist/esm/nodeviews/table.js +3 -1
- package/dist/types/nodeviews/TableRow.d.ts +1 -0
- package/dist/types/nodeviews/TableRowNativeStickyWithFallback.d.ts +1 -0
- package/package.json +3 -3
|
@@ -14,6 +14,7 @@ import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
|
14
14
|
import { tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
15
15
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
16
16
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
17
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
17
18
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
18
19
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
19
20
|
import { INITIAL_STATIC_VIEWPORT_HEIGHT } from '../pm-plugins/editor-content-area-height';
|
|
@@ -34,7 +35,6 @@ var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
|
34
35
|
var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
35
36
|
var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
36
37
|
function TableRowNativeStickyWithFallback(node, view, getPos, eventDispatcher, api) {
|
|
37
|
-
var _api$limitedMode;
|
|
38
38
|
var _this;
|
|
39
39
|
_classCallCheck(this, TableRowNativeStickyWithFallback);
|
|
40
40
|
_this = _callSuper(this, TableRowNativeStickyWithFallback, [node, view, getPos, eventDispatcher]);
|
|
@@ -112,10 +112,38 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
112
112
|
pluginConfig = _getPluginState.pluginConfig;
|
|
113
113
|
_this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
114
114
|
_this.api = api;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
|
|
116
|
+
// Sticky headers are the only thing limited mode turns off here, so there is nothing to read
|
|
117
|
+
// or subscribe to when they were never enabled for this editor.
|
|
118
|
+
if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
|
|
119
|
+
var _api$limitedMode, _limitedMode$currentS;
|
|
120
|
+
var limitedMode = _this.isStickyHeaderEnabled ? api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.sharedState : undefined;
|
|
121
|
+
if (limitedMode !== null && limitedMode !== void 0 && (_limitedMode$currentS = limitedMode.currentState()) !== null && _limitedMode$currentS !== void 0 && _limitedMode$currentS.enabled) {
|
|
122
|
+
_this.isStickyHeaderEnabled = false;
|
|
123
|
+
} else {
|
|
124
|
+
_this.limitedModeUnsubscribe = limitedMode === null || limitedMode === void 0 ? void 0 : limitedMode.onChange(function (_ref) {
|
|
125
|
+
var _this$limitedModeUnsu, _this3;
|
|
126
|
+
var nextSharedState = _ref.nextSharedState;
|
|
127
|
+
if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.enabled)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Order matters: cleanup() short-circuits unless sticky headers are still marked enabled.
|
|
132
|
+
_this.cleanup();
|
|
133
|
+
_this.isStickyHeaderEnabled = false;
|
|
134
|
+
|
|
135
|
+
// Limited mode never turns back off, so this listener has done its job.
|
|
136
|
+
(_this$limitedModeUnsu = (_this3 = _this).limitedModeUnsubscribe) === null || _this$limitedModeUnsu === void 0 || _this$limitedModeUnsu.call(_this3);
|
|
137
|
+
_this.limitedModeUnsubscribe = undefined;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
var _api$limitedMode2;
|
|
142
|
+
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) {
|
|
143
|
+
_this.isStickyHeaderEnabled = false;
|
|
144
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
145
|
+
document.addEventListener('limited-mode-activated', _this.cleanup);
|
|
146
|
+
}
|
|
119
147
|
}
|
|
120
148
|
var pos = _this.getPos();
|
|
121
149
|
_this.isInNestedTable = false;
|
|
@@ -149,8 +177,8 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
149
177
|
}
|
|
150
178
|
if (_this.isHeaderRow && _this.isStickyHeaderEnabled) {
|
|
151
179
|
var _api$table;
|
|
152
|
-
_this.onEditorContentAreaHeightChange = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.onChange(function (
|
|
153
|
-
var nextSharedState =
|
|
180
|
+
_this.onEditorContentAreaHeightChange = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.onChange(function (_ref2) {
|
|
181
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
154
182
|
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.editorContentAreaHeight && (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.editorContentAreaHeight) !== _this.editorContentAreaHeight) {
|
|
155
183
|
var _this$stickyRowHeight;
|
|
156
184
|
_this.editorContentAreaHeight = nextSharedState.editorContentAreaHeight;
|
|
@@ -239,9 +267,14 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
239
267
|
}
|
|
240
268
|
this.emitOff(true);
|
|
241
269
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
270
|
+
if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
|
|
271
|
+
var _this$limitedModeUnsu2;
|
|
272
|
+
(_this$limitedModeUnsu2 = this.limitedModeUnsubscribe) === null || _this$limitedModeUnsu2 === void 0 || _this$limitedModeUnsu2.call(this);
|
|
273
|
+
this.limitedModeUnsubscribe = undefined;
|
|
274
|
+
} else {
|
|
275
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
276
|
+
document.removeEventListener('limited-mode-activated', this.cleanup);
|
|
277
|
+
}
|
|
245
278
|
if (this.tableContainerObserver) {
|
|
246
279
|
this.tableContainerObserver.disconnect();
|
|
247
280
|
}
|
|
@@ -274,7 +307,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
274
307
|
}, {
|
|
275
308
|
key: "subscribe",
|
|
276
309
|
value: function subscribe() {
|
|
277
|
-
var
|
|
310
|
+
var _this4 = this;
|
|
278
311
|
// Ignored via go/ees005
|
|
279
312
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
280
313
|
this.editorScrollableElement = findOverflowScrollParent(this.view.dom) || window;
|
|
@@ -282,39 +315,39 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
282
315
|
this.initObservers();
|
|
283
316
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
284
317
|
this.scrollListener = function () {
|
|
285
|
-
var
|
|
286
|
-
if (
|
|
318
|
+
var _this4$overflowObserv;
|
|
319
|
+
if (_this4.hasScrolledSinceLoad) {
|
|
287
320
|
return;
|
|
288
321
|
}
|
|
289
|
-
|
|
290
|
-
if (!
|
|
322
|
+
_this4.hasScrolledSinceLoad = true;
|
|
323
|
+
if (!_this4.overflowObserver) {
|
|
291
324
|
return;
|
|
292
325
|
}
|
|
293
326
|
|
|
294
327
|
// Re-check intersection state now that scrolling has occurred
|
|
295
|
-
var entries = (
|
|
296
|
-
|
|
328
|
+
var entries = (_this4$overflowObserv = _this4.overflowObserverEntries) !== null && _this4$overflowObserv !== void 0 ? _this4$overflowObserv : _this4.overflowObserver.takeRecords();
|
|
329
|
+
_this4.overflowObserverEntries = undefined;
|
|
297
330
|
|
|
298
331
|
/** NOTE: This logic is duplicated in the overflowObserver callback
|
|
299
332
|
* to avoid conflicting with a follow up refactor where this will
|
|
300
333
|
* be cleaned up.
|
|
301
334
|
*/
|
|
302
335
|
entries.forEach(function (entry) {
|
|
303
|
-
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) &&
|
|
336
|
+
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this4.updateSingleRowTableStickyHeaderState()) {
|
|
304
337
|
return;
|
|
305
338
|
}
|
|
306
|
-
var tableWrapper =
|
|
339
|
+
var tableWrapper = _this4.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
307
340
|
if (tableWrapper && tableWrapper instanceof HTMLElement && !areAllRectsZero(entry)) {
|
|
308
341
|
if (entry.isIntersecting) {
|
|
309
342
|
tableWrapper.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
310
|
-
|
|
311
|
-
|
|
343
|
+
_this4.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
344
|
+
_this4.isNativeSticky = true;
|
|
312
345
|
} else {
|
|
313
346
|
tableWrapper.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
314
|
-
|
|
315
|
-
|
|
347
|
+
_this4.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
348
|
+
_this4.isNativeSticky = false;
|
|
316
349
|
}
|
|
317
|
-
|
|
350
|
+
_this4.refreshLegacyStickyState();
|
|
318
351
|
}
|
|
319
352
|
});
|
|
320
353
|
};
|
|
@@ -382,7 +415,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
382
415
|
}, {
|
|
383
416
|
key: "initOverflowObserver",
|
|
384
417
|
value: function initOverflowObserver() {
|
|
385
|
-
var
|
|
418
|
+
var _this5 = this;
|
|
386
419
|
var tableWrapper = this.dom.closest(".".concat(ClassName.TABLE_NODE_WRAPPER));
|
|
387
420
|
if (!tableWrapper) {
|
|
388
421
|
return;
|
|
@@ -393,31 +426,31 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
393
426
|
};
|
|
394
427
|
this.overflowObserver = new IntersectionObserver(function (entries, observer) {
|
|
395
428
|
entries.forEach(function (entry) {
|
|
396
|
-
var
|
|
429
|
+
var _this5$api;
|
|
397
430
|
if (!(observer.root instanceof HTMLElement)) {
|
|
398
431
|
return;
|
|
399
432
|
}
|
|
400
|
-
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) &&
|
|
433
|
+
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this5.updateSingleRowTableStickyHeaderState()) {
|
|
401
434
|
return;
|
|
402
435
|
}
|
|
403
436
|
// Only apply classes if page has scrolled since load
|
|
404
|
-
if (!
|
|
405
|
-
|
|
437
|
+
if (!_this5.hasScrolledSinceLoad) {
|
|
438
|
+
_this5.overflowObserverEntries = entries;
|
|
406
439
|
return;
|
|
407
440
|
}
|
|
408
441
|
if (entry.isIntersecting) {
|
|
409
442
|
observer.root.classList.add(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
410
|
-
if (!
|
|
411
|
-
|
|
443
|
+
if (!_this5.disableNativeSticky) {
|
|
444
|
+
_this5.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
412
445
|
}
|
|
413
|
-
|
|
446
|
+
_this5.isNativeSticky = true;
|
|
414
447
|
} else {
|
|
415
448
|
observer.root.classList.remove(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
416
|
-
|
|
417
|
-
|
|
449
|
+
_this5.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
450
|
+
_this5.isNativeSticky = false;
|
|
418
451
|
}
|
|
419
|
-
|
|
420
|
-
(
|
|
452
|
+
_this5.refreshLegacyStickyState();
|
|
453
|
+
(_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({
|
|
421
454
|
action: TABLE_ACTION.STICKY_HEADER_METHOD_TOGGLED,
|
|
422
455
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
423
456
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE_STICKY_HEADER,
|
|
@@ -438,7 +471,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
438
471
|
}, {
|
|
439
472
|
key: "initStickyStateObserver",
|
|
440
473
|
value: function initStickyStateObserver() {
|
|
441
|
-
var
|
|
474
|
+
var _this6 = this;
|
|
442
475
|
if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
|
|
443
476
|
return;
|
|
444
477
|
}
|
|
@@ -450,17 +483,17 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
450
483
|
this.stickyStateObserver = new IntersectionObserver(function (entries) {
|
|
451
484
|
entries.forEach(function (entry) {
|
|
452
485
|
var _entry$rootBounds;
|
|
453
|
-
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) &&
|
|
486
|
+
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this6.updateSingleRowTableStickyHeaderState()) {
|
|
454
487
|
return;
|
|
455
488
|
}
|
|
456
|
-
var tableContainer =
|
|
457
|
-
if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top) && !
|
|
458
|
-
|
|
489
|
+
var tableContainer = _this6.dom.closest(".".concat(ClassName.TABLE_CONTAINER));
|
|
490
|
+
if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top) && !_this6.disableNativeSticky) {
|
|
491
|
+
_this6.dom.classList.add(ClassName.NATIVE_STICKY_ACTIVE);
|
|
459
492
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
460
493
|
tableContainer.dataset.tableHeaderIsStuck = 'true';
|
|
461
494
|
}
|
|
462
495
|
} else {
|
|
463
|
-
|
|
496
|
+
_this6.dom.classList.remove(ClassName.NATIVE_STICKY_ACTIVE);
|
|
464
497
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
465
498
|
delete tableContainer.dataset.tableHeaderIsStuck;
|
|
466
499
|
}
|
|
@@ -473,7 +506,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
473
506
|
}, {
|
|
474
507
|
key: "initObservers",
|
|
475
508
|
value: function initObservers() {
|
|
476
|
-
var
|
|
509
|
+
var _this7 = this;
|
|
477
510
|
if (!this.dom || this.dom.dataset.isObserved) {
|
|
478
511
|
return;
|
|
479
512
|
}
|
|
@@ -509,7 +542,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
509
542
|
window.requestAnimationFrame(function () {
|
|
510
543
|
var getTableContainer = function getTableContainer() {
|
|
511
544
|
var _getTree;
|
|
512
|
-
return (_getTree = getTree(
|
|
545
|
+
return (_getTree = getTree(_this7.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
|
|
513
546
|
};
|
|
514
547
|
|
|
515
548
|
// we expect tree to be defined after animation frame
|
|
@@ -535,16 +568,16 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
535
568
|
return getSentinelTop() !== null && getSentinelBottom() !== null;
|
|
536
569
|
};
|
|
537
570
|
var observeStickySentinels = function observeStickySentinels() {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
[
|
|
571
|
+
_this7.sentinels.top = getSentinelTop();
|
|
572
|
+
_this7.sentinels.bottom = getSentinelBottom();
|
|
573
|
+
[_this7.sentinels.top, _this7.sentinels.bottom].forEach(function (el) {
|
|
541
574
|
// skip if already observed for another row on this table
|
|
542
575
|
if (el && !el.dataset.isObserved) {
|
|
543
576
|
el.dataset.isObserved = 'true';
|
|
544
577
|
|
|
545
578
|
// Ignored via go/ees005
|
|
546
579
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
547
|
-
|
|
580
|
+
_this7.intersectionObserver.observe(el);
|
|
548
581
|
}
|
|
549
582
|
});
|
|
550
583
|
};
|
|
@@ -559,7 +592,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
559
592
|
// observe sentinels before they are in the DOM, use MutationObserver
|
|
560
593
|
// to wait for sentinels to be added to the parent Table node DOM
|
|
561
594
|
// then attach the IntersectionObserver
|
|
562
|
-
|
|
595
|
+
_this7.tableContainerObserver = new MutationObserver(function () {
|
|
563
596
|
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
564
597
|
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
565
598
|
|
|
@@ -567,14 +600,14 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
567
600
|
tableContainer = getTableContainer();
|
|
568
601
|
}
|
|
569
602
|
if (sentinelsInDom()) {
|
|
570
|
-
var
|
|
603
|
+
var _this7$tableContainer;
|
|
571
604
|
observeStickySentinels();
|
|
572
|
-
(
|
|
605
|
+
(_this7$tableContainer = _this7.tableContainerObserver) === null || _this7$tableContainer === void 0 || _this7$tableContainer.disconnect();
|
|
573
606
|
}
|
|
574
607
|
});
|
|
575
608
|
var mutatingNode = tableContainer;
|
|
576
|
-
if (mutatingNode &&
|
|
577
|
-
|
|
609
|
+
if (mutatingNode && _this7.tableContainerObserver) {
|
|
610
|
+
_this7.tableContainerObserver.observe(mutatingNode, {
|
|
578
611
|
subtree: true,
|
|
579
612
|
childList: true
|
|
580
613
|
});
|
|
@@ -588,23 +621,23 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
588
621
|
}, {
|
|
589
622
|
key: "initNodeVisibilityObserver",
|
|
590
623
|
value: function initNodeVisibilityObserver() {
|
|
591
|
-
var
|
|
624
|
+
var _this8 = this;
|
|
592
625
|
this.nodeVisibilityObserver = new IntersectionObserver(function (entries) {
|
|
593
626
|
entries.forEach(function (entry) {
|
|
594
|
-
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) &&
|
|
627
|
+
if (expValEquals('platform_editor_table_q4_patch_4', 'isEnabled', true) && _this8.updateSingleRowTableStickyHeaderState()) {
|
|
595
628
|
return;
|
|
596
629
|
}
|
|
597
|
-
if (!
|
|
630
|
+
if (!_this8.isNativeSticky) {
|
|
598
631
|
return;
|
|
599
632
|
}
|
|
600
633
|
if (entry.intersectionRatio !== 0 && entry.intersectionRatio !== 1) {
|
|
601
634
|
return;
|
|
602
635
|
}
|
|
603
|
-
if (
|
|
604
|
-
|
|
636
|
+
if (_this8.disableNativeSticky === true) {
|
|
637
|
+
_this8.dom.classList.remove(ClassName.NATIVE_STICKY);
|
|
605
638
|
}
|
|
606
|
-
if (
|
|
607
|
-
|
|
639
|
+
if (_this8.disableNativeSticky === false) {
|
|
640
|
+
_this8.dom.classList.add(ClassName.NATIVE_STICKY);
|
|
608
641
|
}
|
|
609
642
|
});
|
|
610
643
|
}, {
|
|
@@ -617,37 +650,37 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
617
650
|
}, {
|
|
618
651
|
key: "createResizeObserver",
|
|
619
652
|
value: function createResizeObserver() {
|
|
620
|
-
var
|
|
653
|
+
var _this9 = this;
|
|
621
654
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
622
|
-
var tree = getTree(
|
|
655
|
+
var tree = getTree(_this9.dom);
|
|
623
656
|
if (!tree) {
|
|
624
657
|
return;
|
|
625
658
|
}
|
|
626
659
|
var table = tree.table;
|
|
627
660
|
entries.forEach(function (entry) {
|
|
628
|
-
var
|
|
661
|
+
var _this9$editorScrollab;
|
|
629
662
|
// On resize of the parent scroll element we need to adjust the width
|
|
630
663
|
// of the sticky header
|
|
631
664
|
// Ignored via go/ees005
|
|
632
665
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
633
|
-
if (entry.target.className === ((
|
|
634
|
-
|
|
666
|
+
if (entry.target.className === ((_this9$editorScrollab = _this9.editorScrollableElement) === null || _this9$editorScrollab === void 0 ? void 0 : _this9$editorScrollab.className)) {
|
|
667
|
+
_this9.updateStickyHeaderWidth();
|
|
635
668
|
} else {
|
|
636
|
-
var
|
|
669
|
+
var _this9$editorContentA;
|
|
637
670
|
var newHeight = entry.contentRect ? entry.contentRect.height :
|
|
638
671
|
// Ignored via go/ees005
|
|
639
672
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
640
673
|
entry.target.offsetHeight;
|
|
641
|
-
if (
|
|
674
|
+
if (_this9.sentinels.bottom &&
|
|
642
675
|
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
643
676
|
// So we adding this check to allow a 1px difference.
|
|
644
|
-
Math.abs(newHeight - (
|
|
645
|
-
|
|
646
|
-
|
|
677
|
+
Math.abs(newHeight - (_this9.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
|
|
678
|
+
_this9.stickyRowHeight = newHeight;
|
|
679
|
+
_this9.sentinels.bottom.style.bottom = "".concat(tableScrollbarOffset + stickyRowOffsetTop + newHeight, "px");
|
|
647
680
|
updateTableMargin(table);
|
|
648
681
|
}
|
|
649
|
-
var viewportHeight = (
|
|
650
|
-
|
|
682
|
+
var viewportHeight = (_this9$editorContentA = _this9.editorContentAreaHeight) !== null && _this9$editorContentA !== void 0 ? _this9$editorContentA : INITIAL_STATIC_VIEWPORT_HEIGHT;
|
|
683
|
+
_this9.toggleDisableNativeSticky(newHeight, viewportHeight);
|
|
651
684
|
}
|
|
652
685
|
});
|
|
653
686
|
});
|
|
@@ -655,13 +688,13 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
655
688
|
}, {
|
|
656
689
|
key: "createIntersectionObserver",
|
|
657
690
|
value: function createIntersectionObserver() {
|
|
658
|
-
var
|
|
691
|
+
var _this0 = this;
|
|
659
692
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
660
|
-
var
|
|
693
|
+
var _this0$editorScrollab, _this0$editorScrollab2;
|
|
661
694
|
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
662
695
|
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
663
696
|
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
664
|
-
var rootBounds = (
|
|
697
|
+
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);
|
|
665
698
|
entries.forEach(function (entry) {
|
|
666
699
|
var target = entry.target,
|
|
667
700
|
isIntersecting = entry.isIntersecting,
|
|
@@ -669,15 +702,15 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
669
702
|
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
670
703
|
var targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
671
704
|
// Cache the latest sentinel information
|
|
672
|
-
|
|
705
|
+
_this0.sentinelData[targetKey] = {
|
|
673
706
|
isIntersecting: isIntersecting,
|
|
674
707
|
boundingClientRect: boundingClientRect,
|
|
675
708
|
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
676
709
|
};
|
|
677
710
|
// Keep the other sentinels rootBounds in sync with this latest one
|
|
678
|
-
|
|
711
|
+
_this0.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
679
712
|
});
|
|
680
|
-
|
|
713
|
+
_this0.refreshLegacyStickyState();
|
|
681
714
|
}, {
|
|
682
715
|
threshold: 0,
|
|
683
716
|
root: this.editorScrollableElement
|
|
@@ -888,12 +921,12 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
888
921
|
}, {
|
|
889
922
|
key: "refireIntersectionObservers",
|
|
890
923
|
value: function refireIntersectionObservers() {
|
|
891
|
-
var
|
|
924
|
+
var _this1 = this;
|
|
892
925
|
if (this.isLegacySticky) {
|
|
893
926
|
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
894
|
-
if (el &&
|
|
895
|
-
|
|
896
|
-
|
|
927
|
+
if (el && _this1.intersectionObserver) {
|
|
928
|
+
_this1.intersectionObserver.unobserve(el);
|
|
929
|
+
_this1.intersectionObserver.observe(el);
|
|
897
930
|
}
|
|
898
931
|
});
|
|
899
932
|
}
|
|
@@ -901,7 +934,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
901
934
|
}, {
|
|
902
935
|
key: "checkIsSingleRowTable",
|
|
903
936
|
value: function checkIsSingleRowTable() {
|
|
904
|
-
var
|
|
937
|
+
var _this10 = this;
|
|
905
938
|
var pos = this.getPos();
|
|
906
939
|
if (typeof pos !== 'number') {
|
|
907
940
|
return false;
|
|
@@ -910,7 +943,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
910
943
|
var _findParentNodeCloses3;
|
|
911
944
|
var $tableRowPos = this.view.state.doc.resolve(pos);
|
|
912
945
|
var tableNode = (_findParentNodeCloses3 = findParentNodeClosestToPos($tableRowPos, function (node) {
|
|
913
|
-
return node.type ===
|
|
946
|
+
return node.type === _this10.view.state.schema.nodes.table;
|
|
914
947
|
})) === null || _findParentNodeCloses3 === void 0 ? void 0 : _findParentNodeCloses3.node;
|
|
915
948
|
return (tableNode === null || tableNode === void 0 ? void 0 : tableNode.childCount) === 1;
|
|
916
949
|
} catch (_unused3) {
|
|
@@ -966,7 +999,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
966
999
|
key: "makeHeaderRowLegacySticky",
|
|
967
1000
|
value: function makeHeaderRowLegacySticky(tree, scrollTop) {
|
|
968
1001
|
var _tbody$firstChild,
|
|
969
|
-
|
|
1002
|
+
_this11 = this;
|
|
970
1003
|
// If header row height is more than 50% of viewport height don't do this
|
|
971
1004
|
if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
|
|
972
1005
|
return;
|
|
@@ -1005,7 +1038,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
1005
1038
|
});
|
|
1006
1039
|
var fastScrollThresholdMs = 500;
|
|
1007
1040
|
setTimeout(function () {
|
|
1008
|
-
|
|
1041
|
+
_this11.refireIntersectionObservers();
|
|
1009
1042
|
}, fastScrollThresholdMs);
|
|
1010
1043
|
}
|
|
1011
1044
|
this.dom.style.top = "0px";
|
|
@@ -273,8 +273,10 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
273
273
|
// Read limited mode from the nodeView's own `this.view.state` via the plugin key exposed on
|
|
274
274
|
// the (already-typed) shared state, NOT `currentState().enabled`: during initial EditorView
|
|
275
275
|
// construction the injection API's editor state is undefined, so `.enabled` reads a stale false.
|
|
276
|
+
//
|
|
277
|
+
// Reads the plugin's derived `enabled`, so this covers every reason limited mode can be on.
|
|
276
278
|
var limitedMode = (_this$reactComponentP9 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP9 === void 0 ? void 0 : _this$reactComponentP9.limitedMode;
|
|
277
|
-
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.
|
|
279
|
+
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);
|
|
278
280
|
var applied = applyContentVisibility(this.table, enabled, function () {
|
|
279
281
|
return {
|
|
280
282
|
// The `<table>` is content-sized (`display: table`), so it needs an explicit intrinsic
|
|
@@ -5,6 +5,7 @@ import { type PluginInjectionAPI } from '../types';
|
|
|
5
5
|
import TableNodeView from './TableNodeViewBase';
|
|
6
6
|
export default class TableRow extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
7
7
|
private nodeVisibilityObserverCleanupFn?;
|
|
8
|
+
private limitedModeUnsubscribe?;
|
|
8
9
|
cleanup: () => void;
|
|
9
10
|
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher, api?: PluginInjectionAPI);
|
|
10
11
|
subscribeWhenRowVisible(): void;
|
|
@@ -5,6 +5,7 @@ import { type PluginInjectionAPI } from '../types';
|
|
|
5
5
|
import TableNodeView from './TableNodeViewBase';
|
|
6
6
|
export default class TableRowNativeStickyWithFallback extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
7
7
|
private nodeVisibilityObserverCleanupFn?;
|
|
8
|
+
private limitedModeUnsubscribe?;
|
|
8
9
|
cleanup: () => void;
|
|
9
10
|
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher, api?: PluginInjectionAPI);
|
|
10
11
|
subscribeWhenRowVisible(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.1.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/editor-plugin-extension": "20.0.0",
|
|
33
33
|
"@atlaskit/editor-plugin-guideline": "^17.0.0",
|
|
34
34
|
"@atlaskit/editor-plugin-interaction": "^28.0.0",
|
|
35
|
-
"@atlaskit/editor-plugin-limited-mode": "^14.
|
|
35
|
+
"@atlaskit/editor-plugin-limited-mode": "^14.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-selection": "^17.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-toolbar": "^14.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-ui-control-registry": "^11.0.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"uuid": "^11.1.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@atlaskit/editor-common": "^121.
|
|
71
|
+
"@atlaskit/editor-common": "^121.1.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"
|