@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
package/src/index.ts DELETED
@@ -1,21 +0,0 @@
1
- /* eslint-disable @atlaskit/editor/only-export-plugin */
2
- /* eslint-disable @atlaskit/editor/no-re-export */
3
- // Entry file in package.json
4
-
5
- // eslint-disable-next-line @atlaskit/editor/only-export-plugin
6
- export {
7
- /**
8
- * @private
9
- * @deprecated Use {@link tablePlugin} instead.
10
- */
11
- default as tablesPlugin,
12
- default as tablePlugin,
13
- } from './tablePlugin';
14
- // eslint-disable-next-line @atlaskit/editor/only-export-plugin
15
- export type {
16
- TablePlugin,
17
- TablePluginOptions,
18
- TablePluginDependencies,
19
- TablePluginActions,
20
- TablePluginCommands,
21
- } from './tablePluginType';
@@ -1,91 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
-
3
- import { tableMarginTop } from '@atlaskit/editor-common/styles';
4
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
7
-
8
- import { getColumnsWidths } from '../pm-plugins/utils/column-controls';
9
- import type { DraggableSourceData } from '../types';
10
- import { dropTargetExtendedWidth, dropTargetsZIndex } from '../ui/consts';
11
- import { ColumnDropTarget } from '../ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget';
12
-
13
- export const ExternalDropTargets = ({
14
- editorView,
15
- node,
16
- getScrollOffset,
17
- getTableWrapperWidth,
18
- }: {
19
- editorView: EditorView;
20
- node?: PMNode;
21
- getScrollOffset: () => number;
22
- getTableWrapperWidth: () => number;
23
- }) => {
24
- const [isDragging, setIsDragging] = useState(false);
25
- const currentNodeLocalId = node?.attrs.localId;
26
-
27
- useEffect(() => {
28
- return monitorForElements({
29
- canMonitor({ source }) {
30
- const { type, indexes, localId } = source.data as Partial<DraggableSourceData>;
31
- return type === 'table-column' && !!indexes?.length && localId === currentNodeLocalId;
32
- },
33
- onDragStart() {
34
- setIsDragging(true);
35
- },
36
- onDrop() {
37
- setIsDragging(false);
38
- },
39
- });
40
- }, [currentNodeLocalId, editorView]);
41
-
42
- if (!isDragging) {
43
- return null;
44
- }
45
-
46
- const colWidths = getColumnsWidths(editorView);
47
-
48
- return (
49
- <div
50
- style={{
51
- width: getTableWrapperWidth(),
52
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
53
- overflow: 'hidden',
54
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
55
- position: 'absolute',
56
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
57
- top: `-${dropTargetExtendedWidth - tableMarginTop}px`,
58
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
59
- pointerEvents: 'auto',
60
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
61
- zIndex: `${dropTargetsZIndex}`,
62
- }}
63
- data-testid="table-floating-column-extended-drop-targets"
64
- >
65
- <div
66
- style={{
67
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
68
- display: 'flex',
69
- // move drop targets based on table wrapper scroll
70
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
71
- marginLeft: `-${getScrollOffset()}px`,
72
- }}
73
- >
74
- {colWidths?.map((width, index) => {
75
- return (
76
- <ColumnDropTarget
77
- // Ignored via go/ees005
78
- // eslint-disable-next-line react/no-array-index-key
79
- key={index}
80
- index={index}
81
- localId={currentNodeLocalId}
82
- width={width}
83
- height={dropTargetExtendedWidth}
84
- marginTop={0}
85
- />
86
- );
87
- })}
88
- </div>
89
- </div>
90
- );
91
- };
@@ -1,156 +0,0 @@
1
- import rafSchedule from 'raf-schd';
2
-
3
- import { TableCssClassName as ClassName, ShadowEvent } from '../types';
4
-
5
- import { updateShadowListForStickyStyles } from './update-overflow-shadows';
6
-
7
- export class OverflowShadowsObserver {
8
- private tableIntersectionObserver?: IntersectionObserver;
9
- private updateShadowState: (shadowKey: ShadowEvent, value: boolean) => void;
10
- private table: HTMLElement;
11
- private wrapper: HTMLDivElement;
12
-
13
- private leftShadowSentinel: HTMLElement | null = null;
14
- private rightShadowSentinel: HTMLElement | null = null;
15
- private shadowsObserved: boolean = false;
16
-
17
- private isSticky = false;
18
- private stickyRowHeight = 0;
19
-
20
- // updateShadowState is a method to update shadow key
21
- constructor(
22
- updateShadowState: (shadowKey: ShadowEvent, value: boolean) => void,
23
- table: HTMLElement,
24
- wrapper: HTMLDivElement,
25
- ) {
26
- this.updateShadowState = updateShadowState;
27
- this.table = table;
28
- this.wrapper = wrapper;
29
-
30
- this.init();
31
- }
32
-
33
- private init = () => {
34
- const table = this.table;
35
-
36
- if (!this.wrapper || !table) {
37
- return;
38
- }
39
-
40
- if (!this.tableIntersectionObserver) {
41
- const intersectonOnbserverCallback = (entry: IntersectionObserverEntry) => {
42
- if (entry.target !== this.leftShadowSentinel && entry.target !== this.rightShadowSentinel) {
43
- return;
44
- }
45
-
46
- this.updateStickyShadowsHeightIfChanged();
47
- this.updateShadowState(
48
- this.leftShadowSentinel === entry.target
49
- ? ShadowEvent.SHOW_BEFORE_SHADOW
50
- : ShadowEvent.SHOW_AFTER_SHADOW,
51
- entry.intersectionRatio !== 1,
52
- );
53
- };
54
-
55
- this.tableIntersectionObserver = new IntersectionObserver(
56
- (entries: IntersectionObserverEntry[], _: IntersectionObserver) => {
57
- entries.forEach((entry) => intersectonOnbserverCallback(entry));
58
- },
59
- {
60
- threshold: [0, 1],
61
- root: this.wrapper,
62
- rootMargin: '0px',
63
- },
64
- );
65
- return;
66
- }
67
- };
68
-
69
- private updateStickyShadowsHeightIfChanged() {
70
- if (!this.isSticky) {
71
- return;
72
- }
73
- const stickyCell = this.getStickyCell();
74
- if (!stickyCell) {
75
- return;
76
- }
77
-
78
- this.updateStickyShadows();
79
- }
80
-
81
- private getStickyCell() {
82
- const stickyRow = this.wrapper?.querySelector('tr.sticky');
83
- const stickyCell = stickyRow && stickyRow.firstElementChild;
84
- return stickyCell;
85
- }
86
-
87
- observeShadowSentinels = (isSticky?: boolean) => {
88
- if (this.isSticky === isSticky) {
89
- return;
90
- }
91
-
92
- this.isSticky = !!isSticky;
93
-
94
- // reset height
95
- this.stickyRowHeight = 0;
96
- // update sticky shadows
97
- this.updateStickyShadowsHeightIfChanged();
98
-
99
- this.leftShadowSentinel = this.table?.querySelector(`.${ClassName.TABLE_SHADOW_SENTINEL_LEFT}`);
100
- this.rightShadowSentinel = this.table?.querySelector(
101
- `.${ClassName.TABLE_SHADOW_SENTINEL_RIGHT}`,
102
- );
103
-
104
- if (
105
- this.tableIntersectionObserver &&
106
- this.leftShadowSentinel &&
107
- this.rightShadowSentinel &&
108
- !this.shadowsObserved
109
- ) {
110
- this.tableIntersectionObserver.disconnect();
111
- this.tableIntersectionObserver.observe(this.leftShadowSentinel);
112
- this.tableIntersectionObserver.observe(this.rightShadowSentinel);
113
- this.shadowsObserved = true;
114
- }
115
- };
116
-
117
- /**
118
- * Takes a heightStyle if it can be computed in a less expensive manner,
119
- * e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
120
- * reading it from sticky cell
121
- */
122
- updateStickyShadows = rafSchedule((stickyRowHeight?: number) => {
123
- if (!this.isSticky) {
124
- return;
125
- }
126
- const stickyCell = this.getStickyCell();
127
- if (!stickyCell || !this.wrapper?.parentElement) {
128
- return;
129
- }
130
-
131
- // Reflow Warning! - stickyCell.clientHeight
132
- const newStickyRowHeight = stickyRowHeight || stickyCell.clientHeight + 1;
133
-
134
- if (newStickyRowHeight !== this.stickyRowHeight) {
135
- this.stickyRowHeight = newStickyRowHeight;
136
- const heightStyleOrCompute = `${newStickyRowHeight}px`;
137
- // Use getElementsByClassName here for a live node list to capture
138
- // sticky shadows
139
- const liveRightShadows = this.wrapper?.parentElement?.getElementsByClassName(
140
- `${ClassName.TABLE_RIGHT_SHADOW}`,
141
- );
142
- const liveLeftShadows = this.wrapper?.parentElement?.getElementsByClassName(
143
- `${ClassName.TABLE_LEFT_SHADOW}`,
144
- );
145
- updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
146
- updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
147
- }
148
- });
149
-
150
- dispose() {
151
- if (this.tableIntersectionObserver) {
152
- this.tableIntersectionObserver.disconnect();
153
- this.tableIntersectionObserver = undefined;
154
- }
155
- }
156
- }
@@ -1,134 +0,0 @@
1
- import type { CellDomAttrs } from '@atlaskit/adf-schema';
2
- import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
3
- import {
4
- ACTION_SUBJECT,
5
- type EditorAnalyticsAPI,
6
- EVENT_TYPE,
7
- TABLE_ACTION,
8
- } from '@atlaskit/editor-common/analytics';
9
- import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
10
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
11
- import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
12
-
13
- import TableNodeView from './TableNodeViewBase';
14
-
15
- const DEFAULT_COL_SPAN = 1;
16
- const DEFAULT_ROW_SPAN = 1;
17
-
18
- /**
19
- * For performance reasons we do this in the background - it shouldn't block the main thread
20
- */
21
- function delayUntilIdle(cb: Function) {
22
- if (typeof window === 'undefined') {
23
- return;
24
- }
25
- // eslint-disable-next-line compat/compat
26
- if (window.requestIdleCallback !== undefined) {
27
- // eslint-disable-next-line compat/compat
28
- return window.requestIdleCallback(() => cb(), { timeout: 500 });
29
- }
30
- return window.requestAnimationFrame(() => cb());
31
- }
32
-
33
- // Ignored via go/ees005
34
- // eslint-disable-next-line require-unicode-regexp
35
- const cssVariablePattern = /^VAR\(--.*\)$/;
36
-
37
- export default class TableCell extends TableNodeView<HTMLElement> implements NodeView {
38
- private delayHandle: number | undefined;
39
-
40
- constructor(
41
- node: PMNode,
42
- view: EditorView,
43
- getPos: () => number | undefined,
44
- eventDispatcher: EventDispatcher,
45
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined,
46
- ) {
47
- super(node, view, getPos, eventDispatcher);
48
-
49
- // CONFCLOUD-78239: Previously we had a bug which tried to invert the heading colour of a table
50
- // Obviously design tokens can't be inverted and so it would result in `VAR(--DS-BACKGROUND-ACCENT-GRAY-SUBTLEST, #F4F5F7)`
51
- // which is not a valid CSS variable.
52
- //
53
- // We should follow-up and remove this in TODO-xx in 6 months once we're confident
54
- // that this has fixed most of the cases in the wild.
55
- //
56
- // This is a workaround to fix those cases on the fly. Note it is super specific on purpose
57
- // so that it just fixes the heading token (other tokens should be unaffected)
58
- // At some point in the future
59
- if (cssVariablePattern.test(node.attrs.background)) {
60
- this.delayHandle = delayUntilIdle(() => {
61
- const pos = getPos();
62
- if (pos) {
63
- const tr = view.state.tr;
64
- tr.setNodeAttribute(pos, 'background', node.attrs.background.toLowerCase())
65
- // Ensures dispatch does not contribute to undo history (otherwise user requires multiple undo's to revert table)
66
- .setMeta('addToHistory', false);
67
- editorAnalyticsAPI?.attachAnalyticsEvent({
68
- action: TABLE_ACTION.TABLE_CELL_BACKGROUND_FIXED,
69
- actionSubject: ACTION_SUBJECT.TABLE,
70
- actionSubjectId: null,
71
- eventType: EVENT_TYPE.TRACK,
72
- })(tr);
73
- view.dispatch(tr);
74
- }
75
- });
76
- }
77
- }
78
-
79
- destroy = () => {
80
- if (this.delayHandle && typeof window !== 'undefined') {
81
- // eslint-disable-next-line compat/compat
82
- window?.cancelIdleCallback?.(this.delayHandle);
83
- window?.cancelAnimationFrame?.(this.delayHandle);
84
- }
85
- };
86
-
87
- update(node: PMNode) {
88
- const didUpdate = this.updateNodeView(node);
89
- if (didUpdate) {
90
- this.node = node;
91
- }
92
- return didUpdate;
93
- }
94
-
95
- private updateNodeView(node: PMNode) {
96
- if (this.node.type !== node.type) {
97
- return false;
98
- }
99
-
100
- const attrs = getCellDomAttrs(this.node);
101
- const nextAttrs = getCellDomAttrs(node);
102
-
103
- const { colspan, rowspan } = getCellAttrs(this.dom);
104
-
105
- // need to rerender when colspan/rowspan in dom are different from the node attrs
106
- // this can happen when undoing merge cells
107
- if (
108
- colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) ||
109
- rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)
110
- ) {
111
- return false;
112
- }
113
-
114
- // added + changed attributes
115
- const addedAttrs = Object.entries(nextAttrs).filter(
116
- ([key, value]) => attrs[key as keyof CellDomAttrs] !== value,
117
- );
118
-
119
- const removedAttrs = Object.keys(attrs).filter((key) => !nextAttrs.hasOwnProperty(key));
120
-
121
- if (addedAttrs.length || removedAttrs.length) {
122
- addedAttrs.forEach(([key, value]) => this.dom.setAttribute(key, value || ''));
123
- removedAttrs.forEach((key) => this.dom.removeAttribute(key));
124
- return true;
125
- }
126
-
127
- // Return true to not re-render this node view
128
- if (this.node.sameMarkup(node)) {
129
- return true;
130
- }
131
-
132
- return false;
133
- }
134
- }