@atlaskit/editor-plugin-table 15.6.6 → 15.6.8
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 +19 -0
- package/dist/cjs/nodeviews/TableRowNativeStickyWithFallback.js +179 -105
- 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 +134 -62
- 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 +178 -104
- 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 +9 -3
- 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 +9 -3
- 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 +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 15.6.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b1ea4fa4e8e56`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b1ea4fa4e8e56) -
|
|
8
|
+
Remove static scroll listener
|
|
9
|
+
|
|
10
|
+
## 15.6.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`fe7b3f29093a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fe7b3f29093a6) -
|
|
15
|
+
[ux] EDITOR-2990 Disable native sticky header for tables with headers greater than 50% viewport
|
|
16
|
+
height
|
|
17
|
+
- [`b4a854535b851`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b4a854535b851) -
|
|
18
|
+
[ux] EDITOR-2625 Add missing left border when table controls are showing and header is sticking in
|
|
19
|
+
table with numbered columns
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 15.6.6
|
|
4
23
|
|
|
5
24
|
### 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,8 @@ 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, "hasScrolledSinceLoad", false);
|
|
83
|
+
(0, _defineProperty2.default)(_this, "disableNativeSticky", false);
|
|
80
84
|
/**
|
|
81
85
|
* Methods
|
|
82
86
|
*/
|
|
@@ -92,6 +96,17 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
92
96
|
_this.headerRowMouseScrollEnd();
|
|
93
97
|
}
|
|
94
98
|
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
99
|
+
(0, _defineProperty2.default)(_this, "toggleDisableNativeSticky", function (headerHeight, viewportHeight) {
|
|
100
|
+
if (!_this.disableNativeSticky && headerHeight > viewportHeight * 0.5) {
|
|
101
|
+
_this.disableNativeSticky = true;
|
|
102
|
+
if (_this.isNativeSticky === undefined) {
|
|
103
|
+
_this.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (_this.disableNativeSticky && headerHeight <= viewportHeight * 0.5) {
|
|
107
|
+
_this.disableNativeSticky = false;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
95
110
|
_this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node);
|
|
96
111
|
_this.isLegacySticky = false;
|
|
97
112
|
var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
|
|
@@ -118,6 +133,17 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
118
133
|
}
|
|
119
134
|
});
|
|
120
135
|
}
|
|
136
|
+
if (_this.isHeaderRow && _this.isStickyHeaderEnabled && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
|
|
137
|
+
var _api$table;
|
|
138
|
+
_this.onEditorContentAreaHeightChange = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.onChange(function (_ref2) {
|
|
139
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
140
|
+
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.editorContentAreaHeight && (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.editorContentAreaHeight) !== _this.editorContentAreaHeight) {
|
|
141
|
+
var _this$stickyRowHeight;
|
|
142
|
+
_this.editorContentAreaHeight = nextSharedState.editorContentAreaHeight;
|
|
143
|
+
_this.toggleDisableNativeSticky((_this$stickyRowHeight = _this.stickyRowHeight) !== null && _this$stickyRowHeight !== void 0 ? _this$stickyRowHeight : 0, nextSharedState.editorContentAreaHeight);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
121
147
|
return _this;
|
|
122
148
|
}
|
|
123
149
|
(0, _inherits2.default)(TableRowNativeStickyWithFallback, _ref);
|
|
@@ -181,10 +207,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
181
207
|
key: "destroy",
|
|
182
208
|
value: function destroy() {
|
|
183
209
|
if (this.isStickyHeaderEnabled) {
|
|
210
|
+
var _this$nodeVisibilityO;
|
|
184
211
|
this.unsubscribe();
|
|
185
212
|
this.overflowObserver && this.overflowObserver.disconnect();
|
|
186
213
|
this.overflowObserverEntries = undefined;
|
|
187
214
|
this.stickyStateObserver && this.stickyStateObserver.disconnect();
|
|
215
|
+
(_this$nodeVisibilityO = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO === void 0 || _this$nodeVisibilityO.disconnect();
|
|
188
216
|
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
189
217
|
var tree = (0, _dom2.getTree)(this.dom);
|
|
190
218
|
if (tree) {
|
|
@@ -227,52 +255,50 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
227
255
|
}, {
|
|
228
256
|
key: "subscribe",
|
|
229
257
|
value: function subscribe() {
|
|
230
|
-
var
|
|
258
|
+
var _this3 = this;
|
|
231
259
|
// Ignored via go/ees005
|
|
232
260
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
233
261
|
this.editorScrollableElement = (0, _ui.findOverflowScrollParent)(this.view.dom) || window;
|
|
234
262
|
if (this.editorScrollableElement) {
|
|
235
263
|
this.initObservers();
|
|
236
264
|
this.topPosEditorElement = (0, _dom2.getTop)(this.editorScrollableElement);
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
|
|
265
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_5')) {
|
|
266
|
+
this.scrollListener = function () {
|
|
267
|
+
var _this3$overflowObserv;
|
|
268
|
+
if (_this3.hasScrolledSinceLoad) {
|
|
240
269
|
return;
|
|
241
270
|
}
|
|
242
|
-
|
|
243
|
-
if (!
|
|
271
|
+
_this3.hasScrolledSinceLoad = true;
|
|
272
|
+
if (!_this3.overflowObserver) {
|
|
244
273
|
return;
|
|
245
274
|
}
|
|
246
275
|
|
|
247
276
|
// Re-check intersection state now that scrolling has occurred
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
_this2.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
267
|
-
_this2.isNativeSticky = false;
|
|
268
|
-
}
|
|
269
|
-
_this2.refreshLegacyStickyState();
|
|
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;
|
|
270
295
|
}
|
|
271
|
-
|
|
272
|
-
|
|
296
|
+
_this3.refreshLegacyStickyState();
|
|
297
|
+
}
|
|
298
|
+
});
|
|
273
299
|
};
|
|
274
300
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
275
|
-
this.editorScrollableElement.addEventListener('scroll',
|
|
301
|
+
this.editorScrollableElement.addEventListener('scroll', this.scrollListener, {
|
|
276
302
|
passive: true,
|
|
277
303
|
once: true
|
|
278
304
|
});
|
|
@@ -315,10 +341,10 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
315
341
|
if (this.resizeObserver) {
|
|
316
342
|
this.resizeObserver.disconnect();
|
|
317
343
|
}
|
|
318
|
-
if (
|
|
344
|
+
if (this.scrollListener && this.editorScrollableElement) {
|
|
319
345
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
320
|
-
this.editorScrollableElement.removeEventListener('scroll',
|
|
321
|
-
|
|
346
|
+
this.editorScrollableElement.removeEventListener('scroll', this.scrollListener);
|
|
347
|
+
this.scrollListener = undefined;
|
|
322
348
|
}
|
|
323
349
|
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
324
350
|
// Ignored via go/ees005
|
|
@@ -336,7 +362,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
336
362
|
}, {
|
|
337
363
|
key: "initOverflowObserver",
|
|
338
364
|
value: function initOverflowObserver() {
|
|
339
|
-
var
|
|
365
|
+
var _this4 = this;
|
|
340
366
|
var tableWrapper = this.dom.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
|
|
341
367
|
if (!tableWrapper) {
|
|
342
368
|
return;
|
|
@@ -351,20 +377,32 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
351
377
|
return;
|
|
352
378
|
}
|
|
353
379
|
// Only apply classes if page has scrolled since load
|
|
354
|
-
if (!
|
|
355
|
-
|
|
380
|
+
if (!_this4.hasScrolledSinceLoad && (0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_5')) {
|
|
381
|
+
_this4.overflowObserverEntries = entries;
|
|
356
382
|
return;
|
|
357
383
|
}
|
|
358
384
|
if (entry.isIntersecting) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
385
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
|
|
386
|
+
observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
387
|
+
if (!_this4.disableNativeSticky) {
|
|
388
|
+
_this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
observer.root.classList.add(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
392
|
+
_this4.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
|
|
393
|
+
}
|
|
394
|
+
_this4.isNativeSticky = true;
|
|
362
395
|
} else {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
396
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
|
|
397
|
+
observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
398
|
+
_this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
399
|
+
} else {
|
|
400
|
+
observer.root.classList.remove(_types.TableCssClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW);
|
|
401
|
+
_this4.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
402
|
+
}
|
|
403
|
+
_this4.isNativeSticky = false;
|
|
366
404
|
}
|
|
367
|
-
|
|
405
|
+
_this4.refreshLegacyStickyState();
|
|
368
406
|
});
|
|
369
407
|
}, options);
|
|
370
408
|
}
|
|
@@ -377,7 +415,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
377
415
|
}, {
|
|
378
416
|
key: "initStickyStateObserver",
|
|
379
417
|
value: function initStickyStateObserver() {
|
|
380
|
-
var
|
|
418
|
+
var _this5 = this;
|
|
381
419
|
if (!this.editorScrollableElement || !(this.editorScrollableElement instanceof Element)) {
|
|
382
420
|
return;
|
|
383
421
|
}
|
|
@@ -389,14 +427,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
389
427
|
this.stickyStateObserver = new IntersectionObserver(function (entries) {
|
|
390
428
|
entries.forEach(function (entry) {
|
|
391
429
|
var _entry$rootBounds;
|
|
392
|
-
var tableContainer =
|
|
393
|
-
if (entry.intersectionRect.top === ((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.top)) {
|
|
394
|
-
|
|
430
|
+
var tableContainer = _this5.dom.closest(".".concat(_types.TableCssClassName.TABLE_CONTAINER));
|
|
431
|
+
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'))) {
|
|
432
|
+
_this5.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
|
|
395
433
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
396
434
|
tableContainer.dataset.tableHeaderIsStuck = 'true';
|
|
397
435
|
}
|
|
398
436
|
} else {
|
|
399
|
-
|
|
437
|
+
_this5.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY_ACTIVE);
|
|
400
438
|
if (tableContainer && tableContainer instanceof HTMLElement) {
|
|
401
439
|
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_3')) {
|
|
402
440
|
delete tableContainer.dataset.tableHeaderIsStuck;
|
|
@@ -413,7 +451,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
413
451
|
}, {
|
|
414
452
|
key: "initObservers",
|
|
415
453
|
value: function initObservers() {
|
|
416
|
-
var
|
|
454
|
+
var _this6 = this;
|
|
417
455
|
if (!this.dom || this.dom.dataset.isObserved) {
|
|
418
456
|
return;
|
|
419
457
|
}
|
|
@@ -430,10 +468,17 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
430
468
|
this.dom.style.setProperty('anchor-name', (_this$dom$getAttribut = this.dom.getAttribute('data-node-anchor')) !== null && _this$dom$getAttribut !== void 0 ? _this$dom$getAttribut : '');
|
|
431
469
|
}
|
|
432
470
|
this.initOverflowObserver();
|
|
471
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
|
|
472
|
+
this.initNodeVisibilityObserver();
|
|
473
|
+
}
|
|
433
474
|
var closestTable = this.dom.closest('table');
|
|
434
475
|
if (closestTable) {
|
|
435
476
|
var _this$overflowObserve;
|
|
436
477
|
(_this$overflowObserve = this.overflowObserver) === null || _this$overflowObserve === void 0 || _this$overflowObserve.observe(closestTable);
|
|
478
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
|
|
479
|
+
var _this$nodeVisibilityO2;
|
|
480
|
+
(_this$nodeVisibilityO2 = this.nodeVisibilityObserver) === null || _this$nodeVisibilityO2 === void 0 || _this$nodeVisibilityO2.observe(closestTable);
|
|
481
|
+
}
|
|
437
482
|
}
|
|
438
483
|
this.initStickyStateObserver();
|
|
439
484
|
(_this$stickyStateObse = this.stickyStateObserver) === null || _this$stickyStateObse === void 0 || _this$stickyStateObse.observe(this.dom);
|
|
@@ -447,7 +492,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
447
492
|
window.requestAnimationFrame(function () {
|
|
448
493
|
var getTableContainer = function getTableContainer() {
|
|
449
494
|
var _getTree;
|
|
450
|
-
return (_getTree = (0, _dom2.getTree)(
|
|
495
|
+
return (_getTree = (0, _dom2.getTree)(_this6.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
|
|
451
496
|
};
|
|
452
497
|
|
|
453
498
|
// we expect tree to be defined after animation frame
|
|
@@ -473,16 +518,16 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
473
518
|
return getSentinelTop() !== null && getSentinelBottom() !== null;
|
|
474
519
|
};
|
|
475
520
|
var observeStickySentinels = function observeStickySentinels() {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
[
|
|
521
|
+
_this6.sentinels.top = getSentinelTop();
|
|
522
|
+
_this6.sentinels.bottom = getSentinelBottom();
|
|
523
|
+
[_this6.sentinels.top, _this6.sentinels.bottom].forEach(function (el) {
|
|
479
524
|
// skip if already observed for another row on this table
|
|
480
525
|
if (el && !el.dataset.isObserved) {
|
|
481
526
|
el.dataset.isObserved = 'true';
|
|
482
527
|
|
|
483
528
|
// Ignored via go/ees005
|
|
484
529
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
485
|
-
|
|
530
|
+
_this6.intersectionObserver.observe(el);
|
|
486
531
|
}
|
|
487
532
|
});
|
|
488
533
|
};
|
|
@@ -497,7 +542,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
497
542
|
// observe sentinels before they are in the DOM, use MutationObserver
|
|
498
543
|
// to wait for sentinels to be added to the parent Table node DOM
|
|
499
544
|
// then attach the IntersectionObserver
|
|
500
|
-
|
|
545
|
+
_this6.tableContainerObserver = new MutationObserver(function () {
|
|
501
546
|
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
502
547
|
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
503
548
|
|
|
@@ -505,14 +550,14 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
505
550
|
tableContainer = getTableContainer();
|
|
506
551
|
}
|
|
507
552
|
if (sentinelsInDom()) {
|
|
508
|
-
var
|
|
553
|
+
var _this6$tableContainer;
|
|
509
554
|
observeStickySentinels();
|
|
510
|
-
(
|
|
555
|
+
(_this6$tableContainer = _this6.tableContainerObserver) === null || _this6$tableContainer === void 0 || _this6$tableContainer.disconnect();
|
|
511
556
|
}
|
|
512
557
|
});
|
|
513
558
|
var mutatingNode = tableContainer;
|
|
514
|
-
if (mutatingNode &&
|
|
515
|
-
|
|
559
|
+
if (mutatingNode && _this6.tableContainerObserver) {
|
|
560
|
+
_this6.tableContainerObserver.observe(mutatingNode, {
|
|
516
561
|
subtree: true,
|
|
517
562
|
childList: true
|
|
518
563
|
});
|
|
@@ -522,39 +567,69 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
522
567
|
});
|
|
523
568
|
}
|
|
524
569
|
|
|
570
|
+
// initialise intersection observer to track whether table is in scroll area
|
|
571
|
+
}, {
|
|
572
|
+
key: "initNodeVisibilityObserver",
|
|
573
|
+
value: function initNodeVisibilityObserver() {
|
|
574
|
+
var _this7 = this;
|
|
575
|
+
this.nodeVisibilityObserver = new IntersectionObserver(function (entries) {
|
|
576
|
+
entries.forEach(function (entry) {
|
|
577
|
+
if (!_this7.isNativeSticky) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (entry.intersectionRatio !== 0 && entry.intersectionRatio !== 1) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
if (_this7.disableNativeSticky === true) {
|
|
584
|
+
_this7.dom.classList.remove(_types.TableCssClassName.NATIVE_STICKY);
|
|
585
|
+
}
|
|
586
|
+
if (_this7.disableNativeSticky === false) {
|
|
587
|
+
_this7.dom.classList.add(_types.TableCssClassName.NATIVE_STICKY);
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}, {
|
|
591
|
+
threshold: [0, 0.05, 0.95, 1]
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
525
595
|
// updating bottom sentinel position if sticky header height changes
|
|
526
596
|
// to allocate for new header height
|
|
527
597
|
}, {
|
|
528
598
|
key: "createResizeObserver",
|
|
529
599
|
value: function createResizeObserver() {
|
|
530
|
-
var
|
|
600
|
+
var _this8 = this;
|
|
531
601
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
532
|
-
var tree = (0, _dom2.getTree)(
|
|
602
|
+
var tree = (0, _dom2.getTree)(_this8.dom);
|
|
533
603
|
if (!tree) {
|
|
534
604
|
return;
|
|
535
605
|
}
|
|
536
606
|
var table = tree.table;
|
|
537
607
|
entries.forEach(function (entry) {
|
|
538
|
-
var
|
|
608
|
+
var _this8$editorScrollab;
|
|
539
609
|
// On resize of the parent scroll element we need to adjust the width
|
|
540
610
|
// of the sticky header
|
|
541
611
|
// Ignored via go/ees005
|
|
542
612
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
543
|
-
if (entry.target.className === ((
|
|
544
|
-
|
|
613
|
+
if (entry.target.className === ((_this8$editorScrollab = _this8.editorScrollableElement) === null || _this8$editorScrollab === void 0 ? void 0 : _this8$editorScrollab.className)) {
|
|
614
|
+
_this8.updateStickyHeaderWidth();
|
|
545
615
|
} else {
|
|
546
616
|
var newHeight = entry.contentRect ? entry.contentRect.height :
|
|
547
617
|
// Ignored via go/ees005
|
|
548
618
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
549
619
|
entry.target.offsetHeight;
|
|
550
|
-
if (
|
|
620
|
+
if (_this8.sentinels.bottom &&
|
|
551
621
|
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
552
622
|
// So we adding this check to allow a 1px difference.
|
|
553
|
-
Math.abs(newHeight - (
|
|
554
|
-
|
|
555
|
-
|
|
623
|
+
Math.abs(newHeight - (_this8.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
|
|
624
|
+
_this8.stickyRowHeight = newHeight;
|
|
625
|
+
_this8.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
|
|
556
626
|
(0, _dom.updateStickyMargins)(table);
|
|
557
627
|
}
|
|
628
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_sticky_header_patch_4')) {
|
|
629
|
+
var _this8$editorContentA;
|
|
630
|
+
var viewportHeight = (_this8$editorContentA = _this8.editorContentAreaHeight) !== null && _this8$editorContentA !== void 0 ? _this8$editorContentA : _editorContentAreaHeight.INITIAL_STATIC_VIEWPORT_HEIGHT;
|
|
631
|
+
_this8.toggleDisableNativeSticky(newHeight, viewportHeight);
|
|
632
|
+
}
|
|
558
633
|
}
|
|
559
634
|
});
|
|
560
635
|
});
|
|
@@ -562,13 +637,13 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
562
637
|
}, {
|
|
563
638
|
key: "createIntersectionObserver",
|
|
564
639
|
value: function createIntersectionObserver() {
|
|
565
|
-
var
|
|
640
|
+
var _this9 = this;
|
|
566
641
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
567
|
-
var
|
|
642
|
+
var _this9$editorScrollab, _this9$editorScrollab2;
|
|
568
643
|
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
569
644
|
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
570
645
|
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
571
|
-
var rootBounds = (
|
|
646
|
+
var rootBounds = (_this9$editorScrollab = _this9.editorScrollableElement) === null || _this9$editorScrollab === void 0 || (_this9$editorScrollab2 = _this9$editorScrollab.getBoundingClientRect) === null || _this9$editorScrollab2 === void 0 ? void 0 : _this9$editorScrollab2.call(_this9$editorScrollab);
|
|
572
647
|
entries.forEach(function (entry) {
|
|
573
648
|
var target = entry.target,
|
|
574
649
|
isIntersecting = entry.isIntersecting,
|
|
@@ -576,15 +651,15 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
576
651
|
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
577
652
|
var targetKey = target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
578
653
|
// Cache the latest sentinel information
|
|
579
|
-
|
|
654
|
+
_this9.sentinelData[targetKey] = {
|
|
580
655
|
isIntersecting: isIntersecting,
|
|
581
656
|
boundingClientRect: boundingClientRect,
|
|
582
657
|
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
583
658
|
};
|
|
584
659
|
// Keep the other sentinels rootBounds in sync with this latest one
|
|
585
|
-
|
|
660
|
+
_this9.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
586
661
|
});
|
|
587
|
-
|
|
662
|
+
_this9.refreshLegacyStickyState();
|
|
588
663
|
}, {
|
|
589
664
|
threshold: 0,
|
|
590
665
|
root: this.editorScrollableElement
|
|
@@ -643,27 +718,27 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
643
718
|
value: function isHeaderSticky() {
|
|
644
719
|
var _sentinelTop$rootBoun;
|
|
645
720
|
/*
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
721
|
+
# Overview
|
|
722
|
+
I'm going to list all the view states associated with the sentinels and when they should trigger sticky headers.
|
|
723
|
+
The format of the states are; {top|bottom}:{in|above|below}
|
|
724
|
+
ie sentinel:view-position -- both "above" and "below" are equal to out of the viewport
|
|
725
|
+
For example; "top:in" means top sentinel is within the viewport. "bottom:above" means the bottom sentinel is
|
|
726
|
+
above and out of the viewport
|
|
727
|
+
This will hopefully simplify things and make it easier to determine when sticky should/shouldn't be triggered.
|
|
728
|
+
# States
|
|
729
|
+
top:in / bottom:in - NOT sticky
|
|
730
|
+
top:in / bottom:above - NOT sticky - NOTE: This is an inversion clause
|
|
731
|
+
top:in / bottom:below - NOT sticky
|
|
732
|
+
top:above / bottom:in - STICKY
|
|
733
|
+
top:above / bottom:above - NOT sticky
|
|
734
|
+
top:above / bottom:below - STICKY
|
|
735
|
+
top:below / bottom:in - NOT sticky - NOTE: This is an inversion clause
|
|
736
|
+
top:below / bottom:above - NOT sticky - NOTE: This is an inversion clause
|
|
737
|
+
top:below / bottom:below - NOT sticky
|
|
738
|
+
# Summary
|
|
739
|
+
The only time the header should be sticky is when the top sentinel is above the view and the bottom sentinel
|
|
740
|
+
is in or below it.
|
|
741
|
+
*/
|
|
667
742
|
|
|
668
743
|
var _this$sentinelData = this.sentinelData,
|
|
669
744
|
sentinelTop = _this$sentinelData.top,
|
|
@@ -759,12 +834,12 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
759
834
|
}, {
|
|
760
835
|
key: "refireIntersectionObservers",
|
|
761
836
|
value: function refireIntersectionObservers() {
|
|
762
|
-
var
|
|
837
|
+
var _this0 = this;
|
|
763
838
|
if (this.isLegacySticky) {
|
|
764
839
|
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
765
|
-
if (el &&
|
|
766
|
-
|
|
767
|
-
|
|
840
|
+
if (el && _this0.intersectionObserver) {
|
|
841
|
+
_this0.intersectionObserver.unobserve(el);
|
|
842
|
+
_this0.intersectionObserver.observe(el);
|
|
768
843
|
}
|
|
769
844
|
});
|
|
770
845
|
}
|
|
@@ -773,7 +848,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
773
848
|
key: "makeHeaderRowLegacySticky",
|
|
774
849
|
value: function makeHeaderRowLegacySticky(tree, scrollTop) {
|
|
775
850
|
var _tbody$firstChild,
|
|
776
|
-
|
|
851
|
+
_this1 = this;
|
|
777
852
|
// If header row height is more than 50% of viewport height don't do this
|
|
778
853
|
if (this.isLegacySticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2 || this.isInNestedTable) {
|
|
779
854
|
return;
|
|
@@ -812,7 +887,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
812
887
|
});
|
|
813
888
|
var fastScrollThresholdMs = 500;
|
|
814
889
|
setTimeout(function () {
|
|
815
|
-
|
|
890
|
+
_this1.refireIntersectionObservers();
|
|
816
891
|
}, fastScrollThresholdMs);
|
|
817
892
|
}
|
|
818
893
|
this.dom.style.top = "0px";
|
|
@@ -900,5 +975,4 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
900
975
|
}
|
|
901
976
|
}
|
|
902
977
|
}]);
|
|
903
|
-
}(_TableNodeViewBase.default);
|
|
904
|
-
(0, _defineProperty2.default)(TableRowNativeStickyWithFallback, "hasScrolledSinceLoad", false);
|
|
978
|
+
}(_TableNodeViewBase.default);
|
|
@@ -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
|
+
};
|