@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.
@@ -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
- _this2 = this;
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
- _this2.wrapperWidth = (_entry$contentRect3 = entry.contentRect) === null || _entry$contentRect3 === void 0 ? void 0 : _entry$contentRect3.width;
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
- _this3 = this;
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 _this3$props$options, _this3$props$options2;
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 (!((_this3$props$options = _this3.props.options) !== null && _this3$props$options !== void 0 && _this3$props$options.isCommentEditor) || (_this3$props$options2 = _this3.props.options) !== null && _this3$props$options2 !== void 0 && _this3$props$options2.isCommentEditor && tableNode.attrs.width) {
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
- _this3.table, shouldUseIncreasedScalingPercent);
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, _this3.table);
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
- _this3.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
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
- _this4 = this;
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
- _this4.overflowShadowsObserver = new OverflowShadowsObserver(fg('platform_editor_nested_tables_view_mode_sort') ? _this4.updateShadowStateDebounced : _this4.updateShadowState,
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
- _this4.table, _this4.wrapper);
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 _this5 = this,
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 _this5$wrapper;
916
- return ((_this5$wrapper = _this5.wrapper) === null || _this5$wrapper === void 0 ? void 0 : _this5$wrapper.scrollLeft) || 0;
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 _this5$wrapper2;
989
- return ((_this5$wrapper2 = _this5.wrapper) === null || _this5$wrapper2 === void 0 ? void 0 : _this5$wrapper2.scrollLeft) || 0;
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 _this5$wrapper3;
993
- return ((_this5$wrapper3 = _this5.wrapper) === null || _this5$wrapper3 === void 0 ? void 0 : _this5$wrapper3.clientWidth) || 760;
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
- _this5.wrapper = elem;
1039
+ _this6.wrapper = elem;
1016
1040
  if (elem) {
1017
- _this5.props.contentDOM(elem);
1041
+ _this6.props.contentDOM(elem);
1018
1042
  var tableElement = elem.querySelector('table');
1019
- if (tableElement !== _this5.table) {
1020
- _this5.table = tableElement;
1021
- _this5.createShadowSentinels(_this5.table);
1022
- _this5.observeTable(_this5.table);
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
  }
@@ -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 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
36
37
  // widthState
37
38
  var width = useSharedPluginStateSelector(api, 'width.width');
38
39
  var lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
40
+
41
+ // interactionState
42
+ var interaction = useSharedPluginStateSelector(api, 'interaction.interactionState');
39
43
  return {
40
44
  tableState: undefined,
41
45
  widthState: undefined,
@@ -53,15 +57,17 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
53
57
  selection: selection,
54
58
  mode: mode,
55
59
  width: width,
56
- lineLength: lineLength
60
+ lineLength: lineLength,
61
+ interaction: interaction
57
62
  };
58
63
  }, function (api) {
59
- var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']),
64
+ var _useSharedPluginState = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode', 'interaction']),
60
65
  widthState = _useSharedPluginState.widthState,
61
66
  tableState = _useSharedPluginState.tableState,
62
67
  mediaState = _useSharedPluginState.mediaState,
63
68
  selectionState = _useSharedPluginState.selectionState,
64
- editorViewModeState = _useSharedPluginState.editorViewModeState;
69
+ editorViewModeState = _useSharedPluginState.editorViewModeState,
70
+ interactionState = _useSharedPluginState.interactionState;
65
71
  var tableStateInternal = tableState;
66
72
  return {
67
73
  tableState: tableState,
@@ -80,7 +86,8 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
80
86
  selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection,
81
87
  mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
82
88
  width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
83
- lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength
89
+ lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
90
+ interaction: interactionState === null || interactionState === void 0 ? void 0 : interactionState.interactionState
84
91
  };
85
92
  });
86
93
 
@@ -118,7 +125,8 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
118
125
  lineLength = _useSharedState.lineLength,
119
126
  ordering = _useSharedState.ordering,
120
127
  selection = _useSharedState.selection,
121
- width = _useSharedState.width;
128
+ width = _useSharedState.width,
129
+ interaction = _useSharedState.interaction;
122
130
  var isLivePageViewMode = mode === 'view';
123
131
  if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
124
132
  return null;
@@ -152,7 +160,7 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
152
160
  isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
153
161
  allowTableAlignment: allowTableAlignment,
154
162
  allowTableResizing: allowTableResizing,
155
- tableActive: tableActive && !isLivePageViewMode,
163
+ tableActive: tableActive && !isLivePageViewMode && (interaction !== 'hasNotHadInteraction' || !fg('platform_editor_hide_expand_selection_states')),
156
164
  ordering: ordering,
157
165
  isResizing: isResizing,
158
166
  getNode: getNode,
@@ -13,6 +13,7 @@ import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keyma
13
13
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
14
14
  import { logException } from '@atlaskit/editor-common/monitoring';
15
15
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
16
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
16
17
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
17
18
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
18
19
  import { findTable } from '@atlaskit/editor-tables/utils';
@@ -139,6 +140,7 @@ export var TableResizer = function TableResizer(_ref) {
139
140
  var isResizing = useRef(false);
140
141
  var areResizeMetaKeysPressed = useRef(false);
141
142
  var resizerRef = useRef(null);
143
+ var interactionState = useSharedPluginStateSelector(pluginInjectionApi, 'interaction.interactionState');
142
144
  var _useSharedState = useSharedState(pluginInjectionApi),
143
145
  widthToWidest = _useSharedState.widthToWidest;
144
146
 
@@ -160,6 +162,9 @@ export var TableResizer = function TableResizer(_ref) {
160
162
  if (typeof tableFromSelectionPosition !== 'number') {
161
163
  return false;
162
164
  }
165
+ if (interactionState === 'hasNotHadInteraction' && fg('platform_editor_hide_expand_selection_states')) {
166
+ return false;
167
+ }
163
168
  var currentNodePosition;
164
169
  try {
165
170
  // The React Table and the ProseMirror can endup out-of-sync
@@ -172,7 +177,7 @@ export var TableResizer = function TableResizer(_ref) {
172
177
  return false;
173
178
  }
174
179
  return tableFromSelectionPosition === currentNodePosition;
175
- }, [tableFromSelectionPosition, getPos]);
180
+ }, [tableFromSelectionPosition, interactionState, getPos]);
176
181
  var resizerMinWidth = getResizerMinWidth(node);
177
182
  var handleSize = getResizerHandleHeight(tableRef);
178
183
  var _useMeasureFramerate = useMeasureFramerate(),
@@ -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
- _this.dom.setAttribute('data-header-row', 'true');
81
- if (_this.isStickyHeaderEnabled) {
82
- _this.subscribe();
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
  */
@@ -8,6 +8,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
8
8
  import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
9
9
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
10
10
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
11
+ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
11
12
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
12
13
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
13
14
  import type { PluginConfig, TableSharedState } from './types';
@@ -47,7 +48,8 @@ export type TablePluginDependencies = [
47
48
  OptionalPlugin<MediaPlugin>,
48
49
  OptionalPlugin<EditorViewModePlugin>,
49
50
  OptionalPlugin<FeatureFlagsPlugin>,
50
- OptionalPlugin<ExtensionPlugin>
51
+ OptionalPlugin<ExtensionPlugin>,
52
+ OptionalPlugin<InteractionPlugin>
51
53
  ];
52
54
  export type TablePlugin = NextEditorPlugin<'table', {
53
55
  pluginConfiguration: TablePluginOptions | undefined;
@@ -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
  */
@@ -8,6 +8,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
8
8
  import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
9
9
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
10
10
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
11
+ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
11
12
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
12
13
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
13
14
  import type { PluginConfig, TableSharedState } from './types';
@@ -47,7 +48,8 @@ export type TablePluginDependencies = [
47
48
  OptionalPlugin<MediaPlugin>,
48
49
  OptionalPlugin<EditorViewModePlugin>,
49
50
  OptionalPlugin<FeatureFlagsPlugin>,
50
- OptionalPlugin<ExtensionPlugin>
51
+ OptionalPlugin<ExtensionPlugin>,
52
+ OptionalPlugin<InteractionPlugin>
51
53
  ];
52
54
  export type TablePlugin = NextEditorPlugin<'table', {
53
55
  pluginConfiguration: TablePluginOptions | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.10.7",
3
+ "version": "10.11.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,21 +32,22 @@
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.9.0",
35
+ "@atlaskit/editor-common": "^105.11.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": "^3.1.0",
42
- "@atlaskit/editor-plugin-extension": "5.4.1",
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
+ "@atlaskit/editor-plugin-interaction": "^1.1.0",
44
45
  "@atlaskit/editor-plugin-selection": "^2.2.0",
45
46
  "@atlaskit/editor-plugin-width": "^3.0.0",
46
47
  "@atlaskit/editor-prosemirror": "7.0.0",
47
48
  "@atlaskit/editor-shared-styles": "^3.4.0",
48
49
  "@atlaskit/editor-tables": "^2.9.0",
49
- "@atlaskit/icon": "^26.2.0",
50
+ "@atlaskit/icon": "^26.3.0",
50
51
  "@atlaskit/menu": "^8.0.0",
51
52
  "@atlaskit/platform-feature-flags": "^1.1.0",
52
53
  "@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
@@ -54,7 +55,7 @@
54
55
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
55
56
  "@atlaskit/primitives": "^14.8.0",
56
57
  "@atlaskit/theme": "^18.0.0",
57
- "@atlaskit/tmp-editor-statsig": "^4.25.0",
58
+ "@atlaskit/tmp-editor-statsig": "^5.1.0",
58
59
  "@atlaskit/toggle": "^15.0.0",
59
60
  "@atlaskit/tokens": "^4.9.0",
60
61
  "@atlaskit/tooltip": "^20.0.0",
@@ -218,6 +219,9 @@
218
219
  },
219
220
  "platform_editor_table_fw_numcol_overflow_fix": {
220
221
  "type": "boolean"
222
+ },
223
+ "platform_editor_hide_expand_selection_states": {
224
+ "type": "boolean"
221
225
  }
222
226
  }
223
227
  }
@@ -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
 
@@ -11,6 +11,7 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
11
11
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
12
12
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
13
13
  import { findTable } from '@atlaskit/editor-tables';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
14
15
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
16
 
16
17
  import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
@@ -68,6 +69,9 @@ const useSharedState = sharedPluginStateHookMigratorFactory(
68
69
  const width = useSharedPluginStateSelector(api, 'width.width');
69
70
  const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
70
71
 
72
+ // interactionState
73
+ const interaction = useSharedPluginStateSelector(api, 'interaction.interactionState');
74
+
71
75
  return {
72
76
  tableState: undefined,
73
77
  widthState: undefined,
@@ -86,11 +90,25 @@ const useSharedState = sharedPluginStateHookMigratorFactory(
86
90
  mode,
87
91
  width,
88
92
  lineLength,
93
+ interaction,
89
94
  };
90
95
  },
91
96
  (api: PluginInjectionAPI | undefined) => {
92
- const { widthState, tableState, mediaState, selectionState, editorViewModeState } =
93
- useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
97
+ const {
98
+ widthState,
99
+ tableState,
100
+ mediaState,
101
+ selectionState,
102
+ editorViewModeState,
103
+ interactionState,
104
+ } = useSharedPluginState(api, [
105
+ 'width',
106
+ 'table',
107
+ 'media',
108
+ 'selection',
109
+ 'editorViewMode',
110
+ 'interaction',
111
+ ]);
94
112
  const tableStateInternal = tableState as TableSharedStateInternal | undefined;
95
113
 
96
114
  return {
@@ -111,6 +129,7 @@ const useSharedState = sharedPluginStateHookMigratorFactory(
111
129
  mode: editorViewModeState?.mode,
112
130
  width: widthState?.width,
113
131
  lineLength: widthState?.lineLength,
132
+ interaction: interactionState?.interactionState,
114
133
  };
115
134
  },
116
135
  );
@@ -151,7 +170,9 @@ export const TableComponentWithSharedState = ({
151
170
  ordering,
152
171
  selection,
153
172
  width,
173
+ interaction,
154
174
  } = useSharedState(api);
175
+
155
176
  const isLivePageViewMode = mode === 'view';
156
177
 
157
178
  if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
@@ -195,7 +216,12 @@ export const TableComponentWithSharedState = ({
195
216
  isTableScalingEnabled={options?.isTableScalingEnabled}
196
217
  allowTableAlignment={allowTableAlignment}
197
218
  allowTableResizing={allowTableResizing}
198
- tableActive={tableActive && !isLivePageViewMode}
219
+ tableActive={
220
+ tableActive &&
221
+ !isLivePageViewMode &&
222
+ (interaction !== 'hasNotHadInteraction' ||
223
+ !fg('platform_editor_hide_expand_selection_states'))
224
+ }
199
225
  ordering={ordering}
200
226
  isResizing={isResizing}
201
227
  getNode={getNode}
@@ -22,6 +22,7 @@ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
22
22
  import { logException } from '@atlaskit/editor-common/monitoring';
23
23
  import type { HandleResize, HandleSize } from '@atlaskit/editor-common/resizer';
24
24
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
25
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
25
26
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
26
27
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
27
28
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -231,6 +232,12 @@ export const TableResizer = ({
231
232
  const isResizing = useRef(false);
232
233
  const areResizeMetaKeysPressed = useRef(false);
233
234
  const resizerRef = useRef<ResizerNextHandler>(null);
235
+
236
+ const interactionState = useSharedPluginStateSelector(
237
+ pluginInjectionApi,
238
+ 'interaction.interactionState',
239
+ );
240
+
234
241
  const { widthToWidest } = useSharedState(pluginInjectionApi);
235
242
 
236
243
  // used to reposition tooltip when table is resizing via keyboard
@@ -250,6 +257,13 @@ export const TableResizer = ({
250
257
  return false;
251
258
  }
252
259
 
260
+ if (
261
+ interactionState === 'hasNotHadInteraction' &&
262
+ fg('platform_editor_hide_expand_selection_states')
263
+ ) {
264
+ return false;
265
+ }
266
+
253
267
  let currentNodePosition: number | undefined;
254
268
  try {
255
269
  // The React Table and the ProseMirror can endup out-of-sync
@@ -263,7 +277,7 @@ export const TableResizer = ({
263
277
  }
264
278
 
265
279
  return tableFromSelectionPosition === currentNodePosition;
266
- }, [tableFromSelectionPosition, getPos]);
280
+ }, [tableFromSelectionPosition, interactionState, getPos]);
267
281
 
268
282
  const resizerMinWidth = getResizerMinWidth(node);
269
283
  const handleSize = getResizerHandleHeight(tableRef);