@atlaskit/editor-plugin-table 0.0.2 → 0.0.3

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 (182) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +2 -2
  3. package/dist/cjs/version.json +1 -1
  4. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +2 -2
  5. package/dist/es2019/version.json +1 -1
  6. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +2 -2
  7. package/dist/esm/version.json +1 -1
  8. package/dist/types-ts4.0/index.d.ts +1 -0
  9. package/dist/types-ts4.0/plugins/plugin-key.d.ts +4 -0
  10. package/dist/types-ts4.0/plugins/table/commands/clear.d.ts +3 -0
  11. package/dist/types-ts4.0/plugins/table/commands/collapse.d.ts +2 -0
  12. package/dist/types-ts4.0/plugins/table/commands/go-to-next-cell.d.ts +4 -0
  13. package/dist/types-ts4.0/plugins/table/commands/hover.d.ts +8 -0
  14. package/dist/types-ts4.0/plugins/table/commands/index.d.ts +7 -0
  15. package/dist/types-ts4.0/plugins/table/commands/insert.d.ts +10 -0
  16. package/dist/types-ts4.0/plugins/table/commands/misc.d.ts +27 -0
  17. package/dist/types-ts4.0/plugins/table/commands/selection.d.ts +8 -0
  18. package/dist/types-ts4.0/plugins/table/commands/sort.d.ts +3 -0
  19. package/dist/types-ts4.0/plugins/table/commands/split-cell.d.ts +6 -0
  20. package/dist/types-ts4.0/plugins/table/commands/toggle.d.ts +12 -0
  21. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +26 -0
  22. package/dist/types-ts4.0/plugins/table/create-plugin-config.d.ts +2 -0
  23. package/dist/types-ts4.0/plugins/table/event-handlers.d.ts +16 -0
  24. package/dist/types-ts4.0/plugins/table/handlers.d.ts +3 -0
  25. package/dist/types-ts4.0/plugins/table/index.d.ts +17 -0
  26. package/dist/types-ts4.0/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +26 -0
  27. package/dist/types-ts4.0/plugins/table/nodeviews/TableComponent.d.ts +72 -0
  28. package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +9 -0
  29. package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +9 -0
  30. package/dist/types-ts4.0/plugins/table/nodeviews/table.d.ts +31 -0
  31. package/dist/types-ts4.0/plugins/table/nodeviews/tableCell.d.ts +19 -0
  32. package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +23 -0
  33. package/dist/types-ts4.0/plugins/table/nodeviews/update-overflow-shadows.d.ts +8 -0
  34. package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/plugin.d.ts +7 -0
  35. package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -0
  36. package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +2 -0
  37. package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +2 -0
  38. package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/index.d.ts +3 -0
  39. package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/types.d.ts +6 -0
  40. package/dist/types-ts4.0/plugins/table/pm-plugins/default-table-selection.d.ts +5 -0
  41. package/dist/types-ts4.0/plugins/table/pm-plugins/keymap.d.ts +5 -0
  42. package/dist/types-ts4.0/plugins/table/pm-plugins/main.d.ts +8 -0
  43. package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-factory.d.ts +1 -0
  44. package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
  45. package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts +4 -0
  46. package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +15 -0
  47. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/commands.d.ts +3 -0
  48. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/index.d.ts +6 -0
  49. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +6 -0
  50. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +65 -0
  51. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +3 -0
  52. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -0
  53. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +4 -0
  54. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/types.d.ts +16 -0
  55. package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/util.d.ts +2 -0
  56. package/dist/types-ts4.0/plugins/table/pm-plugins/table-local-id.d.ts +22 -0
  57. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/commands.d.ts +25 -0
  58. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +4 -0
  59. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +3 -0
  60. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +4 -0
  61. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +3 -0
  62. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin.d.ts +6 -0
  63. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/reducer.d.ts +3 -0
  64. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -0
  65. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +14 -0
  66. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +4 -0
  67. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +13 -0
  68. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +12 -0
  69. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +22 -0
  70. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -0
  71. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
  72. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +29 -0
  73. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +17 -0
  74. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +22 -0
  75. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +1 -0
  76. package/dist/types-ts4.0/plugins/table/pm-plugins/table-selection-keymap.d.ts +4 -0
  77. package/dist/types-ts4.0/plugins/table/reducer.d.ts +3 -0
  78. package/dist/types-ts4.0/plugins/table/todo-stubs.d.ts +1 -0
  79. package/dist/types-ts4.0/plugins/table/toolbar.d.ts +36 -0
  80. package/dist/types-ts4.0/plugins/table/transforms/column-width.d.ts +18 -0
  81. package/dist/types-ts4.0/plugins/table/transforms/delete-columns.d.ts +3 -0
  82. package/dist/types-ts4.0/plugins/table/transforms/delete-rows.d.ts +3 -0
  83. package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +10 -0
  84. package/dist/types-ts4.0/plugins/table/transforms/index.d.ts +7 -0
  85. package/dist/types-ts4.0/plugins/table/transforms/merge.d.ts +5 -0
  86. package/dist/types-ts4.0/plugins/table/transforms/metadata.d.ts +21 -0
  87. package/dist/types-ts4.0/plugins/table/transforms/replace-table.d.ts +5 -0
  88. package/dist/types-ts4.0/plugins/table/transforms/split.d.ts +9 -0
  89. package/dist/types-ts4.0/plugins/table/types.d.ts +328 -0
  90. package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/index.d.ts +29 -0
  91. package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/styles.d.ts +1 -0
  92. package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +87 -0
  93. package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/index.d.ts +22 -0
  94. package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -0
  95. package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +14 -0
  96. package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +10 -0
  97. package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/index.d.ts +54 -0
  98. package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/types.d.ts +1 -0
  99. package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +12 -0
  100. package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +3 -0
  101. package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/index.d.ts +35 -0
  102. package/dist/types-ts4.0/plugins/table/ui/LayoutButton/index.d.ts +21 -0
  103. package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +19 -0
  104. package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +21 -0
  105. package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +17 -0
  106. package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/index.d.ts +40 -0
  107. package/dist/types-ts4.0/plugins/table/ui/common-styles.d.ts +4 -0
  108. package/dist/types-ts4.0/plugins/table/ui/consts.d.ts +39 -0
  109. package/dist/types-ts4.0/plugins/table/ui/messages.d.ts +38 -0
  110. package/dist/types-ts4.0/plugins/table/ui/ui-styles.d.ts +15 -0
  111. package/dist/types-ts4.0/plugins/table/utils/analytics.d.ts +18 -0
  112. package/dist/types-ts4.0/plugins/table/utils/collapse.d.ts +29 -0
  113. package/dist/types-ts4.0/plugins/table/utils/column-controls.d.ts +10 -0
  114. package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +16 -0
  115. package/dist/types-ts4.0/plugins/table/utils/dom.d.ts +20 -0
  116. package/dist/types-ts4.0/plugins/table/utils/get-allow-add-column-custom-step.d.ts +2 -0
  117. package/dist/types-ts4.0/plugins/table/utils/index.d.ts +11 -0
  118. package/dist/types-ts4.0/plugins/table/utils/nodes.d.ts +12 -0
  119. package/dist/types-ts4.0/plugins/table/utils/paste.d.ts +14 -0
  120. package/dist/types-ts4.0/plugins/table/utils/referentiality.d.ts +2 -0
  121. package/dist/types-ts4.0/plugins/table/utils/row-controls.d.ts +16 -0
  122. package/dist/types-ts4.0/plugins/table/utils/selection.d.ts +6 -0
  123. package/dist/types-ts4.0/plugins/table/utils/table.d.ts +4 -0
  124. package/dist/types-ts4.0/plugins/table/utils/update-plugin-state-decorations.d.ts +4 -0
  125. package/dist/types-ts4.0/plugins/table-plugin.d.ts +2 -0
  126. package/dist/types-ts4.0/types.d.ts +3 -0
  127. package/examples/99-testing.tsx +227 -0
  128. package/package.json +16 -3
  129. package/src/plugins/table/__tests__/integration/__fixtures__/auto-size-documents.ts +439 -0
  130. package/src/plugins/table/__tests__/integration/__fixtures__/basic-table.ts +120 -0
  131. package/src/plugins/table/__tests__/integration/__fixtures__/empty-paragraph-underneath-table.ts +396 -0
  132. package/src/plugins/table/__tests__/integration/__fixtures__/even-columns.ts +493 -0
  133. package/src/plugins/table/__tests__/integration/__fixtures__/layout-documents.ts +607 -0
  134. package/src/plugins/table/__tests__/integration/__fixtures__/merged-rows-and-cols-document.ts +343 -0
  135. package/src/plugins/table/__tests__/integration/__fixtures__/nested-in-extension.ts +163 -0
  136. package/src/plugins/table/__tests__/integration/__fixtures__/paragraph-and-table-adf.json +130 -0
  137. package/src/plugins/table/__tests__/integration/__fixtures__/resize-documents.ts +1610 -0
  138. package/src/plugins/table/__tests__/integration/__fixtures__/scale.ts +825 -0
  139. package/src/plugins/table/__tests__/integration/__fixtures__/table-inside-layout.ts +145 -0
  140. package/src/plugins/table/__tests__/integration/__fixtures__/table-with-min-width-columns-document.ts +175 -0
  141. package/src/plugins/table/__tests__/integration/__fixtures__/table-with-multiline-date.adf.json +168 -0
  142. package/src/plugins/table/__tests__/integration/__fixtures__/table-with-text-and-empty-row.ts +216 -0
  143. package/src/plugins/table/__tests__/integration/__snapshots__/auto-size.ts.snap +609 -0
  144. package/src/plugins/table/__tests__/integration/__snapshots__/change-date-inside-table.ts.snap +173 -0
  145. package/src/plugins/table/__tests__/integration/__snapshots__/copy-button.ts.snap +421 -0
  146. package/src/plugins/table/__tests__/integration/__snapshots__/delete-columns.ts.snap +818 -0
  147. package/src/plugins/table/__tests__/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +119 -0
  148. package/src/plugins/table/__tests__/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +119 -0
  149. package/src/plugins/table/__tests__/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +227 -0
  150. package/src/plugins/table/__tests__/integration/__snapshots__/delete-rows.ts.snap +959 -0
  151. package/src/plugins/table/__tests__/integration/__snapshots__/delete-table-when-selected.ts.snap +101 -0
  152. package/src/plugins/table/__tests__/integration/__snapshots__/deleting-empty-paragraph-under-table.ts.snap +502 -0
  153. package/src/plugins/table/__tests__/integration/__snapshots__/even-columns.ts.snap +645 -0
  154. package/src/plugins/table/__tests__/integration/__snapshots__/insert-cell-header-with-strong-mark.ts.snap +172 -0
  155. package/src/plugins/table/__tests__/integration/__snapshots__/insert-row-inside-layout.ts.snap +238 -0
  156. package/src/plugins/table/__tests__/integration/__snapshots__/layout.ts.snap +1645 -0
  157. package/src/plugins/table/__tests__/integration/__snapshots__/resize.ts.snap +2674 -0
  158. package/src/plugins/table/__tests__/integration/__snapshots__/scale.ts.snap +1083 -0
  159. package/src/plugins/table/__tests__/integration/arrow-down-into-table.ts +38 -0
  160. package/src/plugins/table/__tests__/integration/auto-size.ts +87 -0
  161. package/src/plugins/table/__tests__/integration/block-node-selection.ts +162 -163
  162. package/src/plugins/table/__tests__/integration/cell-selection.ts +101 -0
  163. package/src/plugins/table/__tests__/integration/change-date-inside-table.ts +47 -0
  164. package/src/plugins/table/__tests__/integration/copy-button.ts +179 -0
  165. package/src/plugins/table/__tests__/integration/delete-columns.ts +95 -0
  166. package/src/plugins/table/__tests__/integration/delete-last-column-in-full-width.ts +70 -0
  167. package/src/plugins/table/__tests__/integration/delete-last-column-with-empty-action.ts +58 -0
  168. package/src/plugins/table/__tests__/integration/delete-last-row-with-empty-action.ts +97 -0
  169. package/src/plugins/table/__tests__/integration/delete-rows.ts +122 -0
  170. package/src/plugins/table/__tests__/integration/delete-table-when-selected.ts +110 -0
  171. package/src/plugins/table/__tests__/integration/deleting-empty-paragraph-under-table.ts +86 -0
  172. package/src/plugins/table/__tests__/integration/even-columns.ts +72 -0
  173. package/src/plugins/table/__tests__/integration/insert-cell-header-with-strong-mark.ts +40 -0
  174. package/src/plugins/table/__tests__/integration/insert-long-smart-link.ts +52 -0
  175. package/src/plugins/table/__tests__/integration/insert-row-inside-layout.ts +47 -0
  176. package/src/plugins/table/__tests__/integration/layout.ts +224 -0
  177. package/src/plugins/table/__tests__/integration/resize-handler.ts +101 -0
  178. package/src/plugins/table/__tests__/integration/resize.ts +342 -0
  179. package/src/plugins/table/__tests__/integration/scale.ts +67 -0
  180. package/src/plugins/table/__tests__/integration/table-controls-selection.ts +70 -0
  181. package/src/plugins/table/ui/FloatingContextualButton/index.tsx +2 -2
  182. package/types/package.json +8 -1
@@ -0,0 +1,101 @@
1
+ import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
2
+ import {
3
+ fullpage,
4
+ quickInsert,
5
+ hoverResizeHandler,
6
+ } from '@atlaskit/editor-test-helpers/integration/helpers';
7
+ import {
8
+ clickFirstCell,
9
+ getSelectorForTableCell,
10
+ } from '@atlaskit/editor-test-helpers/page-objects/table';
11
+ import {
12
+ goToEditorTestingWDExample,
13
+ mountEditor,
14
+ } from '@atlaskit/editor-test-helpers/testing-example-page';
15
+
16
+ interface BBoxWithId {
17
+ left: number;
18
+ top: number;
19
+ width: number;
20
+ height: number;
21
+ id: string;
22
+ }
23
+
24
+ function calcOffset(
25
+ element: 'start' | 'target',
26
+ side: 'left' | 'top',
27
+ rect: BBoxWithId,
28
+ ): number {
29
+ if (element === 'target' && side === 'left') {
30
+ return -(rect.width / 2);
31
+ } else if (element === 'start' && side === 'left') {
32
+ return +(rect.width * 0.8);
33
+ }
34
+
35
+ return 0;
36
+ }
37
+
38
+ /*
39
+ * This is a regression test.
40
+ *
41
+ * The goal of this test is to make sure
42
+ * we can resize the table after a CellSelectio, and here is the why:
43
+ *
44
+ *
45
+ * Given this cell A1
46
+ *
47
+ * ```
48
+ * ▁▁▁▁▁▁▁▁▁▁▁▁▁
49
+ * | ▒▒|
50
+ * | A1 ▒▒|
51
+ * | ▒▒|
52
+ * ▔▔▔▔▔▔▔▔▔▔▔▔▔
53
+ * ```
54
+ *
55
+ * This element is a div, and every time the user hovers it, we should display a resize line.
56
+ * However, keeping a div for each cell in a table increases the HTML a lot,
57
+ * resulting in performance degradation to any DOM diff action.
58
+ * To avoid that, we decided to add the div on demand.
59
+ * Then, when the user comes close to that gap, we added a DIV.
60
+ * Next, we needed to check if the handle was already there using the resizeHandleColumnIndex from the PluginState.
61
+ * However, if that state was not clean properly, we could end up not adding the DIV element,
62
+ * then the user could not resize the column until they hover another one.
63
+ *
64
+ * We solved this problem search for the decorations too: if the DIV is not there, we will add it.
65
+ */
66
+ BrowserTestCase(
67
+ 'Should display the resizer handler after a cellselection',
68
+ // We are skipping other browsers because this test relies on drag and drop,
69
+ // and this API isn't stable in other browsers
70
+ { skip: ['firefox', 'safari'] },
71
+ async (client: any, testName: string) => {
72
+ const page = await goToEditorTestingWDExample(
73
+ client,
74
+ 'editor-plugin-table',
75
+ );
76
+
77
+ await mountEditor(page, {
78
+ appearance: fullpage.appearance,
79
+ allowTables: {
80
+ advanced: true,
81
+ },
82
+ });
83
+ await quickInsert(page, 'Table');
84
+
85
+ await clickFirstCell(page);
86
+
87
+ const firstCell = getSelectorForTableCell({
88
+ row: 2,
89
+ cell: 1,
90
+ });
91
+ const lastCell = getSelectorForTableCell({ row: 2, cell: 2 });
92
+ await hoverResizeHandler(page, 2, 1);
93
+
94
+ await page.simulateUserSelection(firstCell, lastCell, calcOffset);
95
+
96
+ // if it is not possible to resize this method will fail
97
+ await hoverResizeHandler(page, 2, 1);
98
+
99
+ expect(true).toBe(true);
100
+ },
101
+ );
@@ -0,0 +1,342 @@
1
+ import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
2
+ import { tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
3
+ import { PluginKey } from 'prosemirror-state';
4
+ import {
5
+ editable,
6
+ getDocFromElement,
7
+ fullpage,
8
+ resizeColumn,
9
+ selectColumns,
10
+ updateEditorProps,
11
+ } from '@atlaskit/editor-test-helpers/integration/helpers';
12
+
13
+ import {
14
+ insertColumn,
15
+ clickFirstCell,
16
+ selectTable,
17
+ } from '@atlaskit/editor-test-helpers/page-objects/table';
18
+
19
+ import {
20
+ tableWithRowSpan,
21
+ tableWithRowSpanAndColSpan,
22
+ twoColFullWidthTableWithContent,
23
+ tableInsideColumns,
24
+ resizedTableWithStackedColumns,
25
+ tableForBulkResize,
26
+ tableForBulkResize3Cols,
27
+ tableForBulkResizeWithNumberCol,
28
+ } from './__fixtures__/resize-documents';
29
+ import { tableWithMinWidthColumnsDocument } from './__fixtures__/table-with-min-width-columns-document';
30
+ import { pluginKey as tableResizingPluginKey } from '@atlaskit/editor-core/src/plugins/table/pm-plugins/table-resizing';
31
+
32
+ import {
33
+ goToEditorTestingWDExample,
34
+ mountEditor,
35
+ } from '@atlaskit/editor-test-helpers/testing-example-page';
36
+
37
+ BrowserTestCase(
38
+ 'Can resize normally with a rowspan in the non last column.',
39
+ {},
40
+ async (client: any, testName: string) => {
41
+ const page = await goToEditorTestingWDExample(
42
+ client,
43
+ 'editor-plugin-table',
44
+ );
45
+
46
+ await mountEditor(page, {
47
+ appearance: fullpage.appearance,
48
+ defaultValue: JSON.stringify(tableWithRowSpan),
49
+ allowTables: {
50
+ advanced: true,
51
+ },
52
+ });
53
+
54
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 50 });
55
+
56
+ const doc = await page.$eval(editable, getDocFromElement);
57
+ expect(doc).toMatchCustomDocSnapshot(testName);
58
+ },
59
+ );
60
+
61
+ BrowserTestCase(
62
+ 'Can resize normally with a rowspan and colspan',
63
+ {},
64
+ async (client: any, testName: string) => {
65
+ const page = await goToEditorTestingWDExample(
66
+ client,
67
+ 'editor-plugin-table',
68
+ );
69
+
70
+ await mountEditor(page, {
71
+ appearance: fullpage.appearance,
72
+ defaultValue: JSON.stringify(tableWithRowSpanAndColSpan),
73
+ allowTables: {
74
+ advanced: true,
75
+ },
76
+ });
77
+
78
+ await resizeColumn(page, { cellHandlePos: 22, resizeWidth: -50 });
79
+
80
+ const doc = await page.$eval(editable, getDocFromElement);
81
+ expect(doc).toMatchCustomDocSnapshot(testName);
82
+ },
83
+ );
84
+
85
+ BrowserTestCase(
86
+ 'Can resize normally on a full width table with content',
87
+ { skip: ['firefox', 'safari'] },
88
+ async (client: any, testName: string) => {
89
+ const page = await goToEditorTestingWDExample(
90
+ client,
91
+ 'editor-plugin-table',
92
+ );
93
+
94
+ await mountEditor(page, {
95
+ appearance: fullpage.appearance,
96
+ defaultValue: JSON.stringify(twoColFullWidthTableWithContent),
97
+ allowTables: {
98
+ advanced: true,
99
+ },
100
+ });
101
+
102
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: -100 });
103
+
104
+ const doc = await page.$eval(editable, getDocFromElement);
105
+ expect(doc).toMatchCustomDocSnapshot(testName);
106
+ },
107
+ );
108
+
109
+ BrowserTestCase(
110
+ `Created column should be set to ${tableNewColumnMinWidth}px`,
111
+ { skip: ['safari'] },
112
+ async (client: any, testName: string) => {
113
+ const page = await goToEditorTestingWDExample(
114
+ client,
115
+ 'editor-plugin-table',
116
+ );
117
+
118
+ await mountEditor(page, {
119
+ appearance: fullpage.appearance,
120
+ defaultValue: JSON.stringify(tableWithMinWidthColumnsDocument),
121
+ allowTables: {
122
+ advanced: true,
123
+ },
124
+ });
125
+
126
+ await insertColumn(page, 0, 'right');
127
+
128
+ const doc = await page.$eval(editable, getDocFromElement);
129
+ expect(doc).toMatchCustomDocSnapshot(testName);
130
+ },
131
+ );
132
+
133
+ BrowserTestCase(
134
+ 'Can resize the last column when table is nested in Columns',
135
+ { skip: ['firefox', 'safari'] },
136
+ async (client: any, testName: string) => {
137
+ const page = await goToEditorTestingWDExample(
138
+ client,
139
+ 'editor-plugin-table',
140
+ );
141
+
142
+ await mountEditor(page, {
143
+ appearance: fullpage.appearance,
144
+ defaultValue: JSON.stringify(tableInsideColumns),
145
+ allowTables: {
146
+ advanced: true,
147
+ },
148
+ allowLayouts: true,
149
+ });
150
+
151
+ await resizeColumn(page, { cellHandlePos: 10, resizeWidth: -100 });
152
+
153
+ const doc = await page.$eval(editable, getDocFromElement);
154
+ expect(doc).toMatchCustomDocSnapshot(testName);
155
+ },
156
+ );
157
+
158
+ BrowserTestCase(
159
+ 'Should stack columns to the left when widths of some of the columns equal minWidth',
160
+ {},
161
+ async (client: any, testName: string) => {
162
+ const page = await goToEditorTestingWDExample(
163
+ client,
164
+ 'editor-plugin-table',
165
+ );
166
+
167
+ await mountEditor(page, {
168
+ appearance: fullpage.appearance,
169
+ defaultValue: JSON.stringify(resizedTableWithStackedColumns),
170
+ allowTables: {
171
+ advanced: true,
172
+ },
173
+ });
174
+
175
+ await resizeColumn(page, { cellHandlePos: 14, resizeWidth: -200 });
176
+
177
+ const doc = await page.$eval(editable, getDocFromElement);
178
+ expect(doc).toMatchCustomDocSnapshot(testName);
179
+ },
180
+ );
181
+
182
+ [
183
+ {
184
+ test: 'Should stack columns to the right and go to overflow',
185
+ featureFlags: {},
186
+ },
187
+ {
188
+ test:
189
+ 'Should stack columns to the right and go to overflow with overflowShadowsOptimisation',
190
+ featureFlags: {
191
+ tableOverflowShadowsOptimization: true,
192
+ },
193
+ },
194
+ ].forEach(({ test, featureFlags }) => {
195
+ BrowserTestCase(test, {}, async (client: any, testName: string) => {
196
+ const page = await goToEditorTestingWDExample(
197
+ client,
198
+ 'editor-plugin-table',
199
+ );
200
+
201
+ await mountEditor(page, {
202
+ appearance: fullpage.appearance,
203
+ defaultValue: JSON.stringify(resizedTableWithStackedColumns),
204
+ allowTables: {
205
+ advanced: true,
206
+ },
207
+ featureFlags,
208
+ });
209
+
210
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 420 });
211
+
212
+ const doc = await page.$eval(editable, getDocFromElement);
213
+ expect(doc).toMatchCustomDocSnapshot(testName);
214
+ });
215
+ });
216
+
217
+ BrowserTestCase(
218
+ 'Should bulk resize 3 columns in 4 columns table',
219
+ { skip: ['firefox', 'safari'] },
220
+ async (client: any, testName: string) => {
221
+ const page = await goToEditorTestingWDExample(
222
+ client,
223
+ 'editor-plugin-table',
224
+ );
225
+
226
+ await mountEditor(page, {
227
+ appearance: fullpage.appearance,
228
+ defaultValue: JSON.stringify(tableForBulkResize3Cols),
229
+ allowTables: {
230
+ advanced: true,
231
+ },
232
+ });
233
+
234
+ await clickFirstCell(page);
235
+ await selectTable(page);
236
+ await resizeColumn(page, { cellHandlePos: 6, resizeWidth: -20 });
237
+
238
+ const doc = await page.$eval(editable, getDocFromElement);
239
+ expect(doc).toMatchCustomDocSnapshot(testName);
240
+ },
241
+ );
242
+
243
+ BrowserTestCase(
244
+ 'Should recover from overflow when number col is selected',
245
+ { skip: ['firefox', 'safari'] },
246
+ async (client: any, testName: string) => {
247
+ const page = await goToEditorTestingWDExample(
248
+ client,
249
+ 'editor-plugin-table',
250
+ );
251
+
252
+ await mountEditor(page, {
253
+ appearance: fullpage.appearance,
254
+ defaultValue: JSON.stringify(tableForBulkResizeWithNumberCol),
255
+ allowTables: {
256
+ advanced: true,
257
+ },
258
+ });
259
+
260
+ await clickFirstCell(page);
261
+ await selectTable(page);
262
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: -20 });
263
+
264
+ const doc = await page.$eval(editable, getDocFromElement);
265
+ expect(doc).toMatchCustomDocSnapshot(testName);
266
+ },
267
+ );
268
+
269
+ BrowserTestCase(
270
+ 'Should bulk resize selected columns',
271
+ { skip: ['firefox', 'safari'] },
272
+ async (client: any, testName: string) => {
273
+ const page = await goToEditorTestingWDExample(
274
+ client,
275
+ 'editor-plugin-table',
276
+ );
277
+
278
+ await mountEditor(page, {
279
+ appearance: fullpage.appearance,
280
+ defaultValue: JSON.stringify(tableForBulkResize),
281
+ allowTables: {
282
+ advanced: true,
283
+ },
284
+ });
285
+
286
+ await clickFirstCell(page);
287
+ await selectColumns(page, [0, 1]);
288
+ await resizeColumn(page, { cellHandlePos: 2, resizeWidth: 52 });
289
+
290
+ const doc = await page.$eval(editable, getDocFromElement);
291
+ expect(doc).toMatchCustomDocSnapshot(testName);
292
+ },
293
+ );
294
+
295
+ BrowserTestCase(
296
+ 'Can resize normally while editor changes its appearance',
297
+ { skip: ['firefox', 'safari'] },
298
+ async (client: any, testName: string) => {
299
+ const page = await goToEditorTestingWDExample(
300
+ client,
301
+ 'editor-plugin-table',
302
+ );
303
+
304
+ await mountEditor(page, {
305
+ appearance: fullpage.appearance,
306
+ defaultValue: JSON.stringify(tableForBulkResize),
307
+ allowTables: {
308
+ advanced: true,
309
+ },
310
+ });
311
+
312
+ const resizeHandlePos = 2;
313
+
314
+ // We grab the resize handle and then change editor appearance to full-widths
315
+ // in which case we expect the editor not to throw
316
+ await (page as any).browser.execute(
317
+ (handlePos: number, pluginKey: PluginKey) => {
318
+ const view = (window as any).__editorView;
319
+ if (!view) {
320
+ return;
321
+ }
322
+ view.dispatch(
323
+ view.state.tr.setMeta(pluginKey, {
324
+ type: 'SET_RESIZE_HANDLE_POSITION',
325
+ data: {
326
+ resizeHandlePos: handlePos,
327
+ },
328
+ }),
329
+ );
330
+ view.dom.dispatchEvent(
331
+ new MouseEvent('mousedown', { clientX: handlePos }),
332
+ );
333
+ },
334
+ resizeHandlePos,
335
+ tableResizingPluginKey,
336
+ );
337
+
338
+ // doesn't reject the promise (throw)
339
+ expect(updateEditorProps(page, { appearance: 'full-width' })).resolves
340
+ .toBeUndefined;
341
+ },
342
+ );
@@ -0,0 +1,67 @@
1
+ import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
2
+ import {
3
+ editable,
4
+ getDocFromElement,
5
+ fullpage,
6
+ } from '@atlaskit/editor-test-helpers/integration/helpers';
7
+ import {
8
+ insertColumn,
9
+ deleteColumn,
10
+ } from '@atlaskit/editor-test-helpers/page-objects/table';
11
+ import {
12
+ tableWithManyMinWidthCols,
13
+ tableInOverflow,
14
+ } from './__fixtures__/scale';
15
+
16
+ import {
17
+ goToEditorTestingWDExample,
18
+ mountEditor,
19
+ } from '@atlaskit/editor-test-helpers/testing-example-page';
20
+
21
+ BrowserTestCase(
22
+ 'Should scale remaining columns when adding a new column preventing from going to overflow',
23
+ { skip: ['safari'] },
24
+ async (client: any, testName: string) => {
25
+ const page = await goToEditorTestingWDExample(
26
+ client,
27
+ 'editor-plugin-table',
28
+ );
29
+
30
+ await mountEditor(page, {
31
+ appearance: fullpage.appearance,
32
+ defaultValue: JSON.stringify(tableWithManyMinWidthCols),
33
+ allowTables: {
34
+ advanced: true,
35
+ },
36
+ });
37
+
38
+ await insertColumn(page, 5, 'left');
39
+
40
+ const doc = await page.$eval(editable, getDocFromElement);
41
+ expect(doc).toMatchCustomDocSnapshot(testName);
42
+ },
43
+ );
44
+
45
+ BrowserTestCase(
46
+ 'Should scale remaining columns when deleting a column recovering table from overflow',
47
+ { skip: [] },
48
+ async (client: any, testName: string) => {
49
+ const page = await goToEditorTestingWDExample(
50
+ client,
51
+ 'editor-plugin-table',
52
+ );
53
+
54
+ await mountEditor(page, {
55
+ appearance: fullpage.appearance,
56
+ defaultValue: JSON.stringify(tableInOverflow),
57
+ allowTables: {
58
+ advanced: true,
59
+ },
60
+ });
61
+
62
+ await deleteColumn(page, 1);
63
+
64
+ const doc = await page.$eval(editable, getDocFromElement);
65
+ expect(doc).toMatchCustomDocSnapshot(testName);
66
+ },
67
+ );
@@ -0,0 +1,70 @@
1
+ //TODO: [ED-15027] remove and relocate this test once the behaviour has been corrected.\
2
+ import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
3
+ import { BrowserObject } from '@atlaskit/webdriver-runner/wd-wrapper';
4
+ import {
5
+ goToEditorTestingWDExample,
6
+ mountEditor,
7
+ } from '@atlaskit/editor-test-helpers/testing-example-page';
8
+ import {
9
+ fullpage,
10
+ expectToMatchSelection,
11
+ setProseMirrorTextSelection,
12
+ } from '@atlaskit/editor-test-helpers/integration/helpers';
13
+ import type { WebDriverPage } from '@atlaskit/editor-test-helpers/integration/types';
14
+ import adf from './__fixtures__/table-with-multiline-date.adf.json';
15
+
16
+ describe('table with multiline date', () => {
17
+ const initEditor = async ({
18
+ client,
19
+ selection,
20
+ adf,
21
+ }: {
22
+ client: BrowserObject;
23
+ selection: { anchor: number; head: number };
24
+ adf: string;
25
+ }): Promise<WebDriverPage> => {
26
+ const page = await goToEditorTestingWDExample(
27
+ client,
28
+ 'editor-plugin-table',
29
+ );
30
+ const props = {
31
+ appearance: fullpage.appearance,
32
+ defaultValue: adf,
33
+ allowTextAlignment: true,
34
+ allowTables: {
35
+ advanced: true,
36
+ allowColumnResizing: true,
37
+ },
38
+ allowDate: true,
39
+ };
40
+
41
+ await mountEditor(page, props, undefined, { clickInEditor: false });
42
+
43
+ await page.waitForSelector('.inlineNodeView');
44
+
45
+ await setProseMirrorTextSelection(page, selection);
46
+
47
+ return page;
48
+ };
49
+ BrowserTestCase(
50
+ 'Does not select table corner controls when navigating up from a multiline node inside a table',
51
+ {
52
+ skip: ['firefox', 'safari'],
53
+ },
54
+ async (client: BrowserObject) => {
55
+ const page = await initEditor({
56
+ client,
57
+ selection: { anchor: 27, head: 27 },
58
+ adf,
59
+ });
60
+
61
+ await page.keys('ArrowUp');
62
+
63
+ await expectToMatchSelection(page, {
64
+ type: 'text',
65
+ anchor: 27,
66
+ head: 27,
67
+ });
68
+ },
69
+ );
70
+ });
@@ -83,8 +83,8 @@ export class FloatingContextualButtonInner extends React.Component<
83
83
  selection: editorView.state.selection.toJSON(),
84
84
  position: targetCellPosition,
85
85
  docSize: editorView.state.doc.nodeSize,
86
- error: error.toString(),
87
- errorStack: error.stack || undefined,
86
+ error: error instanceof Error ? error.message : String(error),
87
+ errorStack: error instanceof Error ? error.stack : undefined,
88
88
  },
89
89
  };
90
90
  dispatchAnalyticsEvent(payload);
@@ -3,5 +3,12 @@
3
3
  "main": "../dist/cjs/types.js",
4
4
  "module": "../dist/esm/types.js",
5
5
  "module:es2019": "../dist/es2019/types.js",
6
- "types": "../dist/types/types.d.ts"
6
+ "types": "../dist/types/types.d.ts",
7
+ "typesVersions": {
8
+ ">=4.0 <4.5": {
9
+ "*": [
10
+ "../dist/types-ts4.0/types.d.ts"
11
+ ]
12
+ }
13
+ }
7
14
  }