@atlaskit/editor-plugin-table 4.0.1 → 4.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 (209) hide show
  1. package/CHANGELOG.md +146 -133
  2. package/README.md +1 -1
  3. package/dist/cjs/i18n/cs.js +2 -3
  4. package/dist/cjs/i18n/da.js +2 -3
  5. package/dist/cjs/i18n/de.js +2 -3
  6. package/dist/cjs/i18n/en.js +2 -3
  7. package/dist/cjs/i18n/en_GB.js +2 -3
  8. package/dist/cjs/i18n/en_ZZ.js +2 -3
  9. package/dist/cjs/i18n/es.js +2 -3
  10. package/dist/cjs/i18n/fi.js +2 -3
  11. package/dist/cjs/i18n/fr.js +2 -3
  12. package/dist/cjs/i18n/hu.js +2 -3
  13. package/dist/cjs/i18n/it.js +2 -3
  14. package/dist/cjs/i18n/ja.js +2 -3
  15. package/dist/cjs/i18n/ko.js +2 -3
  16. package/dist/cjs/i18n/nb.js +2 -3
  17. package/dist/cjs/i18n/nl.js +2 -3
  18. package/dist/cjs/i18n/pl.js +2 -3
  19. package/dist/cjs/i18n/pt_BR.js +2 -3
  20. package/dist/cjs/i18n/ru.js +2 -3
  21. package/dist/cjs/i18n/sv.js +2 -3
  22. package/dist/cjs/i18n/th.js +2 -3
  23. package/dist/cjs/i18n/tr.js +2 -3
  24. package/dist/cjs/i18n/uk.js +2 -3
  25. package/dist/cjs/i18n/vi.js +2 -3
  26. package/dist/cjs/i18n/zh.js +2 -3
  27. package/dist/cjs/i18n/zh_TW.js +2 -3
  28. package/dist/cjs/plugins/table/commands/clear.js +3 -5
  29. package/dist/cjs/plugins/table/commands/collapse.js +2 -3
  30. package/dist/cjs/plugins/table/commands/go-to-next-cell.js +2 -3
  31. package/dist/cjs/plugins/table/commands/hover.js +8 -15
  32. package/dist/cjs/plugins/table/commands/insert.js +8 -13
  33. package/dist/cjs/plugins/table/commands/misc.js +23 -45
  34. package/dist/cjs/plugins/table/commands/referentiality.js +2 -3
  35. package/dist/cjs/plugins/table/commands/selection.js +3 -6
  36. package/dist/cjs/plugins/table/commands/sort.js +5 -6
  37. package/dist/cjs/plugins/table/commands/split-cell.js +2 -3
  38. package/dist/cjs/plugins/table/commands/toggle.js +7 -13
  39. package/dist/cjs/plugins/table/commands-with-analytics.js +19 -37
  40. package/dist/cjs/plugins/table/create-plugin-config.js +2 -3
  41. package/dist/cjs/plugins/table/event-handlers.js +12 -22
  42. package/dist/cjs/plugins/table/handlers.js +4 -5
  43. package/dist/cjs/plugins/table/index.js +8 -9
  44. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +5 -6
  45. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -3
  46. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +10 -13
  47. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +4 -5
  48. package/dist/cjs/plugins/table/nodeviews/TableStickyScrollbar.js +5 -10
  49. package/dist/cjs/plugins/table/nodeviews/table.js +4 -6
  50. package/dist/cjs/plugins/table/nodeviews/tableCell.js +2 -3
  51. package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +2 -3
  52. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +5 -9
  53. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +3 -5
  54. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +3 -5
  55. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +2 -3
  56. package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +2 -3
  57. package/dist/cjs/plugins/table/pm-plugins/keymap.js +1 -2
  58. package/dist/cjs/plugins/table/pm-plugins/main.js +2 -3
  59. package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +3 -6
  60. package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +1 -2
  61. package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +3 -5
  62. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +3 -5
  63. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +3 -5
  64. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +6 -8
  65. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +1 -2
  66. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +2 -4
  67. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +2 -3
  68. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +2 -3
  69. package/dist/cjs/plugins/table/pm-plugins/table-analytics.js +5 -8
  70. package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +2 -3
  71. package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +7 -13
  72. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +3 -4
  73. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +3 -6
  74. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +1 -2
  75. package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +2 -3
  76. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +7 -13
  77. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +5 -10
  78. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/consts.js +2 -4
  79. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +8 -15
  80. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +2 -3
  81. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +2 -3
  82. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +70 -71
  83. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +11 -21
  84. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +5 -9
  85. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +2 -3
  86. package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +1 -2
  87. package/dist/cjs/plugins/table/pm-plugins/table-width.js +3 -5
  88. package/dist/cjs/plugins/table/reducer.js +2 -3
  89. package/dist/cjs/plugins/table/toolbar.js +8 -12
  90. package/dist/cjs/plugins/table/transforms/column-width.js +4 -6
  91. package/dist/cjs/plugins/table/transforms/delete-columns.js +60 -60
  92. package/dist/cjs/plugins/table/transforms/delete-rows.js +52 -52
  93. package/dist/cjs/plugins/table/transforms/fix-tables.js +3 -6
  94. package/dist/cjs/plugins/table/transforms/replace-table.js +3 -4
  95. package/dist/cjs/plugins/table/types.js +5 -9
  96. package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +2 -3
  97. package/dist/cjs/plugins/table/ui/FloatingContextualButton/FixedButton.js +5 -10
  98. package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +3 -5
  99. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +7 -10
  100. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +1 -2
  101. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +2 -4
  102. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +1 -2
  103. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
  104. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +1 -2
  105. package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +1 -2
  106. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +2 -4
  107. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +1 -2
  108. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +1 -2
  109. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +2 -3
  110. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +1 -2
  111. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +1 -2
  112. package/dist/cjs/plugins/table/ui/common-styles.js +23 -14
  113. package/dist/cjs/plugins/table/ui/consts.js +47 -94
  114. package/dist/cjs/plugins/table/ui/messages.js +2 -3
  115. package/dist/cjs/plugins/table/ui/ui-styles.js +32 -38
  116. package/dist/cjs/plugins/table/utils/analytics.js +7 -12
  117. package/dist/cjs/plugins/table/utils/collapse.js +3 -5
  118. package/dist/cjs/plugins/table/utils/column-controls.js +6 -11
  119. package/dist/cjs/plugins/table/utils/decoration.js +10 -19
  120. package/dist/cjs/plugins/table/utils/dom.js +16 -28
  121. package/dist/cjs/plugins/table/utils/guidelines.js +1 -2
  122. package/dist/cjs/plugins/table/utils/nodes.js +12 -23
  123. package/dist/cjs/plugins/table/utils/paste.js +10 -16
  124. package/dist/cjs/plugins/table/utils/row-controls.js +7 -13
  125. package/dist/cjs/plugins/table/utils/selection.js +5 -9
  126. package/dist/cjs/plugins/table/utils/snapping.js +4 -7
  127. package/dist/cjs/plugins/table/utils/table.js +3 -5
  128. package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +2 -3
  129. package/dist/cjs/plugins/table-plugin.js +1 -2
  130. package/dist/es2019/plugins/table/commands/insert.js +1 -1
  131. package/dist/es2019/plugins/table/commands/sort.js +1 -1
  132. package/dist/es2019/plugins/table/handlers.js +1 -1
  133. package/dist/es2019/plugins/table/toolbar.js +1 -1
  134. package/dist/es2019/plugins/table/transforms/delete-columns.js +1 -1
  135. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  136. package/dist/es2019/plugins/table/ui/common-styles.js +40 -4
  137. package/dist/es2019/plugins/table/ui/ui-styles.js +223 -85
  138. package/dist/esm/plugins/table/commands/insert.js +1 -1
  139. package/dist/esm/plugins/table/commands/sort.js +1 -1
  140. package/dist/esm/plugins/table/event-handlers.js +1 -1
  141. package/dist/esm/plugins/table/handlers.js +1 -1
  142. package/dist/esm/plugins/table/index.js +7 -7
  143. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +3 -3
  144. package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -1
  145. package/dist/esm/plugins/table/nodeviews/TableContainer.js +6 -6
  146. package/dist/esm/plugins/table/nodeviews/TableResizer.js +2 -2
  147. package/dist/esm/plugins/table/nodeviews/TableStickyScrollbar.js +3 -7
  148. package/dist/esm/plugins/table/nodeviews/table.js +1 -1
  149. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +3 -3
  150. package/dist/esm/plugins/table/pm-plugins/table-analytics.js +1 -1
  151. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
  152. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +68 -67
  153. package/dist/esm/plugins/table/toolbar.js +2 -2
  154. package/dist/esm/plugins/table/transforms/column-width.js +1 -1
  155. package/dist/esm/plugins/table/transforms/delete-columns.js +57 -56
  156. package/dist/esm/plugins/table/transforms/delete-rows.js +51 -50
  157. package/dist/esm/plugins/table/transforms/replace-table.js +1 -1
  158. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
  159. package/dist/esm/plugins/table/ui/common-styles.js +20 -6
  160. package/dist/esm/plugins/table/ui/ui-styles.js +18 -10
  161. package/dist/esm/plugins/table/utils/analytics.js +1 -1
  162. package/dist/esm/plugins/table/utils/dom.js +1 -1
  163. package/dist/esm/plugins/table/utils/paste.js +4 -4
  164. package/dist/types/plugins/table/commands/sort.d.ts +2 -2
  165. package/dist/types/plugins/table/commands-with-analytics.d.ts +4 -4
  166. package/dist/types/plugins/table/handlers.d.ts +2 -2
  167. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -1
  168. package/dist/types/plugins/table/types.d.ts +1 -1
  169. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +4 -4
  170. package/dist/types-ts4.5/plugins/table/commands/sort.d.ts +2 -2
  171. package/dist/types-ts4.5/plugins/table/commands-with-analytics.d.ts +4 -4
  172. package/dist/types-ts4.5/plugins/table/handlers.d.ts +2 -2
  173. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +1 -1
  174. package/dist/types-ts4.5/plugins/table/types.d.ts +1 -1
  175. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +4 -4
  176. package/docs/0-intro.tsx +1 -1
  177. package/package.json +8 -4
  178. package/src/__tests__/integration/__snapshots__/auto-size.ts.snap +3 -0
  179. package/src/__tests__/integration/__snapshots__/copy-button.ts.snap +2 -0
  180. package/src/__tests__/integration/__snapshots__/delete-columns.ts.snap +2 -0
  181. package/src/__tests__/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +1 -0
  182. package/src/__tests__/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +1 -0
  183. package/src/__tests__/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +2 -0
  184. package/src/__tests__/integration/__snapshots__/delete-rows.ts.snap +3 -0
  185. package/src/__tests__/integration/__snapshots__/deleting-empty-paragraph-under-table.ts.snap +3 -0
  186. package/src/__tests__/integration/__snapshots__/even-columns.ts.snap +2 -0
  187. package/src/__tests__/integration/__snapshots__/insert-cell-header-with-strong-mark.ts.snap +1 -0
  188. package/src/__tests__/integration/__snapshots__/insert-row-inside-layout.ts.snap +1 -0
  189. package/src/__tests__/integration/__snapshots__/layout.ts.snap +9 -0
  190. package/src/__tests__/integration/__snapshots__/resize.ts.snap +11 -0
  191. package/src/__tests__/integration/__snapshots__/scale.ts.snap +2 -0
  192. package/src/__tests__/unit/commands/sort.ts +1 -1
  193. package/src/__tests__/unit/pm-plugins/table-width.ts +190 -1
  194. package/src/__tests__/unit/sort-column.ts +1 -1
  195. package/src/plugins/table/commands/insert.ts +1 -1
  196. package/src/plugins/table/commands/sort.ts +7 -7
  197. package/src/plugins/table/commands-with-analytics.ts +11 -6
  198. package/src/plugins/table/handlers.ts +7 -8
  199. package/src/plugins/table/nodeviews/TableComponent.tsx +1 -1
  200. package/src/plugins/table/nodeviews/table.tsx +1 -1
  201. package/src/plugins/table/toolbar.tsx +1 -1
  202. package/src/plugins/table/transforms/delete-columns.ts +1 -1
  203. package/src/plugins/table/types.ts +1 -1
  204. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +1 -1
  205. package/src/plugins/table/ui/TableFloatingControls/index.tsx +4 -4
  206. package/src/plugins/table/ui/common-styles.ts +46 -4
  207. package/src/plugins/table/ui/ui-styles.ts +235 -90
  208. package/tsconfig.app.json +3 -0
  209. package/tsconfig.dev.json +3 -0
@@ -9,6 +9,7 @@ Object {
9
9
  "isNumberColumnEnabled": true,
10
10
  "layout": "full-width",
11
11
  "localId": "abc-123",
12
+ "width": null,
12
13
  },
13
14
  "content": Array [
14
15
  Object {
@@ -248,6 +249,7 @@ Object {
248
249
  "isNumberColumnEnabled": false,
249
250
  "layout": "default",
250
251
  "localId": "abc-123",
252
+ "width": null,
251
253
  },
252
254
  "content": Array [
253
255
  Object {
@@ -405,6 +407,7 @@ Object {
405
407
  "isNumberColumnEnabled": false,
406
408
  "layout": "default",
407
409
  "localId": "abc-123",
410
+ "width": null,
408
411
  },
409
412
  "content": Array [
410
413
  Object {
@@ -566,6 +569,7 @@ Object {
566
569
  "isNumberColumnEnabled": false,
567
570
  "layout": "default",
568
571
  "localId": "abc-123",
572
+ "width": null,
569
573
  },
570
574
  "content": Array [
571
575
  Object {
@@ -761,6 +765,7 @@ Object {
761
765
  "isNumberColumnEnabled": false,
762
766
  "layout": "default",
763
767
  "localId": "abc-123",
768
+ "width": null,
764
769
  },
765
770
  "content": Array [
766
771
  Object {
@@ -1035,6 +1040,7 @@ Object {
1035
1040
  "isNumberColumnEnabled": false,
1036
1041
  "layout": "default",
1037
1042
  "localId": "abc-123",
1043
+ "width": null,
1038
1044
  },
1039
1045
  "content": Array [
1040
1046
  Object {
@@ -1261,6 +1267,7 @@ Object {
1261
1267
  "isNumberColumnEnabled": false,
1262
1268
  "layout": "default",
1263
1269
  "localId": "abc-123",
1270
+ "width": null,
1264
1271
  },
1265
1272
  "content": Array [
1266
1273
  Object {
@@ -1631,6 +1638,7 @@ Object {
1631
1638
  "isNumberColumnEnabled": true,
1632
1639
  "layout": "default",
1633
1640
  "localId": "abc-123",
1641
+ "width": null,
1634
1642
  },
1635
1643
  "content": Array [
1636
1644
  Object {
@@ -1860,6 +1868,7 @@ Object {
1860
1868
  "isNumberColumnEnabled": false,
1861
1869
  "layout": "default",
1862
1870
  "localId": "abc-123",
1871
+ "width": null,
1863
1872
  },
1864
1873
  "content": Array [
1865
1874
  Object {
@@ -2134,6 +2143,7 @@ Object {
2134
2143
  "isNumberColumnEnabled": false,
2135
2144
  "layout": "default",
2136
2145
  "localId": "abc-123",
2146
+ "width": null,
2137
2147
  },
2138
2148
  "content": Array [
2139
2149
  Object {
@@ -2408,6 +2418,7 @@ Object {
2408
2418
  "isNumberColumnEnabled": false,
2409
2419
  "layout": "default",
2410
2420
  "localId": "abc-123",
2421
+ "width": null,
2411
2422
  },
2412
2423
  "content": Array [
2413
2424
  Object {
@@ -9,6 +9,7 @@ Object {
9
9
  "isNumberColumnEnabled": false,
10
10
  "layout": "default",
11
11
  "localId": "abc-123",
12
+ "width": null,
12
13
  },
13
14
  "content": Array [
14
15
  Object {
@@ -718,6 +719,7 @@ Object {
718
719
  "isNumberColumnEnabled": false,
719
720
  "layout": "default",
720
721
  "localId": "abc-123",
722
+ "width": null,
721
723
  },
722
724
  "content": Array [
723
725
  Object {
@@ -1,5 +1,5 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
- import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
2
+ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
4
4
  import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
5
5
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
@@ -6,6 +6,7 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
6
6
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
7
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
8
8
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
9
+ import { undo } from '@atlaskit/editor-prosemirror/history';
9
10
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
10
11
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
11
12
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
@@ -26,6 +27,42 @@ import {
26
27
  import tablePlugin from '../../../plugins/table-plugin';
27
28
  import { pluginKey as tablePluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
28
29
 
30
+ const createDoc = (attrs: any) =>
31
+ doc(
32
+ table(attrs)(
33
+ tr(tdEmpty, tdEmpty, tdEmpty),
34
+ tr(tdEmpty, tdEmpty, tdEmpty),
35
+ tr(tdEmpty, tdEmpty, tdEmpty),
36
+ ),
37
+ );
38
+
39
+ const expectedDocuments = {
40
+ fullWidthAppearanceLayoutDefault: createDoc({
41
+ localId: 'localId',
42
+ isNumberColumnEnabled: false,
43
+ layout: 'default',
44
+ width: 1800,
45
+ }),
46
+ fixedWidthAppearanceLayoutDefault: createDoc({
47
+ localId: 'localId',
48
+ isNumberColumnEnabled: false,
49
+ layout: 'default',
50
+ width: 760,
51
+ }),
52
+ fixedWidthAppearanceLayoutWide: createDoc({
53
+ localId: 'localId',
54
+ isNumberColumnEnabled: false,
55
+ layout: 'wide',
56
+ width: 960,
57
+ }),
58
+ fixedWidthAppearanceLayoutFullWidth: createDoc({
59
+ localId: 'localId',
60
+ isNumberColumnEnabled: false,
61
+ layout: 'full-width',
62
+ width: 1800,
63
+ }),
64
+ };
65
+
29
66
  describe('table width', () => {
30
67
  const createEditor = createProsemirrorEditorFactory();
31
68
 
@@ -34,7 +71,7 @@ describe('table width', () => {
34
71
  global['fetch'] = jest.fn();
35
72
  });
36
73
 
37
- const editor = (doc: DocBuilder) => {
74
+ const editor = (doc: DocBuilder, isFullWidthEnabled = false) => {
38
75
  return createEditor({
39
76
  doc,
40
77
  attachTo: document.body,
@@ -48,6 +85,7 @@ describe('table width', () => {
48
85
  .add([
49
86
  tablePlugin,
50
87
  {
88
+ fullWidthEnabled: isFullWidthEnabled,
51
89
  tableResizingEnabled: true, // so table-width plugin is enabled
52
90
  tableOptions: {
53
91
  advanced: true,
@@ -99,4 +137,155 @@ describe('table width', () => {
99
137
  );
100
138
  });
101
139
  });
140
+
141
+ describe('Load an existing table with width attr equal null', () => {
142
+ describe('full-width editor appearance', () => {
143
+ it('should translate table width attr to 1800', () => {
144
+ const { editorView } = editor(
145
+ doc(
146
+ // @ts-ignore
147
+ table({ localId: 'localId', layout: 'default', width: null })(
148
+ tr(tdEmpty, tdEmpty, tdEmpty),
149
+ tr(tdEmpty, tdEmpty, tdEmpty),
150
+ tr(tdEmpty, tdEmpty, tdEmpty),
151
+ ),
152
+ ),
153
+ true,
154
+ );
155
+
156
+ // create `replaceDocument` step
157
+ editorView.dispatch(
158
+ editorView.state.tr.setMeta('replaceDocument', true),
159
+ );
160
+
161
+ expect(editorView.state.doc).toEqualDocument(
162
+ expectedDocuments.fullWidthAppearanceLayoutDefault,
163
+ );
164
+ });
165
+
166
+ it('should not remove width when undo is sent', () => {
167
+ const { editorView } = editor(
168
+ doc(
169
+ // @ts-ignore
170
+ table({ localId: 'localId', layout: 'default', width: null })(
171
+ tr(tdEmpty, tdEmpty, tdEmpty),
172
+ tr(tdEmpty, tdEmpty, tdEmpty),
173
+ tr(tdEmpty, tdEmpty, tdEmpty),
174
+ ),
175
+ ),
176
+ true,
177
+ );
178
+
179
+ // create `replaceDocument` step
180
+ editorView.dispatch(
181
+ editorView.state.tr.setMeta('replaceDocument', true),
182
+ );
183
+
184
+ expect(editorView.state.doc).toEqualDocument(
185
+ expectedDocuments.fullWidthAppearanceLayoutDefault,
186
+ );
187
+
188
+ undo(editorView.state, editorView.dispatch);
189
+
190
+ expect(editorView.state.doc).toEqualDocument(
191
+ expectedDocuments.fullWidthAppearanceLayoutDefault,
192
+ );
193
+ });
194
+ });
195
+ describe('fixed-width editor appearance', () => {
196
+ it('should translate table width attr to 760 for default layout', () => {
197
+ const { editorView } = editor(
198
+ doc(
199
+ // @ts-ignore
200
+ table({ localId: 'localId', layout: 'default', width: null })(
201
+ tr(tdEmpty, tdEmpty, tdEmpty),
202
+ tr(tdEmpty, tdEmpty, tdEmpty),
203
+ tr(tdEmpty, tdEmpty, tdEmpty),
204
+ ),
205
+ ),
206
+ );
207
+
208
+ // create `replaceDocument` step
209
+ editorView.dispatch(
210
+ editorView.state.tr.setMeta('replaceDocument', true),
211
+ );
212
+
213
+ expect(editorView.state.doc).toEqualDocument(
214
+ expectedDocuments.fixedWidthAppearanceLayoutDefault,
215
+ );
216
+ });
217
+
218
+ it('should not remove width when undo is sent', () => {
219
+ const { editorView } = editor(
220
+ doc(
221
+ // @ts-ignore
222
+ table({ localId: 'localId', layout: 'default', width: null })(
223
+ tr(tdEmpty, tdEmpty, tdEmpty),
224
+ tr(tdEmpty, tdEmpty, tdEmpty),
225
+ tr(tdEmpty, tdEmpty, tdEmpty),
226
+ ),
227
+ ),
228
+ );
229
+
230
+ // create `replaceDocument` step
231
+ editorView.dispatch(
232
+ editorView.state.tr.setMeta('replaceDocument', true),
233
+ );
234
+
235
+ expect(editorView.state.doc).toEqualDocument(
236
+ expectedDocuments.fixedWidthAppearanceLayoutDefault,
237
+ );
238
+
239
+ undo(editorView.state, editorView.dispatch);
240
+
241
+ expect(editorView.state.doc).toEqualDocument(
242
+ expectedDocuments.fixedWidthAppearanceLayoutDefault,
243
+ );
244
+ });
245
+
246
+ it('should translate table width attr to 960 for wide layout', () => {
247
+ const { editorView } = editor(
248
+ doc(
249
+ // @ts-ignore
250
+ table({ localId: 'localId', layout: 'wide', width: null })(
251
+ tr(tdEmpty, tdEmpty, tdEmpty),
252
+ tr(tdEmpty, tdEmpty, tdEmpty),
253
+ tr(tdEmpty, tdEmpty, tdEmpty),
254
+ ),
255
+ ),
256
+ );
257
+
258
+ // create `replaceDocument` step
259
+ editorView.dispatch(
260
+ editorView.state.tr.setMeta('replaceDocument', true),
261
+ );
262
+
263
+ expect(editorView.state.doc).toEqualDocument(
264
+ expectedDocuments.fixedWidthAppearanceLayoutWide,
265
+ );
266
+ });
267
+
268
+ it('should translate table width attr to 1800 for full-width layout', () => {
269
+ const { editorView } = editor(
270
+ doc(
271
+ // @ts-ignore
272
+ table({ localId: 'localId', layout: 'full-width', width: null })(
273
+ tr(tdEmpty, tdEmpty, tdEmpty),
274
+ tr(tdEmpty, tdEmpty, tdEmpty),
275
+ tr(tdEmpty, tdEmpty, tdEmpty),
276
+ ),
277
+ ),
278
+ );
279
+
280
+ // create `replaceDocument` step
281
+ editorView.dispatch(
282
+ editorView.state.tr.setMeta('replaceDocument', true),
283
+ );
284
+
285
+ expect(editorView.state.doc).toEqualDocument(
286
+ expectedDocuments.fixedWidthAppearanceLayoutFullWidth,
287
+ );
288
+ });
289
+ });
290
+ });
102
291
  });
@@ -1,5 +1,5 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
- import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
2
+ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
3
3
  import type { DocBuilder } from '@atlaskit/editor-common/types';
4
4
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
5
5
  import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
@@ -1,5 +1,5 @@
1
1
  // #region Imports
2
- import { AddColumnStep } from '@atlaskit/adf-schema/steps';
2
+ import { AddColumnStep } from '@atlaskit/custom-steps';
3
3
  import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
4
4
  import type {
5
5
  Command,
@@ -1,16 +1,16 @@
1
- import { CardAttributes, DataType, UrlType } from '@atlaskit/adf-schema';
1
+ import type { CardAttributes, DataType, UrlType } from '@atlaskit/adf-schema';
2
2
  import {
3
3
  TableSortOrder as SortOrder,
4
4
  TableSortStep,
5
- } from '@atlaskit/adf-schema/steps';
6
- import { Command } from '@atlaskit/editor-common/types';
5
+ } from '@atlaskit/custom-steps';
6
+ import type { Command } from '@atlaskit/editor-common/types';
7
7
  import { createCompareNodes } from '@atlaskit/editor-common/utils';
8
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
9
- import {
8
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
9
+ import type {
10
10
  EditorState,
11
- Selection,
12
11
  Transaction,
13
12
  } from '@atlaskit/editor-prosemirror/state';
13
+ import { Selection } from '@atlaskit/editor-prosemirror/state';
14
14
  import { TableMap } from '@atlaskit/editor-tables/table-map';
15
15
  import {
16
16
  convertArrayOfRowsToTableNode,
@@ -22,7 +22,7 @@ import {
22
22
  } from '@atlaskit/editor-tables/utils';
23
23
 
24
24
  import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
25
- import { TablePluginState } from '../types';
25
+ import type { TablePluginState } from '../types';
26
26
 
27
27
  const createGetInlineCardTextFromStore = (
28
28
  attrs: CardAttributes,
@@ -1,5 +1,6 @@
1
- import { tableBackgroundColorPalette, TableLayout } from '@atlaskit/adf-schema';
2
- import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
3
+ import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
3
4
  import {
4
5
  ACTION_SUBJECT,
5
6
  EVENT_TYPE,
@@ -15,9 +16,9 @@ import type {
15
16
  Command,
16
17
  GetEditorContainerWidth,
17
18
  } from '@atlaskit/editor-common/types';
18
- import { Selection } from '@atlaskit/editor-prosemirror/state';
19
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
19
20
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
20
- import { Rect } from '@atlaskit/editor-tables/table-map';
21
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
21
22
  import {
22
23
  findCellClosestToPos,
23
24
  findCellRectClosestToPos,
@@ -43,9 +44,13 @@ import {
43
44
  } from './commands/toggle';
44
45
  import { getPluginState } from './pm-plugins/plugin-factory';
45
46
  import { distributeColumnsWidths } from './pm-plugins/table-resizing/commands';
46
- import { ResizeStateWithAnalytics } from './pm-plugins/table-resizing/utils';
47
+ import type { ResizeStateWithAnalytics } from './pm-plugins/table-resizing/utils';
47
48
  import { deleteColumns, deleteRows, mergeCells } from './transforms';
48
- import { InsertRowMethods, InsertRowOptions, RowInsertPosition } from './types';
49
+ import type {
50
+ InsertRowMethods,
51
+ InsertRowOptions,
52
+ RowInsertPosition,
53
+ } from './types';
49
54
  import {
50
55
  checkIfNumberColumnEnabled,
51
56
  getSelectedCellInfo,
@@ -1,21 +1,20 @@
1
1
  // #region Imports
2
- import { TableColumnOrdering, TableSortStep } from '@atlaskit/adf-schema/steps';
2
+ import { TableSortStep } from '@atlaskit/custom-steps';
3
+ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
3
4
  import { isTextInput } from '@atlaskit/editor-common/utils';
4
- import { NodeType } from '@atlaskit/editor-prosemirror/model';
5
+ import type { NodeType } from '@atlaskit/editor-prosemirror/model';
5
6
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
6
- import {
7
+ import type {
7
8
  ReadonlyTransaction,
8
9
  Transaction,
9
10
  } from '@atlaskit/editor-prosemirror/state';
10
- import {
11
- ContentNodeWithPos,
12
- findParentNodeOfType,
13
- } from '@atlaskit/editor-prosemirror/utils';
11
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
12
+ import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
14
13
  import { findTable } from '@atlaskit/editor-tables/utils';
15
14
 
16
15
  import { defaultTableSelection } from './pm-plugins/default-table-selection';
17
16
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
18
- import { TablePluginState } from './types';
17
+ import type { TablePluginState } from './types';
19
18
  import { isTableCollapsible } from './utils/collapse';
20
19
  import {
21
20
  checkIfHeaderColumnEnabled,
@@ -5,7 +5,7 @@ import classnames from 'classnames';
5
5
  import memoizeOne from 'memoize-one';
6
6
  import rafSchedule from 'raf-schd';
7
7
 
8
- import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
8
+ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
9
9
  import {
10
10
  ACTION_SUBJECT,
11
11
  EVENT_TYPE,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
3
+ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
6
6
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
@@ -2,7 +2,7 @@
2
2
  import { jsx } from '@emotion/react';
3
3
  import { defineMessages } from 'react-intl-next';
4
4
 
5
- import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
5
+ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
6
6
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
7
7
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import {
@@ -1,5 +1,5 @@
1
1
  import type { CellAttributes } from '@atlaskit/adf-schema';
2
- import { AddColumnStep } from '@atlaskit/adf-schema/steps';
2
+ import { AddColumnStep } from '@atlaskit/custom-steps';
3
3
  import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -6,7 +6,7 @@ import {
6
6
  tableHeaderSelector,
7
7
  tablePrefixSelector,
8
8
  } from '@atlaskit/adf-schema';
9
- import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
9
+ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
10
10
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
11
11
  import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
12
12
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
@@ -11,7 +11,7 @@ type DropdownItem = MenuItem & {
11
11
  };
12
12
  };
13
13
 
14
- import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
14
+ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
15
15
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
16
16
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
17
17
  import {
@@ -1,13 +1,13 @@
1
1
  import React, { Component } from 'react';
2
2
 
3
- import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
3
+ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
4
4
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
5
  import { browser } from '@atlaskit/editor-common/utils';
6
- import { Selection } from '@atlaskit/editor-prosemirror/state';
7
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
7
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
 
9
9
  import { hoverRows, selectRow } from '../../commands';
10
- import { RowStickyState } from '../../pm-plugins/sticky-headers';
10
+ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
11
11
  import { isSelectionUpdated } from '../../utils';
12
12
 
13
13
  import { CornerControls } from './CornerControls';
@@ -194,6 +194,50 @@ const breakoutWidthStyling = () => {
194
194
  `;
195
195
  };
196
196
 
197
+ const tableBorderStyles = (
198
+ props: ThemeProps & { featureFlags?: FeatureFlags },
199
+ ) => {
200
+ if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
201
+ return `border-color: ${tableBorderDeleteColor(props)}`;
202
+ } else {
203
+ return `border: 1px solid ${tableBorderDeleteColor(props)}`;
204
+ }
205
+ };
206
+
207
+ const tableStickyHeaderColumnControlsDecorationsStyle = (
208
+ props: ThemeProps & { featureFlags?: FeatureFlags },
209
+ ) => {
210
+ if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
211
+ return css`
212
+ .${ClassName.TABLE_STICKY} .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
213
+ z-index: 0;
214
+ left: -1px;
215
+ }
216
+
217
+ .${ClassName.TABLE_STICKY}
218
+ .${ClassName.COLUMN_CONTROLS_DECORATIONS}::after {
219
+ border-left: 1px solid ${tableBorderColor(props)};
220
+ }
221
+
222
+ .${ClassName.TABLE_STICKY}
223
+ tr:first-of-type
224
+ th.${ClassName.TABLE_HEADER_CELL} {
225
+ &.${ClassName.COLUMN_SELECTED}, &.${ClassName.HOVERED_COLUMN} {
226
+ .${ClassName.COLUMN_CONTROLS_DECORATIONS}::after {
227
+ left: 0;
228
+ }
229
+ }
230
+ }
231
+ `;
232
+ } else {
233
+ return css`
234
+ .${ClassName.TABLE_STICKY} .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
235
+ z-index: 0;
236
+ }
237
+ `;
238
+ }
239
+ };
240
+
197
241
  const tableWrapperStyles = () => {
198
242
  if (getBooleanFF('platform.editor.custom-table-width')) {
199
243
  return css`
@@ -323,9 +367,7 @@ export const tableStyles = (
323
367
  width: ${tableToolbarSize}px;
324
368
  }
325
369
 
326
- .${ClassName.TABLE_STICKY} .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
327
- z-index: 0;
328
- }
370
+ ${tableStickyHeaderColumnControlsDecorationsStyle(props)}
329
371
 
330
372
  .${ClassName.TABLE_STICKY}
331
373
  .${ClassName.ROW_CONTROLS}
@@ -798,7 +840,7 @@ export const tableStyles = (
798
840
  pointer-events: none;
799
841
  }
800
842
  &.${ClassName.HOVERED_CELL_IN_DANGER}::after {
801
- border: 1px solid ${tableBorderDeleteColor(props)};
843
+ ${tableBorderStyles(props)};
802
844
  z-index: ${akEditorUnitZIndex * 100};
803
845
  }
804
846
  }