@atlaskit/editor-plugin-table 5.1.0 → 5.2.1

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 (81) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/index.js +3 -2
  3. package/dist/cjs/plugins/table/nodeviews/TableCell.js +111 -0
  4. package/dist/cjs/plugins/table/nodeviews/TableNodeViewBase.js +30 -0
  5. package/dist/cjs/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +363 -303
  6. package/dist/cjs/plugins/table/pm-plugins/main.js +16 -13
  7. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +1 -8
  8. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  9. package/dist/cjs/plugins/table/types.js +4 -1
  10. package/dist/cjs/plugins/table/utils/dom.js +31 -1
  11. package/dist/cjs/plugins/table/utils/index.js +12 -0
  12. package/dist/cjs/plugins/table/utils/nodes.js +31 -7
  13. package/dist/es2019/plugins/table/index.js +3 -2
  14. package/dist/es2019/plugins/table/nodeviews/{tableCell.js → TableCell.js} +28 -24
  15. package/dist/es2019/plugins/table/nodeviews/TableNodeViewBase.js +22 -0
  16. package/dist/es2019/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +324 -280
  17. package/dist/es2019/plugins/table/pm-plugins/main.js +8 -8
  18. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
  19. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  20. package/dist/es2019/plugins/table/types.js +5 -1
  21. package/dist/es2019/plugins/table/utils/dom.js +30 -0
  22. package/dist/es2019/plugins/table/utils/index.js +1 -1
  23. package/dist/es2019/plugins/table/utils/nodes.js +16 -0
  24. package/dist/esm/plugins/table/index.js +3 -2
  25. package/dist/esm/plugins/table/nodeviews/TableCell.js +105 -0
  26. package/dist/esm/plugins/table/nodeviews/TableNodeViewBase.js +24 -0
  27. package/dist/esm/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +364 -303
  28. package/dist/esm/plugins/table/pm-plugins/main.js +16 -13
  29. package/dist/esm/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
  30. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  31. package/dist/esm/plugins/table/types.js +5 -1
  32. package/dist/esm/plugins/table/utils/dom.js +30 -0
  33. package/dist/esm/plugins/table/utils/index.js +1 -1
  34. package/dist/esm/plugins/table/utils/nodes.js +24 -0
  35. package/dist/types/plugins/table/nodeviews/TableCell.d.ts +13 -0
  36. package/dist/types/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
  37. package/dist/types/plugins/table/nodeviews/TableRow.d.ts +62 -0
  38. package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
  39. package/dist/types/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
  40. package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
  41. package/dist/types/plugins/table/types.d.ts +15 -0
  42. package/dist/types/plugins/table/utils/dom.d.ts +6 -0
  43. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  44. package/dist/types/plugins/table/utils/nodes.d.ts +12 -2
  45. package/dist/types-ts4.5/plugins/table/nodeviews/TableCell.d.ts +13 -0
  46. package/dist/types-ts4.5/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
  47. package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +62 -0
  48. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
  49. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
  50. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
  51. package/dist/types-ts4.5/plugins/table/types.d.ts +15 -0
  52. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +6 -0
  53. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  54. package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +12 -2
  55. package/package.json +4 -2
  56. package/src/__tests__/unit/nodeviews/cell.ts +2 -2
  57. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -148
  58. package/src/plugins/table/index.tsx +2 -0
  59. package/src/plugins/table/nodeviews/{tableCell.tsx → TableCell.ts} +41 -46
  60. package/src/plugins/table/nodeviews/TableNodeViewBase.ts +32 -0
  61. package/src/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.ts → nodeviews/TableRow.ts} +246 -246
  62. package/src/plugins/table/pm-plugins/main.ts +10 -19
  63. package/src/plugins/table/pm-plugins/sticky-headers/index.ts +0 -1
  64. package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -9
  65. package/src/plugins/table/types.ts +18 -0
  66. package/src/plugins/table/utils/dom.ts +38 -0
  67. package/src/plugins/table/utils/index.ts +2 -0
  68. package/src/plugins/table/utils/nodes.ts +30 -2
  69. package/tsconfig.app.json +6 -0
  70. package/dist/cjs/plugins/table/nodeviews/tableCell.js +0 -99
  71. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -35
  72. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
  73. package/dist/esm/plugins/table/nodeviews/tableCell.js +0 -93
  74. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
  75. package/dist/types/plugins/table/nodeviews/tableCell.d.ts +0 -17
  76. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
  77. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
  78. package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +0 -17
  79. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
  80. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
  81. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.ts +0 -37
@@ -1,73 +0,0 @@
1
- /// <reference types="lodash" />
2
- import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
- import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
5
- import type { TablePluginState } from '../../../types';
6
- import type { TableDOMElements } from './dom';
7
- /**
8
- * Check if a given node is a header row with this definition:
9
- * - all children are tableHeader cells
10
- * - no table cells have been have merged with other table row cells
11
- *
12
- * @param node ProseMirror node
13
- * @return boolean if it meets definition
14
- */
15
- export declare const supportedHeaderRow: (node: PmNode) => boolean;
16
- export declare class TableRowNodeView implements NodeView {
17
- view: EditorView;
18
- node: PmNode;
19
- getPos: () => number;
20
- eventDispatcher: EventDispatcher;
21
- dom: HTMLTableRowElement;
22
- contentDOM: HTMLElement;
23
- isHeaderRow: boolean;
24
- editorScrollableElement?: HTMLElement | Window;
25
- colControlsOffset: number;
26
- focused: boolean;
27
- topPosEditorElement: number;
28
- isSticky: boolean;
29
- lastStickyTimestamp: number | undefined;
30
- lastTimePainted: number;
31
- private intersectionObserver?;
32
- private resizeObserver?;
33
- private sentinels;
34
- private stickyRowHeight?;
35
- get tree(): TableDOMElements | null | undefined;
36
- constructor(node: PmNode, view: EditorView, getPos: any, eventDispatcher: EventDispatcher);
37
- listening: boolean;
38
- headerRowMouseScrollEnd: import("lodash").DebouncedFunc<() => void>;
39
- headerRowMouseScroll: import("lodash").DebouncedFunc<() => void>;
40
- subscribe(): void;
41
- unsubscribe(): void;
42
- private initObservers;
43
- private createResizeObserver;
44
- private createIntersectionObserver;
45
- previousDomTop: number | undefined;
46
- previousPadding: number | undefined;
47
- latestDomTop: number | undefined;
48
- nextFrame: number | undefined;
49
- update(node: PmNode, ..._args: any[]): boolean;
50
- destroy(): void;
51
- ignoreMutation(mutationRecord: MutationRecord | {
52
- type: 'selection';
53
- target: Element;
54
- }): boolean;
55
- onTablePluginState: (state: TablePluginState) => void;
56
- updateStickyHeaderWidth: () => void;
57
- shouldHeaderStick: (tree: TableDOMElements) => boolean;
58
- /**
59
- * Manually refire the intersection observers.
60
- * Useful when the header may have detached from the table.
61
- */
62
- refireIntersectionObservers: () => void;
63
- makeHeaderRowSticky: (tree: TableDOMElements, scrollTop?: number) => void;
64
- makeRowHeaderNotSticky: (table: HTMLElement, isEditorDestroyed?: boolean) => void;
65
- getWrapperoffset: (inverse?: boolean) => number;
66
- getWrapperRefTop: (wrapper: HTMLElement) => number;
67
- getScrolledTableTop: (wrapper: HTMLElement) => number;
68
- getCurrentTableTop: (tree: TableDOMElements) => number;
69
- padding: number;
70
- top: number;
71
- emitOn: (top: number, padding: number) => void;
72
- emitOff: (isEditorDestroyed: boolean) => void;
73
- }
@@ -1,37 +0,0 @@
1
- export type TableDOMElements = {
2
- wrapper: HTMLDivElement;
3
- table: HTMLTableElement;
4
- };
5
-
6
- export const getTree = (tr: HTMLTableRowElement): TableDOMElements | null => {
7
- // pm renders into tbody, owned by react
8
- const tbody = tr.parentElement;
9
- if (!tbody) {
10
- return null;
11
- }
12
-
13
- // rendered by react
14
- const table = tbody.parentElement;
15
- if (!table) {
16
- return null;
17
- }
18
-
19
- // rendered by react
20
- const wrapper = table.parentElement;
21
- if (!wrapper) {
22
- return null;
23
- }
24
-
25
- return {
26
- wrapper: wrapper as HTMLDivElement,
27
- table: table as HTMLTableElement,
28
- };
29
- };
30
-
31
- export const getTop = (element: HTMLElement | Window | undefined): number => {
32
- if (!element || element instanceof Window) {
33
- return 0;
34
- }
35
-
36
- return element.getBoundingClientRect().top;
37
- };