@atlaskit/editor-plugin-table 12.2.6 → 12.3.0

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 +19 -0
  2. package/dist/cjs/pm-plugins/view-mode-sort/index.js +1 -3
  3. package/dist/es2019/pm-plugins/view-mode-sort/index.js +1 -3
  4. package/dist/esm/pm-plugins/view-mode-sort/index.js +1 -3
  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 -175
  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,42 +0,0 @@
1
- import type { Command } from '@atlaskit/editor-common/types';
2
- import type { Rect } from '@atlaskit/editor-tables/table-map';
3
-
4
- import type { PluginInjectionAPI } from '../../types';
5
- import { pluginKey } from '../plugin-key';
6
- import { deleteColumns } from '../transforms/delete-columns';
7
- import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
8
-
9
- export const deleteColumnsCommand =
10
- (
11
- rect: Rect,
12
- api: PluginInjectionAPI | undefined | null,
13
- isTableScalingEnabled = false,
14
- isTableFixedColumnWidthsOptionEnabled = false,
15
- shouldUseIncreasedScalingPercent = false,
16
- isCommentEditor = false,
17
- ): Command =>
18
- (state, dispatch, view) => {
19
- const tr = deleteColumns(
20
- rect,
21
- getAllowAddColumnCustomStep(state),
22
- api,
23
- view,
24
- isTableScalingEnabled,
25
- isTableFixedColumnWidthsOptionEnabled,
26
- shouldUseIncreasedScalingPercent,
27
- isCommentEditor,
28
- )(state.tr);
29
- // If we delete a column we should also clean up the hover selection
30
- tr.setMeta(pluginKey, {
31
- type: 'CLEAR_HOVER_SELECTION',
32
- data: {
33
- isInDanger: false,
34
- isWholeTableInDanger: false,
35
- },
36
- });
37
- if (dispatch) {
38
- dispatch(tr);
39
- return true;
40
- }
41
- return false;
42
- };
@@ -1,18 +0,0 @@
1
- import type { EditorCommand } from '@atlaskit/editor-common/types';
2
- import { findTable } from '@atlaskit/editor-tables/utils';
3
-
4
- export const setTableDisplayMode: EditorCommand = ({ tr }) => {
5
- const table = findTable(tr.selection);
6
- if (!table) {
7
- return null;
8
- }
9
-
10
- const { displayMode } = table.node.attrs;
11
-
12
- tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, {
13
- ...table.node.attrs,
14
- displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default',
15
- });
16
-
17
- return tr.setMeta('scrollIntoView', false);
18
- };
@@ -1,198 +0,0 @@
1
- import type { IntlShape } from 'react-intl-next/src/types';
2
-
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
5
- import { isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
6
- import type { Command } from '@atlaskit/editor-common/types';
7
- import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
- import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
- import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
10
- import { TableMap } from '@atlaskit/editor-tables/table-map';
11
- import type { Direction } from '@atlaskit/editor-tables/types';
12
- import {
13
- goToNextCell as baseGotoNextCell,
14
- findCellClosestToPos,
15
- findTable,
16
- findTableClosestToPos,
17
- isTableSelected,
18
- } from '@atlaskit/editor-tables/utils';
19
-
20
- import { getPluginState } from '../plugin-factory';
21
-
22
- import { stopKeyboardColumnResizing } from './column-resize';
23
- import { insertRowWithAnalytics } from './commands-with-analytics';
24
-
25
- const TAB_FORWARD_DIRECTION = 1;
26
- const TAB_BACKWARD_DIRECTION = -1;
27
-
28
- export const goToNextCell =
29
- (
30
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
31
- ariaNotify?: (message: string) => void,
32
- getIntl?: () => IntlShape,
33
- ) =>
34
- (direction: Direction): Command =>
35
- (state, dispatch, view) => {
36
- const table = findTable(state.selection);
37
- if (!table) {
38
- return false;
39
- }
40
-
41
- const isColumnResizing = getPluginState(state)?.isKeyboardResize;
42
- if (isColumnResizing) {
43
- stopKeyboardColumnResizing({
44
- ariaNotify: ariaNotify,
45
- getIntl: getIntl,
46
- })(state, dispatch, view);
47
- return true;
48
- }
49
-
50
- const map = TableMap.get(table.node);
51
- const { tableCell, tableHeader } = state.schema.nodes;
52
- // Ignored via go/ees005
53
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
54
- const cell = findParentNodeOfType([tableCell, tableHeader])(state.selection)!;
55
- const firstCellPos = map.positionAt(0, 0, table.node) + table.start;
56
- const lastCellPos = map.positionAt(map.height - 1, map.width - 1, table.node) + table.start;
57
-
58
- // When tabbing backwards at first cell (top left), insert row at the start of table
59
- if (firstCellPos === cell.pos && direction === TAB_BACKWARD_DIRECTION) {
60
- insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
61
- index: 0,
62
- moveCursorToInsertedRow: true,
63
- })(state, dispatch);
64
- return true;
65
- }
66
-
67
- // When tabbing forwards at last cell (bottom right), insert row at the end of table
68
- if (lastCellPos === cell.pos && direction === TAB_FORWARD_DIRECTION) {
69
- insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, {
70
- index: map.height,
71
- moveCursorToInsertedRow: true,
72
- })(state, dispatch);
73
- return true;
74
- }
75
-
76
- if (dispatch) {
77
- return baseGotoNextCell(direction)(state, dispatch);
78
- }
79
-
80
- return true;
81
- };
82
-
83
- /**
84
- * Moves the cursor vertically from a NodeSelection within a table cell.
85
- * - If content exists above/below within the cell, lets ProseMirror handle it.
86
- * - Otherwise, moves to the next cell (down to start, up to last line).
87
- */
88
- export const goToNextCellVertical =
89
- (direction: Direction): Command =>
90
- (state, dispatch) => {
91
- const { selection } = state;
92
- const nestedTableSelection = isSelectionTableNestedInTable(state);
93
-
94
- if (!(selection instanceof NodeSelection) && !nestedTableSelection) {
95
- return false; // Let ProseMirror handle other selection types
96
- }
97
-
98
- let table = findTable(selection);
99
- let cell = findCellClosestToPos(state.doc.resolve(selection.from));
100
- let selectionPos = selection.from;
101
-
102
- // Handle when we have nested table fully selected
103
- if (table && nestedTableSelection && isTableSelected(selection)) {
104
- const parentTablePos = table.pos;
105
- table = findTableClosestToPos(state.doc.resolve(parentTablePos));
106
- cell = findCellClosestToPos(state.doc.resolve(parentTablePos));
107
- selectionPos = parentTablePos;
108
- }
109
-
110
- if (!table || !cell || !cell.pos) {
111
- return false;
112
- }
113
-
114
- const { tableCell, tableHeader } = state.schema.nodes;
115
-
116
- // Let ProseMirror handle movement within the cell if content exists above/below
117
- if (cellHasContentInDirection(cell.node, cell.pos, selectionPos, direction)) {
118
- return false;
119
- }
120
-
121
- // Move to the next cell vertically
122
- const map = TableMap.get(table.node);
123
- const nextCellPos = map.nextCell(cell.pos - table.start, 'vert', direction);
124
- if (dispatch && nextCellPos) {
125
- const nextCellStart = table.start + nextCellPos;
126
- const $nextCell = state.doc.resolve(nextCellStart);
127
-
128
- if (
129
- $nextCell.nodeAfter?.type &&
130
- [tableCell, tableHeader].includes($nextCell.nodeAfter?.type)
131
- ) {
132
- const contentPos = getTargetPositionInNextCell(
133
- $nextCell.nodeAfter,
134
- nextCellStart,
135
- direction,
136
- );
137
-
138
- dispatch(state.tr.setSelection(TextSelection.create(state.doc, contentPos)));
139
- return true;
140
- }
141
-
142
- return false;
143
- }
144
-
145
- return false; // No next cell found
146
- };
147
-
148
- function cellHasContentInDirection(
149
- cellNode: PMNode,
150
- cellPos: number,
151
- selectionPos: number,
152
- direction: Direction,
153
- ): boolean {
154
- let hasContent = false;
155
-
156
- cellNode.content.forEach((node: PMNode, offset: number) => {
157
- const nodeStart = cellPos + 1 + offset;
158
- const nodeEnd = nodeStart + node.nodeSize;
159
-
160
- if (direction === 1 && nodeStart > selectionPos && node.isBlock) {
161
- hasContent = true; // Content below
162
- } else if (direction === -1 && nodeEnd <= selectionPos && node.isBlock) {
163
- hasContent = true; // Content above
164
- }
165
- });
166
-
167
- return hasContent;
168
- }
169
-
170
- function getTargetPositionInNextCell(
171
- cellNode: PMNode,
172
- nextCellStart: number,
173
- direction: Direction,
174
- ): number {
175
- let contentPos = nextCellStart + 1; // Default: just inside the cell
176
- if (cellNode.content.size > 0) {
177
- if (direction === 1) {
178
- const firstChild = cellNode.firstChild;
179
- if (firstChild && firstChild.isBlock) {
180
- contentPos = nextCellStart + 1 + (firstChild.isLeaf ? 0 : 1); // Down: Start of first block
181
- }
182
- } else if (direction === -1) {
183
- let lastBlock: PMNode | undefined;
184
- let lastOffset = 0;
185
- cellNode.content.forEach((node: PMNode, offset: number) => {
186
- if (node.isBlock) {
187
- lastBlock = node;
188
- lastOffset = offset;
189
- }
190
- });
191
- if (lastBlock) {
192
- contentPos =
193
- nextCellStart + 1 + lastOffset + (lastBlock.isLeaf ? 0 : lastBlock.nodeSize - 1);
194
- }
195
- }
196
- }
197
- return contentPos;
198
- }
@@ -1,242 +0,0 @@
1
- // #region Imports
2
- import { TableMap } from '@atlaskit/editor-tables/table-map';
3
- import { findTable, getCellsInColumn, getCellsInRow } from '@atlaskit/editor-tables/utils';
4
-
5
- import type { Cell, CellColumnPositioning } from '../../types';
6
- import { TableDecorations } from '../../types';
7
- import { createCommand, getPluginState } from '../plugin-factory';
8
- import {
9
- createCellHoverDecoration,
10
- createColumnLineResize,
11
- createControlsHoverDecoration,
12
- } from '../utils/decoration';
13
- import { getMergedCellsPositions } from '../utils/table';
14
- import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
15
-
16
- const makeArray = (n: number) => Array.from(Array(n).keys());
17
-
18
- export const hoverMergedCells = () =>
19
- createCommand(
20
- (state) => {
21
- const mergedCellsPositions = getMergedCellsPositions(state.tr);
22
- if (!mergedCellsPositions.length) {
23
- return false;
24
- }
25
- const table = findTable(state.tr.selection);
26
- if (!table) {
27
- return false;
28
- }
29
-
30
- const mergedCells: Cell[] = mergedCellsPositions.map((pos) => ({
31
- pos: pos + table.start,
32
- start: pos + table.start + 1,
33
- // Ignored via go/ees005
34
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
35
- node: table.node.nodeAt(pos)!,
36
- }));
37
-
38
- const decorations = createCellHoverDecoration(mergedCells);
39
-
40
- return {
41
- type: 'HOVER_MERGED_CELLS',
42
- data: {
43
- decorationSet: updatePluginStateDecorations(
44
- state,
45
- decorations,
46
- TableDecorations.CELL_CONTROLS_HOVER,
47
- ),
48
- },
49
- };
50
- },
51
- (tr) => tr.setMeta('addToHistory', false),
52
- );
53
-
54
- export const hoverColumns = (hoveredColumns: number[], isInDanger?: boolean) =>
55
- createCommand(
56
- (state) => {
57
- const cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
58
-
59
- const { isDragAndDropEnabled } = getPluginState(state);
60
- if (!cells) {
61
- return false;
62
- }
63
-
64
- const decorations = createControlsHoverDecoration(
65
- cells,
66
- 'column',
67
- state.tr,
68
- isDragAndDropEnabled,
69
- hoveredColumns,
70
- isInDanger,
71
- );
72
-
73
- return {
74
- type: 'HOVER_COLUMNS',
75
- data: {
76
- decorationSet: updatePluginStateDecorations(
77
- state,
78
- decorations,
79
- TableDecorations.COLUMN_CONTROLS_HOVER,
80
- ),
81
- hoveredColumns,
82
- isInDanger,
83
- },
84
- };
85
- },
86
- (tr) => tr.setMeta('addToHistory', false),
87
- );
88
-
89
- export const hoverRows = (hoveredRows: number[], isInDanger?: boolean) =>
90
- createCommand(
91
- (state) => {
92
- const cells = getCellsInRow(hoveredRows)(state.selection);
93
- if (!cells) {
94
- return false;
95
- }
96
- const { isDragAndDropEnabled } = getPluginState(state);
97
- const decorations = createControlsHoverDecoration(
98
- cells,
99
- 'row',
100
- state.tr,
101
- isDragAndDropEnabled,
102
- hoveredRows,
103
- isInDanger,
104
- );
105
-
106
- return {
107
- type: 'HOVER_ROWS',
108
- data: {
109
- decorationSet: updatePluginStateDecorations(
110
- state,
111
- decorations,
112
- TableDecorations.ROW_CONTROLS_HOVER,
113
- ),
114
- hoveredRows,
115
- isInDanger,
116
- },
117
- };
118
- },
119
- (tr) => tr.setMeta('addToHistory', false),
120
- );
121
-
122
- export const hoverTable = (isInDanger?: boolean, isSelected?: boolean) =>
123
- createCommand(
124
- (state) => {
125
- const table = findTable(state.selection);
126
- if (!table) {
127
- return false;
128
- }
129
- const map = TableMap.get(table.node);
130
- const hoveredColumns = makeArray(map.width);
131
- const hoveredRows = makeArray(map.height);
132
- const cells = getCellsInRow(hoveredRows)(state.selection);
133
- if (!cells) {
134
- return false;
135
- }
136
- const { isDragAndDropEnabled } = getPluginState(state);
137
- const decorations = createControlsHoverDecoration(
138
- cells,
139
- 'table',
140
- state.tr,
141
- isDragAndDropEnabled,
142
- [],
143
- isInDanger,
144
- isSelected,
145
- );
146
-
147
- return {
148
- type: 'HOVER_TABLE',
149
- data: {
150
- decorationSet: updatePluginStateDecorations(
151
- state,
152
- decorations,
153
- TableDecorations.TABLE_CONTROLS_HOVER,
154
- ),
155
- hoveredColumns,
156
- hoveredRows,
157
- isInDanger,
158
- isWholeTableInDanger: isInDanger,
159
- },
160
- };
161
- },
162
- (tr) => tr.setMeta('addToHistory', false),
163
- );
164
-
165
- export const clearHoverSelection = () =>
166
- createCommand((state) => ({
167
- type: 'CLEAR_HOVER_SELECTION',
168
- data: {
169
- decorationSet: updatePluginStateDecorations(state, [], TableDecorations.ALL_CONTROLS_HOVER),
170
- isInDanger: false,
171
- isWholeTableInDanger: false,
172
- },
173
- }));
174
-
175
- export const showResizeHandleLine = (cellColumnPositioning: CellColumnPositioning) =>
176
- createCommand((state) => {
177
- const { isDragAndDropEnabled } = getPluginState(state);
178
-
179
- return {
180
- type: 'SHOW_RESIZE_HANDLE_LINE',
181
- data: {
182
- decorationSet: updatePluginStateDecorations(
183
- state,
184
- createColumnLineResize(state.selection, cellColumnPositioning, isDragAndDropEnabled),
185
- TableDecorations.COLUMN_RESIZING_HANDLE_LINE,
186
- ),
187
- },
188
- };
189
- });
190
-
191
- export const hideResizeHandleLine = () =>
192
- createCommand((state) => ({
193
- type: 'HIDE_RESIZE_HANDLE_LINE',
194
- data: {
195
- decorationSet: updatePluginStateDecorations(
196
- state,
197
- [],
198
- TableDecorations.COLUMN_RESIZING_HANDLE_LINE,
199
- ),
200
- },
201
- }));
202
-
203
- export const setTableHovered = (hovered: boolean) =>
204
- createCommand(
205
- () => {
206
- return {
207
- type: 'TABLE_HOVERED',
208
- data: {
209
- isTableHovered: hovered,
210
- },
211
- };
212
- },
213
- (tr) => tr.setMeta('addToHistory', false),
214
- );
215
-
216
- export const hoverCell = (rowIndex?: number, colIndex?: number) =>
217
- createCommand(
218
- (state) => {
219
- const { hoveredCell: prevHoveredCell } = getPluginState(state);
220
-
221
- // If no arguments have been passed then the intention it to reset the hover cell data
222
- const clear = rowIndex === undefined && colIndex === undefined;
223
-
224
- const nextRowIndex = clear ? undefined : rowIndex ?? prevHoveredCell.rowIndex;
225
- const nextColIndex = clear ? undefined : colIndex ?? prevHoveredCell.colIndex;
226
-
227
- if (nextRowIndex === prevHoveredCell.rowIndex && nextColIndex === prevHoveredCell.colIndex) {
228
- return false;
229
- }
230
-
231
- return {
232
- type: 'HOVER_CELL',
233
- data: {
234
- hoveredCell: {
235
- rowIndex: nextRowIndex,
236
- colIndex: nextColIndex,
237
- },
238
- },
239
- };
240
- },
241
- (tr) => tr.setMeta('addToHistory', false),
242
- );
@@ -1,51 +0,0 @@
1
- /* eslint-disable @atlaskit/editor/no-re-export */
2
- // Entry file in package.json
3
-
4
- export {
5
- hoverColumns,
6
- hoverRows,
7
- hoverTable,
8
- hoverCell,
9
- hoverMergedCells,
10
- clearHoverSelection,
11
- showResizeHandleLine,
12
- hideResizeHandleLine,
13
- setTableHovered,
14
- } from './hover';
15
- export { insertColumn, insertRow, createTable } from './insert';
16
- export {
17
- getNextLayout,
18
- toggleContextualMenu,
19
- toggleHeaderColumn,
20
- toggleHeaderRow,
21
- toggleNumberColumn,
22
- toggleTableLayout,
23
- } from './toggle';
24
- export { clearMultipleCells } from './clear';
25
- export {
26
- autoSizeTable,
27
- convertFirstRowToHeader,
28
- deleteTable,
29
- hideInsertColumnOrRowButton,
30
- moveCursorBackward,
31
- selectColumn,
32
- selectColumns,
33
- selectRow,
34
- selectRows,
35
- setCellAttr,
36
- setEditorFocus,
37
- setMultipleCellAttrs,
38
- setTableRef,
39
- showInsertColumnButton,
40
- showInsertRowButton,
41
- transformSliceToAddTableHeaders,
42
- triggerUnlessTableHeader,
43
- addBoldInEmptyHeaderCells,
44
- addResizeHandleDecorations,
45
- updateWidthToWidest,
46
- setFocusToCellMenu,
47
- } from './misc';
48
- export { sortByColumn } from './sort';
49
- export { goToNextCell } from './go-to-next-cell';
50
- export { removeDescendantNodes } from './referentiality';
51
- export { setTableDisplayMode } from './display-mode';