@atlaskit/editor-plugin-table 10.9.23 → 10.9.25

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 (29) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/nodeviews/TableContainer.js +16 -0
  3. package/dist/cjs/pm-plugins/decorations/plugin.js +19 -1
  4. package/dist/cjs/ui/hooks/useInternalTablePluginStateSelector.js +2 -0
  5. package/dist/cjs/ui/toolbar.js +2 -2
  6. package/dist/es2019/nodeviews/TableContainer.js +16 -0
  7. package/dist/es2019/pm-plugins/decorations/plugin.js +19 -1
  8. package/dist/es2019/ui/hooks/useInternalTablePluginStateSelector.js +2 -0
  9. package/dist/es2019/ui/toolbar.js +2 -2
  10. package/dist/esm/nodeviews/TableContainer.js +16 -0
  11. package/dist/esm/pm-plugins/decorations/plugin.js +19 -1
  12. package/dist/esm/ui/hooks/useInternalTablePluginStateSelector.js +2 -0
  13. package/dist/esm/ui/toolbar.js +2 -2
  14. package/dist/types/types/index.d.ts +1 -1
  15. package/dist/types/ui/ContentComponent.d.ts +3 -3
  16. package/dist/types/ui/SizeSelector/index.d.ts +1 -1
  17. package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +5 -3
  18. package/dist/types-ts4.5/types/index.d.ts +1 -1
  19. package/dist/types-ts4.5/ui/ContentComponent.d.ts +3 -3
  20. package/dist/types-ts4.5/ui/SizeSelector/index.d.ts +1 -1
  21. package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +5 -3
  22. package/package.json +11 -5
  23. package/src/nodeviews/TableContainer.tsx +17 -0
  24. package/src/pm-plugins/decorations/plugin.ts +24 -1
  25. package/src/types/index.ts +1 -1
  26. package/src/ui/ContentComponent.tsx +5 -5
  27. package/src/ui/SizeSelector/index.tsx +1 -1
  28. package/src/ui/hooks/useInternalTablePluginStateSelector.ts +5 -3
  29. package/src/ui/toolbar.tsx +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 10.9.25
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 10.9.24
10
+
11
+ ### Patch Changes
12
+
13
+ - [#154343](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154343)
14
+ [`65a57af636614`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65a57af636614) -
15
+ [ux] ED-27894: add platform_editor_table_fw_numcol_overflow_fix to stop first-paint flash and
16
+ overflow on full-width numbered-column tables when refreshing page
17
+
3
18
  ## 10.9.23
4
19
 
5
20
  ### Patch Changes
@@ -238,6 +238,22 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
238
238
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
239
239
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
240
240
  responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2 - resizeHandleSpacing;
241
+
242
+ // platform_editor_table_fw_numcol_overflow_fix:
243
+ // lineLength is undefined on first paint → width: NaN → wrapper expands to page
244
+ // width. rAF col-sizing then runs before the number-column padding and
245
+ // the final shrink, so column widths are locked in wrong.
246
+ // With the flag ON, if the value isn’t finite we fall back to gutterWidth
247
+ // for that first frame—no flash, no premature rAF.
248
+ //
249
+ // Type clean-up comes later:
250
+ // 1) ship this runtime guard (quick fix, no breakage);
251
+ // 2) TODO: widen lineLength to `number|undefined` and remove this block.
252
+ if ((0, _platformFeatureFlags.fg)('platform_editor_table_fw_numcol_overflow_fix')) {
253
+ if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
254
+ responsiveContainerWidth = containerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2 - resizeHandleSpacing;
255
+ }
256
+ }
241
257
  } else if (isCommentEditor) {
242
258
  responsiveContainerWidth = containerWidth - _consts.TABLE_OFFSET_IN_COMMENT_EDITOR;
243
259
  } else {
@@ -4,10 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.pluginKey = exports.handleDocOrSelectionChanged = exports.getDecorations = exports.createPlugin = void 0;
7
+ var _coreUtils = require("@atlaskit/editor-common/core-utils");
7
8
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
9
  var _state = require("@atlaskit/editor-prosemirror/state");
9
10
  var _view = require("@atlaskit/editor-prosemirror/view");
10
11
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
12
+ var _utils = require("@atlaskit/editor-tables/utils");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
14
  var _pluginKey = require("../plugin-key");
12
15
  var _tableWidth = require("../table-width");
13
16
  var _columnControls = require("./utils/column-controls");
@@ -21,7 +24,9 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
21
24
  var wasResizing = (_tableWidthPluginKey$2 = _tableWidth.pluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
22
25
  var _ref = _pluginKey.pluginKey.getState(newState) || {},
23
26
  _ref$isDragAndDropEna = _ref.isDragAndDropEnabled,
24
- isDragAndDropEnabled = _ref$isDragAndDropEna === void 0 ? false : _ref$isDragAndDropEna;
27
+ isDragAndDropEnabled = _ref$isDragAndDropEna === void 0 ? false : _ref$isDragAndDropEna,
28
+ isInDanger = _ref.isInDanger,
29
+ isTableHovered = _ref.isTableHovered;
25
30
  var changedResizing = isResizing !== wasResizing;
26
31
 
27
32
  // Remove column controls when resizing and don't add column decoration controls when DnD enabled
@@ -43,6 +48,19 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
43
48
  tr: tr
44
49
  });
45
50
  }
51
+ if ((0, _platformFeatureFlags.fg)('platform_editor_remove_slow_table_transactions')) {
52
+ var _findTable, _findTable2;
53
+ // We're exiting a table with an existing decorations so we should clean it up
54
+ if ((isInDanger || isTableHovered) && (!(0, _coreUtils.insideTable)(newState) || ((_findTable = (0, _utils.findTable)(newState.selection)) === null || _findTable === void 0 ? void 0 : _findTable.node) !== ((_findTable2 = (0, _utils.findTable)(oldState.selection)) === null || _findTable2 === void 0 ? void 0 : _findTable2.node))) {
55
+ return (0, _columnControls.buildColumnControlsDecorations)({
56
+ decorationSet: decorationSet,
57
+ tr: tr,
58
+ options: {
59
+ isDragAndDropEnabled: isDragAndDropEnabled
60
+ }
61
+ });
62
+ }
63
+ }
46
64
  }
47
65
  return decorationSet;
48
66
  };
@@ -15,7 +15,9 @@ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-
15
15
  *
16
16
  * @param api The editor API
17
17
  * @param key Key of TableSharedStateInternal to select
18
+ * @param options
18
19
  * @returns
20
+ * @example
19
21
  */
20
22
  var useInternalTablePluginStateSelector = exports.useInternalTablePluginStateSelector = function useInternalTablePluginStateSelector(api, key, options) {
21
23
  // Need to disable the eslint rule here because the key is for the TableSharedStateInternal type
@@ -804,8 +804,8 @@ var isLayoutOptionDisabled = function isLayoutOptionDisabled(selectedNode, getEd
804
804
 
805
805
  // table may be scaled, use the scale percent to calculate the table width
806
806
  if (editorView) {
807
- var tableWrapper = getDomRef(editorView);
808
- var tableWrapperWidth = (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.clientWidth) || tableContainerWidth;
807
+ var _getDomRef;
808
+ var tableWrapperWidth = (0, _platformFeatureFlags.fg)('platform_editor_remove_slow_table_transactions') ? tableContainerWidth : ((_getDomRef = getDomRef(editorView)) === null || _getDomRef === void 0 ? void 0 : _getDomRef.clientWidth) || tableContainerWidth;
809
809
  var scalePercent = (0, _misc.getStaticTableScalingPercent)(selectedNode, tableWrapperWidth, shouldUseIncreasedScalingPercent);
810
810
  tableContainerWidth = tableContainerWidth * scalePercent;
811
811
  }
@@ -234,6 +234,22 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
234
234
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
235
235
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
236
236
  responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
237
+
238
+ // platform_editor_table_fw_numcol_overflow_fix:
239
+ // lineLength is undefined on first paint → width: NaN → wrapper expands to page
240
+ // width. rAF col-sizing then runs before the number-column padding and
241
+ // the final shrink, so column widths are locked in wrong.
242
+ // With the flag ON, if the value isn’t finite we fall back to gutterWidth
243
+ // for that first frame—no flash, no premature rAF.
244
+ //
245
+ // Type clean-up comes later:
246
+ // 1) ship this runtime guard (quick fix, no breakage);
247
+ // 2) TODO: widen lineLength to `number|undefined` and remove this block.
248
+ if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
249
+ if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
250
+ responsiveContainerWidth = containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
251
+ }
252
+ }
237
253
  } else if (isCommentEditor) {
238
254
  responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
239
255
  } else {
@@ -1,7 +1,10 @@
1
+ import { insideTable } from '@atlaskit/editor-common/core-utils';
1
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
+ import { findTable } from '@atlaskit/editor-tables/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
5
8
  import { pluginKey as tablePluginKey } from '../plugin-key';
6
9
  import { pluginKey as tableWidthPluginKey } from '../table-width';
7
10
  import { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration } from './utils/column-controls';
@@ -12,7 +15,9 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState, newStat
12
15
  const isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
13
16
  const wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
14
17
  const {
15
- isDragAndDropEnabled = false
18
+ isDragAndDropEnabled = false,
19
+ isInDanger,
20
+ isTableHovered
16
21
  } = tablePluginKey.getState(newState) || {};
17
22
  const changedResizing = isResizing !== wasResizing;
18
23
 
@@ -35,6 +40,19 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState, newStat
35
40
  tr
36
41
  });
37
42
  }
43
+ if (fg('platform_editor_remove_slow_table_transactions')) {
44
+ var _findTable, _findTable2;
45
+ // We're exiting a table with an existing decorations so we should clean it up
46
+ if ((isInDanger || isTableHovered) && (!insideTable(newState) || ((_findTable = findTable(newState.selection)) === null || _findTable === void 0 ? void 0 : _findTable.node) !== ((_findTable2 = findTable(oldState.selection)) === null || _findTable2 === void 0 ? void 0 : _findTable2.node))) {
47
+ return buildColumnControlsDecorations({
48
+ decorationSet,
49
+ tr,
50
+ options: {
51
+ isDragAndDropEnabled
52
+ }
53
+ });
54
+ }
55
+ }
38
56
  }
39
57
  return decorationSet;
40
58
  };
@@ -9,7 +9,9 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
9
9
  *
10
10
  * @param api The editor API
11
11
  * @param key Key of TableSharedStateInternal to select
12
+ * @param options
12
13
  * @returns
14
+ * @example
13
15
  */
14
16
  export const useInternalTablePluginStateSelector = (api, key, options) => {
15
17
  // Need to disable the eslint rule here because the key is for the TableSharedStateInternal type
@@ -754,8 +754,8 @@ const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth, getDomRef
754
754
 
755
755
  // table may be scaled, use the scale percent to calculate the table width
756
756
  if (editorView) {
757
- const tableWrapper = getDomRef(editorView);
758
- const tableWrapperWidth = (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.clientWidth) || tableContainerWidth;
757
+ var _getDomRef;
758
+ const tableWrapperWidth = fg('platform_editor_remove_slow_table_transactions') ? tableContainerWidth : ((_getDomRef = getDomRef(editorView)) === null || _getDomRef === void 0 ? void 0 : _getDomRef.clientWidth) || tableContainerWidth;
759
759
  const scalePercent = getStaticTableScalingPercent(selectedNode, tableWrapperWidth, shouldUseIncreasedScalingPercent);
760
760
  tableContainerWidth = tableContainerWidth * scalePercent;
761
761
  }
@@ -228,6 +228,22 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
228
228
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
229
229
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
230
230
  responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
231
+
232
+ // platform_editor_table_fw_numcol_overflow_fix:
233
+ // lineLength is undefined on first paint → width: NaN → wrapper expands to page
234
+ // width. rAF col-sizing then runs before the number-column padding and
235
+ // the final shrink, so column widths are locked in wrong.
236
+ // With the flag ON, if the value isn’t finite we fall back to gutterWidth
237
+ // for that first frame—no flash, no premature rAF.
238
+ //
239
+ // Type clean-up comes later:
240
+ // 1) ship this runtime guard (quick fix, no breakage);
241
+ // 2) TODO: widen lineLength to `number|undefined` and remove this block.
242
+ if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
243
+ if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
244
+ responsiveContainerWidth = containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
245
+ }
246
+ }
231
247
  } else if (isCommentEditor) {
232
248
  responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
233
249
  } else {
@@ -1,7 +1,10 @@
1
+ import { insideTable } from '@atlaskit/editor-common/core-utils';
1
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
+ import { findTable } from '@atlaskit/editor-tables/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
5
8
  import { pluginKey as tablePluginKey } from '../plugin-key';
6
9
  import { pluginKey as tableWidthPluginKey } from '../table-width';
7
10
  import { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration } from './utils/column-controls';
@@ -15,7 +18,9 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
15
18
  var wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
16
19
  var _ref = tablePluginKey.getState(newState) || {},
17
20
  _ref$isDragAndDropEna = _ref.isDragAndDropEnabled,
18
- isDragAndDropEnabled = _ref$isDragAndDropEna === void 0 ? false : _ref$isDragAndDropEna;
21
+ isDragAndDropEnabled = _ref$isDragAndDropEna === void 0 ? false : _ref$isDragAndDropEna,
22
+ isInDanger = _ref.isInDanger,
23
+ isTableHovered = _ref.isTableHovered;
19
24
  var changedResizing = isResizing !== wasResizing;
20
25
 
21
26
  // Remove column controls when resizing and don't add column decoration controls when DnD enabled
@@ -37,6 +42,19 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
37
42
  tr: tr
38
43
  });
39
44
  }
45
+ if (fg('platform_editor_remove_slow_table_transactions')) {
46
+ var _findTable, _findTable2;
47
+ // We're exiting a table with an existing decorations so we should clean it up
48
+ if ((isInDanger || isTableHovered) && (!insideTable(newState) || ((_findTable = findTable(newState.selection)) === null || _findTable === void 0 ? void 0 : _findTable.node) !== ((_findTable2 = findTable(oldState.selection)) === null || _findTable2 === void 0 ? void 0 : _findTable2.node))) {
49
+ return buildColumnControlsDecorations({
50
+ decorationSet: decorationSet,
51
+ tr: tr,
52
+ options: {
53
+ isDragAndDropEnabled: isDragAndDropEnabled
54
+ }
55
+ });
56
+ }
57
+ }
40
58
  }
41
59
  return decorationSet;
42
60
  };
@@ -9,7 +9,9 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
9
9
  *
10
10
  * @param api The editor API
11
11
  * @param key Key of TableSharedStateInternal to select
12
+ * @param options
12
13
  * @returns
14
+ * @example
13
15
  */
14
16
  export var useInternalTablePluginStateSelector = function useInternalTablePluginStateSelector(api, key, options) {
15
17
  // Need to disable the eslint rule here because the key is for the TableSharedStateInternal type
@@ -796,8 +796,8 @@ var isLayoutOptionDisabled = function isLayoutOptionDisabled(selectedNode, getEd
796
796
 
797
797
  // table may be scaled, use the scale percent to calculate the table width
798
798
  if (editorView) {
799
- var tableWrapper = getDomRef(editorView);
800
- var tableWrapperWidth = (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.clientWidth) || tableContainerWidth;
799
+ var _getDomRef;
800
+ var tableWrapperWidth = fg('platform_editor_remove_slow_table_transactions') ? tableContainerWidth : ((_getDomRef = getDomRef(editorView)) === null || _getDomRef === void 0 ? void 0 : _getDomRef.clientWidth) || tableContainerWidth;
801
801
  var scalePercent = getStaticTableScalingPercent(selectedNode, tableWrapperWidth, shouldUseIncreasedScalingPercent);
802
802
  tableContainerWidth = tableContainerWidth * scalePercent;
803
803
  }
@@ -8,7 +8,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
8
8
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import type { Rect } from '@atlaskit/editor-tables/table-map';
10
10
  import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
11
- import { RowStickyState } from '../pm-plugins/sticky-headers/types';
11
+ import type { RowStickyState } from '../pm-plugins/sticky-headers/types';
12
12
  import type { TablePlugin } from '../tablePluginType';
13
13
  export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
14
14
  export type RowInsertPosition = 'TOP' | 'BOTTOM';
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
- import { ExtractInjectionAPI, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
2
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
+ import { type ExtractInjectionAPI, type GetEditorContainerWidth, type GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
4
4
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import { TablePlugin, TablePluginOptions } from '../tablePluginType';
5
+ import { type TablePlugin, type TablePluginOptions } from '../tablePluginType';
6
6
  export type ContentComponentProps = {
7
7
  api: ExtractInjectionAPI<TablePlugin> | undefined;
8
8
  editorView: EditorView;
@@ -1,7 +1,7 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { type TableSelectorPopupProps } from '@atlaskit/editor-common/ui';
4
- import { TablePlugin } from '../../tablePluginType';
4
+ import type { TablePlugin } from '../../tablePluginType';
5
5
  interface SizeSelectorProps extends Omit<TableSelectorPopupProps, 'handleClickOutside' | 'onSelection' | 'unUnmount'> {
6
6
  api?: ExtractInjectionAPI<TablePlugin>;
7
7
  }
@@ -1,6 +1,6 @@
1
- import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import { TablePlugin } from '../../tablePluginType';
3
- import { TableSharedStateInternal } from '../../types';
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { TablePlugin } from '../../tablePluginType';
3
+ import type { TableSharedStateInternal } from '../../types';
4
4
  type Options = {
5
5
  disabled?: boolean;
6
6
  };
@@ -14,7 +14,9 @@ type Options = {
14
14
  *
15
15
  * @param api The editor API
16
16
  * @param key Key of TableSharedStateInternal to select
17
+ * @param options
17
18
  * @returns
19
+ * @example
18
20
  */
19
21
  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" | "isSizeSelectorOpen" | "sizeSelectorTargetRef">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
20
22
  export {};
@@ -8,7 +8,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
8
8
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import type { Rect } from '@atlaskit/editor-tables/table-map';
10
10
  import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
11
- import { RowStickyState } from '../pm-plugins/sticky-headers/types';
11
+ import type { RowStickyState } from '../pm-plugins/sticky-headers/types';
12
12
  import type { TablePlugin } from '../tablePluginType';
13
13
  export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
14
14
  export type RowInsertPosition = 'TOP' | 'BOTTOM';
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
- import { ExtractInjectionAPI, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
2
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
+ import { type ExtractInjectionAPI, type GetEditorContainerWidth, type GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
4
4
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import { TablePlugin, TablePluginOptions } from '../tablePluginType';
5
+ import { type TablePlugin, type TablePluginOptions } from '../tablePluginType';
6
6
  export type ContentComponentProps = {
7
7
  api: ExtractInjectionAPI<TablePlugin> | undefined;
8
8
  editorView: EditorView;
@@ -1,7 +1,7 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { type TableSelectorPopupProps } from '@atlaskit/editor-common/ui';
4
- import { TablePlugin } from '../../tablePluginType';
4
+ import type { TablePlugin } from '../../tablePluginType';
5
5
  interface SizeSelectorProps extends Omit<TableSelectorPopupProps, 'handleClickOutside' | 'onSelection' | 'unUnmount'> {
6
6
  api?: ExtractInjectionAPI<TablePlugin>;
7
7
  }
@@ -1,6 +1,6 @@
1
- import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import { TablePlugin } from '../../tablePluginType';
3
- import { TableSharedStateInternal } from '../../types';
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { TablePlugin } from '../../tablePluginType';
3
+ import type { TableSharedStateInternal } from '../../types';
4
4
  type Options = {
5
5
  disabled?: boolean;
6
6
  };
@@ -14,7 +14,9 @@ type Options = {
14
14
  *
15
15
  * @param api The editor API
16
16
  * @param key Key of TableSharedStateInternal to select
17
+ * @param options
17
18
  * @returns
19
+ * @example
18
20
  */
19
21
  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" | "isSizeSelectorOpen" | "sizeSelectorTargetRef">(api: ExtractInjectionAPI<TablePlugin> | undefined, key: K, options?: Options) => TableSharedStateInternal[K] | undefined;
20
22
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "10.9.23",
3
+ "version": "10.9.25",
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": "^105.2.0",
35
+ "@atlaskit/editor-common": "^105.5.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",
@@ -47,14 +47,14 @@
47
47
  "@atlaskit/editor-shared-styles": "^3.4.0",
48
48
  "@atlaskit/editor-tables": "^2.9.0",
49
49
  "@atlaskit/icon": "^26.0.0",
50
- "@atlaskit/menu": "^5.0.0",
50
+ "@atlaskit/menu": "^6.0.0",
51
51
  "@atlaskit/platform-feature-flags": "^1.1.0",
52
52
  "@atlaskit/pragmatic-drag-and-drop": "^1.6.0",
53
53
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
54
- "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
54
+ "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
55
55
  "@atlaskit/primitives": "^14.7.0",
56
56
  "@atlaskit/theme": "^18.0.0",
57
- "@atlaskit/tmp-editor-statsig": "^4.21.0",
57
+ "@atlaskit/tmp-editor-statsig": "^4.22.0",
58
58
  "@atlaskit/toggle": "^15.0.0",
59
59
  "@atlaskit/tokens": "^4.8.0",
60
60
  "@atlaskit/tooltip": "^20.0.0",
@@ -195,6 +195,9 @@
195
195
  "platform_editor_controls_table_picker": {
196
196
  "type": "boolean"
197
197
  },
198
+ "platform_editor_remove_slow_table_transactions": {
199
+ "type": "boolean"
200
+ },
198
201
  "platform_editor_controls_patch_6": {
199
202
  "type": "boolean"
200
203
  },
@@ -209,6 +212,9 @@
209
212
  },
210
213
  "platform_editor_controls_patch_8": {
211
214
  "type": "boolean"
215
+ },
216
+ "platform_editor_table_fw_numcol_overflow_fix": {
217
+ "type": "boolean"
212
218
  }
213
219
  }
214
220
  }
@@ -352,6 +352,23 @@ export const ResizableTableContainer = React.memo(
352
352
  responsiveContainerWidth = isTableScalingEnabled
353
353
  ? lineLength
354
354
  : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
355
+
356
+ // platform_editor_table_fw_numcol_overflow_fix:
357
+ // lineLength is undefined on first paint → width: NaN → wrapper expands to page
358
+ // width. rAF col-sizing then runs before the number-column padding and
359
+ // the final shrink, so column widths are locked in wrong.
360
+ // With the flag ON, if the value isn’t finite we fall back to gutterWidth
361
+ // for that first frame—no flash, no premature rAF.
362
+ //
363
+ // Type clean-up comes later:
364
+ // 1) ship this runtime guard (quick fix, no breakage);
365
+ // 2) TODO: widen lineLength to `number|undefined` and remove this block.
366
+ if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
367
+ if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
368
+ responsiveContainerWidth =
369
+ containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
370
+ }
371
+ }
355
372
  } else if (isCommentEditor) {
356
373
  responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
357
374
  } else {
@@ -1,3 +1,4 @@
1
+ import { insideTable } from '@atlaskit/editor-common/core-utils';
1
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import type {
3
4
  EditorState,
@@ -8,6 +9,8 @@ import type {
8
9
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
10
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
11
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
12
+ import { findTable } from '@atlaskit/editor-tables/utils';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
11
14
 
12
15
  import { pluginKey as tablePluginKey } from '../plugin-key';
13
16
  import { pluginKey as tableWidthPluginKey } from '../table-width';
@@ -29,7 +32,11 @@ export const handleDocOrSelectionChanged = (
29
32
  ): DecorationSet => {
30
33
  const isResizing = tableWidthPluginKey.getState(newState)?.resizing;
31
34
  const wasResizing = tableWidthPluginKey.getState(oldState)?.resizing;
32
- const { isDragAndDropEnabled = false } = tablePluginKey.getState(newState) || {};
35
+ const {
36
+ isDragAndDropEnabled = false,
37
+ isInDanger,
38
+ isTableHovered,
39
+ } = tablePluginKey.getState(newState) || {};
33
40
 
34
41
  const changedResizing = isResizing !== wasResizing;
35
42
 
@@ -52,6 +59,22 @@ export const handleDocOrSelectionChanged = (
52
59
  tr,
53
60
  });
54
61
  }
62
+ if (fg('platform_editor_remove_slow_table_transactions')) {
63
+ // We're exiting a table with an existing decorations so we should clean it up
64
+ if (
65
+ (isInDanger || isTableHovered) &&
66
+ (!insideTable(newState) ||
67
+ findTable(newState.selection)?.node !== findTable(oldState.selection)?.node)
68
+ ) {
69
+ return buildColumnControlsDecorations({
70
+ decorationSet,
71
+ tr,
72
+ options: {
73
+ isDragAndDropEnabled,
74
+ },
75
+ });
76
+ }
77
+ }
55
78
  }
56
79
 
57
80
  return decorationSet;
@@ -15,7 +15,7 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
15
15
  import type { Rect } from '@atlaskit/editor-tables/table-map';
16
16
  import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
17
17
 
18
- import { RowStickyState } from '../pm-plugins/sticky-headers/types';
18
+ import type { RowStickyState } from '../pm-plugins/sticky-headers/types';
19
19
  import type { TablePlugin } from '../tablePluginType';
20
20
 
21
21
  export const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
@@ -3,21 +3,21 @@ import React from 'react';
3
3
  import {
4
4
  ACTION_SUBJECT,
5
5
  ACTION_SUBJECT_ID,
6
- DispatchAnalyticsEvent,
6
+ type DispatchAnalyticsEvent,
7
7
  } from '@atlaskit/editor-common/analytics';
8
8
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
9
9
  import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
10
10
  import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
11
11
  import {
12
- ExtractInjectionAPI,
13
- GetEditorContainerWidth,
14
- GetEditorFeatureFlags,
12
+ type ExtractInjectionAPI,
13
+ type GetEditorContainerWidth,
14
+ type GetEditorFeatureFlags,
15
15
  } from '@atlaskit/editor-common/types';
16
16
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
17
17
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
18
18
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
19
19
 
20
- import { TablePlugin, TablePluginOptions } from '../tablePluginType';
20
+ import { type TablePlugin, type TablePluginOptions } from '../tablePluginType';
21
21
 
22
22
  import FloatingContextualButton from './FloatingContextualButton';
23
23
  import FloatingContextualMenu from './FloatingContextualMenu';
@@ -11,7 +11,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
11
11
  import { TableSelectorPopup, type TableSelectorPopupProps } from '@atlaskit/editor-common/ui';
12
12
 
13
13
  import { pluginKey } from '../../pm-plugins/table-size-selector';
14
- import { TablePlugin } from '../../tablePluginType';
14
+ import type { TablePlugin } from '../../tablePluginType';
15
15
 
16
16
  interface SizeSelectorProps
17
17
  extends Omit<TableSelectorPopupProps, 'handleClickOutside' | 'onSelection' | 'unUnmount'> {
@@ -1,8 +1,8 @@
1
- import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
3
3
 
4
- import { TablePlugin } from '../../tablePluginType';
5
- import { TableSharedStateInternal } from '../../types';
4
+ import type { TablePlugin } from '../../tablePluginType';
5
+ import type { TableSharedStateInternal } from '../../types';
6
6
 
7
7
  type Options = {
8
8
  disabled?: boolean;
@@ -18,7 +18,9 @@ type Options = {
18
18
  *
19
19
  * @param api The editor API
20
20
  * @param key Key of TableSharedStateInternal to select
21
+ * @param options
21
22
  * @returns
23
+ * @example
22
24
  */
23
25
  export const useInternalTablePluginStateSelector = <K extends keyof TableSharedStateInternal>(
24
26
  api: ExtractInjectionAPI<TablePlugin> | undefined,
@@ -1144,8 +1144,9 @@ const isLayoutOptionDisabled = (
1144
1144
 
1145
1145
  // table may be scaled, use the scale percent to calculate the table width
1146
1146
  if (editorView) {
1147
- const tableWrapper = getDomRef(editorView);
1148
- const tableWrapperWidth = tableWrapper?.clientWidth || tableContainerWidth;
1147
+ const tableWrapperWidth = fg('platform_editor_remove_slow_table_transactions')
1148
+ ? tableContainerWidth
1149
+ : getDomRef(editorView)?.clientWidth || tableContainerWidth;
1149
1150
  const scalePercent = getStaticTableScalingPercent(
1150
1151
  selectedNode,
1151
1152
  tableWrapperWidth,