@atlaskit/editor-plugin-table 0.0.5 → 0.0.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 (63) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/plugins/table/commands-with-analytics.js +6 -0
  3. package/dist/cjs/plugins/table/event-handlers.js +7 -6
  4. package/dist/cjs/plugins/table/nodeviews/tableCell.js +4 -4
  5. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
  6. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
  7. package/dist/cjs/plugins/table/utils/column-controls.js +1 -1
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -0
  10. package/dist/es2019/plugins/table/event-handlers.js +8 -7
  11. package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -4
  12. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
  13. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
  14. package/dist/es2019/plugins/table/utils/column-controls.js +1 -1
  15. package/dist/es2019/version.json +1 -1
  16. package/dist/esm/plugins/table/commands-with-analytics.js +6 -0
  17. package/dist/esm/plugins/table/event-handlers.js +8 -7
  18. package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -4
  19. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
  20. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
  21. package/dist/esm/plugins/table/utils/column-controls.js +1 -1
  22. package/dist/esm/version.json +1 -1
  23. package/package.json +9 -7
  24. package/report.api.md +13 -6
  25. package/src/__tests__/unit/analytics.ts +737 -0
  26. package/src/__tests__/unit/collab.ts +76 -0
  27. package/src/__tests__/unit/commands/sort.ts +230 -0
  28. package/src/__tests__/unit/copy-paste.ts +686 -0
  29. package/src/__tests__/unit/event-handlers/index.ts +106 -0
  30. package/src/__tests__/unit/event-handlers.ts +202 -0
  31. package/src/__tests__/unit/fix-tables.ts +156 -0
  32. package/src/__tests__/unit/floating-toolbar.ts +95 -0
  33. package/src/__tests__/unit/handlers.ts +81 -0
  34. package/src/__tests__/unit/hover-selection.ts +277 -0
  35. package/src/__tests__/unit/index-with-fake-timers.ts +106 -0
  36. package/src/__tests__/unit/index.ts +986 -0
  37. package/src/__tests__/unit/keymap.ts +602 -0
  38. package/src/__tests__/unit/layout.ts +196 -0
  39. package/src/__tests__/unit/nodeviews/cell.ts +167 -0
  40. package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +33 -0
  41. package/src/__tests__/unit/sort-column.ts +512 -0
  42. package/src/__tests__/unit/transforms/delete-columns.ts +499 -0
  43. package/src/__tests__/unit/transforms/delete-rows.ts +557 -0
  44. package/src/__tests__/unit/transforms/merging.ts +374 -0
  45. package/src/__tests__/unit/ui/CornerControls.tsx +80 -0
  46. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +95 -0
  47. package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +175 -0
  48. package/src/__tests__/unit/ui/FloatingInsertButton.tsx +266 -0
  49. package/src/__tests__/unit/ui/RowControls.tsx +301 -0
  50. package/src/__tests__/unit/ui/TableFloatingControls.tsx +93 -0
  51. package/src/__tests__/unit/undo-redo.ts +202 -0
  52. package/src/__tests__/unit/utils/dom.ts +286 -0
  53. package/src/__tests__/unit/utils/nodes.ts +59 -0
  54. package/src/__tests__/unit/utils/row-controls.ts +176 -0
  55. package/src/__tests__/unit/utils/table.ts +93 -0
  56. package/src/__tests__/unit/utils.ts +652 -0
  57. package/src/plugins/table/commands-with-analytics.ts +3 -0
  58. package/src/plugins/table/event-handlers.ts +5 -6
  59. package/src/plugins/table/nodeviews/tableCell.tsx +5 -4
  60. package/src/plugins/table/pm-plugins/table-resizing/utils/column-state.ts +1 -1
  61. package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +6 -2
  62. package/src/plugins/table/utils/column-controls.ts +1 -1
  63. package/tmp/api-report-tmp.d.ts +91 -0
@@ -11,6 +11,9 @@ import {
11
11
  } from '@atlaskit/adf-schema';
12
12
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
13
13
 
14
+ const DEFAULT_COL_SPAN = 1;
15
+ const DEFAULT_ROW_SPAN = 1;
16
+
14
17
  export default class TableCellNodeView implements NodeView {
15
18
  node: Node;
16
19
  dom: HTMLElement;
@@ -62,11 +65,9 @@ export default class TableCellNodeView implements NodeView {
62
65
 
63
66
  // need to rerender when colspan/rowspan in dom are different from the node attrs
64
67
  // this can happen when undoing merge cells
65
- const defaultColspan = 1,
66
- defaultRowspan = 1;
67
68
  if (
68
- colspan !== (node.attrs.colspan || defaultColspan) ||
69
- rowspan !== (node.attrs.rowspan || defaultRowspan)
69
+ colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) ||
70
+ rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)
70
71
  ) {
71
72
  return false;
72
73
  }
@@ -62,7 +62,7 @@ export const getCellsRefsInColumn = (
62
62
  return cells;
63
63
  };
64
64
 
65
- // calculates column withs based on `cells` DOM refs
65
+ // calculates column widths based on `cells` DOM refs
66
66
  export const calculateColumnWidth = (
67
67
  cells: HTMLElement[],
68
68
  calculateColumnWidthCb: (
@@ -8,8 +8,8 @@ export const growColumn = (
8
8
  amount: number,
9
9
  selectedColumns?: number[],
10
10
  ): ResizeState => {
11
- // can't grow the last column
12
- if (!state.cols[colIndex + 1]) {
11
+ // can't grow if columns don't exist or it's the last column
12
+ if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
13
13
  return state;
14
14
  }
15
15
  const res = moveSpaceFrom(state, colIndex + 1, colIndex, amount);
@@ -32,6 +32,10 @@ export const shrinkColumn = (
32
32
  amount: number,
33
33
  selectedColumns?: number[],
34
34
  ): ResizeState => {
35
+ // can't shrink if columns don't exist
36
+ if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
37
+ return state;
38
+ }
35
39
  // try to shrink dragging column by giving from the column to the right first
36
40
  const res = moveSpaceFrom(state, colIndex, colIndex + 1, -amount);
37
41
  let newState = res.state;
@@ -144,7 +144,7 @@ const getRelativeDomCellWidths = ({
144
144
  // for cells in a table with unchanged column widths,
145
145
  // these are identified by the lack of colwidth data attribute,
146
146
  // return equally partitioned total cell width in DOM for each cell.
147
- if (colspan <= 1 || !colwidth) {
147
+ if (colspan === 1 || !colwidth) {
148
148
  return new Array(colspan).fill(width / colspan);
149
149
  }
150
150
 
@@ -0,0 +1,91 @@
1
+ ## API Report File for "@atlaskit/editor-plugin-table"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
8
+ import type { EditorPlugin } from '@atlaskit/editor-common/types';
9
+ import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
10
+ import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
11
+ import { TableLayout } from '@atlaskit/adf-schema';
12
+
13
+ // @public (undocumented)
14
+ type PermittedLayoutsDescriptor = 'all' | TableLayout[];
15
+
16
+ // @public (undocumented)
17
+ interface PluginConfig {
18
+ // (undocumented)
19
+ advanced?: boolean;
20
+ // (undocumented)
21
+ allowAddColumnWithCustomStep?: boolean;
22
+ // (undocumented)
23
+ allowBackgroundColor?: boolean;
24
+ // (undocumented)
25
+ allowCellOptionsInFloatingToolbar?: boolean;
26
+ // (undocumented)
27
+ allowCollapse?: boolean;
28
+ // (undocumented)
29
+ allowColumnResizing?: boolean;
30
+ // (undocumented)
31
+ allowColumnSorting?: boolean;
32
+ // (undocumented)
33
+ allowControls?: boolean;
34
+ // (undocumented)
35
+ allowDistributeColumns?: boolean;
36
+ // (undocumented)
37
+ allowHeaderColumn?: boolean;
38
+ // (undocumented)
39
+ allowHeaderRow?: boolean;
40
+ // (undocumented)
41
+ allowMergeCells?: boolean;
42
+ // (undocumented)
43
+ allowNumberColumn?: boolean;
44
+ // (undocumented)
45
+ initialRenderOptimization?: boolean;
46
+ // (undocumented)
47
+ isHeaderRowRequired?: boolean;
48
+ // (undocumented)
49
+ mouseMoveOptimization?: boolean;
50
+ // (undocumented)
51
+ permittedLayouts?: PermittedLayoutsDescriptor;
52
+ // (undocumented)
53
+ stickToolbarToBottom?: boolean;
54
+ // (undocumented)
55
+ stickyHeaders?: boolean;
56
+ // (undocumented)
57
+ stickyHeadersOptimization?: boolean;
58
+ // (undocumented)
59
+ tableCellOptimization?: boolean;
60
+ // (undocumented)
61
+ tableOverflowShadowsOptimization?: boolean;
62
+ // (undocumented)
63
+ tableRenderOptimization?: boolean;
64
+ }
65
+
66
+ // @public (undocumented)
67
+ interface TablePluginOptions {
68
+ // (undocumented)
69
+ allowContextualMenu?: boolean;
70
+ // (undocumented)
71
+ breakoutEnabled?: boolean;
72
+ // (undocumented)
73
+ editorAnalyticsAPI?: EditorAnalyticsAPI;
74
+ // (undocumented)
75
+ editorSelectionAPI?: EditorSelectionAPI;
76
+ // (undocumented)
77
+ fullWidthEnabled?: boolean;
78
+ // (undocumented)
79
+ getEditorFeatureFlags?: GetEditorFeatureFlags;
80
+ // (undocumented)
81
+ tableOptions: PluginConfig;
82
+ // (undocumented)
83
+ wasFullWidthEnabled?: boolean;
84
+ }
85
+
86
+ // @public (undocumented)
87
+ export const tablesPlugin: (options?: TablePluginOptions | undefined) => EditorPlugin;
88
+
89
+ // (No @packageDocumentation comment for this package)
90
+
91
+ ```