@atlaskit/editor-plugin-table 5.1.0 → 5.2.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 (77) hide show
  1. package/CHANGELOG.md +6 -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} +313 -307
  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/utils/dom.js +31 -1
  10. package/dist/cjs/plugins/table/utils/index.js +12 -0
  11. package/dist/cjs/plugins/table/utils/nodes.js +31 -7
  12. package/dist/es2019/plugins/table/index.js +3 -2
  13. package/dist/es2019/plugins/table/nodeviews/{tableCell.js → TableCell.js} +28 -24
  14. package/dist/es2019/plugins/table/nodeviews/TableNodeViewBase.js +22 -0
  15. package/dist/es2019/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +273 -284
  16. package/dist/es2019/plugins/table/pm-plugins/main.js +8 -8
  17. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
  18. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  19. package/dist/es2019/plugins/table/utils/dom.js +30 -0
  20. package/dist/es2019/plugins/table/utils/index.js +1 -1
  21. package/dist/es2019/plugins/table/utils/nodes.js +16 -0
  22. package/dist/esm/plugins/table/index.js +3 -2
  23. package/dist/esm/plugins/table/nodeviews/TableCell.js +105 -0
  24. package/dist/esm/plugins/table/nodeviews/TableNodeViewBase.js +24 -0
  25. package/dist/esm/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +314 -307
  26. package/dist/esm/plugins/table/pm-plugins/main.js +16 -13
  27. package/dist/esm/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
  28. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  29. package/dist/esm/plugins/table/utils/dom.js +30 -0
  30. package/dist/esm/plugins/table/utils/index.js +1 -1
  31. package/dist/esm/plugins/table/utils/nodes.js +24 -0
  32. package/dist/types/plugins/table/nodeviews/TableCell.d.ts +13 -0
  33. package/dist/types/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
  34. package/dist/types/plugins/table/nodeviews/TableRow.d.ts +60 -0
  35. package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
  36. package/dist/types/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
  37. package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
  38. package/dist/types/plugins/table/types.d.ts +1 -0
  39. package/dist/types/plugins/table/utils/dom.d.ts +6 -0
  40. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  41. package/dist/types/plugins/table/utils/nodes.d.ts +12 -2
  42. package/dist/types-ts4.5/plugins/table/nodeviews/TableCell.d.ts +13 -0
  43. package/dist/types-ts4.5/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
  44. package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +60 -0
  45. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
  46. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
  47. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
  48. package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
  49. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +6 -0
  50. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  51. package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +12 -2
  52. package/package.json +1 -1
  53. package/src/__tests__/unit/nodeviews/cell.ts +2 -2
  54. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -148
  55. package/src/plugins/table/index.tsx +2 -0
  56. package/src/plugins/table/nodeviews/{tableCell.tsx → TableCell.ts} +41 -46
  57. package/src/plugins/table/nodeviews/TableNodeViewBase.ts +32 -0
  58. package/src/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.ts → nodeviews/TableRow.ts} +193 -246
  59. package/src/plugins/table/pm-plugins/main.ts +10 -19
  60. package/src/plugins/table/pm-plugins/sticky-headers/index.ts +0 -1
  61. package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -9
  62. package/src/plugins/table/types.ts +2 -0
  63. package/src/plugins/table/utils/dom.ts +38 -0
  64. package/src/plugins/table/utils/index.ts +2 -0
  65. package/src/plugins/table/utils/nodes.ts +30 -2
  66. package/dist/cjs/plugins/table/nodeviews/tableCell.js +0 -99
  67. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -35
  68. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
  69. package/dist/esm/plugins/table/nodeviews/tableCell.js +0 -93
  70. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
  71. package/dist/types/plugins/table/nodeviews/tableCell.d.ts +0 -17
  72. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
  73. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
  74. package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +0 -17
  75. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
  76. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
  77. 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
- };