@atlaskit/editor-plugin-table 12.2.6 → 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 (204) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +4 -4
  3. package/afm-cc/tsconfig.json +0 -123
  4. package/afm-dev-agents/tsconfig.json +0 -123
  5. package/afm-jira/tsconfig.json +0 -123
  6. package/afm-passionfruit/tsconfig.json +0 -123
  7. package/afm-post-office/tsconfig.json +0 -123
  8. package/afm-rovo-extension/tsconfig.json +0 -123
  9. package/afm-townsquare/tsconfig.json +0 -123
  10. package/afm-volt/tsconfig.json +0 -114
  11. package/build/tsconfig.json +0 -23
  12. package/docs/0-intro.tsx +0 -57
  13. package/src/index.ts +0 -21
  14. package/src/nodeviews/ExternalDropTargets.tsx +0 -91
  15. package/src/nodeviews/OverflowShadowsObserver.ts +0 -156
  16. package/src/nodeviews/TableCell.ts +0 -134
  17. package/src/nodeviews/TableComponent.tsx +0 -1590
  18. package/src/nodeviews/TableComponentWithSharedState.tsx +0 -278
  19. package/src/nodeviews/TableContainer.tsx +0 -926
  20. package/src/nodeviews/TableNodeViewBase.ts +0 -29
  21. package/src/nodeviews/TableResizer.tsx +0 -884
  22. package/src/nodeviews/TableRow.ts +0 -830
  23. package/src/nodeviews/TableStickyScrollbar.ts +0 -211
  24. package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +0 -15
  25. package/src/nodeviews/__mocks__/OverridableMock.ts +0 -26
  26. package/src/nodeviews/table-container-styles.ts +0 -9
  27. package/src/nodeviews/table-node-views.ts +0 -76
  28. package/src/nodeviews/table.tsx +0 -530
  29. package/src/nodeviews/toDOM.ts +0 -244
  30. package/src/nodeviews/types.ts +0 -36
  31. package/src/nodeviews/update-overflow-shadows.ts +0 -11
  32. package/src/pm-plugins/analytics/actions.ts +0 -21
  33. package/src/pm-plugins/analytics/commands.ts +0 -47
  34. package/src/pm-plugins/analytics/plugin-factory.ts +0 -9
  35. package/src/pm-plugins/analytics/plugin-key.ts +0 -5
  36. package/src/pm-plugins/analytics/plugin.ts +0 -80
  37. package/src/pm-plugins/analytics/reducer.ts +0 -27
  38. package/src/pm-plugins/analytics/types.ts +0 -20
  39. package/src/pm-plugins/analytics/utils/moved-event.ts +0 -51
  40. package/src/pm-plugins/commands/clear.ts +0 -43
  41. package/src/pm-plugins/commands/collapse.ts +0 -17
  42. package/src/pm-plugins/commands/column-resize.ts +0 -478
  43. package/src/pm-plugins/commands/commands-with-analytics.ts +0 -715
  44. package/src/pm-plugins/commands/delete.ts +0 -42
  45. package/src/pm-plugins/commands/display-mode.ts +0 -18
  46. package/src/pm-plugins/commands/go-to-next-cell.ts +0 -198
  47. package/src/pm-plugins/commands/hover.ts +0 -242
  48. package/src/pm-plugins/commands/index.ts +0 -51
  49. package/src/pm-plugins/commands/insert.ts +0 -438
  50. package/src/pm-plugins/commands/misc.ts +0 -811
  51. package/src/pm-plugins/commands/referentiality.ts +0 -15
  52. package/src/pm-plugins/commands/selection.ts +0 -537
  53. package/src/pm-plugins/commands/sort.ts +0 -102
  54. package/src/pm-plugins/commands/split-cell.ts +0 -28
  55. package/src/pm-plugins/commands/toggle.ts +0 -109
  56. package/src/pm-plugins/create-plugin-config.ts +0 -17
  57. package/src/pm-plugins/decorations/plugin.ts +0 -107
  58. package/src/pm-plugins/decorations/utils/column-controls.ts +0 -91
  59. package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -71
  60. package/src/pm-plugins/decorations/utils/compose-decorations.ts +0 -9
  61. package/src/pm-plugins/decorations/utils/types.ts +0 -16
  62. package/src/pm-plugins/default-table-selection.ts +0 -14
  63. package/src/pm-plugins/drag-and-drop/actions.ts +0 -48
  64. package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -222
  65. package/src/pm-plugins/drag-and-drop/commands.ts +0 -194
  66. package/src/pm-plugins/drag-and-drop/consts.ts +0 -7
  67. package/src/pm-plugins/drag-and-drop/plugin-factory.ts +0 -33
  68. package/src/pm-plugins/drag-and-drop/plugin-key.ts +0 -5
  69. package/src/pm-plugins/drag-and-drop/plugin.ts +0 -398
  70. package/src/pm-plugins/drag-and-drop/reducer.ts +0 -38
  71. package/src/pm-plugins/drag-and-drop/types.ts +0 -18
  72. package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +0 -49
  73. package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +0 -9
  74. package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -73
  75. package/src/pm-plugins/handlers.ts +0 -161
  76. package/src/pm-plugins/keymap.ts +0 -436
  77. package/src/pm-plugins/main.ts +0 -433
  78. package/src/pm-plugins/plugin-factory.ts +0 -42
  79. package/src/pm-plugins/plugin-key.ts +0 -8
  80. package/src/pm-plugins/reducer.ts +0 -145
  81. package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -102
  82. package/src/pm-plugins/sticky-headers/commands.ts +0 -8
  83. package/src/pm-plugins/sticky-headers/plugin-key.ts +0 -5
  84. package/src/pm-plugins/sticky-headers/plugin-state.ts +0 -52
  85. package/src/pm-plugins/sticky-headers/plugin.ts +0 -12
  86. package/src/pm-plugins/sticky-headers/types.ts +0 -20
  87. package/src/pm-plugins/sticky-headers/util.ts +0 -18
  88. package/src/pm-plugins/table-analytics.ts +0 -100
  89. package/src/pm-plugins/table-local-id.ts +0 -213
  90. package/src/pm-plugins/table-resizing/commands.ts +0 -116
  91. package/src/pm-plugins/table-resizing/event-handlers.ts +0 -352
  92. package/src/pm-plugins/table-resizing/plugin-factory.ts +0 -29
  93. package/src/pm-plugins/table-resizing/plugin-key.ts +0 -5
  94. package/src/pm-plugins/table-resizing/plugin.ts +0 -94
  95. package/src/pm-plugins/table-resizing/reducer.ts +0 -37
  96. package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -306
  97. package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -120
  98. package/src/pm-plugins/table-resizing/utils/consts.ts +0 -11
  99. package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -118
  100. package/src/pm-plugins/table-resizing/utils/dom.ts +0 -132
  101. package/src/pm-plugins/table-resizing/utils/misc.ts +0 -282
  102. package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -34
  103. package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -289
  104. package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -417
  105. package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -290
  106. package/src/pm-plugins/table-resizing/utils/types.ts +0 -25
  107. package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +0 -1
  108. package/src/pm-plugins/table-selection-keymap.ts +0 -64
  109. package/src/pm-plugins/table-size-selector.ts +0 -39
  110. package/src/pm-plugins/table-width-in-comment-fix.ts +0 -113
  111. package/src/pm-plugins/table-width.ts +0 -153
  112. package/src/pm-plugins/transforms/column-width.ts +0 -249
  113. package/src/pm-plugins/transforms/delete-columns.ts +0 -281
  114. package/src/pm-plugins/transforms/delete-rows.ts +0 -154
  115. package/src/pm-plugins/transforms/fix-tables.ts +0 -249
  116. package/src/pm-plugins/transforms/merge.ts +0 -301
  117. package/src/pm-plugins/transforms/replace-table.ts +0 -38
  118. package/src/pm-plugins/transforms/split.ts +0 -90
  119. package/src/pm-plugins/utils/alignment.ts +0 -33
  120. package/src/pm-plugins/utils/analytics.ts +0 -238
  121. package/src/pm-plugins/utils/collapse.ts +0 -93
  122. package/src/pm-plugins/utils/column-controls.ts +0 -250
  123. package/src/pm-plugins/utils/create.ts +0 -64
  124. package/src/pm-plugins/utils/decoration.ts +0 -672
  125. package/src/pm-plugins/utils/dom.ts +0 -251
  126. package/src/pm-plugins/utils/drag-menu.tsx +0 -491
  127. package/src/pm-plugins/utils/get-allow-add-column-custom-step.ts +0 -10
  128. package/src/pm-plugins/utils/guidelines.ts +0 -30
  129. package/src/pm-plugins/utils/merged-cells.ts +0 -239
  130. package/src/pm-plugins/utils/nodes.ts +0 -162
  131. package/src/pm-plugins/utils/paste.ts +0 -386
  132. package/src/pm-plugins/utils/row-controls.ts +0 -211
  133. package/src/pm-plugins/utils/selection.ts +0 -17
  134. package/src/pm-plugins/utils/snapping.ts +0 -136
  135. package/src/pm-plugins/utils/table.ts +0 -60
  136. package/src/pm-plugins/utils/update-plugin-state-decorations.ts +0 -13
  137. package/src/pm-plugins/view-mode-sort/consts.ts +0 -3
  138. package/src/pm-plugins/view-mode-sort/index.ts +0 -291
  139. package/src/pm-plugins/view-mode-sort/plugin-key.ts +0 -7
  140. package/src/pm-plugins/view-mode-sort/types.ts +0 -23
  141. package/src/pm-plugins/view-mode-sort/utils.ts +0 -136
  142. package/src/tablePlugin.tsx +0 -971
  143. package/src/tablePluginType.ts +0 -102
  144. package/src/types/index.ts +0 -592
  145. package/src/ui/ColumnResizeWidget/index.tsx +0 -61
  146. package/src/ui/ContentComponent.tsx +0 -311
  147. package/src/ui/DragHandle/HandleIconComponent.tsx +0 -21
  148. package/src/ui/DragHandle/index.tsx +0 -391
  149. package/src/ui/DragPreview/index.tsx +0 -51
  150. package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +0 -59
  151. package/src/ui/FloatingContextualButton/FixedButton.tsx +0 -203
  152. package/src/ui/FloatingContextualButton/index.tsx +0 -168
  153. package/src/ui/FloatingContextualButton/styles.ts +0 -69
  154. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +0 -931
  155. package/src/ui/FloatingContextualMenu/index.tsx +0 -141
  156. package/src/ui/FloatingContextualMenu/styles.ts +0 -77
  157. package/src/ui/FloatingDeleteButton/DeleteButton.tsx +0 -54
  158. package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +0 -65
  159. package/src/ui/FloatingDeleteButton/index.tsx +0 -383
  160. package/src/ui/FloatingDeleteButton/types.ts +0 -3
  161. package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -668
  162. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +0 -221
  163. package/src/ui/FloatingDragMenu/index.tsx +0 -136
  164. package/src/ui/FloatingDragMenu/styles.ts +0 -83
  165. package/src/ui/FloatingInsertButton/InsertButton.tsx +0 -263
  166. package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -131
  167. package/src/ui/FloatingInsertButton/index.tsx +0 -314
  168. package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +0 -31
  169. package/src/ui/SizeSelector/index.tsx +0 -74
  170. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -397
  171. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +0 -105
  172. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +0 -63
  173. package/src/ui/TableFloatingColumnControls/index.tsx +0 -151
  174. package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +0 -106
  175. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +0 -143
  176. package/src/ui/TableFloatingControls/CornerControls/types.ts +0 -12
  177. package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +0 -88
  178. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +0 -175
  179. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +0 -131
  180. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -429
  181. package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +0 -96
  182. package/src/ui/TableFloatingControls/index.tsx +0 -275
  183. package/src/ui/TableFullWidthLabel/index.tsx +0 -38
  184. package/src/ui/common-styles.ts +0 -1218
  185. package/src/ui/consts.ts +0 -109
  186. package/src/ui/event-handlers.ts +0 -662
  187. package/src/ui/global-styles.tsx +0 -55
  188. package/src/ui/hooks/useInternalTablePluginStateSelector.ts +0 -38
  189. package/src/ui/icons/AddColLeftIcon.tsx +0 -37
  190. package/src/ui/icons/AddColRightIcon.tsx +0 -37
  191. package/src/ui/icons/AddRowAboveIcon.tsx +0 -22
  192. package/src/ui/icons/AddRowBelowIcon.tsx +0 -39
  193. package/src/ui/icons/DragHandleDisabledIcon.tsx +0 -25
  194. package/src/ui/icons/DragHandleIcon.tsx +0 -16
  195. package/src/ui/icons/DragInMotionIcon.tsx +0 -54
  196. package/src/ui/icons/MergeCellsIcon.tsx +0 -26
  197. package/src/ui/icons/MinimisedHandle.tsx +0 -15
  198. package/src/ui/icons/SortingIconWrapper.tsx +0 -43
  199. package/src/ui/icons/SplitCellIcon.tsx +0 -34
  200. package/src/ui/toolbar.tsx +0 -1153
  201. package/src/ui/ui-styles.ts +0 -960
  202. package/tsconfig.app.json +0 -135
  203. package/tsconfig.dev.json +0 -54
  204. package/tsconfig.json +0 -18
@@ -1,926 +0,0 @@
1
- import type { PropsWithChildren } from 'react';
2
- import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
-
4
- import classNames from 'classnames';
5
-
6
- import {
7
- CHANGE_ALIGNMENT_REASON,
8
- INPUT_METHOD,
9
- type TableEventPayload,
10
- } from '@atlaskit/editor-common/analytics';
11
- import { isSSR } from '@atlaskit/editor-common/core-utils';
12
- import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
13
- import {
14
- type NamedPluginStatesFromInjectionAPI,
15
- sharedPluginStateHookMigratorFactory,
16
- useSharedPluginState,
17
- useSharedPluginStateWithSelector,
18
- } from '@atlaskit/editor-common/hooks';
19
- import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
20
- import type { EditorContainerWidth, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
21
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
22
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
23
- import {
24
- akEditorDefaultLayoutWidth,
25
- akEditorGutterPaddingDynamic,
26
- akEditorGutterPaddingReduced,
27
- akEditorFullPageNarrowBreakout,
28
- akEditorMobileBreakoutPoint,
29
- } from '@atlaskit/editor-shared-styles';
30
- import { fg } from '@atlaskit/platform-feature-flags';
31
- import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
32
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
33
-
34
- import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
35
- import { getPluginState } from '../pm-plugins/plugin-factory';
36
- import {
37
- TABLE_MAX_WIDTH,
38
- TABLE_OFFSET_IN_COMMENT_EDITOR,
39
- } from '../pm-plugins/table-resizing/utils/consts';
40
- import {
41
- getTableResizerContainerMaxWidthInCSS,
42
- getTableResizerContainerForFullPageWidthInCSS,
43
- } from '../pm-plugins/table-resizing/utils/misc';
44
- import { ALIGN_CENTER, ALIGN_START } from '../pm-plugins/utils/alignment';
45
- import type tablePlugin from '../tablePlugin';
46
- import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
47
- import { TableCssClassName as ClassName } from '../types';
48
-
49
- import { getAlignmentStyle } from './table-container-styles';
50
- import { TableResizer } from './TableResizer';
51
-
52
- type InnerContainerProps = {
53
- className: string;
54
- style?: {
55
- width: number | 'inherit';
56
- marginLeft?: number;
57
- };
58
- node: PMNode;
59
- };
60
-
61
- const InnerContainer = forwardRef<HTMLDivElement, PropsWithChildren<InnerContainerProps>>(
62
- ({ className, style, node, children }, ref) => {
63
- return (
64
- <div
65
- ref={ref}
66
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
67
- style={style}
68
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
69
- className={className}
70
- data-number-column={node.attrs.isNumberColumnEnabled}
71
- data-layout={node.attrs.layout}
72
- data-testid="table-container"
73
- >
74
- {children}
75
- </div>
76
- );
77
- },
78
- );
79
-
80
- type AlignmentTableContainerProps = {
81
- node: PMNode;
82
- pluginInjectionApi?: PluginInjectionAPI;
83
- getPos?: () => number | undefined;
84
- editorView?: EditorView;
85
- };
86
-
87
- const useAlignmentTableContainerSharedState = sharedPluginStateHookMigratorFactory(
88
- (pluginInjectionApi: PluginInjectionAPI | undefined) => {
89
- const { isFullWidthModeEnabled, wasFullWidthModeEnabled } = useSharedPluginStateWithSelector(
90
- pluginInjectionApi,
91
- ['table'],
92
- (states) => ({
93
- isFullWidthModeEnabled: states.tableState?.isFullWidthModeEnabled,
94
- wasFullWidthModeEnabled: states.tableState?.wasFullWidthModeEnabled,
95
- }),
96
- );
97
- return {
98
- tableState: undefined,
99
- isFullWidthModeEnabled,
100
- wasFullWidthModeEnabled,
101
- };
102
- },
103
- (pluginInjectionApi: PluginInjectionAPI | undefined) => {
104
- const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
105
- return {
106
- tableState,
107
- isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
108
- wasFullWidthModeEnabled: tableState?.wasFullWidthModeEnabled,
109
- };
110
- },
111
- );
112
-
113
- const AlignmentTableContainer = ({
114
- node,
115
- children,
116
- pluginInjectionApi,
117
- getPos,
118
- editorView,
119
- }: PropsWithChildren<AlignmentTableContainerProps>) => {
120
- const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
121
- const { tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled } =
122
- useAlignmentTableContainerSharedState(pluginInjectionApi);
123
-
124
- useEffect(() => {
125
- if (
126
- !tableState &&
127
- expValEquals('platform_editor_usesharedpluginstatewithselector', 'isEnabled', false)
128
- ) {
129
- return;
130
- }
131
-
132
- if (editorView && getPos) {
133
- const { state, dispatch } = editorView;
134
-
135
- if (
136
- wasFullWidthModeEnabled &&
137
- isFullWidthModeEnabled !== undefined &&
138
- !isFullWidthModeEnabled &&
139
- alignment !== ALIGN_CENTER &&
140
- node.attrs.width > akEditorDefaultLayoutWidth
141
- ) {
142
- const pos = getPos && getPos();
143
-
144
- if (typeof pos !== 'number') {
145
- return;
146
- }
147
-
148
- setTableAlignmentWithTableContentWithPosWithAnalytics(
149
- pluginInjectionApi?.analytics?.actions,
150
- )(
151
- ALIGN_CENTER,
152
- alignment,
153
- { pos, node },
154
- INPUT_METHOD.AUTO,
155
- CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED,
156
- )(state, dispatch);
157
- }
158
- }
159
- // eslint-disable-next-line react-hooks/exhaustive-deps
160
- }, [editorView, tableState, isFullWidthModeEnabled, wasFullWidthModeEnabled, node]);
161
-
162
- const style = useMemo(() => {
163
- return getAlignmentStyle(alignment);
164
- }, [alignment]);
165
-
166
- return (
167
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
168
- <div data-testid="table-alignment-container" style={style}>
169
- {children}
170
- </div>
171
- );
172
- };
173
-
174
- const AlignmentTableContainerWrapper = ({
175
- isTableAlignmentEnabled,
176
- node,
177
- children,
178
- pluginInjectionApi,
179
- getPos,
180
- editorView,
181
- }: PropsWithChildren<AlignmentTableContainerProps & { isTableAlignmentEnabled?: boolean }>) => {
182
- if (!isTableAlignmentEnabled) {
183
- return (
184
- <div
185
- data-testid="table-alignment-container"
186
- style={{
187
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
188
- display: 'flex',
189
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
190
- justifyContent: 'center',
191
- }}
192
- >
193
- {children}
194
- </div>
195
- );
196
- }
197
-
198
- return (
199
- <AlignmentTableContainer
200
- node={node}
201
- pluginInjectionApi={pluginInjectionApi}
202
- getPos={getPos}
203
- editorView={editorView}
204
- >
205
- {children}
206
- </AlignmentTableContainer>
207
- );
208
- };
209
-
210
- type ResizableTableContainerProps = {
211
- containerWidth: number;
212
- lineLength: number;
213
- node: PMNode;
214
- className: string;
215
- editorView: EditorView;
216
- getPos: () => number | undefined;
217
- tableRef: HTMLTableElement;
218
- isResizing?: boolean;
219
- isWindowResized?: boolean;
220
- pluginInjectionApi?: PluginInjectionAPI;
221
- tableWrapperHeight?: number;
222
- isWholeTableInDanger?: boolean;
223
-
224
- isTableScalingEnabled?: boolean;
225
- isTableWithFixedColumnWidthsOptionEnabled?: boolean;
226
- isTableAlignmentEnabled?: boolean;
227
- shouldUseIncreasedScalingPercent?: boolean;
228
- isCommentEditor?: boolean;
229
- isChromelessEditor?: boolean;
230
- };
231
-
232
- const selector = (
233
- states: NamedPluginStatesFromInjectionAPI<
234
- ExtractInjectionAPI<typeof tablePlugin>,
235
- 'editorViewMode'
236
- > & {
237
- tableState: TableSharedStateInternal | undefined;
238
- },
239
- ) => ({
240
- tableState: states.tableState,
241
- editorViewModeState: states.editorViewModeState,
242
- });
243
-
244
- const useSharedState = sharedPluginStateHookMigratorFactory(
245
- (api: PluginInjectionAPI | undefined) => {
246
- const { tableState, editorViewModeState } = useSharedPluginStateWithSelector(
247
- api,
248
- ['table', 'editorViewMode'],
249
- selector,
250
- );
251
- return {
252
- tableState,
253
- editorViewModeState,
254
- };
255
- },
256
- (api: PluginInjectionAPI | undefined) => {
257
- const { tableState, editorViewModeState } = useSharedPluginState(api, [
258
- 'table',
259
- 'editorViewMode',
260
- ]);
261
- return {
262
- tableState,
263
- editorViewModeState,
264
- };
265
- },
266
- );
267
-
268
- const getPadding = (containerWidth: number) => {
269
- return containerWidth <= akEditorFullPageNarrowBreakout &&
270
- expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true)
271
- ? akEditorGutterPaddingReduced
272
- : akEditorGutterPaddingDynamic();
273
- };
274
-
275
- const ResizableTableContainerLegacy = React.memo(
276
- ({
277
- children,
278
- className,
279
- node,
280
- containerWidth,
281
- lineLength,
282
- editorView,
283
- getPos,
284
- tableRef,
285
- isResizing,
286
- pluginInjectionApi,
287
- tableWrapperHeight,
288
- isWholeTableInDanger,
289
- isTableScalingEnabled,
290
- isTableWithFixedColumnWidthsOptionEnabled,
291
- isTableAlignmentEnabled,
292
- shouldUseIncreasedScalingPercent,
293
- isCommentEditor,
294
- }: PropsWithChildren<ResizableTableContainerProps>) => {
295
- const containerRef = useRef<HTMLDivElement | null>(null);
296
- const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
297
- const [resizing, setIsResizing] = useState(false);
298
-
299
- const { tableState, editorViewModeState } = useSharedState(pluginInjectionApi);
300
- const isFullWidthModeEnabled = tableState?.isFullWidthModeEnabled;
301
- const mode = editorViewModeState?.mode;
302
-
303
- const updateContainerHeight = useCallback((height: number | 'auto') => {
304
- // current StickyHeader State is not stable to be fetch.
305
- // we need to update stickyHeader plugin to make sure state can be
306
- // consistently fetch and refactor below
307
- const stickyHeaders = containerRef.current?.getElementsByClassName('pm-table-sticky');
308
- if (!stickyHeaders || stickyHeaders.length < 1) {
309
- // when starting to drag, we need to keep the original space,
310
- // -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
311
- // 1px is border width but collapse make it 0.5.
312
- // -- When sticky header appear, we should add first row height but reduce
313
- // collapsed border
314
- return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
315
- } else {
316
- const stickyHeaderHeight =
317
- containerRef.current?.getElementsByTagName('th')[0].getBoundingClientRect().height || 0;
318
-
319
- return typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto';
320
- }
321
- }, []);
322
-
323
- const onResizeStart = useCallback(() => {
324
- setIsResizing(true);
325
- }, []);
326
-
327
- const onResizeStop = useCallback(() => {
328
- setIsResizing(false);
329
- }, []);
330
-
331
- const updateWidth = useCallback((width: number) => {
332
- if (!containerRef.current) {
333
- return;
334
- }
335
-
336
- // make sure during resizing
337
- // the pm-table-resizer-container width is the same as its child div resizer-item
338
- // otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
339
- // and cause the fabric-editor-popup-scroll-parent to overflow
340
- if (containerRef.current.style.width !== `${width}px`) {
341
- containerRef.current.style.width = `${width}px`;
342
- }
343
- }, []);
344
-
345
- const displayGuideline = useCallback(
346
- (guidelines: GuidelineConfig[]) => {
347
- return (
348
- pluginInjectionApi?.guideline?.actions?.displayGuideline(editorView)({
349
- guidelines,
350
- }) ?? false
351
- );
352
- },
353
- [pluginInjectionApi, editorView],
354
- );
355
-
356
- const attachAnalyticsEvent = useCallback(
357
- (payload: TableEventPayload) => {
358
- return pluginInjectionApi?.analytics?.actions.attachAnalyticsEvent(payload);
359
- },
360
- [pluginInjectionApi],
361
- );
362
-
363
- const displayGapCursor = useCallback(
364
- (toggle: boolean) => {
365
- return (
366
- pluginInjectionApi?.core?.actions.execute(
367
- pluginInjectionApi?.selection?.commands.displayGapCursor(toggle),
368
- ) ?? false
369
- );
370
- },
371
- [pluginInjectionApi],
372
- );
373
-
374
- const tableWidth = getTableContainerWidth(node);
375
-
376
- let responsiveContainerWidth = 0;
377
- const resizeHandleSpacing = 12;
378
- const padding = getPadding(containerWidth);
379
- // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
380
- // updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
381
- // issues when viwport width is less than full width Editor's width. To detect avoid them
382
- // we need to use lineLength to defined responsiveWidth instead of containerWidth
383
- // (which does not get updated when Mac setting changes) in Full-width editor.
384
- if (isFullWidthModeEnabled) {
385
- // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
386
- // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
387
- // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
388
- responsiveContainerWidth = isTableScalingEnabled
389
- ? lineLength
390
- : containerWidth - padding * 2 - resizeHandleSpacing;
391
-
392
- // platform_editor_table_fw_numcol_overflow_fix:
393
- // lineLength is undefined on first paint → width: NaN → wrapper expands to page
394
- // width. rAF col-sizing then runs before the number-column padding and
395
- // the final shrink, so column widths are locked in wrong.
396
- // With the flag ON, if the value isn’t finite we fall back to gutterWidth
397
- // for that first frame—no flash, no premature rAF.
398
- //
399
- // Type clean-up comes later:
400
- // 1) ship this runtime guard (quick fix, no breakage);
401
- // 2) TODO: widen lineLength to `number|undefined` and remove this block.
402
- if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
403
- if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
404
- responsiveContainerWidth = containerWidth - padding * 2 - resizeHandleSpacing;
405
- }
406
- }
407
- } else if (isCommentEditor) {
408
- responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
409
- } else {
410
- // 76 is currently an accepted padding value considering the spacing for resizer handle
411
- // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
412
- // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
413
- // padding left = padding right = akEditorGutterPadding = 32
414
- responsiveContainerWidth = isTableScalingEnabled
415
- ? containerWidth - padding * 2
416
- : containerWidth - padding * 2 - resizeHandleSpacing;
417
- }
418
- const width =
419
- !node.attrs.width && isCommentEditor
420
- ? responsiveContainerWidth
421
- : Math.min(tableWidth, responsiveContainerWidth);
422
-
423
- if (!isResizing) {
424
- tableWidthRef.current = width;
425
- }
426
- const maxResizerWidth = isCommentEditor
427
- ? responsiveContainerWidth
428
- : Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
429
-
430
- const tableResizerProps = {
431
- width,
432
- maxWidth: maxResizerWidth,
433
- containerWidth,
434
- lineLength,
435
- updateWidth,
436
- editorView,
437
- getPos,
438
- node,
439
- tableRef,
440
- displayGuideline,
441
- attachAnalyticsEvent,
442
- displayGapCursor,
443
- isTableAlignmentEnabled,
444
- isFullWidthModeEnabled,
445
- isTableScalingEnabled,
446
- isTableWithFixedColumnWidthsOptionEnabled,
447
- isWholeTableInDanger,
448
- shouldUseIncreasedScalingPercent,
449
- pluginInjectionApi,
450
- onResizeStart,
451
- onResizeStop,
452
- isCommentEditor,
453
- };
454
-
455
- const isLivePageViewMode = mode === 'view';
456
-
457
- return (
458
- <AlignmentTableContainerWrapper
459
- isTableAlignmentEnabled={isTableAlignmentEnabled}
460
- node={node}
461
- pluginInjectionApi={pluginInjectionApi}
462
- getPos={getPos}
463
- editorView={editorView}
464
- >
465
- <div
466
- style={{
467
- width: tableWidthRef.current,
468
- height: resizing ? updateContainerHeight(tableWrapperHeight ?? 'auto') : 'auto',
469
- position: isLivePageViewMode ? 'relative' : 'unset',
470
- }}
471
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
472
- className={ClassName.TABLE_RESIZER_CONTAINER}
473
- ref={containerRef}
474
- >
475
- {fg('platform_editor_live_page_prevent_table_recreation') ? null : isLivePageViewMode ? (
476
- <InnerContainer
477
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
478
- className={className}
479
- node={node}
480
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
481
- style={{ width: 'inherit' }}
482
- >
483
- {children}
484
- </InnerContainer>
485
- ) : (
486
- // Ignored via go/ees005
487
- // eslint-disable-next-line react/jsx-props-no-spreading
488
- <TableResizer {...tableResizerProps}>
489
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
490
- <InnerContainer className={className} node={node}>
491
- {children}
492
- </InnerContainer>
493
- </TableResizer>
494
- )}
495
- {fg('platform_editor_live_page_prevent_table_recreation') ? (
496
- // Ignored via go/ees005
497
- // eslint-disable-next-line react/jsx-props-no-spreading
498
- <TableResizer {...tableResizerProps} disabled={isLivePageViewMode}>
499
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
500
- <InnerContainer className={className} node={node}>
501
- {children}
502
- </InnerContainer>
503
- </TableResizer>
504
- ) : null}
505
- </div>
506
- </AlignmentTableContainerWrapper>
507
- );
508
- },
509
- );
510
-
511
- const ResizableTableContainerNext = React.memo(
512
- ({
513
- children,
514
- className,
515
- node,
516
- containerWidth,
517
- lineLength,
518
- editorView,
519
- getPos,
520
- tableRef,
521
- isResizing,
522
- isWindowResized,
523
- pluginInjectionApi,
524
- tableWrapperHeight,
525
- isWholeTableInDanger,
526
- isTableScalingEnabled,
527
- isTableWithFixedColumnWidthsOptionEnabled,
528
- isTableAlignmentEnabled,
529
- shouldUseIncreasedScalingPercent,
530
- isCommentEditor,
531
- isChromelessEditor,
532
- }: PropsWithChildren<ResizableTableContainerProps>) => {
533
- const tableWidth = getTableContainerWidth(node);
534
- const containerRef = useRef<HTMLDivElement | null>(null);
535
- const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
536
- const [resizing, setIsResizing] = useState(false);
537
- const [tableMaxWidthForFullPageOnLoad, setTableMaxWidthForFullPageOnLoad] =
538
- useState<number>(tableWidth);
539
-
540
- const { tableState, editorViewModeState } = useSharedState(pluginInjectionApi);
541
- const isFullWidthModeEnabled = tableState?.isFullWidthModeEnabled;
542
- const mode = editorViewModeState?.mode;
543
-
544
- const updateContainerHeight = useCallback((height: number | 'auto') => {
545
- // current StickyHeader State is not stable to be fetch.
546
- // we need to update stickyHeader plugin to make sure state can be
547
- // consistently fetch and refactor below
548
- const stickyHeaders = containerRef.current?.getElementsByClassName('pm-table-sticky');
549
- if (!stickyHeaders || stickyHeaders.length < 1) {
550
- // when starting to drag, we need to keep the original space,
551
- // -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
552
- // 1px is border width but collapse make it 0.5.
553
- // -- When sticky header appear, we should add first row height but reduce
554
- // collapsed border
555
- return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
556
- } else {
557
- const stickyHeaderHeight =
558
- containerRef.current?.getElementsByTagName('th')[0].getBoundingClientRect().height || 0;
559
-
560
- return typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto';
561
- }
562
- }, []);
563
-
564
- const onResizeStart = useCallback(() => {
565
- setIsResizing(true);
566
- }, []);
567
-
568
- const onResizeStop = useCallback(() => {
569
- setIsResizing(false);
570
- }, []);
571
-
572
- const updateWidth = useCallback((width?: number) => {
573
- if (!containerRef.current) {
574
- return;
575
- }
576
-
577
- // make sure during resizing
578
- // the pm-table-resizer-container width is the same as its child div resizer-item
579
- // otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
580
- // and cause the fabric-editor-popup-scroll-parent to overflow
581
- if (containerRef.current.style.width !== `${width}px`) {
582
- containerRef.current.style.width = `${width}px`;
583
- }
584
- }, []);
585
-
586
- const displayGuideline = useCallback(
587
- (guidelines: GuidelineConfig[]) => {
588
- return (
589
- pluginInjectionApi?.guideline?.actions?.displayGuideline(editorView)({
590
- guidelines,
591
- }) ?? false
592
- );
593
- },
594
- [pluginInjectionApi, editorView],
595
- );
596
-
597
- const attachAnalyticsEvent = useCallback(
598
- (payload: TableEventPayload) => {
599
- return pluginInjectionApi?.analytics?.actions.attachAnalyticsEvent(payload);
600
- },
601
- [pluginInjectionApi],
602
- );
603
-
604
- const displayGapCursor = useCallback(
605
- (toggle: boolean) => {
606
- return (
607
- pluginInjectionApi?.core?.actions.execute(
608
- pluginInjectionApi?.selection?.commands.displayGapCursor(toggle),
609
- ) ?? false
610
- );
611
- },
612
- [pluginInjectionApi],
613
- );
614
-
615
- const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
616
-
617
- let responsiveContainerWidth = 0;
618
- const resizeHandleSpacing = 12;
619
- const padding = getPadding(containerWidth);
620
- // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
621
- // updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
622
- // issues when viwport width is less than full width Editor's width. To detect avoid them
623
- // we need to use lineLength to defined responsiveWidth instead of containerWidth
624
- // (which does not get updated when Mac setting changes) in Full-width editor.
625
- if (isFullWidthModeEnabled) {
626
- // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
627
- // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
628
- // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
629
- responsiveContainerWidth = isTableScalingEnabled
630
- ? lineLength
631
- : containerWidth - padding * 2 - resizeHandleSpacing;
632
-
633
- // platform_editor_table_fw_numcol_overflow_fix:
634
- // lineLength is undefined on first paint → width: NaN → wrapper expands to page
635
- // width. rAF col-sizing then runs before the number-column padding and
636
- // the final shrink, so column widths are locked in wrong.
637
- // With the flag ON, if the value isn’t finite we fall back to gutterWidth
638
- // for that first frame—no flash, no premature rAF.
639
- //
640
- // Type clean-up comes later:
641
- // 1) ship this runtime guard (quick fix, no breakage);
642
- // 2) TODO: widen lineLength to `number|undefined` and remove this block.
643
- if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
644
- if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
645
- responsiveContainerWidth = containerWidth - padding * 2 - resizeHandleSpacing;
646
- }
647
- }
648
- } else if (isCommentEditor) {
649
- responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
650
- } else {
651
- // 76 is currently an accepted padding value considering the spacing for resizer handle
652
- // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
653
- // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
654
- // padding left = padding right = akEditorGutterPadding = 32
655
- responsiveContainerWidth = isTableScalingEnabled
656
- ? containerWidth - padding * 2
657
- : containerWidth - padding * 2 - resizeHandleSpacing;
658
- }
659
-
660
- const width =
661
- !node.attrs.width && isCommentEditor
662
- ? responsiveContainerWidth
663
- : Math.min(tableWidth, responsiveContainerWidth);
664
-
665
- if (!isResizing) {
666
- tableWidthRef.current = width;
667
- }
668
-
669
- const maxResizerWidth = isCommentEditor
670
- ? responsiveContainerWidth
671
- : Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
672
-
673
- // CSS solution for table resizer item width
674
- // The `width` is used for .resizer-item in <TableResizer>, and it has to be a number
675
- // So we can't use min(var(--ak-editor-table-width), ${tableWidth}px) here
676
- // We get the correct width from CSS value on page load
677
- // After window resize, we use the width from plugin state
678
- // After table resize, the table width attribute is used
679
- const tableResizerItemWidth = useMemo(() => {
680
- // if not on full page editor, we just rely on the width calculated from plugin state
681
- // if on full page editor and after window resize, we use the width from plugin state
682
- if (!isFullPageAppearance || (isFullPageAppearance && isWindowResized)) {
683
- return width;
684
- }
685
- if (isResizing) {
686
- return tableWidth;
687
- }
688
- // if on full page editor and on page load, we use the computed value from CSS
689
- return Math.min(tableWidth, tableMaxWidthForFullPageOnLoad);
690
- }, [
691
- isWindowResized,
692
- isResizing,
693
- isFullPageAppearance,
694
- tableMaxWidthForFullPageOnLoad,
695
- tableWidth,
696
- width,
697
- ]);
698
-
699
- // CSS Solution for table resizer container width
700
- const tableResizerContainerWidth = useMemo(() => {
701
- return getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled);
702
- }, [node, isTableScalingEnabled]);
703
-
704
- // CSS Solution for table resizer max width
705
- const tableResizerMaxWidth = React.useMemo(() => {
706
- const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
707
- const nonResizingMaxWidth = isFullPageAppearance
708
- ? getTableResizerContainerMaxWidthInCSS(
709
- isCommentEditor,
710
- isChromelessEditor,
711
- isTableScalingEnabled,
712
- )
713
- : maxResizerWidth;
714
- // isResizing is needed, otherwise we can't resize table.
715
- // when not resizing, maxWidth is calculated based on the container width via CSS
716
- return !isResizing ? nonResizingMaxWidth : maxResizerWidth;
717
- }, [isCommentEditor, isChromelessEditor, isTableScalingEnabled, isResizing, maxResizerWidth]);
718
-
719
- // on SSR, the width would be the default state, which is tableWidth
720
- // but because we have maxWidth set to the editor container width via CSS
721
- // So it would work just fine
722
- useEffect(() => {
723
- if (!isSSR() && isFullPageAppearance && containerRef.current?.firstElementChild) {
724
- // get the computed value of max-width from '.resizer-item', because it uses `cqw` unit in CSS
725
- const computedStyle = window.getComputedStyle(containerRef.current.firstElementChild);
726
- const containerWidth = computedStyle.maxWidth
727
- ? parseFloat(computedStyle.maxWidth)
728
- : tableWidth;
729
- setTableMaxWidthForFullPageOnLoad(Math.min(containerWidth, tableWidth));
730
- }
731
- }, [tableWidthRef, tableWidth, isFullPageAppearance]);
732
-
733
- const tableResizerProps = {
734
- width: tableResizerItemWidth,
735
- maxWidth: tableResizerMaxWidth,
736
- containerWidth,
737
- lineLength,
738
- updateWidth,
739
- editorView,
740
- getPos,
741
- node,
742
- tableRef,
743
- displayGuideline,
744
- attachAnalyticsEvent,
745
- displayGapCursor,
746
- isTableAlignmentEnabled,
747
- isFullWidthModeEnabled,
748
- isTableScalingEnabled,
749
- isTableWithFixedColumnWidthsOptionEnabled,
750
- isWholeTableInDanger,
751
- shouldUseIncreasedScalingPercent,
752
- pluginInjectionApi,
753
- onResizeStart,
754
- onResizeStop,
755
- isCommentEditor,
756
- };
757
-
758
- const isLivePageViewMode = mode === 'view';
759
-
760
- return (
761
- <AlignmentTableContainerWrapper
762
- isTableAlignmentEnabled={isTableAlignmentEnabled}
763
- node={node}
764
- pluginInjectionApi={pluginInjectionApi}
765
- getPos={getPos}
766
- editorView={editorView}
767
- >
768
- <div
769
- style={
770
- {
771
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
772
- '--ak-editor-table-gutter-padding':
773
- 'calc(var(--ak-editor--large-gutter-padding) * 2)',
774
- '--ak-editor-table-width': isFullPageAppearance
775
- ? tableResizerContainerWidth
776
- : `${tableWidthRef.current}px`,
777
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
778
- width: 'var(--ak-editor-table-width)',
779
- height: resizing ? updateContainerHeight(tableWrapperHeight ?? 'auto') : 'auto',
780
- position: isLivePageViewMode ? 'relative' : 'unset',
781
- } as React.CSSProperties
782
- }
783
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
784
- className={ClassName.TABLE_RESIZER_CONTAINER}
785
- ref={containerRef}
786
- >
787
- {fg('platform_editor_live_page_prevent_table_recreation') ? null : isLivePageViewMode ? (
788
- <InnerContainer
789
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
790
- className={className}
791
- node={node}
792
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
793
- style={{ width: 'inherit' }}
794
- >
795
- {children}
796
- </InnerContainer>
797
- ) : (
798
- // Ignored via go/ees005
799
- // eslint-disable-next-line react/jsx-props-no-spreading
800
- <TableResizer {...tableResizerProps}>
801
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
802
- <InnerContainer className={className} node={node}>
803
- {children}
804
- </InnerContainer>
805
- </TableResizer>
806
- )}
807
- {fg('platform_editor_live_page_prevent_table_recreation') ? (
808
- // Ignored via go/ees005
809
- // eslint-disable-next-line react/jsx-props-no-spreading
810
- <TableResizer {...tableResizerProps} disabled={isLivePageViewMode}>
811
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
812
- <InnerContainer className={className} node={node}>
813
- {children}
814
- </InnerContainer>
815
- </TableResizer>
816
- ) : null}
817
- </div>
818
- </AlignmentTableContainerWrapper>
819
- );
820
- },
821
- );
822
-
823
- export const ResizableTableContainer = componentWithCondition(
824
- () => expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true),
825
- ResizableTableContainerNext,
826
- ResizableTableContainerLegacy,
827
- );
828
-
829
- type TableContainerProps = {
830
- node: PMNode;
831
- className: string;
832
- containerWidth: EditorContainerWidth;
833
- editorView: EditorView;
834
- getPos: () => number | undefined;
835
- tableRef: HTMLTableElement;
836
- isNested: boolean;
837
- isResizing?: boolean;
838
- isWindowResized?: boolean;
839
- pluginInjectionApi?: PluginInjectionAPI;
840
- tableWrapperHeight?: number;
841
- isWholeTableInDanger?: boolean;
842
-
843
- isTableResizingEnabled: boolean | undefined;
844
- isTableScalingEnabled?: boolean;
845
- isTableWithFixedColumnWidthsOptionEnabled?: boolean;
846
- isTableAlignmentEnabled?: boolean;
847
- shouldUseIncreasedScalingPercent?: boolean;
848
- isCommentEditor?: boolean;
849
- isChromelessEditor?: boolean;
850
- };
851
-
852
- export const TableContainer = ({
853
- children,
854
- node,
855
- className,
856
- containerWidth: { width: editorWidth, lineLength },
857
- editorView,
858
- getPos,
859
- tableRef,
860
- isNested,
861
- tableWrapperHeight,
862
- isResizing,
863
- isWindowResized,
864
- pluginInjectionApi,
865
- isWholeTableInDanger,
866
- isTableResizingEnabled,
867
- isTableScalingEnabled,
868
- isTableWithFixedColumnWidthsOptionEnabled,
869
- isTableAlignmentEnabled,
870
- shouldUseIncreasedScalingPercent,
871
- isCommentEditor,
872
- isChromelessEditor,
873
- }: PropsWithChildren<TableContainerProps>) => {
874
- if (isTableResizingEnabled && !isNested) {
875
- return (
876
- <ResizableTableContainer
877
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
878
- className={className}
879
- node={node}
880
- // Ignored via go/ees005
881
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
882
- containerWidth={editorWidth!}
883
- // Ignored via go/ees005
884
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
885
- lineLength={lineLength!}
886
- editorView={editorView}
887
- getPos={getPos}
888
- tableRef={tableRef}
889
- tableWrapperHeight={tableWrapperHeight}
890
- isResizing={isResizing}
891
- isWindowResized={isWindowResized}
892
- pluginInjectionApi={pluginInjectionApi}
893
- isTableScalingEnabled={isTableScalingEnabled}
894
- isTableWithFixedColumnWidthsOptionEnabled={isTableWithFixedColumnWidthsOptionEnabled}
895
- isWholeTableInDanger={isWholeTableInDanger}
896
- isTableAlignmentEnabled={isTableAlignmentEnabled}
897
- shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
898
- isCommentEditor={isCommentEditor}
899
- isChromelessEditor={isChromelessEditor}
900
- >
901
- {children}
902
- </ResizableTableContainer>
903
- );
904
- }
905
-
906
- const { isDragAndDropEnabled } = getPluginState(editorView.state);
907
- return (
908
- <InnerContainer
909
- node={node}
910
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
911
- className={classNames(className, {
912
- 'less-padding':
913
- editorWidth < akEditorMobileBreakoutPoint &&
914
- !isNested &&
915
- !(isChromelessEditor && isDragAndDropEnabled),
916
- })}
917
- style={{
918
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
919
- width: 'inherit',
920
- marginLeft: isChromelessEditor ? 18 : undefined,
921
- }}
922
- >
923
- {children}
924
- </InnerContainer>
925
- );
926
- };