@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,131 +0,0 @@
1
- import type { PopupProps } from '@atlaskit/editor-common/ui';
2
- import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
3
-
4
- import type { TableDirection } from '../../types';
5
- import {
6
- tableInsertColumnButtonOffset,
7
- tableInsertColumnButtonSize,
8
- tableToolbarSize,
9
- } from '../consts';
10
-
11
- const HORIZONTAL_ALIGN_COLUMN_BUTTON = -(tableInsertColumnButtonSize / 2);
12
- const HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON =
13
- HORIZONTAL_ALIGN_COLUMN_BUTTON + akEditorTableNumberColumnWidth;
14
-
15
- const VERTICAL_ALIGN_COLUMN_BUTTON = tableToolbarSize + tableInsertColumnButtonOffset;
16
-
17
- const VERTICAL_ALIGN_COLUMN_BUTTON_DRAG = tableInsertColumnButtonOffset;
18
-
19
- const HORIZONTAL_ALIGN_ROW_BUTTON = -(
20
- tableToolbarSize +
21
- tableInsertColumnButtonOffset +
22
- tableInsertColumnButtonSize
23
- );
24
-
25
- const HORIZONTAL_ALIGN_ROW_BUTTON_DRAG = -18;
26
-
27
- const VERTICAL_ALIGN_ROW_BUTTON = tableInsertColumnButtonSize / 2;
28
-
29
- function getRowOptions(index: number, isDragAndDropEnabled: boolean): Partial<PopupProps> {
30
- let defaultOptions = {
31
- alignX: 'left',
32
- alignY: 'bottom',
33
- offset: [0, VERTICAL_ALIGN_ROW_BUTTON],
34
- } as PopupProps;
35
-
36
- if (index === 0) {
37
- defaultOptions = {
38
- ...defaultOptions,
39
- alignY: 'top',
40
- // The offset is the inverse the original, because is align top nop bottom.
41
- offset: [0, -VERTICAL_ALIGN_ROW_BUTTON],
42
- };
43
- }
44
-
45
- return {
46
- ...defaultOptions,
47
- onPositionCalculated(position) {
48
- return {
49
- ...position,
50
- // Left position should be always the offset (To place in the correct position even if the table has overflow).
51
- left: isDragAndDropEnabled ? HORIZONTAL_ALIGN_ROW_BUTTON_DRAG : HORIZONTAL_ALIGN_ROW_BUTTON,
52
- };
53
- },
54
- };
55
- }
56
-
57
- function getColumnOptions(
58
- index: number,
59
- tableContainer: HTMLElement | null,
60
- hasNumberedColumns: boolean,
61
- isDragAndDropEnabled: boolean,
62
- ): Partial<PopupProps> {
63
- const options: Partial<PopupProps> = {
64
- alignX: 'end',
65
- alignY: 'top',
66
- offset: [
67
- HORIZONTAL_ALIGN_COLUMN_BUTTON,
68
- isDragAndDropEnabled ? VERTICAL_ALIGN_COLUMN_BUTTON_DRAG : VERTICAL_ALIGN_COLUMN_BUTTON,
69
- ],
70
- // :: (position: PopupPosition) -> PopupPosition
71
- // Limit the InsertButton position to the table container
72
- // if the left position starts before it
73
- // we should always set the InsertButton on the start,
74
- // considering the offset from the first column
75
- onPositionCalculated(position) {
76
- const { left } = position;
77
- if (!left) {
78
- // If not left, lest skip expensive next calculations.
79
- return position;
80
- }
81
-
82
- if (index === 0) {
83
- return {
84
- ...position,
85
- left: hasNumberedColumns
86
- ? HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON
87
- : HORIZONTAL_ALIGN_COLUMN_BUTTON,
88
- };
89
- }
90
-
91
- // Check if current position is greater than the available container width
92
- const rect = tableContainer ? tableContainer.getBoundingClientRect() : null;
93
-
94
- return {
95
- ...position,
96
- left: rect && left > rect.width ? rect.width : left,
97
- };
98
- },
99
- };
100
-
101
- // We need to change the popup position when
102
- // the column index is zero
103
- if (index === 0) {
104
- return {
105
- ...options,
106
- alignX: 'left',
107
- alignY: 'top',
108
- };
109
- }
110
-
111
- return options;
112
- }
113
-
114
- function getPopupOptions(
115
- direction: TableDirection,
116
- index: number,
117
- hasNumberedColumns: boolean,
118
- isDragAndDropEnabled: boolean,
119
- tableContainer: HTMLElement | null,
120
- ): Partial<PopupProps> {
121
- switch (direction) {
122
- case 'column':
123
- return getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled);
124
- case 'row':
125
- return getRowOptions(index, isDragAndDropEnabled);
126
- default:
127
- return {};
128
- }
129
- }
130
-
131
- export default getPopupOptions;
@@ -1,314 +0,0 @@
1
- import React from 'react';
2
-
3
- import type { WrappedComponentProps } from 'react-intl-next';
4
- import { injectIntl } from 'react-intl-next';
5
-
6
- import type {
7
- AnalyticsEventPayload,
8
- DispatchAnalyticsEvent,
9
- EditorAnalyticsAPI,
10
- } from '@atlaskit/editor-common/analytics';
11
- import {
12
- ACTION,
13
- ACTION_SUBJECT,
14
- CONTENT_COMPONENT,
15
- EVENT_TYPE,
16
- INPUT_METHOD,
17
- } from '@atlaskit/editor-common/analytics';
18
- import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
19
- import { Popup } from '@atlaskit/editor-common/ui';
20
- import { closestElement } from '@atlaskit/editor-common/utils';
21
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
22
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
23
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
24
- import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
25
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
26
- import { TableMap } from '@atlaskit/editor-tables/table-map';
27
- import { findTable } from '@atlaskit/editor-tables/utils';
28
-
29
- import {
30
- insertColumnWithAnalytics,
31
- insertRowWithAnalytics,
32
- } from '../../pm-plugins/commands/commands-with-analytics';
33
- import { checkIfNumberColumnEnabled } from '../../pm-plugins/utils/nodes';
34
- import { TableCssClassName as ClassName } from '../../types';
35
- import type { PluginInjectionAPI } from '../../types';
36
-
37
- import getPopupOptions from './getPopupOptions';
38
- import InsertButton, { DragAndDropInsertButton } from './InsertButton';
39
-
40
- export interface Props {
41
- editorView: EditorView;
42
- getEditorContainerWidth: GetEditorContainerWidth;
43
- tableRef?: HTMLElement;
44
- tableNode?: PmNode;
45
- insertColumnButtonIndex?: number;
46
- insertRowButtonIndex?: number;
47
- isHeaderColumnEnabled?: boolean;
48
- isHeaderRowEnabled?: boolean;
49
- isDragAndDropEnabled?: boolean;
50
- isTableScalingEnabled?: boolean;
51
- mountPoint?: HTMLElement;
52
- boundariesElement?: HTMLElement;
53
- scrollableElement?: HTMLElement;
54
- hasStickyHeaders?: boolean;
55
- api: PluginInjectionAPI | undefined | null;
56
- dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
57
- editorAnalyticsAPI?: EditorAnalyticsAPI;
58
- getEditorFeatureFlags?: GetEditorFeatureFlags;
59
- isChromelessEditor?: boolean;
60
- isCommentEditor?: boolean;
61
- }
62
-
63
- // Ignored via go/ees005
64
- // eslint-disable-next-line @repo/internal/react/no-class-components, @typescript-eslint/no-explicit-any
65
- export class FloatingInsertButton extends React.Component<Props & WrappedComponentProps, any> {
66
- static displayName = 'FloatingInsertButton';
67
-
68
- constructor(props: Props & WrappedComponentProps) {
69
- super(props);
70
- this.insertColumn = this.insertColumn.bind(this);
71
- this.insertRow = this.insertRow.bind(this);
72
- }
73
-
74
- render() {
75
- const {
76
- tableNode,
77
- editorView,
78
- insertColumnButtonIndex,
79
- insertRowButtonIndex,
80
- tableRef,
81
- mountPoint,
82
- boundariesElement,
83
- isHeaderColumnEnabled,
84
- isHeaderRowEnabled,
85
- isDragAndDropEnabled,
86
- dispatchAnalyticsEvent,
87
- isChromelessEditor,
88
- } = this.props;
89
-
90
- // TODO: ED-26961 - temporarily disable insert button for first column and row https://atlassian.slack.com/archives/C05U8HRQM50/p1698363744682219?thread_ts=1698209039.104909&cid=C05U8HRQM50
91
- if (isDragAndDropEnabled && (insertColumnButtonIndex === 0 || insertRowButtonIndex === 0)) {
92
- return null;
93
- }
94
-
95
- const type =
96
- typeof insertColumnButtonIndex !== 'undefined'
97
- ? 'column'
98
- : typeof insertRowButtonIndex !== 'undefined'
99
- ? 'row'
100
- : null;
101
-
102
- if (!tableNode || !tableRef || !type) {
103
- return null;
104
- }
105
-
106
- // We can’t display the insert button for row|colum index 0
107
- // when the header row|colum is enabled, this feature will be change on the future
108
- if (
109
- (type === 'column' && isHeaderColumnEnabled && insertColumnButtonIndex === 0) ||
110
- (type === 'row' && isHeaderRowEnabled && insertRowButtonIndex === 0)
111
- ) {
112
- return null;
113
- }
114
-
115
- const {
116
- state: { tr },
117
- } = editorView;
118
- if (
119
- tr.selection instanceof CellSelection &&
120
- ((tr.selection as CellSelection).isColSelection() ||
121
- (tr.selection as CellSelection).isRowSelection())
122
- ) {
123
- return null;
124
- }
125
- const tablePos = findTable(tr.selection);
126
- if (!tablePos) {
127
- return null;
128
- }
129
-
130
- // the tableNode props is not always latest (when you type some text in a cell, it's not updated yet)
131
- // we need to get the latest one by calling findTable(tr.selection)
132
- const cellPosition = this.getCellPosition(type, tablePos?.node);
133
- if (!cellPosition) {
134
- return null;
135
- }
136
-
137
- const domAtPos = editorView.domAtPos.bind(editorView);
138
- const pos = cellPosition + tablePos.start + 1;
139
-
140
- let target: Node | undefined;
141
- try {
142
- target = findDomRefAtPos(pos, domAtPos);
143
- } catch (error) {
144
- // eslint-disable-next-line no-console
145
- console.warn(error);
146
- if (dispatchAnalyticsEvent) {
147
- const payload: AnalyticsEventPayload = {
148
- action: ACTION.ERRORED,
149
- actionSubject: ACTION_SUBJECT.CONTENT_COMPONENT,
150
- eventType: EVENT_TYPE.OPERATIONAL,
151
- attributes: {
152
- component: CONTENT_COMPONENT.FLOATING_INSERT_BUTTON,
153
- selection: editorView.state.selection.toJSON(),
154
- position: pos,
155
- docSize: editorView.state.doc.nodeSize,
156
- // Ignored via go/ees005
157
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
- error: (error as any)?.toString(),
159
- },
160
- };
161
- dispatchAnalyticsEvent(payload);
162
- }
163
- }
164
-
165
- if (!target || !(target instanceof HTMLElement)) {
166
- return null;
167
- }
168
-
169
- const targetCellRef =
170
- type === 'row' ? closestElement(target, 'tr') : closestElement(target, 'td, th');
171
-
172
- if (!targetCellRef) {
173
- return null;
174
- }
175
-
176
- const tableContainerWrapper = closestElement(targetCellRef, `.${ClassName.TABLE_CONTAINER}`);
177
- const tableWrapper = closestElement(targetCellRef, `.${ClassName.TABLE_NODE_WRAPPER}`);
178
-
179
- // Ignored via go/ees005
180
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
181
- const index: number = type === 'column' ? insertColumnButtonIndex! : insertRowButtonIndex!;
182
-
183
- const hasNumberedColumns = checkIfNumberColumnEnabled(editorView.state.selection);
184
-
185
- // Fixed the 'add column button' not visible issue when sticky header is enabled
186
- // By setting the Popup z-index higher than the sticky header z-index ( common-styles.ts tr.sticky)
187
- // Only when inserting a column, otherwise set to undefined
188
- // Need to set z-index in the Popup, set z-index in the <InsertButton /> will not work
189
- const zIndex: number | undefined =
190
- type === 'column' ? akEditorTableCellOnStickyHeaderZIndex : undefined;
191
-
192
- return (
193
- <Popup
194
- target={targetCellRef}
195
- mountTo={tableContainerWrapper || mountPoint}
196
- boundariesElement={tableContainerWrapper || boundariesElement}
197
- // Ignored via go/ees005
198
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
199
- scrollableElement={tableWrapper!}
200
- forcePlacement={true}
201
- allowOutOfBounds
202
- // Ignored via go/ees005
203
- // eslint-disable-next-line react/jsx-props-no-spreading
204
- {...getPopupOptions(
205
- type,
206
- index,
207
- hasNumberedColumns,
208
- !!isDragAndDropEnabled,
209
- tableContainerWrapper,
210
- )}
211
- zIndex={zIndex}
212
- >
213
- {isDragAndDropEnabled ? (
214
- <DragAndDropInsertButton
215
- type={type}
216
- tableRef={tableRef}
217
- onMouseDown={type === 'column' ? this.insertColumn : this.insertRow}
218
- hasStickyHeaders={this.props.hasStickyHeaders || false}
219
- isChromelessEditor={isChromelessEditor}
220
- />
221
- ) : (
222
- <InsertButton
223
- type={type}
224
- tableRef={tableRef}
225
- onMouseDown={type === 'column' ? this.insertColumn : this.insertRow}
226
- hasStickyHeaders={this.props.hasStickyHeaders || false}
227
- />
228
- )}
229
- </Popup>
230
- );
231
- }
232
-
233
- private getCellPosition(type: 'column' | 'row', tableNode: PmNode): number | null {
234
- const { insertColumnButtonIndex, insertRowButtonIndex } = this.props;
235
- // Ignored via go/ees005
236
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
237
- const tableMap = TableMap.get(tableNode!);
238
-
239
- if (type === 'column') {
240
- // Ignored via go/ees005
241
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
242
- const columnIndex = insertColumnButtonIndex === 0 ? 0 : insertColumnButtonIndex! - 1;
243
-
244
- if (columnIndex > tableMap.width - 1) {
245
- return null;
246
- }
247
-
248
- // Ignored via go/ees005
249
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
250
- return tableMap.positionAt(0, columnIndex!, tableNode!);
251
- } else {
252
- // Ignored via go/ees005
253
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
254
- const rowIndex = insertRowButtonIndex === 0 ? 0 : insertRowButtonIndex! - 1;
255
-
256
- if (rowIndex > tableMap.height - 1) {
257
- return null;
258
- }
259
-
260
- // Ignored via go/ees005
261
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
262
- return tableMap.positionAt(rowIndex!, 0, tableNode!);
263
- }
264
- }
265
-
266
- private insertRow(event: React.SyntheticEvent) {
267
- const { editorView, insertRowButtonIndex, editorAnalyticsAPI } = this.props;
268
-
269
- if (typeof insertRowButtonIndex !== 'undefined') {
270
- event.preventDefault();
271
-
272
- const { state, dispatch } = editorView;
273
-
274
- insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, {
275
- index: insertRowButtonIndex,
276
- moveCursorToInsertedRow: true,
277
- })(state, dispatch);
278
- }
279
- }
280
-
281
- private insertColumn(event: React.SyntheticEvent) {
282
- const {
283
- editorView,
284
- insertColumnButtonIndex,
285
- editorAnalyticsAPI,
286
- getEditorFeatureFlags,
287
- isTableScalingEnabled,
288
- isCommentEditor,
289
- } = this.props;
290
-
291
- if (typeof insertColumnButtonIndex !== 'undefined') {
292
- event.preventDefault();
293
-
294
- const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags
295
- ? getEditorFeatureFlags()
296
- : {};
297
-
298
- const shouldUseIncreasedScalingPercent =
299
- isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
300
-
301
- const { state, dispatch } = editorView;
302
- insertColumnWithAnalytics(
303
- this.props.api,
304
- editorAnalyticsAPI,
305
- isTableScalingEnabled,
306
- tableWithFixedColumnWidthsOption,
307
- shouldUseIncreasedScalingPercent,
308
- isCommentEditor,
309
- )(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
310
- }
311
- }
312
- }
313
-
314
- export default injectIntl(FloatingInsertButton);
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Popup } from '@atlaskit/editor-common/ui';
4
-
5
- interface Props {
6
- target: HTMLElement;
7
- content: React.ReactNode;
8
- alignX?: 'left' | 'center' | 'right';
9
- alignY?: 'top' | 'bottom' | 'start';
10
- zIndex?: number;
11
- forcePlacement?: boolean;
12
- stick?: boolean;
13
- offset?: [number, number];
14
- }
15
-
16
- export const FloatingToolbarLabel = React.memo((props: Props) => {
17
- const { target, content, alignX, alignY, zIndex, forcePlacement, stick, offset } = props;
18
- return (
19
- <Popup
20
- target={target}
21
- alignX={alignX}
22
- alignY={alignY}
23
- zIndex={zIndex}
24
- stick={stick}
25
- forcePlacement={forcePlacement}
26
- offset={offset}
27
- >
28
- {content}
29
- </Popup>
30
- );
31
- });
@@ -1,74 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import { useCallback } from 'react';
6
-
7
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
8
- import { jsx } from '@emotion/react';
9
-
10
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
11
- import { TableSelectorPopup, type TableSelectorPopupProps } from '@atlaskit/editor-common/ui';
12
-
13
- import { pluginKey } from '../../pm-plugins/table-size-selector';
14
- import type { TablePlugin } from '../../tablePluginType';
15
-
16
- interface SizeSelectorProps
17
- extends Omit<TableSelectorPopupProps, 'handleClickOutside' | 'onSelection' | 'unUnmount'> {
18
- api?: ExtractInjectionAPI<TablePlugin>;
19
- }
20
-
21
- const DEFAULT_TABLE_SELECTOR_COLS = 3;
22
- const DEFAULT_TABLE_SELECTOR_ROWS = 3;
23
-
24
- export const SizeSelector = ({
25
- api,
26
- target,
27
- popupsMountPoint,
28
- popupsBoundariesElement,
29
- popupsScrollableElement,
30
- }: SizeSelectorProps) => {
31
- const closeSelectorPopup = useCallback(() => {
32
- api?.core.actions.execute(({ tr }) => {
33
- tr.setMeta(pluginKey, {
34
- isSelectorOpen: false,
35
- });
36
-
37
- return tr;
38
- });
39
- }, [api]);
40
-
41
- const onSelection = useCallback(
42
- (rowsCount: number, colsCount: number) => {
43
- api?.core.actions.execute(({ tr }) => {
44
- api?.table.commands.insertTableWithSize(rowsCount, colsCount)({ tr });
45
-
46
- tr.setMeta(pluginKey, {
47
- isSelectorOpen: false,
48
- });
49
-
50
- return tr;
51
- });
52
- },
53
- [api],
54
- );
55
-
56
- const onUnmount = () => {
57
- api?.core.actions.focus();
58
- };
59
-
60
- return (
61
- <TableSelectorPopup
62
- defaultSize={{ row: DEFAULT_TABLE_SELECTOR_ROWS, col: DEFAULT_TABLE_SELECTOR_COLS }}
63
- target={target}
64
- onUnmount={onUnmount}
65
- onSelection={onSelection}
66
- popupsMountPoint={popupsMountPoint}
67
- popupsScrollableElement={popupsScrollableElement}
68
- popupsBoundariesElement={popupsBoundariesElement}
69
- isOpenedByKeyboard={true}
70
- handleClickOutside={closeSelectorPopup}
71
- handleEscapeKeydown={closeSelectorPopup}
72
- />
73
- );
74
- };