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