@atlaskit/editor-plugin-table 10.9.6 → 10.9.8

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +5 -0
  3. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +33 -19
  4. package/dist/cjs/nodeviews/TableContainer.js +1 -1
  5. package/dist/cjs/nodeviews/TableResizer.js +2 -2
  6. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  7. package/dist/cjs/ui/ContentComponent.js +77 -37
  8. package/dist/cjs/ui/DragHandle/index.js +3 -3
  9. package/dist/cjs/ui/hooks/useInternalTablePluginStateSelector.js +27 -0
  10. package/dist/es2019/nodeviews/TableComponent.js +5 -0
  11. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +33 -19
  12. package/dist/es2019/nodeviews/TableContainer.js +1 -1
  13. package/dist/es2019/nodeviews/TableResizer.js +2 -2
  14. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  15. package/dist/es2019/ui/ContentComponent.js +66 -27
  16. package/dist/es2019/ui/DragHandle/index.js +3 -3
  17. package/dist/es2019/ui/hooks/useInternalTablePluginStateSelector.js +21 -0
  18. package/dist/esm/nodeviews/TableComponent.js +5 -0
  19. package/dist/esm/nodeviews/TableComponentWithSharedState.js +33 -19
  20. package/dist/esm/nodeviews/TableContainer.js +1 -1
  21. package/dist/esm/nodeviews/TableResizer.js +2 -2
  22. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  23. package/dist/esm/ui/ContentComponent.js +77 -37
  24. package/dist/esm/ui/DragHandle/index.js +3 -3
  25. package/dist/esm/ui/hooks/useInternalTablePluginStateSelector.js +21 -0
  26. package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +20 -0
  27. package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +20 -0
  28. package/package.json +6 -3
  29. package/src/nodeviews/TableComponent.tsx +5 -0
  30. package/src/nodeviews/TableComponentWithSharedState.tsx +40 -28
  31. package/src/nodeviews/TableContainer.tsx +1 -1
  32. package/src/nodeviews/TableResizer.tsx +4 -4
  33. package/src/pm-plugins/table-resizing/utils/scale-table.ts +5 -3
  34. package/src/ui/ContentComponent.tsx +71 -35
  35. package/src/ui/DragHandle/index.tsx +6 -10
  36. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -1
  37. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +3 -3
  38. package/src/ui/hooks/useInternalTablePluginStateSelector.ts +36 -0
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
3
3
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
4
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
4
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
6
  import FloatingContextualButton from './FloatingContextualButton';
7
7
  import FloatingContextualMenu from './FloatingContextualMenu';
8
8
  import FloatingDeleteButton from './FloatingDeleteButton';
@@ -12,11 +12,8 @@ import FloatingDragMenu from './FloatingDragMenu';
12
12
  import FloatingInsertButton from './FloatingInsertButton';
13
13
  import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
14
14
  import { GlobalStylesWrapper } from './global-styles';
15
+ import { useInternalTablePluginStateSelector } from './hooks/useInternalTablePluginStateSelector';
15
16
  import { FullWidthDisplay } from './TableFullWidthLabel';
16
- const useSharedTablePluginStateSelector = (api, key) => {
17
- const value = useSharedPluginStateSelector(api, `table.${key}`);
18
- return value;
19
- };
20
17
  const ContentComponentInternal = ({
21
18
  api,
22
19
  editorView,
@@ -31,30 +28,72 @@ const ContentComponentInternal = ({
31
28
  var _api$analytics, _api$accessibilityUti;
32
29
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
33
30
  const ariaNotifyPlugin = api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
34
- const resizingTableLocalId = useSharedTablePluginStateSelector(api, 'resizingTableLocalId');
35
- const resizingTableRef = useSharedTablePluginStateSelector(api, 'resizingTableRef');
36
- const isTableResizing = useSharedTablePluginStateSelector(api, 'isTableResizing');
37
- const isResizing = useSharedTablePluginStateSelector(api, 'isResizing');
38
- const widthToWidest = useSharedTablePluginStateSelector(api, 'widthToWidest');
39
- const tableNode = useSharedTablePluginStateSelector(api, 'tableNode');
40
- const targetCellPosition = useSharedTablePluginStateSelector(api, 'targetCellPosition');
41
- const isContextualMenuOpen = useSharedTablePluginStateSelector(api, 'isContextualMenuOpen');
42
- const tableRef = useSharedTablePluginStateSelector(api, 'tableRef');
43
- const pluginConfig = useSharedTablePluginStateSelector(api, 'pluginConfig');
44
- const insertColumnButtonIndex = useSharedTablePluginStateSelector(api, 'insertColumnButtonIndex');
45
- const insertRowButtonIndex = useSharedTablePluginStateSelector(api, 'insertRowButtonIndex');
46
- const isHeaderColumnEnabled = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
47
- const isHeaderRowEnabled = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
48
- const isDragAndDropEnabled = useSharedTablePluginStateSelector(api, 'isDragAndDropEnabled');
49
- const tableWrapperTarget = useSharedTablePluginStateSelector(api, 'tableWrapperTarget');
50
- const isCellMenuOpenByKeyboard = useSharedTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard');
31
+ const resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId', {
32
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
33
+ });
34
+ const resizingTableRef = useInternalTablePluginStateSelector(api, 'resizingTableRef', {
35
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
36
+ });
37
+ const isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing', {
38
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
39
+ });
40
+ const isResizing = useInternalTablePluginStateSelector(api, 'isResizing', {
41
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
42
+ });
43
+ const widthToWidest = useInternalTablePluginStateSelector(api, 'widthToWidest', {
44
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
45
+ });
46
+ const tableNode = useInternalTablePluginStateSelector(api, 'tableNode', {
47
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
48
+ });
49
+ const targetCellPosition = useInternalTablePluginStateSelector(api, 'targetCellPosition', {
50
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
51
+ });
52
+ const isContextualMenuOpen = useInternalTablePluginStateSelector(api, 'isContextualMenuOpen', {
53
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
54
+ });
55
+ const tableRef = useInternalTablePluginStateSelector(api, 'tableRef', {
56
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
57
+ });
58
+ const pluginConfig = useInternalTablePluginStateSelector(api, 'pluginConfig', {
59
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
60
+ });
61
+ const insertColumnButtonIndex = useInternalTablePluginStateSelector(api, 'insertColumnButtonIndex', {
62
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
63
+ });
64
+ const insertRowButtonIndex = useInternalTablePluginStateSelector(api, 'insertRowButtonIndex', {
65
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
66
+ });
67
+ const isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled', {
68
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
69
+ });
70
+ const isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled', {
71
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
72
+ });
73
+ const isDragAndDropEnabled = useInternalTablePluginStateSelector(api, 'isDragAndDropEnabled', {
74
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
75
+ });
76
+ const tableWrapperTarget = useInternalTablePluginStateSelector(api, 'tableWrapperTarget', {
77
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
78
+ });
79
+ const isCellMenuOpenByKeyboard = useInternalTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard', {
80
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
81
+ });
51
82
  const {
52
83
  allowControls
53
- } = pluginConfig;
54
- const stickyHeader = useSharedTablePluginStateSelector(api, 'stickyHeader');
55
- const dragMenuDirection = useSharedTablePluginStateSelector(api, 'dragMenuDirection');
56
- const dragMenuIndex = useSharedTablePluginStateSelector(api, 'dragMenuIndex');
57
- const isDragMenuOpen = useSharedTablePluginStateSelector(api, 'isDragMenuOpen');
84
+ } = pluginConfig !== null && pluginConfig !== void 0 ? pluginConfig : {};
85
+ const stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader', {
86
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
87
+ });
88
+ const dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection', {
89
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
90
+ });
91
+ const dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex', {
92
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
93
+ });
94
+ const isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen', {
95
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
96
+ });
58
97
  return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
59
98
  isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
60
99
  editorView: editorView,
@@ -7,7 +7,6 @@ import { injectIntl } from 'react-intl-next';
7
7
  import { browser } from '@atlaskit/editor-common/browser';
8
8
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
11
10
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
12
11
  import { findTable, TableMap } from '@atlaskit/editor-tables';
13
12
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
@@ -19,6 +18,7 @@ import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugi
19
18
  import { TableCssClassName as ClassName } from '../../types';
20
19
  import { dragTableInsertColumnButtonSize } from '../consts';
21
20
  import { DragPreview } from '../DragPreview';
21
+ import { useInternalTablePluginStateSelector } from '../hooks/useInternalTablePluginStateSelector';
22
22
  import { HandleIconComponent } from './HandleIconComponent';
23
23
  const DragHandleComponent = ({
24
24
  isDragMenuTarget,
@@ -275,13 +275,13 @@ const DragHandleComponentWithSharedState = ({
275
275
  });
276
276
 
277
277
  // hoveredColumns
278
- const hoveredColumnsSelector = useSharedPluginStateSelector(api, 'table.hoveredColumns', {
278
+ const hoveredColumnsSelector = useInternalTablePluginStateSelector(api, 'hoveredColumns', {
279
279
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
280
280
  });
281
281
  const hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredColumnsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns;
282
282
 
283
283
  // hoveredRows
284
- const hoveredRowsSelector = useSharedPluginStateSelector(api, 'table.hoveredRows', {
284
+ const hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
285
285
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
286
286
  });
287
287
  const hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows;
@@ -0,0 +1,21 @@
1
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
2
+ /**
3
+ * **This hook is only for internal use and should not be used outside of the table plugin.**
4
+ *
5
+ * Hook to select a value from the internal table plugin state.
6
+ * This is a wrapper around `useSharedPluginStateSelector` to provide access to the entire
7
+ * `TableSharedStateInternal` type. Since tables plugin has a lot of internal state that is not
8
+ * exposed via the `TableSharedState` type, we need to use this hook to access it in a type safe way.
9
+ *
10
+ * @param api The editor API
11
+ * @param key Key of TableSharedStateInternal to select
12
+ * @returns
13
+ */
14
+ export const useInternalTablePluginStateSelector = (api, key, options) => {
15
+ // Need to disable the eslint rule here because the key is for the TableSharedStateInternal type
16
+ // and we are using it as a string to access the value in the useSharedPluginStateSelector
17
+ // which is typed only for the public TableSharedState type.
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ const value = useSharedPluginStateSelector(api, `table.${key}`, options);
20
+ return value;
21
+ };
@@ -248,6 +248,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
248
248
  )(state.tr);
249
249
  if (!isUserTriggered) {
250
250
  tintDirtyTransaction(tr);
251
+ if (fg('platform_editor_fix_table_resizing_undo')) {
252
+ // Avoid adding this transaction separately to the history as these are automatic updates
253
+ // as a consequence of another action
254
+ tr.setMeta('addToHistory', false);
255
+ }
251
256
  }
252
257
  dispatch(tr);
253
258
  });
@@ -3,18 +3,12 @@ import { 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
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
+ import { useInternalTablePluginStateSelector } from '../ui/hooks/useInternalTablePluginStateSelector';
6
7
  import TableComponent from './TableComponent';
7
8
 
8
9
  // Ignored via go/ees005
9
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
11
 
11
- var useSharedTablePluginStateSelector = function useSharedTablePluginStateSelector(api, key) {
12
- var value = useSharedPluginStateSelector(api, "table.".concat(key), {
13
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
14
- });
15
- return value;
16
- };
17
-
18
12
  /**
19
13
  * Use useSharedPluginState to control re-renders from plugin dependencies
20
14
  */
@@ -40,16 +34,36 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
40
34
  mediaState = _useSharedPluginState.mediaState,
41
35
  selectionState = _useSharedPluginState.selectionState,
42
36
  editorViewModeState = _useSharedPluginState.editorViewModeState;
43
- var isTableResizingSelector = useSharedTablePluginStateSelector(api, 'isTableResizing');
44
- var isHeaderColumnEnabledSelector = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
45
- var isHeaderRowEnabledSelector = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
46
- var orderingSelector = useSharedTablePluginStateSelector(api, 'ordering');
47
- var isResizingSelector = useSharedTablePluginStateSelector(api, 'isResizing');
48
- var isInDangerSelector = useSharedTablePluginStateSelector(api, 'isInDanger');
49
- var hoveredCellSelector = useSharedTablePluginStateSelector(api, 'hoveredCell');
50
- var hoveredRowsSelector = useSharedTablePluginStateSelector(api, 'hoveredRows');
51
- var isTableHoveredSelector = useSharedTablePluginStateSelector(api, 'isTableHovered');
52
- var isWholeTableInDangerSelector = useSharedTablePluginStateSelector(api, 'isWholeTableInDanger');
37
+ var isTableResizingSelector = useInternalTablePluginStateSelector(api, 'isTableResizing', {
38
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
39
+ });
40
+ var isHeaderColumnEnabledSelector = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled', {
41
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
42
+ });
43
+ var isHeaderRowEnabledSelector = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled', {
44
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
45
+ });
46
+ var orderingSelector = useInternalTablePluginStateSelector(api, 'ordering', {
47
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
48
+ });
49
+ var isResizingSelector = useInternalTablePluginStateSelector(api, 'isResizing', {
50
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
51
+ });
52
+ var isInDangerSelector = useInternalTablePluginStateSelector(api, 'isInDanger', {
53
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
54
+ });
55
+ var hoveredCellSelector = useInternalTablePluginStateSelector(api, 'hoveredCell', {
56
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
57
+ });
58
+ var hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
59
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
60
+ });
61
+ var isTableHoveredSelector = useInternalTablePluginStateSelector(api, 'isTableHovered', {
62
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
63
+ });
64
+ var isWholeTableInDangerSelector = useInternalTablePluginStateSelector(api, 'isWholeTableInDanger', {
65
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
66
+ });
53
67
 
54
68
  // mediaState
55
69
  var isFullscreenSelector = useSharedPluginStateSelector(api, 'media.isFullscreen', {
@@ -117,8 +131,8 @@ export var TableComponentWithSharedState = function TableComponentWithSharedStat
117
131
  isMediaFullscreen: isFullscreen,
118
132
  options: options,
119
133
  allowControls: allowControls,
120
- isHeaderRowEnabled: isHeaderRowEnabled,
121
- isHeaderColumnEnabled: isHeaderColumnEnabled,
134
+ isHeaderRowEnabled: isHeaderRowEnabled !== null && isHeaderRowEnabled !== void 0 ? isHeaderRowEnabled : false,
135
+ isHeaderColumnEnabled: isHeaderColumnEnabled !== null && isHeaderColumnEnabled !== void 0 ? isHeaderColumnEnabled : false,
122
136
  isDragAndDropEnabled: (options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled) && !isLivePageViewMode,
123
137
  isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
124
138
  allowTableAlignment: allowTableAlignment,
@@ -58,7 +58,7 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
58
58
  });
59
59
  var wasFullWidthModeEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? wasFullWidthModeEnabledSelector : tableState === null || tableState === void 0 ? void 0 : tableState.wasFullWidthModeEnabled;
60
60
  useEffect(function () {
61
- if (editorExperiment('platform_editor_usesharedpluginstateselector', false) && !tableState) {
61
+ if (!tableState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
62
62
  return;
63
63
  }
64
64
  if (editorView && getPos) {
@@ -13,7 +13,6 @@ 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';
17
16
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
18
17
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
19
18
  import { findTable } from '@atlaskit/editor-tables/utils';
@@ -31,6 +30,7 @@ import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFram
31
30
  import { defaultGuidelines, defaultGuidelinesForPreserveTable, PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET } from '../pm-plugins/utils/guidelines';
32
31
  import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap, PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET } from '../pm-plugins/utils/snapping';
33
32
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
33
+ import { useInternalTablePluginStateSelector } from '../ui/hooks/useInternalTablePluginStateSelector';
34
34
  var RESIZE_STEP_VALUE = 10;
35
35
  var handles = {
36
36
  right: true
@@ -133,7 +133,7 @@ export var TableResizer = function TableResizer(_ref) {
133
133
  tableState = _useSharedPluginState.tableState;
134
134
 
135
135
  // widthToWidest
136
- var widthToWidestSelector = useSharedPluginStateSelector(pluginInjectionApi, 'table.widthToWidest', {
136
+ var widthToWidestSelector = useInternalTablePluginStateSelector(pluginInjectionApi, 'widthToWidest', {
137
137
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
138
138
  });
139
139
  var widthToWidest = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthToWidestSelector : tableState.widthToWidest;
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
5
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { updateColumnWidths } from '../../transforms/column-width';
8
9
  import { getTableWidth } from '../../utils/nodes';
9
10
  import { getLayoutSize } from '../utils/misc';
@@ -169,9 +170,9 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos, api) {
169
170
  }
170
171
  if (resizeState) {
171
172
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
172
- // Avoid adding this transaction separately to the history as these are automatic updates
173
- // as a consequence of another action
174
- tr.setMeta('addToHistory', false);
173
+ if (!fg('platform_editor_fix_table_resizing_undo')) {
174
+ tr.setMeta('addToHistory', false);
175
+ }
175
176
  if (tr.docChanged) {
176
177
  tr.setMeta('scrollIntoView', false);
177
178
  // TODO: ED-8995 - We need to do this check to reduce the number of race conditions when working with tables.
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
3
3
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
4
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
4
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
6
  import FloatingContextualButton from './FloatingContextualButton';
7
7
  import FloatingContextualMenu from './FloatingContextualMenu';
8
8
  import FloatingDeleteButton from './FloatingDeleteButton';
@@ -12,11 +12,8 @@ import FloatingDragMenu from './FloatingDragMenu';
12
12
  import FloatingInsertButton from './FloatingInsertButton';
13
13
  import { FloatingToolbarLabel } from './FloatingToolbarLabel/FloatingToolbarLabel';
14
14
  import { GlobalStylesWrapper } from './global-styles';
15
+ import { useInternalTablePluginStateSelector } from './hooks/useInternalTablePluginStateSelector';
15
16
  import { FullWidthDisplay } from './TableFullWidthLabel';
16
- var useSharedTablePluginStateSelector = function useSharedTablePluginStateSelector(api, key) {
17
- var value = useSharedPluginStateSelector(api, "table.".concat(key));
18
- return value;
19
- };
20
17
  var ContentComponentInternal = function ContentComponentInternal(_ref) {
21
18
  var _api$analytics, _api$accessibilityUti;
22
19
  var api = _ref.api,
@@ -30,28 +27,71 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
30
27
  defaultGetEditorFeatureFlags = _ref.defaultGetEditorFeatureFlags;
31
28
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
32
29
  var ariaNotifyPlugin = api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify;
33
- var resizingTableLocalId = useSharedTablePluginStateSelector(api, 'resizingTableLocalId');
34
- var resizingTableRef = useSharedTablePluginStateSelector(api, 'resizingTableRef');
35
- var isTableResizing = useSharedTablePluginStateSelector(api, 'isTableResizing');
36
- var isResizing = useSharedTablePluginStateSelector(api, 'isResizing');
37
- var widthToWidest = useSharedTablePluginStateSelector(api, 'widthToWidest');
38
- var tableNode = useSharedTablePluginStateSelector(api, 'tableNode');
39
- var targetCellPosition = useSharedTablePluginStateSelector(api, 'targetCellPosition');
40
- var isContextualMenuOpen = useSharedTablePluginStateSelector(api, 'isContextualMenuOpen');
41
- var tableRef = useSharedTablePluginStateSelector(api, 'tableRef');
42
- var pluginConfig = useSharedTablePluginStateSelector(api, 'pluginConfig');
43
- var insertColumnButtonIndex = useSharedTablePluginStateSelector(api, 'insertColumnButtonIndex');
44
- var insertRowButtonIndex = useSharedTablePluginStateSelector(api, 'insertRowButtonIndex');
45
- var isHeaderColumnEnabled = useSharedTablePluginStateSelector(api, 'isHeaderColumnEnabled');
46
- var isHeaderRowEnabled = useSharedTablePluginStateSelector(api, 'isHeaderRowEnabled');
47
- var isDragAndDropEnabled = useSharedTablePluginStateSelector(api, 'isDragAndDropEnabled');
48
- var tableWrapperTarget = useSharedTablePluginStateSelector(api, 'tableWrapperTarget');
49
- var isCellMenuOpenByKeyboard = useSharedTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard');
50
- var allowControls = pluginConfig.allowControls;
51
- var stickyHeader = useSharedTablePluginStateSelector(api, 'stickyHeader');
52
- var dragMenuDirection = useSharedTablePluginStateSelector(api, 'dragMenuDirection');
53
- var dragMenuIndex = useSharedTablePluginStateSelector(api, 'dragMenuIndex');
54
- var isDragMenuOpen = useSharedTablePluginStateSelector(api, 'isDragMenuOpen');
30
+ var resizingTableLocalId = useInternalTablePluginStateSelector(api, 'resizingTableLocalId', {
31
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
32
+ });
33
+ var resizingTableRef = useInternalTablePluginStateSelector(api, 'resizingTableRef', {
34
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
35
+ });
36
+ var isTableResizing = useInternalTablePluginStateSelector(api, 'isTableResizing', {
37
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
38
+ });
39
+ var isResizing = useInternalTablePluginStateSelector(api, 'isResizing', {
40
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
41
+ });
42
+ var widthToWidest = useInternalTablePluginStateSelector(api, 'widthToWidest', {
43
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
44
+ });
45
+ var tableNode = useInternalTablePluginStateSelector(api, 'tableNode', {
46
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
47
+ });
48
+ var targetCellPosition = useInternalTablePluginStateSelector(api, 'targetCellPosition', {
49
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
50
+ });
51
+ var isContextualMenuOpen = useInternalTablePluginStateSelector(api, 'isContextualMenuOpen', {
52
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
53
+ });
54
+ var tableRef = useInternalTablePluginStateSelector(api, 'tableRef', {
55
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
56
+ });
57
+ var pluginConfig = useInternalTablePluginStateSelector(api, 'pluginConfig', {
58
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
59
+ });
60
+ var insertColumnButtonIndex = useInternalTablePluginStateSelector(api, 'insertColumnButtonIndex', {
61
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
62
+ });
63
+ var insertRowButtonIndex = useInternalTablePluginStateSelector(api, 'insertRowButtonIndex', {
64
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
65
+ });
66
+ var isHeaderColumnEnabled = useInternalTablePluginStateSelector(api, 'isHeaderColumnEnabled', {
67
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
68
+ });
69
+ var isHeaderRowEnabled = useInternalTablePluginStateSelector(api, 'isHeaderRowEnabled', {
70
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
71
+ });
72
+ var isDragAndDropEnabled = useInternalTablePluginStateSelector(api, 'isDragAndDropEnabled', {
73
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
74
+ });
75
+ var tableWrapperTarget = useInternalTablePluginStateSelector(api, 'tableWrapperTarget', {
76
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
77
+ });
78
+ var isCellMenuOpenByKeyboard = useInternalTablePluginStateSelector(api, 'isCellMenuOpenByKeyboard', {
79
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
80
+ });
81
+ var _ref2 = pluginConfig !== null && pluginConfig !== void 0 ? pluginConfig : {},
82
+ allowControls = _ref2.allowControls;
83
+ var stickyHeader = useInternalTablePluginStateSelector(api, 'stickyHeader', {
84
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
85
+ });
86
+ var dragMenuDirection = useInternalTablePluginStateSelector(api, 'dragMenuDirection', {
87
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
88
+ });
89
+ var dragMenuIndex = useInternalTablePluginStateSelector(api, 'dragMenuIndex', {
90
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
91
+ });
92
+ var isDragMenuOpen = useInternalTablePluginStateSelector(api, 'isDragMenuOpen', {
93
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
94
+ });
55
95
  return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
56
96
  isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
57
97
  editorView: editorView,
@@ -139,17 +179,17 @@ var ContentComponentInternal = function ContentComponentInternal(_ref) {
139
179
  offset: [0, 10]
140
180
  }));
141
181
  };
142
- export var ContentComponent = function ContentComponent(_ref2) {
182
+ export var ContentComponent = function ContentComponent(_ref3) {
143
183
  var _api$featureFlags;
144
- var api = _ref2.api,
145
- editorView = _ref2.editorView,
146
- dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
147
- options = _ref2.options,
148
- popupsMountPoint = _ref2.popupsMountPoint,
149
- popupsBoundariesElement = _ref2.popupsBoundariesElement,
150
- popupsScrollableElement = _ref2.popupsScrollableElement,
151
- defaultGetEditorContainerWidth = _ref2.defaultGetEditorContainerWidth,
152
- defaultGetEditorFeatureFlags = _ref2.defaultGetEditorFeatureFlags;
184
+ var api = _ref3.api,
185
+ editorView = _ref3.editorView,
186
+ dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
187
+ options = _ref3.options,
188
+ popupsMountPoint = _ref3.popupsMountPoint,
189
+ popupsBoundariesElement = _ref3.popupsBoundariesElement,
190
+ popupsScrollableElement = _ref3.popupsScrollableElement,
191
+ defaultGetEditorContainerWidth = _ref3.defaultGetEditorContainerWidth,
192
+ defaultGetEditorFeatureFlags = _ref3.defaultGetEditorFeatureFlags;
153
193
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
154
194
  component: ACTION_SUBJECT.TABLES_PLUGIN,
155
195
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -9,7 +9,6 @@ import { injectIntl } from 'react-intl-next';
9
9
  import { browser } from '@atlaskit/editor-common/browser';
10
10
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
11
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
12
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
13
12
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
14
13
  import { findTable, TableMap } from '@atlaskit/editor-tables';
15
14
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
@@ -21,6 +20,7 @@ import { findDuplicatePosition, hasMergedCellsInSelection } from '../../pm-plugi
21
20
  import { TableCssClassName as ClassName } from '../../types';
22
21
  import { dragTableInsertColumnButtonSize } from '../consts';
23
22
  import { DragPreview } from '../DragPreview';
23
+ import { useInternalTablePluginStateSelector } from '../hooks/useInternalTablePluginStateSelector';
24
24
  import { HandleIconComponent } from './HandleIconComponent';
25
25
  var DragHandleComponent = function DragHandleComponent(_ref) {
26
26
  var isDragMenuTarget = _ref.isDragMenuTarget,
@@ -268,13 +268,13 @@ var DragHandleComponentWithSharedState = function DragHandleComponentWithSharedS
268
268
  tableState = _ref6.tableState;
269
269
 
270
270
  // hoveredColumns
271
- var hoveredColumnsSelector = useSharedPluginStateSelector(api, 'table.hoveredColumns', {
271
+ var hoveredColumnsSelector = useInternalTablePluginStateSelector(api, 'hoveredColumns', {
272
272
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
273
273
  });
274
274
  var hoveredColumns = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredColumnsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredColumns;
275
275
 
276
276
  // hoveredRows
277
- var hoveredRowsSelector = useSharedPluginStateSelector(api, 'table.hoveredRows', {
277
+ var hoveredRowsSelector = useInternalTablePluginStateSelector(api, 'hoveredRows', {
278
278
  disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
279
279
  });
280
280
  var hoveredRows = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hoveredRowsSelector : tableState === null || tableState === void 0 ? void 0 : tableState.hoveredRows;
@@ -0,0 +1,21 @@
1
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
2
+ /**
3
+ * **This hook is only for internal use and should not be used outside of the table plugin.**
4
+ *
5
+ * Hook to select a value from the internal table plugin state.
6
+ * This is a wrapper around `useSharedPluginStateSelector` to provide access to the entire
7
+ * `TableSharedStateInternal` type. Since tables plugin has a lot of internal state that is not
8
+ * exposed via the `TableSharedState` type, we need to use this hook to access it in a type safe way.
9
+ *
10
+ * @param api The editor API
11
+ * @param key Key of TableSharedStateInternal to select
12
+ * @returns
13
+ */
14
+ export var useInternalTablePluginStateSelector = function useInternalTablePluginStateSelector(api, key, options) {
15
+ // Need to disable the eslint rule here because the key is for the TableSharedStateInternal type
16
+ // and we are using it as a string to access the value in the useSharedPluginStateSelector
17
+ // which is typed only for the public TableSharedState type.
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ var value = useSharedPluginStateSelector(api, "table.".concat(key), options);
20
+ return value;
21
+ };
@@ -0,0 +1,20 @@
1
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { TablePlugin } from '../../tablePluginType';
3
+ import { TableSharedStateInternal } from '../../types';
4
+ type Options = {
5
+ disabled?: boolean;
6
+ };
7
+ /**
8
+ * **This hook is only for internal use and should not be used outside of the table plugin.**
9
+ *
10
+ * Hook to select a value from the internal table plugin state.
11
+ * This is a wrapper around `useSharedPluginStateSelector` to provide access to the entire
12
+ * `TableSharedStateInternal` type. Since tables plugin has a lot of internal state that is not
13
+ * exposed via the `TableSharedState` type, we need to use this hook to access it in a type safe way.
14
+ *
15
+ * @param api The editor API
16
+ * @param key Key of TableSharedStateInternal to select
17
+ * @returns
18
+ */
19
+ export declare const useInternalTablePluginStateSelector: <K extends "isFullWidthModeEnabled" | "wasFullWidthModeEnabled" | "isHeaderRowEnabled" | "isHeaderColumnEnabled" | "ordering" | "isInDanger" | "hoveredRows" | "hoveredColumns" | "hoveredCell" | "isTableHovered" | "tableNode" | "widthToWidest" | "tableRef" | "tablePos" | "targetCellPosition" | "isContextualMenuOpen" | "pluginConfig" | "insertColumnButtonIndex" | "insertRowButtonIndex" | "isDragAndDropEnabled" | "tableWrapperTarget" | "isCellMenuOpenByKeyboard" | "isWholeTableInDanger" | "isDragMenuOpen" | "dragMenuDirection" | "dragMenuIndex" | "isResizing" | "isTableResizing" | "resizingTableRef" | "resizingTableLocalId" | "stickyHeader">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
20
+ export {};
@@ -0,0 +1,20 @@
1
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { TablePlugin } from '../../tablePluginType';
3
+ import { TableSharedStateInternal } from '../../types';
4
+ type Options = {
5
+ disabled?: boolean;
6
+ };
7
+ /**
8
+ * **This hook is only for internal use and should not be used outside of the table plugin.**
9
+ *
10
+ * Hook to select a value from the internal table plugin state.
11
+ * This is a wrapper around `useSharedPluginStateSelector` to provide access to the entire
12
+ * `TableSharedStateInternal` type. Since tables plugin has a lot of internal state that is not
13
+ * exposed via the `TableSharedState` type, we need to use this hook to access it in a type safe way.
14
+ *
15
+ * @param api The editor API
16
+ * @param key Key of TableSharedStateInternal to select
17
+ * @returns
18
+ */
19
+ export declare const useInternalTablePluginStateSelector: <K extends "isFullWidthModeEnabled" | "wasFullWidthModeEnabled" | "isHeaderRowEnabled" | "isHeaderColumnEnabled" | "ordering" | "isInDanger" | "hoveredRows" | "hoveredColumns" | "hoveredCell" | "isTableHovered" | "tableNode" | "widthToWidest" | "tableRef" | "tablePos" | "targetCellPosition" | "isContextualMenuOpen" | "pluginConfig" | "insertColumnButtonIndex" | "insertRowButtonIndex" | "isDragAndDropEnabled" | "tableWrapperTarget" | "isCellMenuOpenByKeyboard" | "isWholeTableInDanger" | "isDragMenuOpen" | "dragMenuDirection" | "dragMenuIndex" | "isResizing" | "isTableResizing" | "resizingTableRef" | "resizingTableLocalId" | "stickyHeader">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
20
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.9.6",
3
+ "version": "10.9.8",
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.0.0",
34
34
  "@atlaskit/custom-steps": "^0.11.0",
35
- "@atlaskit/editor-common": "^103.16.0",
35
+ "@atlaskit/editor-common": "^103.18.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.2.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/icon": "^25.6.0",
50
50
  "@atlaskit/menu": "^3.2.0",
51
51
  "@atlaskit/platform-feature-flags": "^1.1.0",
52
- "@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
52
+ "@atlaskit/pragmatic-drag-and-drop": "^1.6.0",
53
53
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
54
54
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
55
55
  "@atlaskit/primitives": "^14.4.0",
@@ -206,6 +206,9 @@
206
206
  },
207
207
  "platform_editor_controls_patch_6": {
208
208
  "type": "boolean"
209
+ },
210
+ "platform_editor_fix_table_resizing_undo": {
211
+ "type": "boolean"
209
212
  }
210
213
  }
211
214
  }
@@ -1308,6 +1308,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
1308
1308
 
1309
1309
  if (!isUserTriggered) {
1310
1310
  tintDirtyTransaction(tr);
1311
+ if (fg('platform_editor_fix_table_resizing_undo')) {
1312
+ // Avoid adding this transaction separately to the history as these are automatic updates
1313
+ // as a consequence of another action
1314
+ tr.setMeta('addToHistory', false);
1315
+ }
1311
1316
  }
1312
1317
 
1313
1318
  dispatch(tr);