@atlaskit/editor-plugin-table 10.11.0 → 10.11.2

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#161309](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/161309)
8
+ [`ec4edba1f5f2d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ec4edba1f5f2d) -
9
+ Fix selection colour bug after deleting a column or row
10
+ - Updated dependencies
11
+
12
+ ## 10.11.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#159070](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/159070)
17
+ [`9857b771c1da1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9857b771c1da1) -
18
+ [ux] [ED-27778] Fix selection state hiding for tables, breakout buttons and layout
19
+ - Updated dependencies
20
+
3
21
  ## 10.11.0
4
22
 
5
23
  ### Minor Changes
@@ -50,6 +50,9 @@
50
50
  {
51
51
  "path": "../../editor-plugin-guideline/afm-cc/tsconfig.json"
52
52
  },
53
+ {
54
+ "path": "../../editor-plugin-interaction/afm-cc/tsconfig.json"
55
+ },
53
56
  {
54
57
  "path": "../../editor-plugin-selection/afm-cc/tsconfig.json"
55
58
  },
@@ -50,6 +50,9 @@
50
50
  {
51
51
  "path": "../../editor-plugin-guideline/afm-jira/tsconfig.json"
52
52
  },
53
+ {
54
+ "path": "../../editor-plugin-interaction/afm-jira/tsconfig.json"
55
+ },
53
56
  {
54
57
  "path": "../../editor-plugin-selection/afm-jira/tsconfig.json"
55
58
  },
@@ -50,6 +50,9 @@
50
50
  {
51
51
  "path": "../../editor-plugin-guideline/afm-post-office/tsconfig.json"
52
52
  },
53
+ {
54
+ "path": "../../editor-plugin-interaction/afm-post-office/tsconfig.json"
55
+ },
53
56
  {
54
57
  "path": "../../editor-plugin-selection/afm-post-office/tsconfig.json"
55
58
  },
@@ -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)(),
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.deleteColumnsCommand = void 0;
7
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
+ var _pluginKey = require("../plugin-key");
7
9
  var _deleteColumns = require("../transforms/delete-columns");
8
10
  var _getAllowAddColumnCustomStep = require("../utils/get-allow-add-column-custom-step");
9
11
  var deleteColumnsCommand = exports.deleteColumnsCommand = function deleteColumnsCommand(rect, api) {
@@ -13,6 +15,16 @@ var deleteColumnsCommand = exports.deleteColumnsCommand = function deleteColumns
13
15
  var isCommentEditor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
14
16
  return function (state, dispatch, view) {
15
17
  var tr = (0, _deleteColumns.deleteColumns)(rect, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(state), api, view, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(state.tr);
18
+ // If we delete a column we should also clean up the hover selection
19
+ if ((0, _platformFeatureFlags.fg)('platform_editor_remove_slow_table_transactions')) {
20
+ tr.setMeta(_pluginKey.pluginKey, {
21
+ type: 'CLEAR_HOVER_SELECTION',
22
+ data: {
23
+ isInDanger: false,
24
+ isWholeTableInDanger: false
25
+ }
26
+ });
27
+ }
16
28
  if (dispatch) {
17
29
  dispatch(tr);
18
30
  return true;
@@ -10,6 +10,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
11
  var _tableMap = require("@atlaskit/editor-tables/table-map");
12
12
  var _utils = require("@atlaskit/editor-tables/utils");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
+ var _pluginKey = require("../plugin-key");
13
15
  var _merge = require("./merge");
14
16
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -116,6 +118,17 @@ var deleteRows = exports.deleteRows = function deleteRows(rect) {
116
118
  return tr;
117
119
  }
118
120
  var cursorPos = getNextCursorPos(newTable, rowsToDelete);
121
+
122
+ // If we delete a row we should also clean up the hover selection
123
+ if ((0, _platformFeatureFlags.fg)('platform_editor_remove_slow_table_transactions')) {
124
+ tr.setMeta(_pluginKey.pluginKey, {
125
+ type: 'CLEAR_HOVER_SELECTION',
126
+ data: {
127
+ isInDanger: false,
128
+ isWholeTableInDanger: false
129
+ }
130
+ });
131
+ }
119
132
  return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
120
133
  // move cursor before the deleted rows if possible, otherwise - to the first row
121
134
  .setSelection(_state.Selection.near(tr.doc.resolve(table.pos + cursorPos)));
@@ -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
- } = useSharedPluginState(api, ['width', 'table', 'media', 'selection', 'editorViewMode']);
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 {
@@ -1,7 +1,19 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { pluginKey } from '../plugin-key';
1
3
  import { deleteColumns } from '../transforms/delete-columns';
2
4
  import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
3
5
  export const deleteColumnsCommand = (rect, api, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => (state, dispatch, view) => {
4
6
  const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), api, view, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(state.tr);
7
+ // If we delete a column we should also clean up the hover selection
8
+ if (fg('platform_editor_remove_slow_table_transactions')) {
9
+ tr.setMeta(pluginKey, {
10
+ type: 'CLEAR_HOVER_SELECTION',
11
+ data: {
12
+ isInDanger: false,
13
+ isWholeTableInDanger: false
14
+ }
15
+ });
16
+ }
5
17
  if (dispatch) {
6
18
  dispatch(tr);
7
19
  return true;
@@ -1,6 +1,8 @@
1
1
  import { Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { TableMap } from '@atlaskit/editor-tables/table-map';
3
3
  import { findTable } from '@atlaskit/editor-tables/utils';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { pluginKey } from '../plugin-key';
4
6
  import { mergeEmptyColumns } from './merge';
5
7
  export const deleteRows = (rect, isHeaderRowRequired = false) => tr => {
6
8
  const table = findTable(tr.selection);
@@ -97,6 +99,17 @@ export const deleteRows = (rect, isHeaderRowRequired = false) => tr => {
97
99
  return tr;
98
100
  }
99
101
  const cursorPos = getNextCursorPos(newTable, rowsToDelete);
102
+
103
+ // If we delete a row we should also clean up the hover selection
104
+ if (fg('platform_editor_remove_slow_table_transactions')) {
105
+ tr.setMeta(pluginKey, {
106
+ type: 'CLEAR_HOVER_SELECTION',
107
+ data: {
108
+ isInDanger: false,
109
+ isWholeTableInDanger: false
110
+ }
111
+ });
112
+ }
100
113
  return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
101
114
  // move cursor before the deleted rows if possible, otherwise - to the first row
102
115
  .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
@@ -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(),
@@ -1,3 +1,5 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { pluginKey } from '../plugin-key';
1
3
  import { deleteColumns } from '../transforms/delete-columns';
2
4
  import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
3
5
  export var deleteColumnsCommand = function deleteColumnsCommand(rect, api) {
@@ -7,6 +9,16 @@ export var deleteColumnsCommand = function deleteColumnsCommand(rect, api) {
7
9
  var isCommentEditor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
8
10
  return function (state, dispatch, view) {
9
11
  var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), api, view, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(state.tr);
12
+ // If we delete a column we should also clean up the hover selection
13
+ if (fg('platform_editor_remove_slow_table_transactions')) {
14
+ tr.setMeta(pluginKey, {
15
+ type: 'CLEAR_HOVER_SELECTION',
16
+ data: {
17
+ isInDanger: false,
18
+ isWholeTableInDanger: false
19
+ }
20
+ });
21
+ }
10
22
  if (dispatch) {
11
23
  dispatch(tr);
12
24
  return true;
@@ -5,6 +5,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import { Selection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
7
7
  import { findTable } from '@atlaskit/editor-tables/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { pluginKey } from '../plugin-key';
8
10
  import { mergeEmptyColumns } from './merge';
9
11
  export var deleteRows = function deleteRows(rect) {
10
12
  var isHeaderRowRequired = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -109,6 +111,17 @@ export var deleteRows = function deleteRows(rect) {
109
111
  return tr;
110
112
  }
111
113
  var cursorPos = getNextCursorPos(newTable, rowsToDelete);
114
+
115
+ // If we delete a row we should also clean up the hover selection
116
+ if (fg('platform_editor_remove_slow_table_transactions')) {
117
+ tr.setMeta(pluginKey, {
118
+ type: 'CLEAR_HOVER_SELECTION',
119
+ data: {
120
+ isInDanger: false,
121
+ isWholeTableInDanger: false
122
+ }
123
+ });
124
+ }
112
125
  return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
113
126
  // move cursor before the deleted rows if possible, otherwise - to the first row
114
127
  .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
@@ -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;
@@ -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.11.0",
3
+ "version": "10.11.2",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,7 +32,7 @@
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.10.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",
@@ -41,6 +41,7 @@
41
41
  "@atlaskit/editor-plugin-editor-viewmode": "^4.0.0",
42
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",
@@ -54,10 +55,10 @@
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": "^5.0.0",
58
+ "@atlaskit/tmp-editor-statsig": "^5.1.0",
58
59
  "@atlaskit/toggle": "^15.0.0",
59
60
  "@atlaskit/tokens": "^4.9.0",
60
- "@atlaskit/tooltip": "^20.0.0",
61
+ "@atlaskit/tooltip": "^20.1.0",
61
62
  "@babel/runtime": "^7.0.0",
62
63
  "@emotion/react": "^11.7.1",
63
64
  "classnames": "^2.2.5",
@@ -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
  }
@@ -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);
@@ -1,7 +1,9 @@
1
1
  import type { Command } from '@atlaskit/editor-common/types';
2
2
  import type { Rect } from '@atlaskit/editor-tables/table-map';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
 
4
5
  import type { PluginInjectionAPI } from '../../types';
6
+ import { pluginKey } from '../plugin-key';
5
7
  import { deleteColumns } from '../transforms/delete-columns';
6
8
  import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
7
9
 
@@ -25,6 +27,16 @@ export const deleteColumnsCommand =
25
27
  shouldUseIncreasedScalingPercent,
26
28
  isCommentEditor,
27
29
  )(state.tr);
30
+ // If we delete a column we should also clean up the hover selection
31
+ if (fg('platform_editor_remove_slow_table_transactions')) {
32
+ tr.setMeta(pluginKey, {
33
+ type: 'CLEAR_HOVER_SELECTION',
34
+ data: {
35
+ isInDanger: false,
36
+ isWholeTableInDanger: false,
37
+ },
38
+ });
39
+ }
28
40
  if (dispatch) {
29
41
  dispatch(tr);
30
42
  return true;
@@ -5,6 +5,9 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { Rect } from '@atlaskit/editor-tables/table-map';
6
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
7
7
  import { findTable } from '@atlaskit/editor-tables/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
9
+
10
+ import { pluginKey } from '../plugin-key';
8
11
 
9
12
  import { mergeEmptyColumns } from './merge';
10
13
 
@@ -127,6 +130,17 @@ export const deleteRows =
127
130
  }
128
131
  const cursorPos = getNextCursorPos(newTable, rowsToDelete);
129
132
 
133
+ // If we delete a row we should also clean up the hover selection
134
+ if (fg('platform_editor_remove_slow_table_transactions')) {
135
+ tr.setMeta(pluginKey, {
136
+ type: 'CLEAR_HOVER_SELECTION',
137
+ data: {
138
+ isInDanger: false,
139
+ isWholeTableInDanger: false,
140
+ },
141
+ });
142
+ }
143
+
130
144
  return (
131
145
  tr
132
146
  .replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
@@ -14,6 +14,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
14
14
  import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
15
15
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
16
16
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
17
+ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
17
18
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
18
19
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
19
20
 
@@ -82,6 +83,7 @@ export type TablePluginDependencies = [
82
83
  OptionalPlugin<EditorViewModePlugin>,
83
84
  OptionalPlugin<FeatureFlagsPlugin>,
84
85
  OptionalPlugin<ExtensionPlugin>,
86
+ OptionalPlugin<InteractionPlugin>,
85
87
  ];
86
88
 
87
89
  export type TablePlugin = NextEditorPlugin<
package/tsconfig.app.json CHANGED
@@ -68,6 +68,9 @@
68
68
  {
69
69
  "path": "../editor-plugin-guideline/tsconfig.app.json"
70
70
  },
71
+ {
72
+ "path": "../editor-plugin-interaction/tsconfig.app.json"
73
+ },
71
74
  {
72
75
  "path": "../editor-plugin-selection/tsconfig.app.json"
73
76
  },