@atlaskit/editor-plugin-table 3.0.2 → 3.0.4

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 (108) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +12 -1
  3. package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +1 -1
  4. package/dist/cjs/plugins/table/ui/consts.js +6 -4
  5. package/dist/cjs/plugins/table/ui/ui-styles.js +1 -1
  6. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +14 -3
  7. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +1 -1
  8. package/dist/es2019/plugins/table/ui/consts.js +5 -4
  9. package/dist/es2019/plugins/table/ui/ui-styles.js +2 -2
  10. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +14 -3
  11. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +1 -1
  12. package/dist/esm/plugins/table/ui/consts.js +5 -4
  13. package/dist/esm/plugins/table/ui/ui-styles.js +1 -1
  14. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +6 -5
  15. package/dist/types/plugins/table/pm-plugins/sticky-headers/util.d.ts +1 -1
  16. package/dist/types/plugins/table/pm-plugins/table-local-id.d.ts +1 -1
  17. package/dist/types/plugins/table/ui/consts.d.ts +2 -1
  18. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +6 -5
  19. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/util.d.ts +1 -1
  20. package/dist/types-ts4.5/plugins/table/pm-plugins/table-local-id.d.ts +1 -1
  21. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -1
  22. package/package.json +6 -6
  23. package/src/__tests__/integration/arrow-down-into-table.ts +2 -0
  24. package/src/__tests__/integration/auto-size.ts +3 -0
  25. package/src/__tests__/integration/cell-selection.ts +3 -0
  26. package/src/__tests__/integration/delete-columns.ts +2 -0
  27. package/src/__tests__/integration/delete-last-column-in-full-width.ts +2 -0
  28. package/src/__tests__/integration/delete-last-column-with-empty-action.ts +2 -0
  29. package/src/__tests__/integration/delete-last-row-with-empty-action.ts +2 -0
  30. package/src/__tests__/integration/delete-rows.ts +3 -0
  31. package/src/__tests__/integration/delete-table-when-selected.ts +3 -0
  32. package/src/__tests__/integration/deleting-empty-paragraph-under-table.ts +2 -0
  33. package/src/__tests__/integration/even-columns.ts +3 -0
  34. package/src/__tests__/integration/horizontal-scroll-shadows.ts +2 -0
  35. package/src/__tests__/integration/horizontal-scroll.ts +4 -1
  36. package/src/__tests__/integration/insert-cell-header-with-strong-mark.ts +2 -0
  37. package/src/__tests__/integration/insert-row-inside-layout.ts +3 -0
  38. package/src/__tests__/integration/layout.ts +3 -0
  39. package/src/__tests__/integration/meta-arrowup-cursor-in-first-row.ts +2 -0
  40. package/src/__tests__/integration/resize-handler.ts +3 -0
  41. package/src/__tests__/integration/resize.ts +4 -1
  42. package/src/__tests__/integration/scale.ts +3 -0
  43. package/src/__tests__/integration/sticky-header.ts +3 -1
  44. package/src/__tests__/unit/analytics.ts +4 -0
  45. package/src/__tests__/unit/collab.ts +3 -0
  46. package/src/__tests__/unit/commands/go-to-next-cell.ts +3 -0
  47. package/src/__tests__/unit/commands/insert.ts +3 -0
  48. package/src/__tests__/unit/commands/misc.ts +3 -0
  49. package/src/__tests__/unit/commands/sort.ts +3 -0
  50. package/src/__tests__/unit/commands.ts +3 -0
  51. package/src/__tests__/unit/copy-paste.ts +5 -0
  52. package/src/__tests__/unit/event-handlers/index.ts +3 -0
  53. package/src/__tests__/unit/event-handlers.ts +3 -0
  54. package/src/__tests__/unit/fix-tables.ts +3 -0
  55. package/src/__tests__/unit/get-toolbar-config.ts +3 -0
  56. package/src/__tests__/unit/handlers.ts +3 -0
  57. package/src/__tests__/unit/hover-selection.ts +4 -0
  58. package/src/__tests__/unit/index-with-fake-timers.ts +2 -0
  59. package/src/__tests__/unit/index.ts +4 -0
  60. package/src/__tests__/unit/layout.ts +3 -0
  61. package/src/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +1 -0
  62. package/src/__tests__/unit/nodeviews/TableComponent.tsx +2 -0
  63. package/src/__tests__/unit/nodeviews/TableContainer.tsx +2 -0
  64. package/src/__tests__/unit/nodeviews/cell.ts +3 -0
  65. package/src/__tests__/unit/nodeviews/table.ts +4 -0
  66. package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +2 -0
  67. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +3 -0
  68. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +3 -0
  69. package/src/__tests__/unit/pm-plugins/main.ts +3 -0
  70. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +3 -0
  71. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +5 -1
  72. package/src/__tests__/unit/pm-plugins/table-local-id.ts +4 -0
  73. package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +2 -0
  74. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +3 -0
  75. package/src/__tests__/unit/pm-plugins/table-width.ts +3 -0
  76. package/src/__tests__/unit/sort-column.ts +3 -0
  77. package/src/__tests__/unit/toolbar.ts +3 -0
  78. package/src/__tests__/unit/transforms/delete-columns.ts +3 -0
  79. package/src/__tests__/unit/transforms/delete-rows.ts +3 -0
  80. package/src/__tests__/unit/transforms/merging.ts +3 -0
  81. package/src/__tests__/unit/ui/ContextualMenu.tsx +3 -0
  82. package/src/__tests__/unit/ui/CornerControls.tsx +3 -0
  83. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +3 -0
  84. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +3 -0
  85. package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +3 -0
  86. package/src/__tests__/unit/ui/FloatingInsertButton.tsx +3 -0
  87. package/src/__tests__/unit/ui/RowControls.tsx +4 -0
  88. package/src/__tests__/unit/ui/TableFloatingControls.tsx +3 -0
  89. package/src/__tests__/unit/undo-redo.ts +4 -0
  90. package/src/__tests__/unit/utils/collapse.ts +3 -0
  91. package/src/__tests__/unit/utils/nodes.ts +3 -0
  92. package/src/__tests__/unit/utils/row-controls.ts +3 -0
  93. package/src/__tests__/unit/utils/table.ts +2 -0
  94. package/src/__tests__/unit/utils.ts +3 -0
  95. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +2 -2
  96. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
  97. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +2 -2
  98. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
  99. package/src/__tests__/visual-regression/cell-options-menu.ts +3 -1
  100. package/src/__tests__/visual-regression/index.ts +4 -1
  101. package/src/__tests__/visual-regression/sticky-header.ts +4 -1
  102. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +26 -7
  103. package/src/plugins/table/pm-plugins/sticky-headers/util.ts +1 -1
  104. package/src/plugins/table/pm-plugins/table-local-id.ts +5 -4
  105. package/src/plugins/table/ui/consts.ts +13 -2
  106. package/src/plugins/table/ui/ui-styles.ts +2 -2
  107. package/src/__tests__/integration/__snapshots__/floating-toolbar.ts.snap +0 -613
  108. package/src/__tests__/integration/floating-toolbar.ts +0 -374
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e09a662deaa9b014c1e12fd8fb2f9d459e6d111d5678837ad029e099d1ca8520
3
- size 15379
2
+ oid sha256:62f21c718cb5c25d43706c9c34275db8ed11bd33b6fe8e6ed1068c2ccc9f0e93
3
+ size 15405
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7e8a49dcb4d8cc54649f09578e9918425d1eb17e7d7783ad8e1e083ca096c185
3
- size 33219
2
+ oid sha256:a477e5c2e5c14b2eb39aaf5d33020f4183de81f3a4cbead7efb5d8a13f1d5b08
3
+ size 33229
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7050307cfa80b31c43ec57d695a37a7812f4037fd5b07b8d771c335b7bda005f
3
- size 15307
2
+ oid sha256:ea02c0da089226d50b728af2b06dfda143df89c42f02acbb637a973d303c3850
3
+ size 15326
@@ -1,3 +1,3 @@
1
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:65193ee6064523ad095458c47dfb4377fe145ab71886eb4b5088e6cd2914bfb1
3
- size 33260
2
+ oid sha256:9b38819ea18d4c8ab4aa5118d3e81c8875b95cdd7e9fbcc61e6d3bc414dc85d4
3
+ size 33268
@@ -1,9 +1,11 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
1
2
  import { insertTable } from '@atlaskit/editor-test-helpers/page-objects/table';
3
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
2
4
  import {
3
5
  initFullPageEditorWithAdf,
4
6
  snapshot,
5
7
  } from '@atlaskit/editor-test-helpers/vr-utils/base-utils';
6
- import { PuppeteerPage } from '@atlaskit/visual-regression/helper';
8
+ import type { PuppeteerPage } from '@atlaskit/visual-regression/helper';
7
9
 
8
10
  const firstCellSelector = 'table tbody th p';
9
11
  const cellOptionsSelector = '[aria-label="Cell options"]';
@@ -1,13 +1,16 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
1
2
  import {
2
3
  scrollToBottom,
3
4
  scrollToElement,
4
5
  } from '@atlaskit/editor-test-helpers/page-objects/editor';
6
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
5
7
  import {
6
8
  initFullPageEditorWithAdf,
7
9
  snapshot,
8
10
  } from '@atlaskit/editor-test-helpers/vr-utils/base-utils';
11
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
9
12
  import { Device } from '@atlaskit/editor-test-helpers/vr-utils/device-viewport';
10
- import { PuppeteerPage } from '@atlaskit/visual-regression/helper';
13
+ import type { PuppeteerPage } from '@atlaskit/visual-regression/helper';
11
14
 
12
15
  import tableWith100ListItemsADF from './__fixtures__/table-with-100-numbered-list-items.json';
13
16
 
@@ -1,11 +1,14 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
1
2
  import { scrollToElement } from '@atlaskit/editor-test-helpers/page-objects/editor';
3
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
2
4
  import { clickFirstCell } from '@atlaskit/editor-test-helpers/page-objects/table';
5
+ // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
3
6
  import {
4
7
  Appearance,
5
8
  initEditorWithAdf,
6
9
  snapshot,
7
10
  } from '@atlaskit/editor-test-helpers/vr-utils/base-utils';
8
- import { PuppeteerPage } from '@atlaskit/visual-regression/helper';
11
+ import type { PuppeteerPage } from '@atlaskit/visual-regression/helper';
9
12
 
10
13
  import stickyHeaderWithHorizontalScroll from './__fixtures__/sticky-header-with-horizontal-scroll.json';
11
14
 
@@ -1,18 +1,19 @@
1
1
  import debounce from 'lodash/debounce';
2
2
  import throttle from 'lodash/throttle';
3
3
 
4
- import { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
6
- import { mapChildren } from '@atlaskit/editor-common/utils';
7
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
- import { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
6
+ import { browser, mapChildren } from '@atlaskit/editor-common/utils';
7
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
9
9
 
10
+ import type { TablePluginState } from '../../../types';
10
11
  import {
11
12
  TableCssClassName as ClassName,
12
13
  TableCssClassName,
13
- TablePluginState,
14
14
  } from '../../../types';
15
15
  import {
16
+ STICKY_HEADER_TOGGLE_TOLERANCE_MS,
16
17
  stickyHeaderBorderBottomWidth,
17
18
  stickyRowOffsetTop,
18
19
  tableControlsSpacing,
@@ -25,7 +26,8 @@ import {
25
26
  } from '../../table-resizing/utils/dom';
26
27
  import { updateStickyState } from '../commands';
27
28
 
28
- import { getTop, getTree, TableDOMElements } from './dom';
29
+ import type { TableDOMElements } from './dom';
30
+ import { getTop, getTree } from './dom';
29
31
 
30
32
  // limit scroll event calls
31
33
  const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
@@ -73,6 +75,7 @@ export class TableRowNodeView implements NodeView {
73
75
  focused = false;
74
76
  topPosEditorElement = 0;
75
77
  isSticky: boolean;
78
+ lastStickyTimestamp: number | undefined;
76
79
  lastTimePainted: number;
77
80
 
78
81
  private intersectionObserver?: IntersectionObserver;
@@ -104,6 +107,7 @@ export class TableRowNodeView implements NodeView {
104
107
  this.lastTimePainted = 0;
105
108
  this.isHeaderRow = supportedHeaderRow(node);
106
109
  this.isSticky = false;
110
+ this.lastStickyTimestamp = undefined;
107
111
 
108
112
  if (this.isHeaderRow) {
109
113
  this.dom.setAttribute('data-header-row', 'true');
@@ -257,6 +261,7 @@ export class TableRowNodeView implements NodeView {
257
261
  this.sentinels.bottom.style.bottom = `${
258
262
  tableScrollbarOffset + stickyRowOffsetTop + newHeight
259
263
  }px`;
264
+
260
265
  updateTableMargin(table);
261
266
  }
262
267
  }
@@ -293,6 +298,7 @@ export class TableRowNodeView implements NodeView {
293
298
  if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
294
299
  this.tree &&
295
300
  this.makeHeaderRowSticky(this.tree, entry.rootBounds?.top);
301
+ this.lastStickyTimestamp = Date.now();
296
302
  } else {
297
303
  table && this.makeRowHeaderNotSticky(table);
298
304
  }
@@ -306,12 +312,25 @@ export class TableRowNodeView implements NodeView {
306
312
  (entry.rootBounds?.top || 0);
307
313
 
308
314
  if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
309
- this.makeRowHeaderNotSticky(table);
315
+ // Not a perfect solution, but need to this code specific for FireFox ED-19177
316
+ if (browser.gecko) {
317
+ if (
318
+ this.lastStickyTimestamp &&
319
+ Date.now() - this.lastStickyTimestamp >
320
+ STICKY_HEADER_TOGGLE_TOLERANCE_MS
321
+ ) {
322
+ this.makeRowHeaderNotSticky(table);
323
+ }
324
+ } else {
325
+ this.makeRowHeaderNotSticky(table);
326
+ }
310
327
  } else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
311
328
  this.tree &&
312
329
  this.makeHeaderRowSticky(this.tree, entry?.rootBounds?.top);
330
+ this.lastStickyTimestamp = Date.now();
313
331
  }
314
332
  }
333
+ return;
315
334
  });
316
335
  },
317
336
  { root: this.editorScrollableElement as Element },
@@ -1,4 +1,4 @@
1
- import { StickyPluginState } from './types';
1
+ import type { StickyPluginState } from './types';
2
2
 
3
3
  // only worry about the first row for now
4
4
  export const findStickyHeaderForTable = (
@@ -13,11 +13,12 @@
13
13
  import rafSchedule from 'raf-schd';
14
14
 
15
15
  import { uuid } from '@atlaskit/adf-schema';
16
- import { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
16
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
17
17
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
18
18
  import { stepHasSlice } from '@atlaskit/editor-common/utils';
19
- import { Node as ProsemirrorNode } from '@atlaskit/editor-prosemirror/model';
20
- import { EditorState, PluginKey } from '@atlaskit/editor-prosemirror/state';
19
+ import type { Node as ProsemirrorNode } from '@atlaskit/editor-prosemirror/model';
20
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
21
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
21
22
 
22
23
  interface TableLocalIdPluginState {
23
24
  // One time parse for initial load with existing tables without localIds
@@ -95,7 +96,7 @@ const createPlugin = (dispatch: Dispatch) =>
95
96
 
96
97
  const { table } = state.schema.nodes;
97
98
  rafSchedule(() => {
98
- const tr = state.tr;
99
+ const tr = editorView.state.tr;
99
100
  let tableIdWasAdded = false;
100
101
  editorView.state.doc.descendants((node, pos) => {
101
102
  const isTable = node.type === table;
@@ -8,6 +8,8 @@ import {
8
8
  akEditorTableBorderSelected,
9
9
  akEditorTableCellBlanketDeleted,
10
10
  akEditorTableCellBlanketSelected,
11
+ akEditorTableHeaderCellBackground,
12
+ akEditorTableHeaderCellBackgroundDark,
11
13
  akEditorTableToolbar,
12
14
  akEditorTableToolbarDark,
13
15
  akEditorTableToolbarSize,
@@ -42,10 +44,18 @@ export const tableCellBackgroundColor = themed({
42
44
  light: token('elevation.surface', N0),
43
45
  dark: token('elevation.surface', DN30),
44
46
  });
47
+
45
48
  export const tableHeaderCellBackgroundColor = themed({
46
- light: token('color.background.neutral', akEditorTableToolbar),
47
- dark: token('color.background.neutral', akEditorTableToolbarDark),
49
+ light: token(
50
+ 'color.background.accent.gray.subtlest',
51
+ akEditorTableHeaderCellBackground,
52
+ ),
53
+ dark: token(
54
+ 'color.background.accent.gray.subtlest',
55
+ akEditorTableHeaderCellBackgroundDark,
56
+ ),
48
57
  });
58
+
49
59
  export const tableToolbarColor = themed({
50
60
  light: token('color.background.neutral.subtle', akEditorTableToolbar),
51
61
  dark: token('color.background.neutral.subtle', akEditorTableToolbarDark),
@@ -135,3 +145,4 @@ export const tableOverflowShadowWidth = 8;
135
145
  export const TABLE_SNAP_GAP = 9;
136
146
  export const TABLE_HIGHLIGHT_GAP = 10;
137
147
  export const TABLE_HIGHLIGHT_TOLERANCE = 2;
148
+ export const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
@@ -510,7 +510,7 @@ export const resizeHandle = (props: ThemeProps) => css`
510
510
  td.${ClassName.WITH_RESIZE_LINE}::before {
511
511
  content: ' ';
512
512
  position: absolute;
513
- left: -2px;
513
+ left: ${token('space.negative.025', '-2px')};
514
514
  top: -1px;
515
515
  width: ${resizeLineWidth}px;
516
516
  height: calc(100% + 2px);
@@ -520,7 +520,7 @@ export const resizeHandle = (props: ThemeProps) => css`
520
520
 
521
521
  th.${ClassName.WITH_RESIZE_LINE}::before {
522
522
  content: ' ';
523
- left: -2px;
523
+ left: ${token('space.negative.025', '-2px')};
524
524
  position: absolute;
525
525
  width: ${resizeLineWidth}px;
526
526
  height: calc(100% + ${tableToolbarSize + tableCellBorderWidth}px);