@atlaskit/editor-plugin-table 7.3.6 → 7.3.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 +7 -0
- package/dist/cjs/nodeviews/TableRow.js +25 -83
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/es2019/nodeviews/TableRow.js +27 -87
- package/dist/es2019/ui/common-styles.js +1 -1
- package/dist/esm/nodeviews/TableRow.js +26 -84
- package/dist/esm/ui/common-styles.js +1 -1
- package/dist/types/nodeviews/TableRow.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/TableRow.d.ts +0 -1
- package/package.json +2 -5
- package/src/nodeviews/TableRow.ts +32 -106
- package/src/ui/common-styles.ts +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.3.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#70116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70116) [`31f1fa8d4ba3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/31f1fa8d4ba3) - Removed Feature Flag for platform.editor.table.alternative-sticky-header-logic
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 7.3.6
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -15,8 +15,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
15
15
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
16
16
|
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
17
17
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
18
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
21
19
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
22
20
|
var _commands = require("../pm-plugins/sticky-headers/commands");
|
|
@@ -280,88 +278,32 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
|
|
|
280
278
|
key: "createIntersectionObserver",
|
|
281
279
|
value: function createIntersectionObserver() {
|
|
282
280
|
var _this4 = this;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
_this4.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
304
|
-
});
|
|
305
|
-
_this4.refreshStickyState();
|
|
306
|
-
}, {
|
|
307
|
-
threshold: 0,
|
|
308
|
-
root: this.editorScrollableElement
|
|
309
|
-
});
|
|
310
|
-
} else {
|
|
311
|
-
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
312
|
-
var tree = (0, _dom2.getTree)(_this4.dom);
|
|
313
|
-
if (!tree) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
var table = tree.table;
|
|
317
|
-
if (table.rows.length < 2) {
|
|
318
|
-
// ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
|
|
319
|
-
// toggling side-effects because the intersection observers gets confused.
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
entries.forEach(function (entry) {
|
|
323
|
-
var _entry$rootBounds;
|
|
324
|
-
var target = entry.target;
|
|
325
|
-
|
|
326
|
-
// if the rootBounds has 0 height, e.g. confluence preview mode, we do nothing.
|
|
327
|
-
if (((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.height) === 0) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
if (target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP)) {
|
|
331
|
-
var _entry$rootBounds2;
|
|
332
|
-
var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
333
|
-
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
334
|
-
var _entry$rootBounds3;
|
|
335
|
-
tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
336
|
-
_this4.lastStickyTimestamp = Date.now();
|
|
337
|
-
} else {
|
|
338
|
-
table && _this4.makeRowHeaderNotSticky(table);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
if (target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
342
|
-
var _entry$rootBounds4;
|
|
343
|
-
var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
|
|
344
|
-
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
345
|
-
// Not a perfect solution, but need to this code specific for FireFox ED-19177
|
|
346
|
-
if (_utils.browser.gecko) {
|
|
347
|
-
if (_this4.lastStickyTimestamp && Date.now() - _this4.lastStickyTimestamp > _consts.STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
|
|
348
|
-
_this4.makeRowHeaderNotSticky(table);
|
|
349
|
-
}
|
|
350
|
-
} else {
|
|
351
|
-
_this4.makeRowHeaderNotSticky(table);
|
|
352
|
-
}
|
|
353
|
-
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
354
|
-
var _entry$rootBounds5;
|
|
355
|
-
tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
356
|
-
_this4.lastStickyTimestamp = Date.now();
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return;
|
|
360
|
-
});
|
|
361
|
-
}, {
|
|
362
|
-
root: this.editorScrollableElement
|
|
281
|
+
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
282
|
+
var _this4$editorScrollab, _this4$editorScrollab2;
|
|
283
|
+
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
284
|
+
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
285
|
+
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
286
|
+
var rootBounds = (_this4$editorScrollab = _this4.editorScrollableElement) === null || _this4$editorScrollab === void 0 || (_this4$editorScrollab2 = _this4$editorScrollab.getBoundingClientRect) === null || _this4$editorScrollab2 === void 0 ? void 0 : _this4$editorScrollab2.call(_this4$editorScrollab);
|
|
287
|
+
entries.forEach(function (entry) {
|
|
288
|
+
var target = entry.target,
|
|
289
|
+
isIntersecting = entry.isIntersecting,
|
|
290
|
+
boundingClientRect = entry.boundingClientRect;
|
|
291
|
+
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
292
|
+
var targetKey = target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
293
|
+
// Cache the latest sentinel information
|
|
294
|
+
_this4.sentinelData[targetKey] = {
|
|
295
|
+
isIntersecting: isIntersecting,
|
|
296
|
+
boundingClientRect: boundingClientRect,
|
|
297
|
+
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
298
|
+
};
|
|
299
|
+
// Keep the other sentinels rootBounds in sync with this latest one
|
|
300
|
+
_this4.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
363
301
|
});
|
|
364
|
-
|
|
302
|
+
_this4.refreshStickyState();
|
|
303
|
+
}, {
|
|
304
|
+
threshold: 0,
|
|
305
|
+
root: this.editorScrollableElement
|
|
306
|
+
});
|
|
365
307
|
}
|
|
366
308
|
}, {
|
|
367
309
|
key: "refreshStickyState",
|
|
@@ -58,7 +58,7 @@ var tableStickyHeaderFirefoxFixStyle = function tableStickyHeaderFirefoxFixStyle
|
|
|
58
58
|
This fixes a bug which occurs in firefox when the first row becomes sticky.
|
|
59
59
|
see https://product-fabric.atlassian.net/browse/ED-19177
|
|
60
60
|
*/
|
|
61
|
-
if (_utils.browser.gecko
|
|
61
|
+
if (_utils.browser.gecko) {
|
|
62
62
|
return (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n .", " > tbody::before {\n content: '';\n }\n "])), _types.TableCssClassName.TABLE_STICKY);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
@@ -2,14 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import debounce from 'lodash/debounce';
|
|
3
3
|
import throttle from 'lodash/throttle';
|
|
4
4
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
5
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
8
6
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
9
7
|
import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
|
|
10
8
|
import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
|
|
11
9
|
import { TableCssClassName as ClassName, TableCssClassName } from '../types';
|
|
12
|
-
import {
|
|
10
|
+
import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
|
|
13
11
|
import { getTop, getTree } from '../utils/dom';
|
|
14
12
|
import { supportedHeaderRow } from '../utils/nodes';
|
|
15
13
|
import TableNodeView from './TableNodeViewBase';
|
|
@@ -244,92 +242,34 @@ export default class TableRow extends TableNodeView {
|
|
|
244
242
|
});
|
|
245
243
|
}
|
|
246
244
|
createIntersectionObserver() {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
entries.forEach(entry => {
|
|
255
|
-
const {
|
|
256
|
-
target,
|
|
257
|
-
isIntersecting,
|
|
258
|
-
boundingClientRect
|
|
259
|
-
} = entry;
|
|
260
|
-
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
261
|
-
const targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
262
|
-
// Cache the latest sentinel information
|
|
263
|
-
this.sentinelData[targetKey] = {
|
|
264
|
-
isIntersecting,
|
|
265
|
-
boundingClientRect,
|
|
266
|
-
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
267
|
-
};
|
|
268
|
-
// Keep the other sentinels rootBounds in sync with this latest one
|
|
269
|
-
this.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
270
|
-
});
|
|
271
|
-
this.refreshStickyState();
|
|
272
|
-
}, {
|
|
273
|
-
threshold: 0,
|
|
274
|
-
root: this.editorScrollableElement
|
|
275
|
-
});
|
|
276
|
-
} else {
|
|
277
|
-
this.intersectionObserver = new IntersectionObserver((entries, _) => {
|
|
278
|
-
const tree = getTree(this.dom);
|
|
279
|
-
if (!tree) {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
245
|
+
this.intersectionObserver = new IntersectionObserver((entries, _) => {
|
|
246
|
+
var _this$editorScrollabl2, _this$editorScrollabl3;
|
|
247
|
+
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
248
|
+
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
249
|
+
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
250
|
+
const rootBounds = (_this$editorScrollabl2 = this.editorScrollableElement) === null || _this$editorScrollabl2 === void 0 ? void 0 : (_this$editorScrollabl3 = _this$editorScrollabl2.getBoundingClientRect) === null || _this$editorScrollabl3 === void 0 ? void 0 : _this$editorScrollabl3.call(_this$editorScrollabl2);
|
|
251
|
+
entries.forEach(entry => {
|
|
282
252
|
const {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP)) {
|
|
299
|
-
var _entry$rootBounds2;
|
|
300
|
-
const sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
301
|
-
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
302
|
-
var _entry$rootBounds3;
|
|
303
|
-
tree && this.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
304
|
-
this.lastStickyTimestamp = Date.now();
|
|
305
|
-
} else {
|
|
306
|
-
table && this.makeRowHeaderNotSticky(table);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
310
|
-
var _entry$rootBounds4;
|
|
311
|
-
const sentinelIsAboveScrollArea = entry.boundingClientRect.top - this.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
|
|
312
|
-
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
313
|
-
// Not a perfect solution, but need to this code specific for FireFox ED-19177
|
|
314
|
-
if (browser.gecko) {
|
|
315
|
-
if (this.lastStickyTimestamp && Date.now() - this.lastStickyTimestamp > STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
|
|
316
|
-
this.makeRowHeaderNotSticky(table);
|
|
317
|
-
}
|
|
318
|
-
} else {
|
|
319
|
-
this.makeRowHeaderNotSticky(table);
|
|
320
|
-
}
|
|
321
|
-
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
322
|
-
var _entry$rootBounds5;
|
|
323
|
-
tree && this.makeHeaderRowSticky(tree, entry === null || entry === void 0 ? void 0 : (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
324
|
-
this.lastStickyTimestamp = Date.now();
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return;
|
|
328
|
-
});
|
|
329
|
-
}, {
|
|
330
|
-
root: this.editorScrollableElement
|
|
253
|
+
target,
|
|
254
|
+
isIntersecting,
|
|
255
|
+
boundingClientRect
|
|
256
|
+
} = entry;
|
|
257
|
+
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
258
|
+
const targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
259
|
+
// Cache the latest sentinel information
|
|
260
|
+
this.sentinelData[targetKey] = {
|
|
261
|
+
isIntersecting,
|
|
262
|
+
boundingClientRect,
|
|
263
|
+
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
264
|
+
};
|
|
265
|
+
// Keep the other sentinels rootBounds in sync with this latest one
|
|
266
|
+
this.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
331
267
|
});
|
|
332
|
-
|
|
268
|
+
this.refreshStickyState();
|
|
269
|
+
}, {
|
|
270
|
+
threshold: 0,
|
|
271
|
+
root: this.editorScrollableElement
|
|
272
|
+
});
|
|
333
273
|
}
|
|
334
274
|
refreshStickyState() {
|
|
335
275
|
const tree = getTree(this.dom);
|
|
@@ -165,7 +165,7 @@ const tableStickyHeaderFirefoxFixStyle = () => {
|
|
|
165
165
|
This fixes a bug which occurs in firefox when the first row becomes sticky.
|
|
166
166
|
see https://product-fabric.atlassian.net/browse/ED-19177
|
|
167
167
|
*/
|
|
168
|
-
if (browser.gecko
|
|
168
|
+
if (browser.gecko) {
|
|
169
169
|
return css`
|
|
170
170
|
.${ClassName.TABLE_STICKY} > tbody::before {
|
|
171
171
|
content: '';
|
|
@@ -10,14 +10,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
10
10
|
import debounce from 'lodash/debounce';
|
|
11
11
|
import throttle from 'lodash/throttle';
|
|
12
12
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
14
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
16
14
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
17
15
|
import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
|
|
18
16
|
import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
|
|
19
17
|
import { TableCssClassName as ClassName, TableCssClassName } from '../types';
|
|
20
|
-
import {
|
|
18
|
+
import { stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
|
|
21
19
|
import { getTop, getTree } from '../utils/dom';
|
|
22
20
|
import { supportedHeaderRow } from '../utils/nodes';
|
|
23
21
|
import TableNodeView from './TableNodeViewBase';
|
|
@@ -273,88 +271,32 @@ var TableRow = /*#__PURE__*/function (_ref) {
|
|
|
273
271
|
key: "createIntersectionObserver",
|
|
274
272
|
value: function createIntersectionObserver() {
|
|
275
273
|
var _this4 = this;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
_this4.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
297
|
-
});
|
|
298
|
-
_this4.refreshStickyState();
|
|
299
|
-
}, {
|
|
300
|
-
threshold: 0,
|
|
301
|
-
root: this.editorScrollableElement
|
|
302
|
-
});
|
|
303
|
-
} else {
|
|
304
|
-
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
305
|
-
var tree = getTree(_this4.dom);
|
|
306
|
-
if (!tree) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
var table = tree.table;
|
|
310
|
-
if (table.rows.length < 2) {
|
|
311
|
-
// ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
|
|
312
|
-
// toggling side-effects because the intersection observers gets confused.
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
entries.forEach(function (entry) {
|
|
316
|
-
var _entry$rootBounds;
|
|
317
|
-
var target = entry.target;
|
|
318
|
-
|
|
319
|
-
// if the rootBounds has 0 height, e.g. confluence preview mode, we do nothing.
|
|
320
|
-
if (((_entry$rootBounds = entry.rootBounds) === null || _entry$rootBounds === void 0 ? void 0 : _entry$rootBounds.height) === 0) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP)) {
|
|
324
|
-
var _entry$rootBounds2;
|
|
325
|
-
var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
326
|
-
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
327
|
-
var _entry$rootBounds3;
|
|
328
|
-
tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
329
|
-
_this4.lastStickyTimestamp = Date.now();
|
|
330
|
-
} else {
|
|
331
|
-
table && _this4.makeRowHeaderNotSticky(table);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
335
|
-
var _entry$rootBounds4;
|
|
336
|
-
var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
|
|
337
|
-
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
338
|
-
// Not a perfect solution, but need to this code specific for FireFox ED-19177
|
|
339
|
-
if (browser.gecko) {
|
|
340
|
-
if (_this4.lastStickyTimestamp && Date.now() - _this4.lastStickyTimestamp > STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
|
|
341
|
-
_this4.makeRowHeaderNotSticky(table);
|
|
342
|
-
}
|
|
343
|
-
} else {
|
|
344
|
-
_this4.makeRowHeaderNotSticky(table);
|
|
345
|
-
}
|
|
346
|
-
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
347
|
-
var _entry$rootBounds5;
|
|
348
|
-
tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
349
|
-
_this4.lastStickyTimestamp = Date.now();
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return;
|
|
353
|
-
});
|
|
354
|
-
}, {
|
|
355
|
-
root: this.editorScrollableElement
|
|
274
|
+
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
275
|
+
var _this4$editorScrollab, _this4$editorScrollab2;
|
|
276
|
+
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
277
|
+
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
278
|
+
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
279
|
+
var rootBounds = (_this4$editorScrollab = _this4.editorScrollableElement) === null || _this4$editorScrollab === void 0 || (_this4$editorScrollab2 = _this4$editorScrollab.getBoundingClientRect) === null || _this4$editorScrollab2 === void 0 ? void 0 : _this4$editorScrollab2.call(_this4$editorScrollab);
|
|
280
|
+
entries.forEach(function (entry) {
|
|
281
|
+
var target = entry.target,
|
|
282
|
+
isIntersecting = entry.isIntersecting,
|
|
283
|
+
boundingClientRect = entry.boundingClientRect;
|
|
284
|
+
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
285
|
+
var targetKey = target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP) ? 'top' : 'bottom';
|
|
286
|
+
// Cache the latest sentinel information
|
|
287
|
+
_this4.sentinelData[targetKey] = {
|
|
288
|
+
isIntersecting: isIntersecting,
|
|
289
|
+
boundingClientRect: boundingClientRect,
|
|
290
|
+
rootBounds: rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds
|
|
291
|
+
};
|
|
292
|
+
// Keep the other sentinels rootBounds in sync with this latest one
|
|
293
|
+
_this4.sentinelData[targetKey === 'top' ? 'bottom' : targetKey].rootBounds = rootBounds !== null && rootBounds !== void 0 ? rootBounds : entry.rootBounds;
|
|
356
294
|
});
|
|
357
|
-
|
|
295
|
+
_this4.refreshStickyState();
|
|
296
|
+
}, {
|
|
297
|
+
threshold: 0,
|
|
298
|
+
root: this.editorScrollableElement
|
|
299
|
+
});
|
|
358
300
|
}
|
|
359
301
|
}, {
|
|
360
302
|
key: "refreshStickyState",
|
|
@@ -51,7 +51,7 @@ var tableStickyHeaderFirefoxFixStyle = function tableStickyHeaderFirefoxFixStyle
|
|
|
51
51
|
This fixes a bug which occurs in firefox when the first row becomes sticky.
|
|
52
52
|
see https://product-fabric.atlassian.net/browse/ED-19177
|
|
53
53
|
*/
|
|
54
|
-
if (browser.gecko
|
|
54
|
+
if (browser.gecko) {
|
|
55
55
|
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n .", " > tbody::before {\n content: '';\n }\n "])), ClassName.TABLE_STICKY);
|
|
56
56
|
}
|
|
57
57
|
};
|
|
@@ -14,7 +14,6 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
14
14
|
private focused;
|
|
15
15
|
private topPosEditorElement;
|
|
16
16
|
private isSticky;
|
|
17
|
-
private lastStickyTimestamp;
|
|
18
17
|
private intersectionObserver?;
|
|
19
18
|
private resizeObserver?;
|
|
20
19
|
private sentinels;
|
|
@@ -14,7 +14,6 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
14
14
|
private focused;
|
|
15
15
|
private topPosEditorElement;
|
|
16
16
|
private isSticky;
|
|
17
|
-
private lastStickyTimestamp;
|
|
18
17
|
private intersectionObserver?;
|
|
19
18
|
private resizeObserver?;
|
|
20
19
|
private sentinels;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.7",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^35.5.1",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.0.13",
|
|
33
|
-
"@atlaskit/editor-common": "^78.
|
|
33
|
+
"@atlaskit/editor-common": "^78.1.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.2",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^1.0.0",
|
|
@@ -117,9 +117,6 @@
|
|
|
117
117
|
"platform.editor.table.shift-arrowup-fix": {
|
|
118
118
|
"type": "boolean"
|
|
119
119
|
},
|
|
120
|
-
"platform.editor.table.alternative-sticky-header-logic": {
|
|
121
|
-
"type": "boolean"
|
|
122
|
-
},
|
|
123
120
|
"platform.editor.table.analytics-plugin-moved-event": {
|
|
124
121
|
"type": "boolean"
|
|
125
122
|
},
|
|
@@ -3,10 +3,8 @@ import throttle from 'lodash/throttle';
|
|
|
3
3
|
|
|
4
4
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
5
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
6
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
6
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
7
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
8
|
|
|
11
9
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
12
10
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -18,7 +16,6 @@ import {
|
|
|
18
16
|
import type { TablePluginState } from '../types';
|
|
19
17
|
import { TableCssClassName as ClassName, TableCssClassName } from '../types';
|
|
20
18
|
import {
|
|
21
|
-
STICKY_HEADER_TOGGLE_TOLERANCE_MS,
|
|
22
19
|
stickyHeaderBorderBottomWidth,
|
|
23
20
|
stickyRowOffsetTop,
|
|
24
21
|
tableControlsSpacing,
|
|
@@ -80,7 +77,6 @@ export default class TableRow
|
|
|
80
77
|
private focused = false;
|
|
81
78
|
private topPosEditorElement = 0;
|
|
82
79
|
private isSticky: boolean;
|
|
83
|
-
private lastStickyTimestamp: number | undefined;
|
|
84
80
|
private intersectionObserver?: IntersectionObserver;
|
|
85
81
|
private resizeObserver?: ResizeObserver;
|
|
86
82
|
private sentinels: {
|
|
@@ -349,108 +345,38 @@ export default class TableRow
|
|
|
349
345
|
}
|
|
350
346
|
|
|
351
347
|
private createIntersectionObserver() {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
);
|
|
385
|
-
} else {
|
|
386
|
-
this.intersectionObserver = new IntersectionObserver(
|
|
387
|
-
(entries: IntersectionObserverEntry[], _: IntersectionObserver) => {
|
|
388
|
-
const tree = getTree(this.dom);
|
|
389
|
-
if (!tree) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
const { table } = tree;
|
|
393
|
-
|
|
394
|
-
if (table.rows.length < 2) {
|
|
395
|
-
// ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
|
|
396
|
-
// toggling side-effects because the intersection observers gets confused.
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
entries.forEach((entry) => {
|
|
401
|
-
const target = entry.target as HTMLElement;
|
|
402
|
-
|
|
403
|
-
// if the rootBounds has 0 height, e.g. confluence preview mode, we do nothing.
|
|
404
|
-
if (entry.rootBounds?.height === 0) {
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (
|
|
409
|
-
target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_TOP)
|
|
410
|
-
) {
|
|
411
|
-
const sentinelIsBelowScrollArea =
|
|
412
|
-
(entry.rootBounds?.bottom || 0) <
|
|
413
|
-
entry.boundingClientRect.bottom;
|
|
414
|
-
|
|
415
|
-
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
416
|
-
tree && this.makeHeaderRowSticky(tree, entry.rootBounds?.top);
|
|
417
|
-
this.lastStickyTimestamp = Date.now();
|
|
418
|
-
} else {
|
|
419
|
-
table && this.makeRowHeaderNotSticky(table);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (
|
|
424
|
-
target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)
|
|
425
|
-
) {
|
|
426
|
-
const sentinelIsAboveScrollArea =
|
|
427
|
-
entry.boundingClientRect.top - this.dom.offsetHeight <
|
|
428
|
-
(entry.rootBounds?.top || 0);
|
|
429
|
-
|
|
430
|
-
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
431
|
-
// Not a perfect solution, but need to this code specific for FireFox ED-19177
|
|
432
|
-
if (browser.gecko) {
|
|
433
|
-
if (
|
|
434
|
-
this.lastStickyTimestamp &&
|
|
435
|
-
Date.now() - this.lastStickyTimestamp >
|
|
436
|
-
STICKY_HEADER_TOGGLE_TOLERANCE_MS
|
|
437
|
-
) {
|
|
438
|
-
this.makeRowHeaderNotSticky(table);
|
|
439
|
-
}
|
|
440
|
-
} else {
|
|
441
|
-
this.makeRowHeaderNotSticky(table);
|
|
442
|
-
}
|
|
443
|
-
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
444
|
-
tree && this.makeHeaderRowSticky(tree, entry?.rootBounds?.top);
|
|
445
|
-
this.lastStickyTimestamp = Date.now();
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
return;
|
|
449
|
-
});
|
|
450
|
-
},
|
|
451
|
-
{ root: this.editorScrollableElement as Element },
|
|
452
|
-
);
|
|
453
|
-
}
|
|
348
|
+
this.intersectionObserver = new IntersectionObserver(
|
|
349
|
+
(entries: IntersectionObserverEntry[], _: IntersectionObserver) => {
|
|
350
|
+
// IMPORTANT: please try and avoid using entry.rootBounds it's terribly inconsistent. For example; sometimes it may return
|
|
351
|
+
// 0 height. In safari it will multiply all values by the window scale factor, however chrome & firfox won't.
|
|
352
|
+
// This is why i just get the scroll view bounding rect here and use it, and fallback to the entry.rootBounds if needed.
|
|
353
|
+
const rootBounds = (
|
|
354
|
+
this.editorScrollableElement as Element
|
|
355
|
+
)?.getBoundingClientRect?.();
|
|
356
|
+
|
|
357
|
+
entries.forEach((entry) => {
|
|
358
|
+
const { target, isIntersecting, boundingClientRect } = entry;
|
|
359
|
+
// This observer only every looks at the top/bottom sentinels, we can assume if it's not one then it's the other.
|
|
360
|
+
const targetKey = target.classList.contains(
|
|
361
|
+
ClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
362
|
+
)
|
|
363
|
+
? 'top'
|
|
364
|
+
: 'bottom';
|
|
365
|
+
// Cache the latest sentinel information
|
|
366
|
+
this.sentinelData[targetKey] = {
|
|
367
|
+
isIntersecting,
|
|
368
|
+
boundingClientRect,
|
|
369
|
+
rootBounds: rootBounds ?? entry.rootBounds,
|
|
370
|
+
};
|
|
371
|
+
// Keep the other sentinels rootBounds in sync with this latest one
|
|
372
|
+
this.sentinelData[
|
|
373
|
+
targetKey === 'top' ? 'bottom' : targetKey
|
|
374
|
+
].rootBounds = rootBounds ?? entry.rootBounds;
|
|
375
|
+
});
|
|
376
|
+
this.refreshStickyState();
|
|
377
|
+
},
|
|
378
|
+
{ threshold: 0, root: this.editorScrollableElement as Element },
|
|
379
|
+
);
|
|
454
380
|
}
|
|
455
381
|
|
|
456
382
|
private refreshStickyState() {
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -247,10 +247,7 @@ const tableStickyHeaderFirefoxFixStyle = () => {
|
|
|
247
247
|
This fixes a bug which occurs in firefox when the first row becomes sticky.
|
|
248
248
|
see https://product-fabric.atlassian.net/browse/ED-19177
|
|
249
249
|
*/
|
|
250
|
-
if (
|
|
251
|
-
browser.gecko &&
|
|
252
|
-
getBooleanFF('platform.editor.table.alternative-sticky-header-logic')
|
|
253
|
-
) {
|
|
250
|
+
if (browser.gecko) {
|
|
254
251
|
return css`
|
|
255
252
|
.${ClassName.TABLE_STICKY} > tbody::before {
|
|
256
253
|
content: '';
|