@atlaskit/editor-plugin-table 10.10.7 → 10.11.1
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 +21 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/dist/cjs/nodeviews/TableComponent.js +48 -24
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +14 -6
- package/dist/cjs/nodeviews/TableResizer.js +6 -1
- package/dist/cjs/nodeviews/TableRow.js +29 -7
- package/dist/es2019/nodeviews/TableComponent.js +22 -0
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +14 -6
- package/dist/es2019/nodeviews/TableResizer.js +6 -1
- package/dist/es2019/nodeviews/TableRow.js +24 -3
- package/dist/esm/nodeviews/TableComponent.js +48 -24
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +14 -6
- package/dist/esm/nodeviews/TableResizer.js +6 -1
- package/dist/esm/nodeviews/TableRow.js +29 -7
- package/dist/types/nodeviews/TableRow.d.ts +2 -0
- package/dist/types/tablePluginType.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableRow.d.ts +2 -0
- package/dist/types-ts4.5/tablePluginType.d.ts +3 -1
- package/package.json +10 -6
- package/src/nodeviews/TableComponent.tsx +24 -0
- package/src/nodeviews/TableComponentWithSharedState.tsx +29 -3
- package/src/nodeviews/TableResizer.tsx +15 -1
- package/src/nodeviews/TableRow.ts +27 -3
- package/src/tablePluginType.ts +2 -0
- package/tsconfig.app.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#159070](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/159070)
|
|
8
|
+
[`9857b771c1da1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9857b771c1da1) -
|
|
9
|
+
[ux] [ED-27778] Fix selection state hiding for tables, breakout buttons and layout
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 10.11.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#156919](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/156919)
|
|
17
|
+
[`379f5c27f4939`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/379f5c27f4939) -
|
|
18
|
+
delay table sticky headers until table is in viewport
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 10.10.7
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -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
|
}
|
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
10
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
11
11
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
14
|
var _useInternalTablePluginStateSelector = require("../ui/hooks/useInternalTablePluginStateSelector");
|
|
14
15
|
var _TableComponent = _interopRequireDefault(require("./TableComponent"));
|
|
@@ -42,6 +43,9 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
42
43
|
// widthState
|
|
43
44
|
var width = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'width.width');
|
|
44
45
|
var lineLength = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'width.lineLength');
|
|
46
|
+
|
|
47
|
+
// interactionState
|
|
48
|
+
var interaction = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'interaction.interactionState');
|
|
45
49
|
return {
|
|
46
50
|
tableState: undefined,
|
|
47
51
|
widthState: undefined,
|
|
@@ -59,15 +63,17 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
59
63
|
selection: selection,
|
|
60
64
|
mode: mode,
|
|
61
65
|
width: width,
|
|
62
|
-
lineLength: lineLength
|
|
66
|
+
lineLength: lineLength,
|
|
67
|
+
interaction: interaction
|
|
63
68
|
};
|
|
64
69
|
}, function (api) {
|
|
65
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'table', 'media', 'selection', 'editorViewMode']),
|
|
70
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'table', 'media', 'selection', 'editorViewMode', 'interaction']),
|
|
66
71
|
widthState = _useSharedPluginState.widthState,
|
|
67
72
|
tableState = _useSharedPluginState.tableState,
|
|
68
73
|
mediaState = _useSharedPluginState.mediaState,
|
|
69
74
|
selectionState = _useSharedPluginState.selectionState,
|
|
70
|
-
editorViewModeState = _useSharedPluginState.editorViewModeState
|
|
75
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState,
|
|
76
|
+
interactionState = _useSharedPluginState.interactionState;
|
|
71
77
|
var tableStateInternal = tableState;
|
|
72
78
|
return {
|
|
73
79
|
tableState: tableState,
|
|
@@ -86,7 +92,8 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
86
92
|
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
|
|
87
93
|
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
88
94
|
width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
|
|
89
|
-
lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength
|
|
95
|
+
lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
96
|
+
interaction: interactionState === null || interactionState === void 0 ? void 0 : interactionState.interactionState
|
|
90
97
|
};
|
|
91
98
|
});
|
|
92
99
|
|
|
@@ -124,7 +131,8 @@ var TableComponentWithSharedState = exports.TableComponentWithSharedState = func
|
|
|
124
131
|
lineLength = _useSharedState.lineLength,
|
|
125
132
|
ordering = _useSharedState.ordering,
|
|
126
133
|
selection = _useSharedState.selection,
|
|
127
|
-
width = _useSharedState.width
|
|
134
|
+
width = _useSharedState.width,
|
|
135
|
+
interaction = _useSharedState.interaction;
|
|
128
136
|
var isLivePageViewMode = mode === 'view';
|
|
129
137
|
if ((0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false) && !tableState) {
|
|
130
138
|
return null;
|
|
@@ -158,7 +166,7 @@ var TableComponentWithSharedState = exports.TableComponentWithSharedState = func
|
|
|
158
166
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
159
167
|
allowTableAlignment: allowTableAlignment,
|
|
160
168
|
allowTableResizing: allowTableResizing,
|
|
161
|
-
tableActive: tableActive && !isLivePageViewMode,
|
|
169
|
+
tableActive: tableActive && !isLivePageViewMode && (interaction !== 'hasNotHadInteraction' || !(0, _platformFeatureFlags.fg)('platform_editor_hide_expand_selection_states')),
|
|
162
170
|
ordering: ordering,
|
|
163
171
|
isResizing: isResizing,
|
|
164
172
|
getNode: getNode,
|
|
@@ -19,6 +19,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
19
19
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
20
20
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
21
21
|
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
22
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
22
23
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
23
24
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
24
25
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
@@ -149,6 +150,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
149
150
|
var isResizing = (0, _react.useRef)(false);
|
|
150
151
|
var areResizeMetaKeysPressed = (0, _react.useRef)(false);
|
|
151
152
|
var resizerRef = (0, _react.useRef)(null);
|
|
153
|
+
var interactionState = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'interaction.interactionState');
|
|
152
154
|
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
153
155
|
widthToWidest = _useSharedState.widthToWidest;
|
|
154
156
|
|
|
@@ -170,6 +172,9 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
170
172
|
if (typeof tableFromSelectionPosition !== 'number') {
|
|
171
173
|
return false;
|
|
172
174
|
}
|
|
175
|
+
if (interactionState === 'hasNotHadInteraction' && (0, _platformFeatureFlags.fg)('platform_editor_hide_expand_selection_states')) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
173
178
|
var currentNodePosition;
|
|
174
179
|
try {
|
|
175
180
|
// The React Table and the ProseMirror can endup out-of-sync
|
|
@@ -182,7 +187,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
182
187
|
return false;
|
|
183
188
|
}
|
|
184
189
|
return tableFromSelectionPosition === currentNodePosition;
|
|
185
|
-
}, [tableFromSelectionPosition, getPos]);
|
|
190
|
+
}, [tableFromSelectionPosition, interactionState, getPos]);
|
|
186
191
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
187
192
|
var handleSize = getResizerHandleHeight(tableRef);
|
|
188
193
|
var _useMeasureFramerate = (0, _analytics2.useMeasureFramerate)(),
|
|
@@ -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,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
4
|
import { findTable } from '@atlaskit/editor-tables';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
import { useInternalTablePluginStateSelector } from '../ui/hooks/useInternalTablePluginStateSelector';
|
|
7
8
|
import TableComponent from './TableComponent';
|
|
@@ -36,6 +37,9 @@ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
|
36
37
|
// widthState
|
|
37
38
|
const width = useSharedPluginStateSelector(api, 'width.width');
|
|
38
39
|
const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
|
|
40
|
+
|
|
41
|
+
// interactionState
|
|
42
|
+
const interaction = useSharedPluginStateSelector(api, 'interaction.interactionState');
|
|
39
43
|
return {
|
|
40
44
|
tableState: undefined,
|
|
41
45
|
widthState: undefined,
|
|
@@ -53,7 +57,8 @@ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
|
53
57
|
selection,
|
|
54
58
|
mode,
|
|
55
59
|
width,
|
|
56
|
-
lineLength
|
|
60
|
+
lineLength,
|
|
61
|
+
interaction
|
|
57
62
|
};
|
|
58
63
|
}, api => {
|
|
59
64
|
const {
|
|
@@ -61,8 +66,9 @@ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
|
61
66
|
tableState,
|
|
62
67
|
mediaState,
|
|
63
68
|
selectionState,
|
|
64
|
-
editorViewModeState
|
|
65
|
-
|
|
69
|
+
editorViewModeState,
|
|
70
|
+
interactionState
|
|
71
|
+
} = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode', 'interaction']);
|
|
66
72
|
const tableStateInternal = tableState;
|
|
67
73
|
return {
|
|
68
74
|
tableState,
|
|
@@ -81,7 +87,8 @@ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
|
81
87
|
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
|
|
82
88
|
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
83
89
|
width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
|
|
84
|
-
lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength
|
|
90
|
+
lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
91
|
+
interaction: interactionState === null || interactionState === void 0 ? void 0 : interactionState.interactionState
|
|
85
92
|
};
|
|
86
93
|
});
|
|
87
94
|
|
|
@@ -120,7 +127,8 @@ export const TableComponentWithSharedState = ({
|
|
|
120
127
|
lineLength,
|
|
121
128
|
ordering,
|
|
122
129
|
selection,
|
|
123
|
-
width
|
|
130
|
+
width,
|
|
131
|
+
interaction
|
|
124
132
|
} = useSharedState(api);
|
|
125
133
|
const isLivePageViewMode = mode === 'view';
|
|
126
134
|
if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
|
|
@@ -155,7 +163,7 @@ export const TableComponentWithSharedState = ({
|
|
|
155
163
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
156
164
|
allowTableAlignment: allowTableAlignment,
|
|
157
165
|
allowTableResizing: allowTableResizing,
|
|
158
|
-
tableActive: tableActive && !isLivePageViewMode,
|
|
166
|
+
tableActive: tableActive && !isLivePageViewMode && (interaction !== 'hasNotHadInteraction' || !fg('platform_editor_hide_expand_selection_states')),
|
|
159
167
|
ordering: ordering,
|
|
160
168
|
isResizing: isResizing,
|
|
161
169
|
getNode: getNode,
|
|
@@ -9,6 +9,7 @@ import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keyma
|
|
|
9
9
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
10
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
11
11
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
12
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
12
13
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
13
14
|
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
14
15
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -137,6 +138,7 @@ export const TableResizer = ({
|
|
|
137
138
|
const isResizing = useRef(false);
|
|
138
139
|
const areResizeMetaKeysPressed = useRef(false);
|
|
139
140
|
const resizerRef = useRef(null);
|
|
141
|
+
const interactionState = useSharedPluginStateSelector(pluginInjectionApi, 'interaction.interactionState');
|
|
140
142
|
const {
|
|
141
143
|
widthToWidest
|
|
142
144
|
} = useSharedState(pluginInjectionApi);
|
|
@@ -157,6 +159,9 @@ export const TableResizer = ({
|
|
|
157
159
|
if (typeof tableFromSelectionPosition !== 'number') {
|
|
158
160
|
return false;
|
|
159
161
|
}
|
|
162
|
+
if (interactionState === 'hasNotHadInteraction' && fg('platform_editor_hide_expand_selection_states')) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
160
165
|
let currentNodePosition;
|
|
161
166
|
try {
|
|
162
167
|
// The React Table and the ProseMirror can endup out-of-sync
|
|
@@ -169,7 +174,7 @@ export const TableResizer = ({
|
|
|
169
174
|
return false;
|
|
170
175
|
}
|
|
171
176
|
return tableFromSelectionPosition === currentNodePosition;
|
|
172
|
-
}, [tableFromSelectionPosition, getPos]);
|
|
177
|
+
}, [tableFromSelectionPosition, interactionState, getPos]);
|
|
173
178
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
174
179
|
const handleSize = getResizerHandleHeight(tableRef);
|
|
175
180
|
const {
|
|
@@ -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);
|