@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,151 +0,0 @@
1
- import React, { useEffect, useMemo, useRef, useState } from 'react';
2
-
3
- import type { TableColumnOrdering } from '@atlaskit/custom-steps';
4
- import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
6
- import type { Selection } from '@atlaskit/editor-prosemirror/state';
7
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
- import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
10
-
11
- import type { RowStickyState } from '../../pm-plugins/sticky-headers/types';
12
- import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
13
- import { containsHeaderColumn } from '../../pm-plugins/utils/nodes';
14
- import { getRowHeights } from '../../pm-plugins/utils/row-controls';
15
- import type { CellHoverMeta, DraggableSourceData, PluginInjectionAPI } from '../../types';
16
- import { TableCssClassName as ClassName } from '../../types';
17
-
18
- import { ColumnControls } from './ColumnControls';
19
- import { ColumnDropTargets } from './ColumnDropTargets';
20
-
21
- interface Props {
22
- editorView: EditorView;
23
- getEditorFeatureFlags: GetEditorFeatureFlags;
24
- selection?: Selection;
25
- tableRef?: HTMLTableElement;
26
- getNode: () => PmNode;
27
- tableActive?: boolean;
28
- isInDanger?: boolean;
29
- hasHeaderRow?: boolean;
30
- headerRowHeight?: number;
31
- hoveredRows?: number[];
32
- hoveredCell?: CellHoverMeta;
33
- isResizing?: boolean;
34
- ordering?: TableColumnOrdering;
35
- stickyHeader?: RowStickyState;
36
- isTableHovered?: boolean;
37
- tableContainerWidth?: number;
38
- isNumberColumnEnabled?: boolean;
39
- getScrollOffset?: () => number;
40
- tableWrapperHeight?: number;
41
- api?: PluginInjectionAPI;
42
- isChromelessEditor?: boolean;
43
- }
44
-
45
- const TableFloatingColumnControls = ({
46
- editorView,
47
- tableRef,
48
- getNode,
49
- tableActive,
50
- hasHeaderRow,
51
- hoveredCell,
52
- isResizing,
53
- stickyHeader,
54
- selection,
55
- isInDanger,
56
- isTableHovered,
57
- tableContainerWidth,
58
- isNumberColumnEnabled,
59
- getScrollOffset,
60
- tableWrapperHeight,
61
- api,
62
- isChromelessEditor,
63
- }: Props) => {
64
- const [isDragging, setIsDragging] = useState(false);
65
- const containerRef = useRef<HTMLDivElement>(null);
66
-
67
- const node = getNode();
68
- const currentNodeLocalId = node?.attrs.localId;
69
- const hasHeaderColumn = containsHeaderColumn(node);
70
- const stickyTop =
71
- stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
72
-
73
- useEffect(() => {
74
- return monitorForElements({
75
- canMonitor({ source }) {
76
- const { type, localId, indexes } = source.data as Partial<DraggableSourceData>;
77
- return type === 'table-column' && !!indexes?.length && localId === currentNodeLocalId;
78
- },
79
- onDragStart() {
80
- setIsDragging(true);
81
- },
82
- onDrop() {
83
- setIsDragging(false);
84
- },
85
- });
86
- }, [editorView, currentNodeLocalId]);
87
-
88
- const rowHeights = useMemo(() => {
89
- // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
90
- if (tableRef && !!tableWrapperHeight) {
91
- return getRowHeights(tableRef);
92
- }
93
- return [0];
94
- }, [tableRef, tableWrapperHeight]);
95
-
96
- if (!tableRef || !tableActive || isResizing) {
97
- return null;
98
- }
99
-
100
- const colWidths = getColumnsWidths(editorView);
101
-
102
- if (stickyTop) {
103
- const columnControlTopOffsetFromParent = '-12px';
104
- containerRef?.current?.style.setProperty('top', columnControlTopOffsetFromParent);
105
- } else {
106
- containerRef?.current?.style.removeProperty('top');
107
- }
108
-
109
- return (
110
- <div
111
- ref={containerRef}
112
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
113
- className={
114
- ClassName.DRAG_COLUMN_CONTROLS_WRAPPER +
115
- (isChromelessEditor ? ' ' + ClassName.TABLE_CHROMELESS : '')
116
- }
117
- data-testid="table-floating-column-controls-wrapper"
118
- >
119
- <ColumnControls
120
- editorView={editorView}
121
- hoveredCell={hoveredCell}
122
- tableRef={tableRef}
123
- tableActive={tableActive}
124
- isTableHovered={isTableHovered}
125
- stickyTop={tableActive ? stickyTop : undefined}
126
- localId={currentNodeLocalId}
127
- isInDanger={isInDanger}
128
- rowHeights={rowHeights}
129
- colWidths={colWidths}
130
- hasHeaderColumn={hasHeaderColumn}
131
- tableContainerWidth={tableContainerWidth}
132
- isNumberColumnEnabled={isNumberColumnEnabled}
133
- isDragging={isDragging}
134
- getScrollOffset={getScrollOffset}
135
- api={fg('platform_editor_table_use_shared_state_hook_fg') ? api : undefined}
136
- />
137
- {isDragging && (
138
- <ColumnDropTargets
139
- tableRef={tableRef}
140
- isHeaderSticky={stickyHeader?.sticky && hasHeaderRow}
141
- tableHeight={tableWrapperHeight}
142
- localId={currentNodeLocalId}
143
- colWidths={colWidths}
144
- getScrollOffset={getScrollOffset}
145
- />
146
- )}
147
- </div>
148
- );
149
- };
150
-
151
- export default TableFloatingColumnControls;
@@ -1,106 +0,0 @@
1
- import React, { Component } from 'react';
2
-
3
- import classnames from 'classnames';
4
- import type { WrappedComponentProps } from 'react-intl-next';
5
- import { injectIntl } from 'react-intl-next';
6
-
7
- import { tableMessages as messages } from '@atlaskit/editor-common/messages';
8
- import { TableMap } from '@atlaskit/editor-tables/table-map';
9
- import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
10
-
11
- import { clearHoverSelection, hoverTable } from '../../../pm-plugins/commands';
12
- import { TableCssClassName as ClassName } from '../../../types';
13
-
14
- import type { CornerControlProps } from './types';
15
-
16
- // Ignored via go/ees005
17
- // eslint-disable-next-line @repo/internal/react/no-class-components, @typescript-eslint/no-explicit-any
18
- class CornerControlComponent extends Component<CornerControlProps & WrappedComponentProps, any> {
19
- render() {
20
- const {
21
- isInDanger,
22
- tableRef,
23
- isHeaderColumnEnabled,
24
- isHeaderRowEnabled,
25
- intl: { formatMessage },
26
- } = this.props;
27
- if (!tableRef) {
28
- return null;
29
- }
30
- const isActive = this.isActive();
31
-
32
- return (
33
- <div
34
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
35
- className={classnames(ClassName.CORNER_CONTROLS, {
36
- active: isActive,
37
- sticky: this.props.stickyTop !== undefined,
38
- })}
39
- style={{
40
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
41
- top: this.props.stickyTop !== undefined ? `0px` : undefined,
42
- }}
43
- contentEditable={false}
44
- >
45
- <button
46
- aria-label={formatMessage(messages.cornerControl)}
47
- type="button"
48
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
49
- className={classnames(ClassName.CONTROLS_CORNER_BUTTON, {
50
- danger: isActive && isInDanger,
51
- })}
52
- onClick={this.selectTable}
53
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
54
- onMouseOver={this.hoverTable}
55
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
56
- onMouseOut={this.clearHoverSelection}
57
- />
58
-
59
- {!isHeaderRowEnabled && (
60
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
61
- <div className={ClassName.CORNER_CONTROLS_INSERT_ROW_MARKER}>
62
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
63
- <div className={ClassName.CONTROLS_INSERT_MARKER} />
64
- </div>
65
- )}
66
- {!isHeaderColumnEnabled && (
67
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
68
- <div className={ClassName.CORNER_CONTROLS_INSERT_COLUMN_MARKER}>
69
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
70
- <div className={ClassName.CONTROLS_INSERT_MARKER} />
71
- </div>
72
- )}
73
- </div>
74
- );
75
- }
76
-
77
- private isActive = () => {
78
- const { editorView, hoveredRows, isResizing } = this.props;
79
- const { selection } = editorView.state;
80
- const table = findTable(selection);
81
- if (!table) {
82
- return false;
83
- }
84
- return (
85
- isTableSelected(selection) ||
86
- (hoveredRows && hoveredRows.length === TableMap.get(table.node).height && !isResizing)
87
- );
88
- };
89
-
90
- private clearHoverSelection = () => {
91
- const { state, dispatch } = this.props.editorView;
92
- clearHoverSelection()(state, dispatch);
93
- };
94
-
95
- private selectTable = () => {
96
- const { state, dispatch } = this.props.editorView;
97
- dispatch(selectTable(state.tr).setMeta('addToHistory', false));
98
- };
99
-
100
- private hoverTable = () => {
101
- const { state, dispatch } = this.props.editorView;
102
- hoverTable()(state, dispatch);
103
- };
104
- }
105
-
106
- export const CornerControls = injectIntl(CornerControlComponent);
@@ -1,143 +0,0 @@
1
- import React, { useMemo } from 'react';
2
-
3
- import classnames from 'classnames';
4
- import type { WrappedComponentProps } from 'react-intl-next';
5
- import { injectIntl } from 'react-intl-next';
6
-
7
- import {
8
- sharedPluginStateHookMigratorFactory,
9
- useSharedPluginState,
10
- useSharedPluginStateWithSelector,
11
- } from '@atlaskit/editor-common/hooks';
12
- import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
14
- import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
15
-
16
- import { clearHoverSelection } from '../../../pm-plugins/commands';
17
- import type { TablePlugin } from '../../../tablePluginType';
18
- import { TableCssClassName as ClassName } from '../../../types';
19
-
20
- import type { CornerControlProps } from './types';
21
-
22
- const DragCornerControlsComponent = ({
23
- editorView,
24
- isInDanger,
25
- isResizing,
26
- intl: { formatMessage },
27
- }: CornerControlProps & WrappedComponentProps) => {
28
- const handleOnClick = () => {
29
- const { state, dispatch } = editorView;
30
- dispatch(selectTable(state.tr).setMeta('addToHistory', false));
31
- };
32
-
33
- const handleMouseOut = () => {
34
- const { state, dispatch } = editorView;
35
- clearHoverSelection()(state, dispatch);
36
- };
37
-
38
- const isActive = useMemo(() => {
39
- const { selection } = editorView.state;
40
- const table = findTable(selection);
41
- if (!table) {
42
- return false;
43
- }
44
- return isTableSelected(selection);
45
- }, [editorView.state]);
46
-
47
- if (isResizing) {
48
- return null;
49
- }
50
-
51
- return (
52
- <button
53
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
54
- className={classnames(ClassName.DRAG_CORNER_BUTTON, {
55
- active: isActive,
56
- danger: isActive && isInDanger,
57
- })}
58
- aria-label={formatMessage(messages.cornerControl)}
59
- type="button"
60
- onClick={handleOnClick}
61
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
62
- onMouseOut={handleMouseOut}
63
- contentEditable={false}
64
- >
65
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
66
- <div className={ClassName.DRAG_CORNER_BUTTON_INNER} />
67
- </button>
68
- );
69
- };
70
-
71
- const useSharedState = sharedPluginStateHookMigratorFactory(
72
- (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
73
- const { selection } = useSharedPluginStateWithSelector(api, ['selection'], (states) => ({
74
- selection: states.selectionState?.selection,
75
- }));
76
- return {
77
- selection,
78
- };
79
- },
80
- (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
81
- const { selectionState } = useSharedPluginState(api, ['selection']);
82
- return {
83
- selection: selectionState?.selection,
84
- };
85
- },
86
- );
87
-
88
- const DragCornerControlsComponentWithSelection = ({
89
- editorView,
90
- isInDanger,
91
- isResizing,
92
- intl: { formatMessage },
93
- api,
94
- }: CornerControlProps & WrappedComponentProps & { api?: ExtractInjectionAPI<TablePlugin> }) => {
95
- const { selection } = useSharedState(api);
96
-
97
- const handleOnClick = () => {
98
- const { state, dispatch } = editorView;
99
- dispatch(selectTable(state.tr).setMeta('addToHistory', false));
100
- };
101
-
102
- const handleMouseOut = () => {
103
- const { state, dispatch } = editorView;
104
- clearHoverSelection()(state, dispatch);
105
- };
106
- const isActive = useMemo(() => {
107
- if (!selection) {
108
- return;
109
- }
110
- const table = findTable(selection);
111
- if (!table) {
112
- return false;
113
- }
114
- return isTableSelected(selection);
115
- }, [selection]);
116
-
117
- if (isResizing) {
118
- return null;
119
- }
120
-
121
- return (
122
- <button
123
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
124
- className={classnames(ClassName.DRAG_CORNER_BUTTON, {
125
- active: isActive,
126
- danger: isActive && isInDanger,
127
- })}
128
- aria-label={formatMessage(messages.cornerControl)}
129
- type="button"
130
- onClick={handleOnClick}
131
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
132
- onMouseOut={handleMouseOut}
133
- contentEditable={false}
134
- >
135
- {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
136
- <div className={ClassName.DRAG_CORNER_BUTTON_INNER} />
137
- </button>
138
- );
139
- };
140
-
141
- export const DragCornerControlsWithSelection = injectIntl(DragCornerControlsComponentWithSelection);
142
-
143
- export const DragCornerControls = injectIntl(DragCornerControlsComponent);
@@ -1,12 +0,0 @@
1
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
-
3
- export type CornerControlProps = {
4
- editorView: EditorView;
5
- tableRef?: HTMLTableElement;
6
- isInDanger?: boolean;
7
- isResizing?: boolean;
8
- hoveredRows?: number[];
9
- isHeaderColumnEnabled?: boolean;
10
- isHeaderRowEnabled?: boolean;
11
- stickyTop?: number;
12
- };
@@ -1,88 +0,0 @@
1
- import React from 'react';
2
-
3
- import {
4
- sharedPluginStateHookMigratorFactory,
5
- useSharedPluginState,
6
- useSharedPluginStateWithSelector,
7
- } from '@atlaskit/editor-common/hooks';
8
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
9
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
-
11
- import type { TablePlugin } from '../../tablePluginType';
12
-
13
- import { CornerControls } from './CornerControls/ClassicCornerControls';
14
- import { RowControls } from './RowControls/ClassicControls';
15
-
16
- type FloatingControlsWithSelectionProps = {
17
- editorView: EditorView;
18
- tableRef: HTMLTableElement;
19
- isInDanger?: boolean;
20
- isResizing?: boolean;
21
- isHeaderRowEnabled?: boolean;
22
- isHeaderColumnEnabled?: boolean;
23
- hoveredRows?: number[];
24
- stickyTop?: number;
25
- hoverRows: (rows: number[]) => void;
26
- selectRow: (row: number, expand: boolean) => void;
27
- tableActive: boolean;
28
- api?: ExtractInjectionAPI<TablePlugin>;
29
- };
30
-
31
- const useSharedState = sharedPluginStateHookMigratorFactory(
32
- (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
33
- const { selection } = useSharedPluginStateWithSelector(api, ['selection'], (states) => ({
34
- selection: states.selectionState?.selection,
35
- }));
36
- return {
37
- selection,
38
- };
39
- },
40
- (api: ExtractInjectionAPI<TablePlugin> | undefined) => {
41
- const { selectionState } = useSharedPluginState(api, ['selection']);
42
- return {
43
- selection: selectionState?.selection,
44
- };
45
- },
46
- );
47
-
48
- export const FloatingControlsWithSelection = ({
49
- editorView,
50
- tableRef,
51
- isInDanger,
52
- isResizing,
53
- isHeaderRowEnabled,
54
- isHeaderColumnEnabled,
55
- hoveredRows,
56
- stickyTop,
57
- hoverRows,
58
- selectRow,
59
- tableActive,
60
- api,
61
- }: FloatingControlsWithSelectionProps) => {
62
- const { selection } = useSharedState(api);
63
- return (
64
- <>
65
- <CornerControls
66
- editorView={editorView}
67
- tableRef={tableRef}
68
- isInDanger={isInDanger}
69
- isResizing={isResizing}
70
- isHeaderRowEnabled={isHeaderRowEnabled}
71
- isHeaderColumnEnabled={isHeaderColumnEnabled}
72
- hoveredRows={hoveredRows}
73
- stickyTop={tableActive ? stickyTop : undefined}
74
- />
75
- <RowControls
76
- selection={selection}
77
- editorView={editorView}
78
- tableRef={tableRef}
79
- hoverRows={hoverRows}
80
- hoveredRows={hoveredRows}
81
- isInDanger={isInDanger}
82
- isResizing={isResizing}
83
- selectRow={selectRow}
84
- stickyTop={tableActive ? stickyTop : undefined}
85
- />
86
- </>
87
- );
88
- };
@@ -1,150 +0,0 @@
1
- import React, { Component } from 'react';
2
-
3
- import classnames from 'classnames';
4
-
5
- import { Selection } from '@atlaskit/editor-prosemirror/state';
6
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
- import { isRowSelected } from '@atlaskit/editor-tables/utils';
8
-
9
- import { clearHoverSelection } from '../../../pm-plugins/commands';
10
- import { getRowHeights } from '../../../pm-plugins/utils/row-controls';
11
- import { TableCssClassName as ClassName } from '../../../types';
12
- import { tableBorderColor } from '../../consts';
13
-
14
- interface Props {
15
- editorView: EditorView;
16
- tableRef: HTMLTableElement;
17
- tableActive?: boolean;
18
- hoverRows: (rows: number[], danger?: boolean) => void;
19
- hoveredRows?: number[];
20
- selectRow: (row: number, expand: boolean) => void;
21
- updateCellHoverLocation: (rowIndex: number) => void;
22
- hasHeaderRow?: boolean;
23
- isInDanger?: boolean;
24
- isResizing?: boolean;
25
- stickyTop?: number;
26
- isDragAndDropEnabled?: boolean;
27
- }
28
-
29
- // Ignored via go/ees005
30
- // eslint-disable-next-line @repo/internal/react/no-class-components, @typescript-eslint/no-explicit-any
31
- export default class NumberColumn extends Component<Props, any> {
32
- render() {
33
- const { tableRef, hasHeaderRow, isDragAndDropEnabled, tableActive, updateCellHoverLocation } =
34
- this.props;
35
- const rowHeights = getRowHeights(tableRef);
36
-
37
- return (
38
- <div
39
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
40
- className={ClassName.NUMBERED_COLUMN}
41
- style={{
42
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
43
- marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined,
44
- borderLeft:
45
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
46
- isDragAndDropEnabled && tableActive ? `1px solid ${tableBorderColor}` : undefined,
47
- }}
48
- contentEditable={false}
49
- >
50
- {rowHeights.map((rowHeight, index) =>
51
- isDragAndDropEnabled ? (
52
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
53
- <div
54
- // Ignored via go/ees005
55
- // eslint-disable-next-line react/no-array-index-key
56
- key={`wrapper-${index}`}
57
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
58
- className={this.getClassNames(index, true)}
59
- data-index={index}
60
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
61
- style={this.getCellStyles(index, rowHeight)}
62
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
63
- onMouseOver={() => updateCellHoverLocation(index)}
64
- >
65
- {hasHeaderRow ? (index > 0 ? index : null) : index + 1}
66
- </div>
67
- ) : (
68
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
69
- <div
70
- // Ignored via go/ees005
71
- // eslint-disable-next-line react/no-array-index-key
72
- key={`wrapper-${index}`}
73
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
74
- className={this.getClassNames(index)}
75
- data-index={index}
76
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
77
- style={this.getCellStyles(index, rowHeight)}
78
- onClick={(event) => this.selectRow(index, event)}
79
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
80
- onMouseOver={() => this.hoverRows(index)}
81
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
82
- onMouseOut={this.clearHoverSelection}
83
- >
84
- {hasHeaderRow ? (index > 0 ? index : null) : index + 1}
85
- </div>
86
- ),
87
- )}
88
- </div>
89
- );
90
- }
91
-
92
- private hoverRows = (index: number) => {
93
- return this.props.tableActive ? this.props.hoverRows([index]) : null;
94
- };
95
- private selectRow = (index: number, event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
96
- const { tableActive, editorView, selectRow } = this.props;
97
- // If selection is outside the table then first reset the selection inside table
98
- if (!tableActive && event.target && event.target instanceof Node) {
99
- const { doc, selection, tr } = editorView.state;
100
- const pos = editorView.posAtDOM(event.target, 1);
101
- const $pos = doc.resolve(pos);
102
- const newPos =
103
- selection.head > pos
104
- ? // Selection is after table
105
- // nodeSize - 3 will move the position inside last table cell
106
- Selection.near(doc.resolve(pos + ($pos.parent.nodeSize - 3)), -1)
107
- : // Selection is before table
108
- Selection.near($pos);
109
- editorView.dispatch(tr.setSelection(newPos));
110
- }
111
- selectRow(index, event.shiftKey);
112
- };
113
-
114
- private clearHoverSelection = () => {
115
- const { tableActive, editorView } = this.props;
116
- if (tableActive) {
117
- const { state, dispatch } = editorView;
118
- clearHoverSelection()(state, dispatch);
119
- }
120
- };
121
-
122
- private getCellStyles = (index: number, rowHeight: number) => {
123
- const { stickyTop, hasHeaderRow } = this.props;
124
- if (stickyTop && hasHeaderRow && index === 0) {
125
- const topOffset = 0;
126
-
127
- return {
128
- height: rowHeight,
129
- top: `${topOffset}px`,
130
- };
131
- }
132
- return {
133
- height: rowHeight,
134
- };
135
- };
136
-
137
- private getClassNames = (index: number, isButtonDisabled = false) => {
138
- const { hoveredRows, editorView, isInDanger, isResizing, tableActive } = this.props;
139
-
140
- const isActive =
141
- isRowSelected(index)(editorView.state.selection) ||
142
- ((hoveredRows || []).indexOf(index) !== -1 && !isResizing);
143
-
144
- return classnames(ClassName.NUMBERED_COLUMN_BUTTON, {
145
- [ClassName.NUMBERED_COLUMN_BUTTON_DISABLED]: isButtonDisabled,
146
- [ClassName.HOVERED_CELL_IN_DANGER]: tableActive && isActive && isInDanger,
147
- [ClassName.HOVERED_CELL_ACTIVE]: tableActive && isActive,
148
- });
149
- };
150
- }