@atlaskit/editor-plugin-table 10.10.7 → 10.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/nodeviews/TableComponent.js +48 -24
- package/dist/cjs/nodeviews/TableRow.js +29 -7
- package/dist/es2019/nodeviews/TableComponent.js +22 -0
- package/dist/es2019/nodeviews/TableRow.js +24 -3
- package/dist/esm/nodeviews/TableComponent.js +48 -24
- package/dist/esm/nodeviews/TableRow.js +29 -7
- package/dist/types/nodeviews/TableRow.d.ts +2 -0
- package/dist/types-ts4.5/nodeviews/TableRow.d.ts +2 -0
- package/package.json +6 -6
- package/src/nodeviews/TableComponent.tsx +24 -0
- package/src/nodeviews/TableRow.ts +27 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#156919](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/156919)
|
|
8
|
+
[`379f5c27f4939`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/379f5c27f4939) -
|
|
9
|
+
delay table sticky headers until table is in viewport
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 10.10.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -20,6 +20,7 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
20
20
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
21
21
|
var _collab = require("@atlaskit/editor-common/collab");
|
|
22
22
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
23
|
+
var _nodeVisibility = require("@atlaskit/editor-common/node-visibility");
|
|
23
24
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
24
25
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
25
26
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -27,6 +28,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
27
28
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
28
29
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
29
30
|
var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
31
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
30
32
|
var _commands = require("../pm-plugins/commands");
|
|
31
33
|
var _autoscrollers = require("../pm-plugins/drag-and-drop/utils/autoscrollers");
|
|
32
34
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
@@ -400,10 +402,29 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
400
402
|
return (0, _createClass2.default)(TableComponent, [{
|
|
401
403
|
key: "componentDidMount",
|
|
402
404
|
value: function componentDidMount() {
|
|
405
|
+
var _this2 = this;
|
|
406
|
+
if ((0, _experiments.editorExperiment)('platform_editor_nodevisibility', false)) {
|
|
407
|
+
this.initialiseEventListenersAfterMount();
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
var _nodeVisibilityManage = (0, _nodeVisibility.nodeVisibilityManager)(this.props.view.dom),
|
|
411
|
+
observe = _nodeVisibilityManage.observe;
|
|
412
|
+
if (this.table) {
|
|
413
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
414
|
+
element: this.table,
|
|
415
|
+
onFirstVisible: function onFirstVisible() {
|
|
416
|
+
_this2.initialiseEventListenersAfterMount();
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}, {
|
|
422
|
+
key: "initialiseEventListenersAfterMount",
|
|
423
|
+
value: function initialiseEventListenersAfterMount() {
|
|
403
424
|
var _this$table,
|
|
404
425
|
_this$table2,
|
|
405
426
|
_this$table3,
|
|
406
|
-
|
|
427
|
+
_this3 = this;
|
|
407
428
|
var _this$props7 = this.props,
|
|
408
429
|
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
409
430
|
allowTableResizing = _this$props7.allowTableResizing,
|
|
@@ -441,7 +462,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
441
462
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
442
463
|
var _entry$contentRect3;
|
|
443
464
|
var entry = _step2.value;
|
|
444
|
-
|
|
465
|
+
_this3.wrapperWidth = (_entry$contentRect3 = entry.contentRect) === null || _entry$contentRect3 === void 0 ? void 0 : _entry$contentRect3.width;
|
|
445
466
|
}
|
|
446
467
|
} catch (err) {
|
|
447
468
|
_iterator2.e(err);
|
|
@@ -515,6 +536,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
515
536
|
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
516
537
|
this.dragAndDropCleanupFn();
|
|
517
538
|
}
|
|
539
|
+
if (this.nodeVisibilityObserverCleanupFn) {
|
|
540
|
+
this.nodeVisibilityObserverCleanupFn();
|
|
541
|
+
}
|
|
518
542
|
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
519
543
|
(_this$wrapperReisizeO = this.wrapperReisizeObserver) === null || _this$wrapperReisizeO === void 0 || _this$wrapperReisizeO.disconnect();
|
|
520
544
|
if (this.stickyScrollbar) {
|
|
@@ -584,7 +608,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
584
608
|
key: "handleColgroupUpdates",
|
|
585
609
|
value: function handleColgroupUpdates() {
|
|
586
610
|
var _this$containerWidth,
|
|
587
|
-
|
|
611
|
+
_this4 = this;
|
|
588
612
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
589
613
|
var _this$props10 = this.props,
|
|
590
614
|
getNode = _this$props10.getNode,
|
|
@@ -661,26 +685,26 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
661
685
|
}
|
|
662
686
|
var scalePercent = 1;
|
|
663
687
|
requestAnimationFrame(function () {
|
|
664
|
-
var
|
|
688
|
+
var _this4$props$options, _this4$props$options2;
|
|
665
689
|
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
666
690
|
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
667
691
|
// inside of getTableScalingPercent returns 0.
|
|
668
|
-
if (!((
|
|
692
|
+
if (!((_this4$props$options = _this4.props.options) !== null && _this4$props$options !== void 0 && _this4$props$options.isCommentEditor) || (_this4$props$options2 = _this4.props.options) !== null && _this4$props$options2 !== void 0 && _this4$props$options2.isCommentEditor && tableNode.attrs.width) {
|
|
669
693
|
scalePercent = (0, _misc.getTableScalingPercent)(tableNode,
|
|
670
694
|
// Ignored via go/ees005
|
|
671
695
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
672
|
-
|
|
696
|
+
_this4.table, shouldUseIncreasedScalingPercent);
|
|
673
697
|
} else {
|
|
674
698
|
// Ignored via go/ees005
|
|
675
699
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
676
|
-
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode,
|
|
700
|
+
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode, _this4.table);
|
|
677
701
|
}
|
|
678
702
|
|
|
679
703
|
// Request animation frame required for Firefox
|
|
680
704
|
(0, _resizeState.updateColgroup)(resizeState,
|
|
681
705
|
// Ignored via go/ees005
|
|
682
706
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
683
|
-
|
|
707
|
+
_this4.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
684
708
|
});
|
|
685
709
|
}
|
|
686
710
|
}
|
|
@@ -700,7 +724,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
700
724
|
var _this$props$options8,
|
|
701
725
|
_this$props$options9,
|
|
702
726
|
_this$wrapper,
|
|
703
|
-
|
|
727
|
+
_this5 = this;
|
|
704
728
|
var _this$props11 = this.props,
|
|
705
729
|
view = _this$props11.view,
|
|
706
730
|
getNode = _this$props11.getNode,
|
|
@@ -748,10 +772,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
748
772
|
// that happens when a table is nested in expand and expand's width is
|
|
749
773
|
// changed via breakout button
|
|
750
774
|
window.requestAnimationFrame(function () {
|
|
751
|
-
|
|
775
|
+
_this5.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_view_mode_sort') ? _this5.updateShadowStateDebounced : _this5.updateShadowState,
|
|
752
776
|
// Ignored via go/ees005
|
|
753
777
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
754
|
-
|
|
778
|
+
_this5.table, _this5.wrapper);
|
|
755
779
|
});
|
|
756
780
|
} else {
|
|
757
781
|
this.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
@@ -828,7 +852,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
828
852
|
}, {
|
|
829
853
|
key: "render",
|
|
830
854
|
value: function render() {
|
|
831
|
-
var
|
|
855
|
+
var _this6 = this,
|
|
832
856
|
_this$props$options10;
|
|
833
857
|
var _this$props12 = this.props,
|
|
834
858
|
view = _this$props12.view,
|
|
@@ -918,8 +942,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
918
942
|
tableContainerWidth: tableContainerWidth,
|
|
919
943
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
920
944
|
getScrollOffset: function getScrollOffset() {
|
|
921
|
-
var
|
|
922
|
-
return ((
|
|
945
|
+
var _this6$wrapper;
|
|
946
|
+
return ((_this6$wrapper = _this6.wrapper) === null || _this6$wrapper === void 0 ? void 0 : _this6$wrapper.scrollLeft) || 0;
|
|
923
947
|
},
|
|
924
948
|
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
925
949
|
api: pluginInjectionApi,
|
|
@@ -991,12 +1015,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
991
1015
|
editorView: view,
|
|
992
1016
|
node: node,
|
|
993
1017
|
getScrollOffset: function getScrollOffset() {
|
|
994
|
-
var
|
|
995
|
-
return ((
|
|
1018
|
+
var _this6$wrapper2;
|
|
1019
|
+
return ((_this6$wrapper2 = _this6.wrapper) === null || _this6$wrapper2 === void 0 ? void 0 : _this6$wrapper2.scrollLeft) || 0;
|
|
996
1020
|
},
|
|
997
1021
|
getTableWrapperWidth: function getTableWrapperWidth() {
|
|
998
|
-
var
|
|
999
|
-
return ((
|
|
1022
|
+
var _this6$wrapper3;
|
|
1023
|
+
return ((_this6$wrapper3 = _this6.wrapper) === null || _this6$wrapper3 === void 0 ? void 0 : _this6$wrapper3.clientWidth) || 760;
|
|
1000
1024
|
}
|
|
1001
1025
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
1002
1026
|
contentEditable: false
|
|
@@ -1018,14 +1042,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1018
1042
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1019
1043
|
className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_NODE_WRAPPER),
|
|
1020
1044
|
ref: function ref(elem) {
|
|
1021
|
-
|
|
1045
|
+
_this6.wrapper = elem;
|
|
1022
1046
|
if (elem) {
|
|
1023
|
-
|
|
1047
|
+
_this6.props.contentDOM(elem);
|
|
1024
1048
|
var tableElement = elem.querySelector('table');
|
|
1025
|
-
if (tableElement !==
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1049
|
+
if (tableElement !== _this6.table) {
|
|
1050
|
+
_this6.table = tableElement;
|
|
1051
|
+
_this6.createShadowSentinels(_this6.table);
|
|
1052
|
+
_this6.observeTable(_this6.table);
|
|
1029
1053
|
}
|
|
1030
1054
|
}
|
|
1031
1055
|
}
|
|
@@ -14,9 +14,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
14
14
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
15
15
|
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
16
16
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
17
|
+
var _nodeVisibility = require("@atlaskit/editor-common/node-visibility");
|
|
17
18
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
19
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
19
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
20
22
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
21
23
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
22
24
|
var _commands = require("../pm-plugins/sticky-headers/commands");
|
|
@@ -84,19 +86,38 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
84
86
|
_this.isInNestedTable = (0, _nesting.getParentOfTypeCount)(view.state.schema.nodes.table)(view.state.doc.resolve(pos)) > 1;
|
|
85
87
|
}
|
|
86
88
|
if (_this.isHeaderRow) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
if ((0, _experiments.editorExperiment)('platform_editor_nodevisibility', false)) {
|
|
90
|
+
_this.subscribeWhenRowVisible();
|
|
91
|
+
} else {
|
|
92
|
+
var _nodeVisibilityManage = (0, _nodeVisibility.nodeVisibilityManager)(view.dom),
|
|
93
|
+
observe = _nodeVisibilityManage.observe;
|
|
94
|
+
_this.nodeVisibilityObserverCleanupFn = observe({
|
|
95
|
+
element: _this.contentDOM,
|
|
96
|
+
onFirstVisible: function onFirstVisible() {
|
|
97
|
+
_this.subscribeWhenRowVisible();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
return _this;
|
|
93
103
|
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Variables
|
|
97
|
-
*/
|
|
98
104
|
(0, _inherits2.default)(TableRow, _TableNodeView);
|
|
99
105
|
return (0, _createClass2.default)(TableRow, [{
|
|
106
|
+
key: "subscribeWhenRowVisible",
|
|
107
|
+
value: function subscribeWhenRowVisible() {
|
|
108
|
+
if (this.listening) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.dom.setAttribute('data-header-row', 'true');
|
|
112
|
+
if (this.isStickyHeaderEnabled) {
|
|
113
|
+
this.subscribe();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Variables
|
|
119
|
+
*/
|
|
120
|
+
}, {
|
|
100
121
|
key: "update",
|
|
101
122
|
value:
|
|
102
123
|
/**
|
|
@@ -138,6 +159,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
138
159
|
value: function destroy() {
|
|
139
160
|
if (this.isStickyHeaderEnabled) {
|
|
140
161
|
this.unsubscribe();
|
|
162
|
+
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
141
163
|
var tree = (0, _dom2.getTree)(this.dom);
|
|
142
164
|
if (tree) {
|
|
143
165
|
this.makeRowHeaderNotSticky(tree.table, true);
|
|
@@ -7,6 +7,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
7
7
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
|
|
9
9
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
10
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
10
11
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
11
12
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
12
13
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
@@ -14,6 +15,7 @@ import { akEditorTableNumberColumnWidth, akEditorTableToolbarSize as tableToolba
|
|
|
14
15
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
18
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
17
19
|
import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
|
|
18
20
|
import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
|
|
19
21
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -385,6 +387,23 @@ class TableComponent extends React.Component {
|
|
|
385
387
|
}
|
|
386
388
|
}
|
|
387
389
|
componentDidMount() {
|
|
390
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
391
|
+
this.initialiseEventListenersAfterMount();
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const {
|
|
395
|
+
observe
|
|
396
|
+
} = nodeVisibilityManager(this.props.view.dom);
|
|
397
|
+
if (this.table) {
|
|
398
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
399
|
+
element: this.table,
|
|
400
|
+
onFirstVisible: () => {
|
|
401
|
+
this.initialiseEventListenersAfterMount();
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
initialiseEventListenersAfterMount() {
|
|
388
407
|
var _this$table, _this$table2, _this$table3;
|
|
389
408
|
const {
|
|
390
409
|
allowColumnResizing,
|
|
@@ -488,6 +507,9 @@ class TableComponent extends React.Component {
|
|
|
488
507
|
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
489
508
|
this.dragAndDropCleanupFn();
|
|
490
509
|
}
|
|
510
|
+
if (this.nodeVisibilityObserverCleanupFn) {
|
|
511
|
+
this.nodeVisibilityObserverCleanupFn();
|
|
512
|
+
}
|
|
491
513
|
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 ? void 0 : _this$resizeObserver.disconnect();
|
|
492
514
|
(_this$wrapperReisizeO = this.wrapperReisizeObserver) === null || _this$wrapperReisizeO === void 0 ? void 0 : _this$wrapperReisizeO.disconnect();
|
|
493
515
|
if (this.stickyScrollbar) {
|
|
@@ -2,9 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import debounce from 'lodash/debounce';
|
|
3
3
|
import throttle from 'lodash/throttle';
|
|
4
4
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
5
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
5
6
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
6
7
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
10
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
9
11
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
10
12
|
import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
|
|
@@ -69,12 +71,30 @@ export default class TableRow extends TableNodeView {
|
|
|
69
71
|
this.isInNestedTable = getParentOfTypeCount(view.state.schema.nodes.table)(view.state.doc.resolve(pos)) > 1;
|
|
70
72
|
}
|
|
71
73
|
if (this.isHeaderRow) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
75
|
+
this.subscribeWhenRowVisible();
|
|
76
|
+
} else {
|
|
77
|
+
const {
|
|
78
|
+
observe
|
|
79
|
+
} = nodeVisibilityManager(view.dom);
|
|
80
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
81
|
+
element: this.contentDOM,
|
|
82
|
+
onFirstVisible: () => {
|
|
83
|
+
this.subscribeWhenRowVisible();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
}
|
|
89
|
+
subscribeWhenRowVisible() {
|
|
90
|
+
if (this.listening) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.dom.setAttribute('data-header-row', 'true');
|
|
94
|
+
if (this.isStickyHeaderEnabled) {
|
|
95
|
+
this.subscribe();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
78
98
|
|
|
79
99
|
/**
|
|
80
100
|
* Variables
|
|
@@ -117,6 +137,7 @@ export default class TableRow extends TableNodeView {
|
|
|
117
137
|
destroy() {
|
|
118
138
|
if (this.isStickyHeaderEnabled) {
|
|
119
139
|
this.unsubscribe();
|
|
140
|
+
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
120
141
|
const tree = getTree(this.dom);
|
|
121
142
|
if (tree) {
|
|
122
143
|
this.makeRowHeaderNotSticky(tree.table, true);
|
|
@@ -20,6 +20,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
20
20
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
21
21
|
import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
|
|
22
22
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
23
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
23
24
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
24
25
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
25
26
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
@@ -27,6 +28,7 @@ import { akEditorTableNumberColumnWidth, akEditorTableToolbarSize as tableToolba
|
|
|
27
28
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
28
29
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
29
30
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
31
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
30
32
|
import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
|
|
31
33
|
import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
|
|
32
34
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -394,10 +396,29 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
394
396
|
return _createClass(TableComponent, [{
|
|
395
397
|
key: "componentDidMount",
|
|
396
398
|
value: function componentDidMount() {
|
|
399
|
+
var _this2 = this;
|
|
400
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
401
|
+
this.initialiseEventListenersAfterMount();
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
var _nodeVisibilityManage = nodeVisibilityManager(this.props.view.dom),
|
|
405
|
+
observe = _nodeVisibilityManage.observe;
|
|
406
|
+
if (this.table) {
|
|
407
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
408
|
+
element: this.table,
|
|
409
|
+
onFirstVisible: function onFirstVisible() {
|
|
410
|
+
_this2.initialiseEventListenersAfterMount();
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "initialiseEventListenersAfterMount",
|
|
417
|
+
value: function initialiseEventListenersAfterMount() {
|
|
397
418
|
var _this$table,
|
|
398
419
|
_this$table2,
|
|
399
420
|
_this$table3,
|
|
400
|
-
|
|
421
|
+
_this3 = this;
|
|
401
422
|
var _this$props7 = this.props,
|
|
402
423
|
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
403
424
|
allowTableResizing = _this$props7.allowTableResizing,
|
|
@@ -435,7 +456,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
435
456
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
436
457
|
var _entry$contentRect3;
|
|
437
458
|
var entry = _step2.value;
|
|
438
|
-
|
|
459
|
+
_this3.wrapperWidth = (_entry$contentRect3 = entry.contentRect) === null || _entry$contentRect3 === void 0 ? void 0 : _entry$contentRect3.width;
|
|
439
460
|
}
|
|
440
461
|
} catch (err) {
|
|
441
462
|
_iterator2.e(err);
|
|
@@ -509,6 +530,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
509
530
|
if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
|
|
510
531
|
this.dragAndDropCleanupFn();
|
|
511
532
|
}
|
|
533
|
+
if (this.nodeVisibilityObserverCleanupFn) {
|
|
534
|
+
this.nodeVisibilityObserverCleanupFn();
|
|
535
|
+
}
|
|
512
536
|
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
513
537
|
(_this$wrapperReisizeO = this.wrapperReisizeObserver) === null || _this$wrapperReisizeO === void 0 || _this$wrapperReisizeO.disconnect();
|
|
514
538
|
if (this.stickyScrollbar) {
|
|
@@ -578,7 +602,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
578
602
|
key: "handleColgroupUpdates",
|
|
579
603
|
value: function handleColgroupUpdates() {
|
|
580
604
|
var _this$containerWidth,
|
|
581
|
-
|
|
605
|
+
_this4 = this;
|
|
582
606
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
583
607
|
var _this$props10 = this.props,
|
|
584
608
|
getNode = _this$props10.getNode,
|
|
@@ -655,26 +679,26 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
655
679
|
}
|
|
656
680
|
var scalePercent = 1;
|
|
657
681
|
requestAnimationFrame(function () {
|
|
658
|
-
var
|
|
682
|
+
var _this4$props$options, _this4$props$options2;
|
|
659
683
|
// Scaling percent has to be calculated inside requestAnimationFrame, otherwise
|
|
660
684
|
// renderWidth calculated as `tableRef?.parentElement?.clientWidth`
|
|
661
685
|
// inside of getTableScalingPercent returns 0.
|
|
662
|
-
if (!((
|
|
686
|
+
if (!((_this4$props$options = _this4.props.options) !== null && _this4$props$options !== void 0 && _this4$props$options.isCommentEditor) || (_this4$props$options2 = _this4.props.options) !== null && _this4$props$options2 !== void 0 && _this4$props$options2.isCommentEditor && tableNode.attrs.width) {
|
|
663
687
|
scalePercent = getTableScalingPercent(tableNode,
|
|
664
688
|
// Ignored via go/ees005
|
|
665
689
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
666
|
-
|
|
690
|
+
_this4.table, shouldUseIncreasedScalingPercent);
|
|
667
691
|
} else {
|
|
668
692
|
// Ignored via go/ees005
|
|
669
693
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
670
|
-
scalePercent = getScalingPercentForTableWithoutWidth(tableNode,
|
|
694
|
+
scalePercent = getScalingPercentForTableWithoutWidth(tableNode, _this4.table);
|
|
671
695
|
}
|
|
672
696
|
|
|
673
697
|
// Request animation frame required for Firefox
|
|
674
698
|
updateColgroup(resizeState,
|
|
675
699
|
// Ignored via go/ees005
|
|
676
700
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
677
|
-
|
|
701
|
+
_this4.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
|
|
678
702
|
});
|
|
679
703
|
}
|
|
680
704
|
}
|
|
@@ -694,7 +718,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
694
718
|
var _this$props$options8,
|
|
695
719
|
_this$props$options9,
|
|
696
720
|
_this$wrapper,
|
|
697
|
-
|
|
721
|
+
_this5 = this;
|
|
698
722
|
var _this$props11 = this.props,
|
|
699
723
|
view = _this$props11.view,
|
|
700
724
|
getNode = _this$props11.getNode,
|
|
@@ -742,10 +766,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
742
766
|
// that happens when a table is nested in expand and expand's width is
|
|
743
767
|
// changed via breakout button
|
|
744
768
|
window.requestAnimationFrame(function () {
|
|
745
|
-
|
|
769
|
+
_this5.overflowShadowsObserver = new OverflowShadowsObserver(fg('platform_editor_nested_tables_view_mode_sort') ? _this5.updateShadowStateDebounced : _this5.updateShadowState,
|
|
746
770
|
// Ignored via go/ees005
|
|
747
771
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
748
|
-
|
|
772
|
+
_this5.table, _this5.wrapper);
|
|
749
773
|
});
|
|
750
774
|
} else {
|
|
751
775
|
this.overflowShadowsObserver = new OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
|
|
@@ -822,7 +846,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
822
846
|
}, {
|
|
823
847
|
key: "render",
|
|
824
848
|
value: function render() {
|
|
825
|
-
var
|
|
849
|
+
var _this6 = this,
|
|
826
850
|
_this$props$options10;
|
|
827
851
|
var _this$props12 = this.props,
|
|
828
852
|
view = _this$props12.view,
|
|
@@ -912,8 +936,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
912
936
|
tableContainerWidth: tableContainerWidth,
|
|
913
937
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
914
938
|
getScrollOffset: function getScrollOffset() {
|
|
915
|
-
var
|
|
916
|
-
return ((
|
|
939
|
+
var _this6$wrapper;
|
|
940
|
+
return ((_this6$wrapper = _this6.wrapper) === null || _this6$wrapper === void 0 ? void 0 : _this6$wrapper.scrollLeft) || 0;
|
|
917
941
|
},
|
|
918
942
|
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
919
943
|
api: pluginInjectionApi,
|
|
@@ -985,12 +1009,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
985
1009
|
editorView: view,
|
|
986
1010
|
node: node,
|
|
987
1011
|
getScrollOffset: function getScrollOffset() {
|
|
988
|
-
var
|
|
989
|
-
return ((
|
|
1012
|
+
var _this6$wrapper2;
|
|
1013
|
+
return ((_this6$wrapper2 = _this6.wrapper) === null || _this6$wrapper2 === void 0 ? void 0 : _this6$wrapper2.scrollLeft) || 0;
|
|
990
1014
|
},
|
|
991
1015
|
getTableWrapperWidth: function getTableWrapperWidth() {
|
|
992
|
-
var
|
|
993
|
-
return ((
|
|
1016
|
+
var _this6$wrapper3;
|
|
1017
|
+
return ((_this6$wrapper3 = _this6.wrapper) === null || _this6$wrapper3 === void 0 ? void 0 : _this6$wrapper3.clientWidth) || 760;
|
|
994
1018
|
}
|
|
995
1019
|
}), /*#__PURE__*/React.createElement("div", {
|
|
996
1020
|
contentEditable: false
|
|
@@ -1012,14 +1036,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1012
1036
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
1013
1037
|
className: classnames(ClassName.TABLE_NODE_WRAPPER),
|
|
1014
1038
|
ref: function ref(elem) {
|
|
1015
|
-
|
|
1039
|
+
_this6.wrapper = elem;
|
|
1016
1040
|
if (elem) {
|
|
1017
|
-
|
|
1041
|
+
_this6.props.contentDOM(elem);
|
|
1018
1042
|
var tableElement = elem.querySelector('table');
|
|
1019
|
-
if (tableElement !==
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1043
|
+
if (tableElement !== _this6.table) {
|
|
1044
|
+
_this6.table = tableElement;
|
|
1045
|
+
_this6.createShadowSentinels(_this6.table);
|
|
1046
|
+
_this6.observeTable(_this6.table);
|
|
1023
1047
|
}
|
|
1024
1048
|
}
|
|
1025
1049
|
}
|
|
@@ -9,9 +9,11 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
9
9
|
import debounce from 'lodash/debounce';
|
|
10
10
|
import throttle from 'lodash/throttle';
|
|
11
11
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
12
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
12
13
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
13
14
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
14
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
17
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
16
18
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
17
19
|
import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
|
|
@@ -77,19 +79,38 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
77
79
|
_this.isInNestedTable = getParentOfTypeCount(view.state.schema.nodes.table)(view.state.doc.resolve(pos)) > 1;
|
|
78
80
|
}
|
|
79
81
|
if (_this.isHeaderRow) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
83
|
+
_this.subscribeWhenRowVisible();
|
|
84
|
+
} else {
|
|
85
|
+
var _nodeVisibilityManage = nodeVisibilityManager(view.dom),
|
|
86
|
+
observe = _nodeVisibilityManage.observe;
|
|
87
|
+
_this.nodeVisibilityObserverCleanupFn = observe({
|
|
88
|
+
element: _this.contentDOM,
|
|
89
|
+
onFirstVisible: function onFirstVisible() {
|
|
90
|
+
_this.subscribeWhenRowVisible();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
return _this;
|
|
86
96
|
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Variables
|
|
90
|
-
*/
|
|
91
97
|
_inherits(TableRow, _TableNodeView);
|
|
92
98
|
return _createClass(TableRow, [{
|
|
99
|
+
key: "subscribeWhenRowVisible",
|
|
100
|
+
value: function subscribeWhenRowVisible() {
|
|
101
|
+
if (this.listening) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.dom.setAttribute('data-header-row', 'true');
|
|
105
|
+
if (this.isStickyHeaderEnabled) {
|
|
106
|
+
this.subscribe();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Variables
|
|
112
|
+
*/
|
|
113
|
+
}, {
|
|
93
114
|
key: "update",
|
|
94
115
|
value:
|
|
95
116
|
/**
|
|
@@ -131,6 +152,7 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
131
152
|
value: function destroy() {
|
|
132
153
|
if (this.isStickyHeaderEnabled) {
|
|
133
154
|
this.unsubscribe();
|
|
155
|
+
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
134
156
|
var tree = getTree(this.dom);
|
|
135
157
|
if (tree) {
|
|
136
158
|
this.makeRowHeaderNotSticky(tree.table, true);
|
|
@@ -3,7 +3,9 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import TableNodeView from './TableNodeViewBase';
|
|
5
5
|
export default class TableRow extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
6
|
+
private nodeVisibilityObserverCleanupFn?;
|
|
6
7
|
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher);
|
|
8
|
+
subscribeWhenRowVisible(): void;
|
|
7
9
|
/**
|
|
8
10
|
* Variables
|
|
9
11
|
*/
|
|
@@ -3,7 +3,9 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import TableNodeView from './TableNodeViewBase';
|
|
5
5
|
export default class TableRow extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
6
|
+
private nodeVisibilityObserverCleanupFn?;
|
|
6
7
|
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher);
|
|
8
|
+
subscribeWhenRowVisible(): void;
|
|
7
9
|
/**
|
|
8
10
|
* Variables
|
|
9
11
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.11.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
33
33
|
"@atlaskit/button": "^23.2.0",
|
|
34
34
|
"@atlaskit/custom-steps": "^0.11.0",
|
|
35
|
-
"@atlaskit/editor-common": "^105.
|
|
35
|
+
"@atlaskit/editor-common": "^105.10.0",
|
|
36
36
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-content-insertion": "^2.1.0",
|
|
41
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
42
|
-
"@atlaskit/editor-plugin-extension": "5.4.
|
|
41
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^4.0.0",
|
|
42
|
+
"@atlaskit/editor-plugin-extension": "5.4.2",
|
|
43
43
|
"@atlaskit/editor-plugin-guideline": "^2.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-selection": "^2.2.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
46
46
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
48
48
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
49
|
-
"@atlaskit/icon": "^26.
|
|
49
|
+
"@atlaskit/icon": "^26.3.0",
|
|
50
50
|
"@atlaskit/menu": "^8.0.0",
|
|
51
51
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
55
55
|
"@atlaskit/primitives": "^14.8.0",
|
|
56
56
|
"@atlaskit/theme": "^18.0.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^5.0.0",
|
|
58
58
|
"@atlaskit/toggle": "^15.0.0",
|
|
59
59
|
"@atlaskit/tokens": "^4.9.0",
|
|
60
60
|
"@atlaskit/tooltip": "^20.0.0",
|
|
@@ -13,6 +13,7 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
|
13
13
|
import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
|
|
14
14
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
15
15
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
16
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
16
17
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
17
18
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
18
19
|
import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
@@ -28,6 +29,7 @@ import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
|
28
29
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
29
30
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
30
31
|
import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
32
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
31
33
|
import { token } from '@atlaskit/tokens';
|
|
32
34
|
|
|
33
35
|
import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
|
|
@@ -180,6 +182,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
180
182
|
private updateColGroupFromFullWidthChange?: boolean;
|
|
181
183
|
|
|
182
184
|
private dragAndDropCleanupFn?: CleanupFn;
|
|
185
|
+
private nodeVisibilityObserverCleanupFn?: CleanupFn;
|
|
183
186
|
|
|
184
187
|
constructor(props: ComponentProps) {
|
|
185
188
|
super(props);
|
|
@@ -249,6 +252,23 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
249
252
|
};
|
|
250
253
|
|
|
251
254
|
componentDidMount() {
|
|
255
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
256
|
+
this.initialiseEventListenersAfterMount();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const { observe } = nodeVisibilityManager(this.props.view.dom);
|
|
261
|
+
if (this.table) {
|
|
262
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
263
|
+
element: this.table,
|
|
264
|
+
onFirstVisible: () => {
|
|
265
|
+
this.initialiseEventListenersAfterMount();
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
initialiseEventListenersAfterMount() {
|
|
252
272
|
const {
|
|
253
273
|
allowColumnResizing,
|
|
254
274
|
allowTableResizing,
|
|
@@ -366,6 +386,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
366
386
|
this.dragAndDropCleanupFn();
|
|
367
387
|
}
|
|
368
388
|
|
|
389
|
+
if (this.nodeVisibilityObserverCleanupFn) {
|
|
390
|
+
this.nodeVisibilityObserverCleanupFn();
|
|
391
|
+
}
|
|
392
|
+
|
|
369
393
|
this.resizeObserver?.disconnect();
|
|
370
394
|
this.wrapperReisizeObserver?.disconnect();
|
|
371
395
|
|
|
@@ -3,11 +3,13 @@ import throttle from 'lodash/throttle';
|
|
|
3
3
|
|
|
4
4
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
5
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
6
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
6
7
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
7
8
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
10
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
10
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
13
|
|
|
12
14
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
15
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -44,6 +46,8 @@ const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
|
44
46
|
const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
45
47
|
|
|
46
48
|
export default class TableRow extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
49
|
+
private nodeVisibilityObserverCleanupFn?: () => void;
|
|
50
|
+
|
|
47
51
|
constructor(
|
|
48
52
|
node: PMNode,
|
|
49
53
|
view: EditorView,
|
|
@@ -66,13 +70,31 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
if (this.isHeaderRow) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
74
|
+
this.subscribeWhenRowVisible();
|
|
75
|
+
} else {
|
|
76
|
+
const { observe } = nodeVisibilityManager(view.dom);
|
|
77
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
78
|
+
element: this.contentDOM,
|
|
79
|
+
onFirstVisible: () => {
|
|
80
|
+
this.subscribeWhenRowVisible();
|
|
81
|
+
},
|
|
82
|
+
});
|
|
72
83
|
}
|
|
73
84
|
}
|
|
74
85
|
}
|
|
75
86
|
|
|
87
|
+
subscribeWhenRowVisible() {
|
|
88
|
+
if (this.listening) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.dom.setAttribute('data-header-row', 'true');
|
|
93
|
+
if (this.isStickyHeaderEnabled) {
|
|
94
|
+
this.subscribe();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
76
98
|
/**
|
|
77
99
|
* Variables
|
|
78
100
|
*/
|
|
@@ -151,6 +173,8 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
151
173
|
if (this.isStickyHeaderEnabled) {
|
|
152
174
|
this.unsubscribe();
|
|
153
175
|
|
|
176
|
+
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
177
|
+
|
|
154
178
|
const tree = getTree(this.dom);
|
|
155
179
|
if (tree) {
|
|
156
180
|
this.makeRowHeaderNotSticky(tree.table, true);
|