@atlaskit/editor-plugin-table 12.2.5 → 12.2.7

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 (207) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +24 -2
  3. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +23 -1
  4. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +24 -2
  5. package/package.json +4 -4
  6. package/afm-cc/tsconfig.json +0 -123
  7. package/afm-dev-agents/tsconfig.json +0 -123
  8. package/afm-jira/tsconfig.json +0 -123
  9. package/afm-passionfruit/tsconfig.json +0 -123
  10. package/afm-post-office/tsconfig.json +0 -123
  11. package/afm-rovo-extension/tsconfig.json +0 -123
  12. package/afm-townsquare/tsconfig.json +0 -123
  13. package/afm-volt/tsconfig.json +0 -114
  14. package/build/tsconfig.json +0 -23
  15. package/docs/0-intro.tsx +0 -57
  16. package/src/index.ts +0 -21
  17. package/src/nodeviews/ExternalDropTargets.tsx +0 -91
  18. package/src/nodeviews/OverflowShadowsObserver.ts +0 -156
  19. package/src/nodeviews/TableCell.ts +0 -134
  20. package/src/nodeviews/TableComponent.tsx +0 -1590
  21. package/src/nodeviews/TableComponentWithSharedState.tsx +0 -278
  22. package/src/nodeviews/TableContainer.tsx +0 -926
  23. package/src/nodeviews/TableNodeViewBase.ts +0 -29
  24. package/src/nodeviews/TableResizer.tsx +0 -884
  25. package/src/nodeviews/TableRow.ts +0 -830
  26. package/src/nodeviews/TableStickyScrollbar.ts +0 -211
  27. package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +0 -15
  28. package/src/nodeviews/__mocks__/OverridableMock.ts +0 -26
  29. package/src/nodeviews/table-container-styles.ts +0 -9
  30. package/src/nodeviews/table-node-views.ts +0 -76
  31. package/src/nodeviews/table.tsx +0 -530
  32. package/src/nodeviews/toDOM.ts +0 -244
  33. package/src/nodeviews/types.ts +0 -36
  34. package/src/nodeviews/update-overflow-shadows.ts +0 -11
  35. package/src/pm-plugins/analytics/actions.ts +0 -21
  36. package/src/pm-plugins/analytics/commands.ts +0 -47
  37. package/src/pm-plugins/analytics/plugin-factory.ts +0 -9
  38. package/src/pm-plugins/analytics/plugin-key.ts +0 -5
  39. package/src/pm-plugins/analytics/plugin.ts +0 -80
  40. package/src/pm-plugins/analytics/reducer.ts +0 -27
  41. package/src/pm-plugins/analytics/types.ts +0 -20
  42. package/src/pm-plugins/analytics/utils/moved-event.ts +0 -51
  43. package/src/pm-plugins/commands/clear.ts +0 -43
  44. package/src/pm-plugins/commands/collapse.ts +0 -17
  45. package/src/pm-plugins/commands/column-resize.ts +0 -478
  46. package/src/pm-plugins/commands/commands-with-analytics.ts +0 -715
  47. package/src/pm-plugins/commands/delete.ts +0 -42
  48. package/src/pm-plugins/commands/display-mode.ts +0 -18
  49. package/src/pm-plugins/commands/go-to-next-cell.ts +0 -198
  50. package/src/pm-plugins/commands/hover.ts +0 -242
  51. package/src/pm-plugins/commands/index.ts +0 -51
  52. package/src/pm-plugins/commands/insert.ts +0 -438
  53. package/src/pm-plugins/commands/misc.ts +0 -811
  54. package/src/pm-plugins/commands/referentiality.ts +0 -15
  55. package/src/pm-plugins/commands/selection.ts +0 -537
  56. package/src/pm-plugins/commands/sort.ts +0 -102
  57. package/src/pm-plugins/commands/split-cell.ts +0 -28
  58. package/src/pm-plugins/commands/toggle.ts +0 -109
  59. package/src/pm-plugins/create-plugin-config.ts +0 -17
  60. package/src/pm-plugins/decorations/plugin.ts +0 -107
  61. package/src/pm-plugins/decorations/utils/column-controls.ts +0 -91
  62. package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -71
  63. package/src/pm-plugins/decorations/utils/compose-decorations.ts +0 -9
  64. package/src/pm-plugins/decorations/utils/types.ts +0 -16
  65. package/src/pm-plugins/default-table-selection.ts +0 -14
  66. package/src/pm-plugins/drag-and-drop/actions.ts +0 -48
  67. package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -222
  68. package/src/pm-plugins/drag-and-drop/commands.ts +0 -194
  69. package/src/pm-plugins/drag-and-drop/consts.ts +0 -7
  70. package/src/pm-plugins/drag-and-drop/plugin-factory.ts +0 -33
  71. package/src/pm-plugins/drag-and-drop/plugin-key.ts +0 -5
  72. package/src/pm-plugins/drag-and-drop/plugin.ts +0 -398
  73. package/src/pm-plugins/drag-and-drop/reducer.ts +0 -38
  74. package/src/pm-plugins/drag-and-drop/types.ts +0 -18
  75. package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +0 -49
  76. package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +0 -9
  77. package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -73
  78. package/src/pm-plugins/handlers.ts +0 -161
  79. package/src/pm-plugins/keymap.ts +0 -436
  80. package/src/pm-plugins/main.ts +0 -433
  81. package/src/pm-plugins/plugin-factory.ts +0 -42
  82. package/src/pm-plugins/plugin-key.ts +0 -8
  83. package/src/pm-plugins/reducer.ts +0 -145
  84. package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -102
  85. package/src/pm-plugins/sticky-headers/commands.ts +0 -8
  86. package/src/pm-plugins/sticky-headers/plugin-key.ts +0 -5
  87. package/src/pm-plugins/sticky-headers/plugin-state.ts +0 -52
  88. package/src/pm-plugins/sticky-headers/plugin.ts +0 -12
  89. package/src/pm-plugins/sticky-headers/types.ts +0 -20
  90. package/src/pm-plugins/sticky-headers/util.ts +0 -18
  91. package/src/pm-plugins/table-analytics.ts +0 -100
  92. package/src/pm-plugins/table-local-id.ts +0 -213
  93. package/src/pm-plugins/table-resizing/commands.ts +0 -116
  94. package/src/pm-plugins/table-resizing/event-handlers.ts +0 -352
  95. package/src/pm-plugins/table-resizing/plugin-factory.ts +0 -29
  96. package/src/pm-plugins/table-resizing/plugin-key.ts +0 -5
  97. package/src/pm-plugins/table-resizing/plugin.ts +0 -94
  98. package/src/pm-plugins/table-resizing/reducer.ts +0 -37
  99. package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -306
  100. package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -120
  101. package/src/pm-plugins/table-resizing/utils/consts.ts +0 -11
  102. package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -118
  103. package/src/pm-plugins/table-resizing/utils/dom.ts +0 -132
  104. package/src/pm-plugins/table-resizing/utils/misc.ts +0 -282
  105. package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -34
  106. package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -289
  107. package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -417
  108. package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -290
  109. package/src/pm-plugins/table-resizing/utils/types.ts +0 -25
  110. package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +0 -1
  111. package/src/pm-plugins/table-selection-keymap.ts +0 -64
  112. package/src/pm-plugins/table-size-selector.ts +0 -39
  113. package/src/pm-plugins/table-width-in-comment-fix.ts +0 -113
  114. package/src/pm-plugins/table-width.ts +0 -153
  115. package/src/pm-plugins/transforms/column-width.ts +0 -249
  116. package/src/pm-plugins/transforms/delete-columns.ts +0 -281
  117. package/src/pm-plugins/transforms/delete-rows.ts +0 -154
  118. package/src/pm-plugins/transforms/fix-tables.ts +0 -249
  119. package/src/pm-plugins/transforms/merge.ts +0 -301
  120. package/src/pm-plugins/transforms/replace-table.ts +0 -38
  121. package/src/pm-plugins/transforms/split.ts +0 -90
  122. package/src/pm-plugins/utils/alignment.ts +0 -33
  123. package/src/pm-plugins/utils/analytics.ts +0 -238
  124. package/src/pm-plugins/utils/collapse.ts +0 -93
  125. package/src/pm-plugins/utils/column-controls.ts +0 -250
  126. package/src/pm-plugins/utils/create.ts +0 -64
  127. package/src/pm-plugins/utils/decoration.ts +0 -672
  128. package/src/pm-plugins/utils/dom.ts +0 -251
  129. package/src/pm-plugins/utils/drag-menu.tsx +0 -491
  130. package/src/pm-plugins/utils/get-allow-add-column-custom-step.ts +0 -10
  131. package/src/pm-plugins/utils/guidelines.ts +0 -30
  132. package/src/pm-plugins/utils/merged-cells.ts +0 -239
  133. package/src/pm-plugins/utils/nodes.ts +0 -162
  134. package/src/pm-plugins/utils/paste.ts +0 -386
  135. package/src/pm-plugins/utils/row-controls.ts +0 -211
  136. package/src/pm-plugins/utils/selection.ts +0 -17
  137. package/src/pm-plugins/utils/snapping.ts +0 -136
  138. package/src/pm-plugins/utils/table.ts +0 -60
  139. package/src/pm-plugins/utils/update-plugin-state-decorations.ts +0 -13
  140. package/src/pm-plugins/view-mode-sort/consts.ts +0 -3
  141. package/src/pm-plugins/view-mode-sort/index.ts +0 -291
  142. package/src/pm-plugins/view-mode-sort/plugin-key.ts +0 -7
  143. package/src/pm-plugins/view-mode-sort/types.ts +0 -23
  144. package/src/pm-plugins/view-mode-sort/utils.ts +0 -136
  145. package/src/tablePlugin.tsx +0 -971
  146. package/src/tablePluginType.ts +0 -102
  147. package/src/types/index.ts +0 -592
  148. package/src/ui/ColumnResizeWidget/index.tsx +0 -61
  149. package/src/ui/ContentComponent.tsx +0 -311
  150. package/src/ui/DragHandle/HandleIconComponent.tsx +0 -21
  151. package/src/ui/DragHandle/index.tsx +0 -391
  152. package/src/ui/DragPreview/index.tsx +0 -51
  153. package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +0 -59
  154. package/src/ui/FloatingContextualButton/FixedButton.tsx +0 -203
  155. package/src/ui/FloatingContextualButton/index.tsx +0 -168
  156. package/src/ui/FloatingContextualButton/styles.ts +0 -69
  157. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +0 -931
  158. package/src/ui/FloatingContextualMenu/index.tsx +0 -141
  159. package/src/ui/FloatingContextualMenu/styles.ts +0 -77
  160. package/src/ui/FloatingDeleteButton/DeleteButton.tsx +0 -54
  161. package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +0 -65
  162. package/src/ui/FloatingDeleteButton/index.tsx +0 -383
  163. package/src/ui/FloatingDeleteButton/types.ts +0 -3
  164. package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -668
  165. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +0 -221
  166. package/src/ui/FloatingDragMenu/index.tsx +0 -136
  167. package/src/ui/FloatingDragMenu/styles.ts +0 -83
  168. package/src/ui/FloatingInsertButton/InsertButton.tsx +0 -263
  169. package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -131
  170. package/src/ui/FloatingInsertButton/index.tsx +0 -314
  171. package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +0 -31
  172. package/src/ui/SizeSelector/index.tsx +0 -74
  173. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -397
  174. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +0 -105
  175. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +0 -63
  176. package/src/ui/TableFloatingColumnControls/index.tsx +0 -151
  177. package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +0 -106
  178. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +0 -143
  179. package/src/ui/TableFloatingControls/CornerControls/types.ts +0 -12
  180. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +0 -88
  181. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +0 -150
  182. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +0 -131
  183. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -429
  184. package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +0 -96
  185. package/src/ui/TableFloatingControls/index.tsx +0 -275
  186. package/src/ui/TableFullWidthLabel/index.tsx +0 -38
  187. package/src/ui/common-styles.ts +0 -1218
  188. package/src/ui/consts.ts +0 -109
  189. package/src/ui/event-handlers.ts +0 -662
  190. package/src/ui/global-styles.tsx +0 -55
  191. package/src/ui/hooks/useInternalTablePluginStateSelector.ts +0 -38
  192. package/src/ui/icons/AddColLeftIcon.tsx +0 -37
  193. package/src/ui/icons/AddColRightIcon.tsx +0 -37
  194. package/src/ui/icons/AddRowAboveIcon.tsx +0 -22
  195. package/src/ui/icons/AddRowBelowIcon.tsx +0 -39
  196. package/src/ui/icons/DragHandleDisabledIcon.tsx +0 -25
  197. package/src/ui/icons/DragHandleIcon.tsx +0 -16
  198. package/src/ui/icons/DragInMotionIcon.tsx +0 -54
  199. package/src/ui/icons/MergeCellsIcon.tsx +0 -26
  200. package/src/ui/icons/MinimisedHandle.tsx +0 -15
  201. package/src/ui/icons/SortingIconWrapper.tsx +0 -43
  202. package/src/ui/icons/SplitCellIcon.tsx +0 -34
  203. package/src/ui/toolbar.tsx +0 -1153
  204. package/src/ui/ui-styles.ts +0 -960
  205. package/tsconfig.app.json +0 -135
  206. package/tsconfig.dev.json +0 -54
  207. package/tsconfig.json +0 -18
@@ -1,884 +0,0 @@
1
- import type { PropsWithChildren } from 'react';
2
- import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
3
-
4
- import rafSchd from 'raf-schd';
5
- import { useIntl } from 'react-intl-next';
6
-
7
- import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
8
- import {
9
- CHANGE_ALIGNMENT_REASON,
10
- INPUT_METHOD,
11
- TABLE_OVERFLOW_CHANGE_TRIGGER,
12
- } from '@atlaskit/editor-common/analytics';
13
- import { browser } from '@atlaskit/editor-common/browser';
14
- import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
15
- import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
16
- import {
17
- sharedPluginStateHookMigratorFactory,
18
- useSharedPluginState,
19
- useSharedPluginStateWithSelector,
20
- } from '@atlaskit/editor-common/hooks';
21
- import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
22
- import { tableMessages as messages } from '@atlaskit/editor-common/messages';
23
- import { logException } from '@atlaskit/editor-common/monitoring';
24
- import type { HandleResize, HandleSize } from '@atlaskit/editor-common/resizer';
25
- import { ResizerNext } from '@atlaskit/editor-common/resizer';
26
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
27
- import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
28
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
29
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
30
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
31
- import {
32
- akEditorGutterPaddingDynamic,
33
- akEditorGutterPaddingReduced,
34
- akEditorFullPageNarrowBreakout,
35
- } from '@atlaskit/editor-shared-styles';
36
- import { findTable } from '@atlaskit/editor-tables/utils';
37
- import { fg } from '@atlaskit/platform-feature-flags';
38
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
39
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
40
- import { token } from '@atlaskit/tokens';
41
-
42
- import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
43
- import { updateWidthToWidest } from '../pm-plugins/commands/misc';
44
- import { META_KEYS } from '../pm-plugins/table-analytics';
45
- import { getColgroupChildrenLength } from '../pm-plugins/table-resizing/utils/colgroup';
46
- import {
47
- COLUMN_MIN_WIDTH,
48
- TABLE_MAX_WIDTH,
49
- TABLE_OFFSET_IN_COMMENT_EDITOR,
50
- } from '../pm-plugins/table-resizing/utils/consts';
51
- import { previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils/scale-table';
52
- import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
53
- import {
54
- ALIGN_CENTER,
55
- ALIGN_START,
56
- normaliseAlignment,
57
- shouldChangeAlignmentToCenterResized,
58
- } from '../pm-plugins/utils/alignment';
59
- import {
60
- generateResizedPayload,
61
- generateResizeFrameRatePayloads,
62
- useMeasureFramerate,
63
- } from '../pm-plugins/utils/analytics';
64
- import {
65
- defaultGuidelines,
66
- defaultGuidelinesForPreserveTable,
67
- PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET,
68
- } from '../pm-plugins/utils/guidelines';
69
- import {
70
- defaultSnappingWidths,
71
- defaultTablePreserveSnappingWidths,
72
- findClosestSnap,
73
- PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET,
74
- } from '../pm-plugins/utils/snapping';
75
- import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
76
- import {
77
- TABLE_GUIDELINE_VISIBLE_ADJUSTMENT,
78
- TABLE_HIGHLIGHT_GAP,
79
- TABLE_HIGHLIGHT_TOLERANCE,
80
- TABLE_SNAP_GAP,
81
- } from '../ui/consts';
82
-
83
- interface TableResizerProps {
84
- width: number;
85
- maxWidth: number | string;
86
- containerWidth: number;
87
- lineLength: number;
88
- updateWidth: (width: number) => void;
89
- editorView: EditorView;
90
- getPos: () => number | undefined;
91
- node: PMNode;
92
- tableRef: HTMLTableElement;
93
- displayGuideline: (guideline: GuidelineConfig[]) => boolean;
94
- attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
95
- displayGapCursor: (toggle: boolean) => boolean;
96
- pluginInjectionApi?: PluginInjectionAPI;
97
- isTableScalingEnabled?: boolean;
98
- isTableWithFixedColumnWidthsOptionEnabled?: boolean;
99
- isTableAlignmentEnabled?: boolean;
100
- isWholeTableInDanger?: boolean;
101
- isFullWidthModeEnabled?: boolean;
102
- shouldUseIncreasedScalingPercent?: boolean;
103
- isCommentEditor?: boolean;
104
- onResizeStop?: () => void;
105
- onResizeStart?: () => void;
106
- disabled?: boolean;
107
- }
108
-
109
- type ResizerNextHandler = React.ElementRef<typeof ResizerNext>;
110
-
111
- const RESIZE_STEP_VALUE = 10;
112
-
113
- const handles = { right: true };
114
- const handleStyles = {
115
- right: {
116
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
117
- right: '-14px',
118
- marginTop: token('space.150', '12px'),
119
- },
120
- };
121
-
122
- const getResizerHandleHeight = (tableRef: HTMLTableElement | undefined): HandleSize | undefined => {
123
- const tableHeight = tableRef?.clientHeight ?? 0;
124
- /*
125
- - One row table height (minimum possible table height) ~ 45px
126
- - Two row table height ~ 90px
127
- - Three row table height ~ 134px
128
-
129
- In the if below we need to use:
130
- - > 46 because the height of the table can be a float number like 45.44.
131
- - < 96 is the height of large resize handle.
132
- */
133
- if (tableHeight >= 96) {
134
- return 'large';
135
- }
136
-
137
- if (tableHeight > 46) {
138
- return 'medium';
139
- }
140
-
141
- return 'small';
142
- };
143
-
144
- const getResizerMinWidth = (node: PMNode) => {
145
- const currentColumnCount = getColgroupChildrenLength(node);
146
- const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
147
- // add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
148
- // the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
149
- return minColumnWidth + 1;
150
- };
151
-
152
- const getPadding = (containerWidth: number) => {
153
- return containerWidth <= akEditorFullPageNarrowBreakout &&
154
- expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true)
155
- ? akEditorGutterPaddingReduced
156
- : akEditorGutterPaddingDynamic();
157
- };
158
-
159
- /**
160
- * When guidelines are outside the viewport, filter them out, do not show
161
- * So the guideline container won't make the fabric-editor-popup-scroll-parent overflow
162
- * @param guidelines
163
- * @param containerWidth editorWidth
164
- * @param lineLength
165
- * @param isTableScalingEnabled
166
- * @param isFullWidthModeEnabled
167
- */
168
- const getVisibleGuidelines = (
169
- guidelines: GuidelineConfig[],
170
- containerWidth: number,
171
- lineLength: number,
172
- isTableScalingEnabled: boolean,
173
- isFullWidthModeEnabled: boolean,
174
- ) => {
175
- let guidelineVisibleAdjustment = TABLE_GUIDELINE_VISIBLE_ADJUSTMENT;
176
- if (isTableScalingEnabled) {
177
- // Notes:
178
- // Example: containerWidth = 1244, lineLength = 1180 (used for when editor full width mode is enabled)
179
- // Full width/dynamic x coordinate can be float number.
180
- // Ex: guideline.position.x can be 590.5. So 590.5 * 2 = 1181 (not 1180).
181
- // For PTW we need to ensure that dynamic guideline never gets excluded: 1181 should be > width + guidelineVisibleAdjustment
182
- // guidelineVisibleAdjustment is set as a negative value, so we making it positive and adding + 1
183
- const preserve_table_widths_adjustment = -1 * PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET + 1;
184
- const padding = getPadding(containerWidth);
185
- guidelineVisibleAdjustment = isFullWidthModeEnabled
186
- ? preserve_table_widths_adjustment // guidelineVisibleAdjustment = -2, if lineLength = 1180, 1181 < 1180 + 2 is true.
187
- : -2 * padding + preserve_table_widths_adjustment; // guidelineVisibleAdjustment = -62, if containerWidth is 1244, 1181 < 1244 - 62 = 1182 is true.
188
- }
189
- const width = isTableScalingEnabled && isFullWidthModeEnabled ? lineLength : containerWidth;
190
-
191
- return guidelines.filter((guideline) => {
192
- return (
193
- guideline.position &&
194
- guideline.position.x !== undefined &&
195
- typeof guideline.position.x === 'number' &&
196
- Math.abs(guideline.position.x * 2) < width + guidelineVisibleAdjustment
197
- );
198
- });
199
- };
200
-
201
- const selector = (states: { tableState: TableSharedStateInternal | undefined }) => ({
202
- widthToWidest: (states.tableState as TableSharedStateInternal | undefined)?.widthToWidest,
203
- });
204
-
205
- const useSharedState = sharedPluginStateHookMigratorFactory(
206
- (api: PluginInjectionAPI | undefined) => {
207
- const { widthToWidest } = useSharedPluginStateWithSelector(api, ['table'], selector);
208
- return {
209
- widthToWidest,
210
- };
211
- },
212
- (api: PluginInjectionAPI | undefined) => {
213
- const { tableState } = useSharedPluginState(api, ['table']);
214
- return {
215
- widthToWidest: (tableState as TableSharedStateInternal | undefined)?.widthToWidest,
216
- };
217
- },
218
- );
219
-
220
- export const TableResizer = ({
221
- children,
222
- width,
223
- maxWidth,
224
- containerWidth,
225
- lineLength,
226
- updateWidth,
227
- onResizeStop,
228
- onResizeStart,
229
- editorView,
230
- getPos,
231
- node,
232
- tableRef,
233
- displayGuideline,
234
- attachAnalyticsEvent,
235
- displayGapCursor,
236
- isTableScalingEnabled,
237
- isTableWithFixedColumnWidthsOptionEnabled,
238
- isTableAlignmentEnabled,
239
- isWholeTableInDanger,
240
- shouldUseIncreasedScalingPercent,
241
- pluginInjectionApi,
242
- isFullWidthModeEnabled,
243
- isCommentEditor,
244
- disabled,
245
- }: PropsWithChildren<TableResizerProps>) => {
246
- const currentGap = useRef(0);
247
- // track resizing state - use ref over state to avoid re-render
248
- const isResizing = useRef(false);
249
- const areResizeMetaKeysPressed = useRef(false);
250
- const resizerRef = useRef<ResizerNextHandler>(null);
251
-
252
- const interactionState = useSharedPluginStateSelector(
253
- pluginInjectionApi,
254
- 'interaction.interactionState',
255
- );
256
-
257
- const { widthToWidest } = useSharedState(pluginInjectionApi);
258
-
259
- // used to reposition tooltip when table is resizing via keyboard
260
- const updateTooltip = React.useRef<() => void>();
261
- const [snappingEnabled, setSnappingEnabled] = useState(false);
262
-
263
- const { formatMessage } = useIntl();
264
-
265
- const currentSelection = editorView.state?.selection;
266
- const tableFromSelection = useMemo(() => {
267
- return findTable(currentSelection);
268
- }, [currentSelection]);
269
- const tableFromSelectionPosition = tableFromSelection?.pos;
270
- const isTableSelected = useMemo(() => {
271
- // Avoid call getPos if there is no table in the current selection,
272
- if (typeof tableFromSelectionPosition !== 'number') {
273
- return false;
274
- }
275
-
276
- if (interactionState === 'hasNotHadInteraction') {
277
- return false;
278
- }
279
-
280
- let currentNodePosition: number | undefined;
281
- try {
282
- // The React Table and the ProseMirror can endup out-of-sync
283
- // ProseMirror always assume the DOM is not managed by other framework
284
- currentNodePosition = getPos();
285
- } catch (e) {
286
- logException(e as Error, {
287
- location: 'editor-plugin-table/table-resizer',
288
- });
289
- return false;
290
- }
291
-
292
- return tableFromSelectionPosition === currentNodePosition;
293
- }, [tableFromSelectionPosition, interactionState, getPos]);
294
-
295
- const resizerMinWidth = getResizerMinWidth(node);
296
- const handleSize = getResizerHandleHeight(tableRef);
297
-
298
- const { startMeasure, endMeasure, countFrames } = useMeasureFramerate();
299
-
300
- const excludeGuidelineConfig = useMemo(
301
- () => ({
302
- innerGuidelines: !!isTableAlignmentEnabled,
303
- breakoutPoints: !!(isTableAlignmentEnabled && isFullWidthModeEnabled),
304
- }),
305
- [isFullWidthModeEnabled, isTableAlignmentEnabled],
306
- );
307
-
308
- const updateActiveGuidelines = useCallback(
309
- ({ gap, keys }: { gap: number; keys: string[] }) => {
310
- if (gap !== currentGap.current) {
311
- currentGap.current = gap;
312
-
313
- const visibleGuidelines = getVisibleGuidelines(
314
- isTableScalingEnabled
315
- ? defaultGuidelinesForPreserveTable(
316
- PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET,
317
- isFullWidthModeEnabled
318
- ? lineLength + 2 * getPadding(containerWidth)
319
- : containerWidth,
320
- excludeGuidelineConfig,
321
- )
322
- : defaultGuidelines,
323
- containerWidth,
324
- lineLength,
325
- Boolean(isTableScalingEnabled),
326
- Boolean(isFullWidthModeEnabled),
327
- );
328
- displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
329
- }
330
- },
331
- [
332
- isTableScalingEnabled,
333
- excludeGuidelineConfig,
334
- containerWidth,
335
- displayGuideline,
336
- lineLength,
337
- isFullWidthModeEnabled,
338
- ],
339
- );
340
-
341
- const guidelineSnaps = useMemo(
342
- () =>
343
- snappingEnabled
344
- ? {
345
- x: isTableScalingEnabled
346
- ? defaultTablePreserveSnappingWidths(
347
- PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET, // was hardcoded to 0, using PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET instead.
348
- isFullWidthModeEnabled
349
- ? lineLength + 2 * getPadding(containerWidth)
350
- : containerWidth,
351
- excludeGuidelineConfig,
352
- )
353
- : defaultSnappingWidths,
354
- }
355
- : undefined,
356
- [
357
- snappingEnabled,
358
- isTableScalingEnabled,
359
- excludeGuidelineConfig,
360
- containerWidth,
361
- lineLength,
362
- isFullWidthModeEnabled,
363
- ],
364
- );
365
-
366
- const switchToCenterAlignment = useCallback(
367
- (
368
- pos: number,
369
- node: PMNode,
370
- // Ignored via go/ees005
371
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
372
- newWidth: any,
373
- state: EditorState,
374
- dispatch: ((tr: Transaction) => void) | undefined,
375
- ) => {
376
- if (
377
- shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, node, lineLength, newWidth) &&
378
- isResizing.current
379
- ) {
380
- const tableNodeWithPos = { pos, node };
381
- setTableAlignmentWithTableContentWithPosWithAnalytics(
382
- pluginInjectionApi?.analytics?.actions,
383
- )(
384
- ALIGN_CENTER,
385
- ALIGN_START,
386
- tableNodeWithPos,
387
- INPUT_METHOD.AUTO,
388
- CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED,
389
- )(state, dispatch);
390
- return true;
391
- }
392
-
393
- return false;
394
- },
395
- [isTableAlignmentEnabled, lineLength, pluginInjectionApi?.analytics?.actions],
396
- );
397
-
398
- useEffect(() => {
399
- return () => {
400
- // only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
401
- // deleted this table
402
- if (isResizing.current) {
403
- const {
404
- dispatch,
405
- state: { tr },
406
- } = editorView;
407
- displayGapCursor(true);
408
- displayGuideline([]);
409
- tr.setMeta(tableWidthPluginKey, {
410
- resizing: false,
411
- tableLocalId: '',
412
- tableRef: null,
413
- });
414
- dispatch(tr);
415
- }
416
- };
417
- }, [editorView, displayGuideline, displayGapCursor]);
418
-
419
- const handleResizeStart = useCallback(() => {
420
- startMeasure();
421
- isResizing.current = true;
422
- const {
423
- dispatch,
424
- state: { tr },
425
- } = editorView;
426
- displayGapCursor(false);
427
-
428
- tr.setMeta(tableWidthPluginKey, {
429
- resizing: true,
430
- tableLocalId: node.attrs.localId,
431
- tableRef: tableRef,
432
- });
433
- tr.setMeta('is-resizer-resizing', true);
434
-
435
- tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
436
- name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED,
437
- });
438
-
439
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
440
- pluginInjectionApi?.userIntent?.commands.setCurrentUserIntent('resizing')({ tr });
441
- }
442
-
443
- dispatch(tr);
444
-
445
- const visibleGuidelines = getVisibleGuidelines(
446
- isTableScalingEnabled
447
- ? defaultGuidelinesForPreserveTable(
448
- PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET,
449
- isFullWidthModeEnabled ? lineLength + 2 * getPadding(containerWidth) : containerWidth,
450
- excludeGuidelineConfig,
451
- )
452
- : defaultGuidelines,
453
- containerWidth,
454
- lineLength,
455
- Boolean(isTableScalingEnabled),
456
- Boolean(isFullWidthModeEnabled),
457
- );
458
-
459
- setSnappingEnabled(displayGuideline(visibleGuidelines));
460
- if (onResizeStart) {
461
- onResizeStart();
462
- }
463
- }, [
464
- startMeasure,
465
- editorView,
466
- displayGapCursor,
467
- node.attrs.localId,
468
- tableRef,
469
- isTableScalingEnabled,
470
- excludeGuidelineConfig,
471
- containerWidth,
472
- lineLength,
473
- displayGuideline,
474
- onResizeStart,
475
- isFullWidthModeEnabled,
476
- pluginInjectionApi,
477
- ]);
478
-
479
- const handleResize = useCallback(
480
- // Ignored via go/ees005
481
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
482
- (originalState: any, delta: any) => {
483
- countFrames();
484
- const newWidth = originalState.width + delta.width;
485
- let pos: number | undefined;
486
- try {
487
- pos = getPos();
488
- } catch (e) {
489
- return;
490
- }
491
- if (typeof pos !== 'number') {
492
- return;
493
- }
494
-
495
- const editorContainerWidth = isFullWidthModeEnabled
496
- ? lineLength + 2 * getPadding(containerWidth)
497
- : containerWidth;
498
-
499
- const closestSnap =
500
- !isCommentEditor &&
501
- findClosestSnap(
502
- newWidth,
503
- isTableScalingEnabled
504
- ? defaultTablePreserveSnappingWidths(
505
- PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET,
506
- editorContainerWidth,
507
- excludeGuidelineConfig,
508
- )
509
- : defaultSnappingWidths,
510
- isTableScalingEnabled
511
- ? defaultGuidelinesForPreserveTable(
512
- PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET,
513
- editorContainerWidth,
514
- excludeGuidelineConfig,
515
- )
516
- : defaultGuidelines,
517
- TABLE_HIGHLIGHT_GAP,
518
- TABLE_HIGHLIGHT_TOLERANCE,
519
- );
520
-
521
- closestSnap && updateActiveGuidelines(closestSnap);
522
-
523
- // When snapping to the full width guideline, resize the table to be 1800px
524
- const { state, dispatch } = editorView;
525
- const currentTableNodeLocalId = node?.attrs?.localId ?? '';
526
-
527
- const fullWidthGuideline = defaultGuidelinesForPreserveTable(
528
- PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET,
529
- editorContainerWidth,
530
- excludeGuidelineConfig,
531
- ).filter((guideline) => guideline.isFullWidth)[0];
532
-
533
- const isFullWidthGuidelineActive =
534
- closestSnap && closestSnap.keys.includes(fullWidthGuideline.key);
535
-
536
- const tableMaxWidth = isCommentEditor
537
- ? Math.floor(containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR)
538
- : TABLE_MAX_WIDTH;
539
-
540
- const shouldUpdateWidthToWidest = isCommentEditor
541
- ? tableMaxWidth <= newWidth
542
- : !!isTableScalingEnabled && isFullWidthGuidelineActive;
543
-
544
- const previewParentWidth =
545
- isCommentEditor && shouldUpdateWidthToWidest ? tableMaxWidth : newWidth;
546
-
547
- previewScaleTable(
548
- tableRef,
549
- {
550
- node,
551
- prevNode: node,
552
- start: pos + 1,
553
- parentWidth: previewParentWidth,
554
- },
555
- editorView.domAtPos.bind(editorView),
556
- isTableScalingEnabled,
557
- isTableWithFixedColumnWidthsOptionEnabled,
558
- isCommentEditor,
559
- );
560
-
561
- chainCommands(
562
- (state, dispatch) => {
563
- return switchToCenterAlignment(pos, node, newWidth, state, dispatch);
564
- },
565
- updateWidthToWidest({
566
- [currentTableNodeLocalId]: shouldUpdateWidthToWidest,
567
- }),
568
- )(state, dispatch);
569
-
570
- updateWidth(shouldUpdateWidthToWidest ? tableMaxWidth : newWidth);
571
-
572
- return newWidth;
573
- },
574
- [
575
- countFrames,
576
- isCommentEditor,
577
- isTableScalingEnabled,
578
- isTableWithFixedColumnWidthsOptionEnabled,
579
- isFullWidthModeEnabled,
580
- excludeGuidelineConfig,
581
- tableRef,
582
- node,
583
- editorView,
584
- updateActiveGuidelines,
585
- containerWidth,
586
- lineLength,
587
- updateWidth,
588
- getPos,
589
- switchToCenterAlignment,
590
- ],
591
- );
592
-
593
- const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
594
-
595
- const handleResizeStop = useCallback<HandleResize>(
596
- (originalState, delta) => {
597
- isResizing.current = false;
598
- let newWidth: number | undefined = originalState.width + delta.width;
599
- const originalNewWidth = newWidth;
600
- const { state, dispatch } = editorView;
601
- const pos = getPos();
602
- const currentTableNodeLocalId = node?.attrs?.localId ?? '';
603
-
604
- const tableMaxWidth = isCommentEditor
605
- ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
606
- : TABLE_MAX_WIDTH;
607
-
608
- newWidth =
609
- widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]
610
- ? tableMaxWidth
611
- : newWidth;
612
-
613
- let tr = state.tr.setMeta(tableWidthPluginKey, {
614
- resizing: false,
615
- tableLocalId: '',
616
- tableRef: null,
617
- });
618
- tr.setMeta('is-resizer-resizing', false);
619
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
620
- pluginInjectionApi?.userIntent?.commands.setCurrentUserIntent('default')({ tr });
621
- }
622
- const frameRateSamples = endMeasure();
623
-
624
- if (frameRateSamples.length > 0) {
625
- const resizeFrameRatePayloads = generateResizeFrameRatePayloads({
626
- docSize: state.doc.nodeSize,
627
- frameRateSamples,
628
- originalNode: node,
629
- });
630
- resizeFrameRatePayloads.forEach((payload) => {
631
- attachAnalyticsEvent(payload)?.(tr);
632
- });
633
- }
634
-
635
- if (typeof pos === 'number') {
636
- tr = tr.setNodeMarkup(pos, undefined, {
637
- ...node.attrs,
638
- width: newWidth,
639
- layout:
640
- node.attrs.layout !== ALIGN_START && node.attrs.layout !== ALIGN_CENTER
641
- ? ALIGN_CENTER
642
- : node.attrs.layout,
643
- });
644
-
645
- // Ignored via go/ees005
646
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
647
- const newNode = tr.doc.nodeAt(pos)!;
648
- tr = scaleTable(
649
- tableRef,
650
- {
651
- node: newNode,
652
- prevNode: node,
653
- start: pos + 1,
654
- // We use originalNewWidth in comment editor, because in comment editor
655
- // newWidth can be underined when table is resized to 'full-width'
656
- // scaleTable function needs number value to work correctly.
657
- parentWidth: isCommentEditor ? originalNewWidth : newWidth,
658
- },
659
- editorView.domAtPos.bind(editorView),
660
- pluginInjectionApi,
661
- isTableScalingEnabled,
662
- shouldUseIncreasedScalingPercent || false,
663
- isCommentEditor,
664
- )(tr);
665
-
666
- // Ignored via go/ees005
667
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
668
- const scaledNode = tr.doc.nodeAt(pos)!;
669
-
670
- attachAnalyticsEvent(
671
- generateResizedPayload({
672
- originalNode: node,
673
- resizedNode: scaledNode,
674
- }),
675
- )?.(tr);
676
- }
677
- displayGapCursor(true);
678
- dispatch(tr);
679
-
680
- if (delta.width < 0 && newWidth !== undefined) {
681
- pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify(
682
- formatMessage(messages.tableSizeDecreaseScreenReaderInformation, {
683
- newWidth: newWidth,
684
- }),
685
- );
686
- } else if (delta.width > 0 && newWidth !== undefined) {
687
- pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify(
688
- formatMessage(messages.tableSizeIncreaseScreenReaderInformation, {
689
- newWidth: newWidth,
690
- }),
691
- );
692
- }
693
-
694
- // Hide guidelines when resizing stops
695
- displayGuideline([]);
696
- newWidth !== undefined && updateWidth(newWidth);
697
- scheduleResize.cancel();
698
-
699
- if (onResizeStop) {
700
- onResizeStop();
701
- }
702
-
703
- return newWidth;
704
- },
705
- [
706
- editorView,
707
- getPos,
708
- node,
709
- isCommentEditor,
710
- widthToWidest,
711
- endMeasure,
712
- displayGapCursor,
713
- displayGuideline,
714
- updateWidth,
715
- scheduleResize,
716
- onResizeStop,
717
- attachAnalyticsEvent,
718
- tableRef,
719
- pluginInjectionApi,
720
- isTableScalingEnabled,
721
- shouldUseIncreasedScalingPercent,
722
- formatMessage,
723
- ],
724
- );
725
-
726
- const handleTableSizeChangeOnKeypress = useCallback(
727
- (step: number) => {
728
- const newWidth = width + step;
729
- if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
730
- if (newWidth < resizerMinWidth) {
731
- return;
732
- }
733
- } else {
734
- // maxWidth when platform_editor_tables_scaling_css off is always a number
735
- if (newWidth > (maxWidth as number) || newWidth < resizerMinWidth) {
736
- return;
737
- }
738
- }
739
- handleResizeStop({ width: width, x: 0, y: 0, height: 0 }, { width: step, height: 0 });
740
- },
741
- [width, handleResizeStop, maxWidth, resizerMinWidth],
742
- );
743
-
744
- const handleEscape = useCallback((): void => {
745
- editorView?.focus();
746
- }, [editorView]);
747
-
748
- const handleKeyDown = useCallback(
749
- (event: KeyboardEvent): void => {
750
- const isBracketKey = event.code === 'BracketRight' || event.code === 'BracketLeft';
751
-
752
- const metaKey = browser.mac ? event.metaKey : event.ctrlKey;
753
-
754
- if (event.altKey || metaKey || event.shiftKey) {
755
- areResizeMetaKeysPressed.current = true;
756
- }
757
- if (event.altKey && metaKey) {
758
- if (isBracketKey) {
759
- event.preventDefault();
760
- handleTableSizeChangeOnKeypress(
761
- event.code === 'BracketRight' ? RESIZE_STEP_VALUE : -RESIZE_STEP_VALUE,
762
- );
763
- }
764
- } else if (!areResizeMetaKeysPressed.current) {
765
- handleEscape();
766
- }
767
- },
768
- [handleEscape, handleTableSizeChangeOnKeypress],
769
- );
770
-
771
- const handleKeyUp = useCallback(
772
- (event: KeyboardEvent): void => {
773
- if (event.altKey || event.metaKey) {
774
- areResizeMetaKeysPressed.current = false;
775
- }
776
- return;
777
- },
778
- [areResizeMetaKeysPressed],
779
- );
780
-
781
- useLayoutEffect(() => {
782
- if (!resizerRef.current) {
783
- return;
784
- }
785
- const resizeHandleThumbEl = resizerRef.current.getResizerThumbEl();
786
-
787
- const globalKeyDownHandler = (event: KeyboardEvent): void => {
788
- const metaKey = browser.mac ? event.metaKey : event.ctrlKey;
789
-
790
- if (!isTableSelected) {
791
- return;
792
- }
793
- if (event.altKey && event.shiftKey && metaKey && event.code === 'KeyR') {
794
- event.preventDefault();
795
-
796
- if (!resizeHandleThumbEl) {
797
- return;
798
- }
799
- resizeHandleThumbEl.focus();
800
- resizeHandleThumbEl.scrollIntoView({
801
- behavior: 'smooth',
802
- block: 'center',
803
- inline: 'nearest',
804
- });
805
- }
806
- };
807
-
808
- const editorViewDom = editorView?.dom as HTMLElement | undefined;
809
- // Ignored via go/ees005
810
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
811
- editorViewDom?.addEventListener('keydown', globalKeyDownHandler);
812
- // Ignored via go/ees005
813
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
814
- resizeHandleThumbEl?.addEventListener('keydown', handleKeyDown);
815
- // Ignored via go/ees005
816
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
817
- resizeHandleThumbEl?.addEventListener('keyup', handleKeyUp);
818
- return () => {
819
- // Ignored via go/ees005
820
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
821
- editorViewDom?.removeEventListener('keydown', globalKeyDownHandler);
822
- // Ignored via go/ees005
823
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
824
- resizeHandleThumbEl?.removeEventListener('keydown', handleKeyDown);
825
- // Ignored via go/ees005
826
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
827
- resizeHandleThumbEl?.removeEventListener('keyup', handleKeyUp);
828
- };
829
- }, [resizerRef, editorView, handleResizeStop, isTableSelected, handleKeyDown, handleKeyUp]);
830
-
831
- useLayoutEffect(() => {
832
- updateTooltip.current?.();
833
- }, [width]);
834
-
835
- const resizeRatio =
836
- !isTableAlignmentEnabled ||
837
- (isTableAlignmentEnabled && normaliseAlignment(node.attrs.layout) === ALIGN_CENTER)
838
- ? 2
839
- : 1;
840
-
841
- return (
842
- <>
843
- <ResizerNext
844
- ref={resizerRef}
845
- enable={
846
- fg('platform_editor_live_page_prevent_table_recreation')
847
- ? disabled
848
- ? {}
849
- : handles
850
- : handles
851
- }
852
- width={width}
853
- handleAlignmentMethod="sticky"
854
- handleSize={handleSize}
855
- handleStyles={handleStyles}
856
- handleResizeStart={handleResizeStart}
857
- handleResize={scheduleResize}
858
- handleResizeStop={handleResizeStop}
859
- resizeRatio={resizeRatio}
860
- minWidth={resizerMinWidth}
861
- maxWidth={maxWidth}
862
- snapGap={TABLE_SNAP_GAP}
863
- snap={guidelineSnaps}
864
- handlePositioning="adjacent"
865
- isHandleVisible={isTableSelected}
866
- needExtendedResizeZone={!isTableSelected}
867
- appearance={isTableSelected && isWholeTableInDanger ? 'danger' : undefined}
868
- handleHighlight="shadow"
869
- handleTooltipContent={({ update }) => {
870
- updateTooltip.current = update;
871
- return (
872
- <ToolTipContent
873
- description={formatMessage(messages.resizeTable)}
874
- keymap={focusTableResizer}
875
- />
876
- );
877
- }}
878
- data-vc-nvs="true"
879
- >
880
- {children}
881
- </ResizerNext>
882
- </>
883
- );
884
- };