@atlaskit/editor-plugin-table 1.3.1 → 1.4.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 (235) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/plugins/table/commands/misc.js +1 -2
  3. package/dist/cjs/plugins/table/index.js +25 -34
  4. package/dist/cjs/plugins/table/transforms/column-width.js +0 -17
  5. package/dist/cjs/plugins/table/transforms/delete-columns.js +4 -13
  6. package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -13
  7. package/dist/cjs/plugins/table/transforms/fix-tables.js +6 -24
  8. package/dist/cjs/plugins/table/transforms/index.js +0 -13
  9. package/dist/cjs/plugins/table/transforms/merge.js +5 -20
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/plugins/table/commands/misc.js +2 -3
  12. package/dist/es2019/plugins/table/index.js +21 -33
  13. package/dist/es2019/plugins/table/transforms/column-width.js +0 -17
  14. package/dist/es2019/plugins/table/transforms/delete-columns.js +4 -13
  15. package/dist/es2019/plugins/table/transforms/delete-rows.js +4 -13
  16. package/dist/es2019/plugins/table/transforms/fix-tables.js +0 -14
  17. package/dist/es2019/plugins/table/transforms/index.js +1 -2
  18. package/dist/es2019/plugins/table/transforms/merge.js +5 -21
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/plugins/table/commands/misc.js +2 -3
  21. package/dist/esm/plugins/table/index.js +25 -34
  22. package/dist/esm/plugins/table/transforms/column-width.js +0 -17
  23. package/dist/esm/plugins/table/transforms/delete-columns.js +4 -13
  24. package/dist/esm/plugins/table/transforms/delete-rows.js +4 -13
  25. package/dist/esm/plugins/table/transforms/fix-tables.js +0 -17
  26. package/dist/esm/plugins/table/transforms/index.js +1 -2
  27. package/dist/esm/plugins/table/transforms/merge.js +5 -21
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/plugins/table/index.d.ts +9 -0
  30. package/dist/types/plugins/table/transforms/fix-tables.d.ts +0 -1
  31. package/dist/types/plugins/table/transforms/index.d.ts +1 -2
  32. package/dist/types-ts4.5/i18n/cs.d.ts +35 -0
  33. package/dist/types-ts4.5/i18n/da.d.ts +33 -0
  34. package/dist/types-ts4.5/i18n/de.d.ts +33 -0
  35. package/dist/types-ts4.5/i18n/en.d.ts +35 -0
  36. package/dist/types-ts4.5/i18n/en_GB.d.ts +35 -0
  37. package/dist/types-ts4.5/i18n/es.d.ts +33 -0
  38. package/dist/types-ts4.5/i18n/fi.d.ts +33 -0
  39. package/dist/types-ts4.5/i18n/fr.d.ts +35 -0
  40. package/dist/types-ts4.5/i18n/hu.d.ts +35 -0
  41. package/dist/types-ts4.5/i18n/it.d.ts +35 -0
  42. package/dist/types-ts4.5/i18n/ja.d.ts +35 -0
  43. package/dist/types-ts4.5/i18n/ko.d.ts +33 -0
  44. package/dist/types-ts4.5/i18n/nb.d.ts +33 -0
  45. package/dist/types-ts4.5/i18n/nl.d.ts +35 -0
  46. package/dist/types-ts4.5/i18n/pl.d.ts +35 -0
  47. package/dist/types-ts4.5/i18n/pt_BR.d.ts +35 -0
  48. package/dist/types-ts4.5/i18n/ru.d.ts +35 -0
  49. package/dist/types-ts4.5/i18n/sv.d.ts +33 -0
  50. package/dist/types-ts4.5/i18n/th.d.ts +33 -0
  51. package/dist/types-ts4.5/i18n/tr.d.ts +35 -0
  52. package/dist/types-ts4.5/i18n/uk.d.ts +35 -0
  53. package/dist/types-ts4.5/i18n/vi.d.ts +33 -0
  54. package/dist/types-ts4.5/i18n/zh.d.ts +35 -0
  55. package/dist/types-ts4.5/i18n/zh_TW.d.ts +35 -0
  56. package/dist/types-ts4.5/index.d.ts +1 -0
  57. package/dist/types-ts4.5/plugins/table/commands/clear.d.ts +3 -0
  58. package/dist/types-ts4.5/plugins/table/commands/collapse.d.ts +2 -0
  59. package/dist/types-ts4.5/plugins/table/commands/go-to-next-cell.d.ts +4 -0
  60. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +8 -0
  61. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +8 -0
  62. package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +10 -0
  63. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +27 -0
  64. package/dist/types-ts4.5/plugins/table/commands/referentiality.d.ts +2 -0
  65. package/dist/types-ts4.5/plugins/table/commands/selection.d.ts +8 -0
  66. package/dist/types-ts4.5/plugins/table/commands/sort.d.ts +3 -0
  67. package/dist/types-ts4.5/plugins/table/commands/split-cell.d.ts +6 -0
  68. package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +12 -0
  69. package/dist/types-ts4.5/plugins/table/commands-with-analytics.d.ts +26 -0
  70. package/dist/types-ts4.5/plugins/table/create-plugin-config.d.ts +2 -0
  71. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +16 -0
  72. package/dist/types-ts4.5/plugins/table/handlers.d.ts +3 -0
  73. package/dist/types-ts4.5/plugins/table/index.d.ts +30 -0
  74. package/dist/types-ts4.5/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +25 -0
  75. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +73 -0
  76. package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +9 -0
  77. package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +9 -0
  78. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +34 -0
  79. package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +19 -0
  80. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +24 -0
  81. package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +8 -0
  82. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +7 -0
  83. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -0
  84. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +2 -0
  85. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +2 -0
  86. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +3 -0
  87. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +6 -0
  88. package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +4 -0
  89. package/dist/types-ts4.5/plugins/table/pm-plugins/keymap.d.ts +5 -0
  90. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +8 -0
  91. package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-factory.d.ts +1 -0
  92. package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
  93. package/dist/types-ts4.5/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +15 -0
  94. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/commands.d.ts +3 -0
  95. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +6 -0
  96. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +6 -0
  97. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +72 -0
  98. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +3 -0
  99. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -0
  100. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +4 -0
  101. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/types.d.ts +16 -0
  102. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/util.d.ts +2 -0
  103. package/dist/types-ts4.5/plugins/table/pm-plugins/table-local-id.d.ts +22 -0
  104. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +25 -0
  105. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +4 -0
  106. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/index.d.ts +4 -0
  107. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +4 -0
  108. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +3 -0
  109. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +6 -0
  110. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/reducer.d.ts +3 -0
  111. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +15 -0
  112. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +14 -0
  113. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +4 -0
  114. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +13 -0
  115. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +12 -0
  116. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +22 -0
  117. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -0
  118. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
  119. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +29 -0
  120. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +17 -0
  121. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +22 -0
  122. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +1 -0
  123. package/dist/types-ts4.5/plugins/table/pm-plugins/table-selection-keymap.d.ts +4 -0
  124. package/dist/types-ts4.5/plugins/table/reducer.d.ts +3 -0
  125. package/dist/types-ts4.5/plugins/table/toolbar.d.ts +37 -0
  126. package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +18 -0
  127. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +3 -0
  128. package/dist/types-ts4.5/plugins/table/transforms/delete-rows.d.ts +3 -0
  129. package/dist/types-ts4.5/plugins/table/transforms/fix-tables.d.ts +9 -0
  130. package/dist/types-ts4.5/plugins/table/transforms/index.d.ts +6 -0
  131. package/dist/types-ts4.5/plugins/table/transforms/merge.d.ts +5 -0
  132. package/dist/types-ts4.5/plugins/table/transforms/replace-table.d.ts +5 -0
  133. package/dist/types-ts4.5/plugins/table/transforms/split.d.ts +9 -0
  134. package/dist/types-ts4.5/plugins/table/types.d.ts +332 -0
  135. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/index.d.ts +29 -0
  136. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/styles.d.ts +3 -0
  137. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +88 -0
  138. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/index.d.ts +23 -0
  139. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -0
  140. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +14 -0
  141. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +10 -0
  142. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +54 -0
  143. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +1 -0
  144. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +12 -0
  145. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +3 -0
  146. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +35 -0
  147. package/dist/types-ts4.5/plugins/table/ui/LayoutButton/index.d.ts +21 -0
  148. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +16 -0
  149. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +21 -0
  150. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +17 -0
  151. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +40 -0
  152. package/dist/types-ts4.5/plugins/table/ui/common-styles.d.ts +8 -0
  153. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +39 -0
  154. package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +58 -0
  155. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +15 -0
  156. package/dist/types-ts4.5/plugins/table/utils/analytics.d.ts +18 -0
  157. package/dist/types-ts4.5/plugins/table/utils/collapse.d.ts +29 -0
  158. package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +10 -0
  159. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +16 -0
  160. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +20 -0
  161. package/dist/types-ts4.5/plugins/table/utils/get-allow-add-column-custom-step.d.ts +2 -0
  162. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +11 -0
  163. package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +12 -0
  164. package/dist/types-ts4.5/plugins/table/utils/paste.d.ts +14 -0
  165. package/dist/types-ts4.5/plugins/table/utils/row-controls.d.ts +16 -0
  166. package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +6 -0
  167. package/dist/types-ts4.5/plugins/table/utils/table.d.ts +4 -0
  168. package/dist/types-ts4.5/plugins/table/utils/update-plugin-state-decorations.d.ts +4 -0
  169. package/dist/types-ts4.5/plugins/table-plugin.d.ts +2 -0
  170. package/dist/types-ts4.5/types/i18n.d.ts +5 -0
  171. package/examples/99-testing.tsx +4 -94
  172. package/package.json +8 -6
  173. package/report.api.md +11 -0
  174. package/src/__tests__/unit/analytics.ts +6 -0
  175. package/src/__tests__/unit/collab.ts +6 -0
  176. package/src/__tests__/unit/color-picker.ts +4 -0
  177. package/src/__tests__/unit/commands/go-to-next-cell.ts +8 -1
  178. package/src/__tests__/unit/commands/insert.ts +6 -0
  179. package/src/__tests__/unit/commands/misc.ts +14 -6
  180. package/src/__tests__/unit/commands/sort.ts +19 -12
  181. package/src/__tests__/unit/commands.ts +10 -2
  182. package/src/__tests__/unit/copy-paste.ts +6 -0
  183. package/src/__tests__/unit/event-handlers/index.ts +13 -8
  184. package/src/__tests__/unit/event-handlers.ts +13 -1
  185. package/src/__tests__/unit/fix-tables.ts +8 -4
  186. package/src/__tests__/unit/get-toolbar-config.ts +4 -0
  187. package/src/__tests__/unit/handlers.ts +8 -1
  188. package/src/__tests__/unit/hover-selection.ts +8 -1
  189. package/src/__tests__/unit/index.ts +10 -2
  190. package/src/__tests__/unit/keymap.ts +10 -4
  191. package/src/__tests__/unit/layout.ts +4 -0
  192. package/src/__tests__/unit/nodeviews/cell.ts +6 -0
  193. package/src/__tests__/unit/nodeviews/table.ts +16 -9
  194. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +14 -4
  195. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +8 -1
  196. package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +4 -0
  197. package/src/__tests__/unit/pm-plugins/main.ts +6 -0
  198. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +8 -4
  199. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +13 -4
  200. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +6 -0
  201. package/src/__tests__/unit/pm-plugins/table-selection-keymap.ts +6 -0
  202. package/src/__tests__/unit/sort-column.ts +6 -0
  203. package/src/__tests__/unit/toolbar.ts +16 -9
  204. package/src/__tests__/unit/transforms/delete-columns.ts +8 -1
  205. package/src/__tests__/unit/transforms/delete-rows.ts +8 -1
  206. package/src/__tests__/unit/transforms/merging.ts +8 -1
  207. package/src/__tests__/unit/ui/ContextualMenu.tsx +8 -4
  208. package/src/__tests__/unit/ui/CornerControls.tsx +8 -1
  209. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +8 -1
  210. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +8 -1
  211. package/src/__tests__/unit/ui/RowControls.tsx +8 -1
  212. package/src/__tests__/unit/ui/TableFloatingControls.tsx +8 -1
  213. package/src/__tests__/unit/undo-redo.ts +6 -0
  214. package/src/__tests__/unit/utils/collapse.ts +4 -0
  215. package/src/__tests__/unit/utils/nodes.ts +8 -1
  216. package/src/__tests__/unit/utils/row-controls.ts +8 -1
  217. package/src/__tests__/unit/utils.ts +8 -1
  218. package/src/plugins/table/commands/misc.ts +2 -4
  219. package/src/plugins/table/index.tsx +39 -40
  220. package/src/plugins/table/transforms/column-width.ts +0 -11
  221. package/src/plugins/table/transforms/delete-columns.ts +4 -5
  222. package/src/plugins/table/transforms/delete-rows.ts +4 -7
  223. package/src/plugins/table/transforms/fix-tables.ts +0 -17
  224. package/src/plugins/table/transforms/index.ts +1 -2
  225. package/src/plugins/table/transforms/merge.ts +9 -20
  226. package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +0 -79
  227. package/dist/cjs/plugins/table/transforms/metadata.js +0 -20
  228. package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +0 -71
  229. package/dist/es2019/plugins/table/transforms/metadata.js +0 -12
  230. package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +0 -71
  231. package/dist/esm/plugins/table/transforms/metadata.js +0 -14
  232. package/dist/types/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts +0 -4
  233. package/dist/types/plugins/table/transforms/metadata.d.ts +0 -21
  234. package/src/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.ts +0 -78
  235. package/src/plugins/table/transforms/metadata.ts +0 -35
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+ - Updated dependencies
9
+
10
+ ## 1.4.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`8a391616ecc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8a391616ecc) - Moving insert node API to a new editor plugin to allow it to be more extensible. Also exposing a new editor plugin action for tables to allow for consistent insertion.
15
+
16
+ ### Patch Changes
17
+
18
+ - [`5cc449dac8d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5cc449dac8d) - Decouple card plugin so that it uses new NextEditorPlugin for any injected dependencies.
19
+ - [`b804d3ad561`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b804d3ad561) - Remove unused code related to GASv2 table analytics from editor-plugin table, editor-core and editor-common
20
+ - [`6550d08f5af`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6550d08f5af) - [ux] Color picker button should not be focused after selecting color.
21
+ - [`f621ae6490a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f621ae6490a) - Adding type dependency on analytics plugin to tables plugin.
22
+ - [`a142ba1aa28`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a142ba1aa28) - [ED17172] Bump prosemirror-model to 1.16.0 and prosemirror-view to 1.23.7 and removed work-arounds for fixed issues
23
+ - Updated dependencies
24
+
3
25
  ## 1.3.1
4
26
 
5
27
  ### Patch Changes
@@ -275,9 +275,8 @@ var setMultipleCellAttrs = function setMultipleCellAttrs(attrs, targetCellPositi
275
275
  cursorPos = cell.pos;
276
276
  }
277
277
  if (tr.docChanged && cursorPos !== undefined) {
278
- var $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
279
278
  if (dispatch) {
280
- dispatch(tr.setSelection(_prosemirrorState.Selection.near($pos)));
279
+ dispatch(tr);
281
280
  }
282
281
  return true;
283
282
  }
@@ -18,7 +18,6 @@ var _messages = require("@atlaskit/editor-common/messages");
18
18
  var _icons = require("@atlaskit/editor-common/icons");
19
19
  var _createPluginConfig = require("./create-plugin-config");
20
20
  var _tableLocalId = require("./pm-plugins/table-local-id");
21
- var _safariDelayedDomSelectionSyncingWorkaround = require("./pm-plugins/safari-delayed-dom-selection-syncing-workaround");
22
21
  var _safariDeleteCompositionTextIssueWorkaround = require("./pm-plugins/safari-delete-composition-text-issue-workaround");
23
22
  var _plugin = require("./pm-plugins/decorations/plugin");
24
23
  var _keymap = require("./pm-plugins/keymap");
@@ -38,7 +37,7 @@ var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
38
37
  var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
39
38
  return {};
40
39
  };
41
- var tablesPlugin = function tablesPlugin(options) {
40
+ var tablesPlugin = function tablesPlugin(options, api) {
42
41
  var editorViewRef = {
43
42
  current: null
44
43
  };
@@ -58,6 +57,25 @@ var tablesPlugin = function tablesPlugin(options) {
58
57
  };
59
58
  return {
60
59
  name: 'table',
60
+ actions: {
61
+ insertTable: function insertTable(analyticsPayload) {
62
+ return function (state, dispatch) {
63
+ var _api$dependencies$con, _api$dependencies, _api$dependencies$con2, _api$dependencies$con3;
64
+ var node = (0, _utils2.createTable)({
65
+ schema: state.schema
66
+ });
67
+ return (_api$dependencies$con = api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$con2 = _api$dependencies.contentInsertion) === null || _api$dependencies$con2 === void 0 ? void 0 : (_api$dependencies$con3 = _api$dependencies$con2.actions) === null || _api$dependencies$con3 === void 0 ? void 0 : _api$dependencies$con3.insert({
68
+ state: state,
69
+ dispatch: dispatch,
70
+ node: node,
71
+ options: {
72
+ selectNodeInserted: false,
73
+ analyticsPayload: analyticsPayload
74
+ }
75
+ })) !== null && _api$dependencies$con !== void 0 ? _api$dependencies$con : false;
76
+ };
77
+ }
78
+ },
61
79
  nodes: function nodes() {
62
80
  return [{
63
81
  name: 'table',
@@ -81,7 +99,9 @@ var tablesPlugin = function tablesPlugin(options) {
81
99
  dispatch = _ref.dispatch,
82
100
  portalProviderAPI = _ref.portalProviderAPI,
83
101
  eventDispatcher = _ref.eventDispatcher;
84
- var _ref2 = options || {},
102
+ var _ref2 = options || {
103
+ editorAnalyticsAPI: api === null || api === void 0 ? void 0 : api.dependencies.analytics.actions
104
+ },
85
105
  fullWidthEnabled = _ref2.fullWidthEnabled,
86
106
  wasFullWidthEnabled = _ref2.wasFullWidthEnabled,
87
107
  breakoutEnabled = _ref2.breakoutEnabled,
@@ -175,21 +195,6 @@ var tablesPlugin = function tablesPlugin(options) {
175
195
  }
176
196
  }];
177
197
 
178
- // workaround for prosemirrors delayed dom selection syncing during pointer drag
179
- // causing issues with table selections in Safari
180
- // https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
181
-
182
- // NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
183
- // https://github.com/ProseMirror/prosemirror-view/pull/116
184
- if (_utils.browser.safari) {
185
- plugins.push({
186
- name: 'tableSafariDelayedDomSelectionSyncingWorkaround',
187
- plugin: function plugin() {
188
- return (0, _safariDelayedDomSelectionSyncingWorkaround.createPlugin)();
189
- }
190
- });
191
- }
192
-
193
198
  // Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
194
199
  // https://github.com/ProseMirror/prosemirror/issues/934
195
200
  if (_utils.browser.safari) {
@@ -300,22 +305,8 @@ var tablesPlugin = function tablesPlugin(options) {
300
305
  }));
301
306
  },
302
307
  pluginsOptions: {
303
- // TODO: ED-14676 This is not the final API design
304
- // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
305
- createNodeHandler: function createNodeHandler(_ref11) {
306
- var nodeName = _ref11.nodeName,
307
- schema = _ref11.schema;
308
- // An EditorPlugin may manage more than one node.
309
- if (nodeName !== 'table') {
310
- return null;
311
- }
312
- var table = (0, _utils2.createTable)({
313
- schema: schema
314
- });
315
- return table;
316
- },
317
- quickInsert: function quickInsert(_ref12) {
318
- var formatMessage = _ref12.formatMessage;
308
+ quickInsert: function quickInsert(_ref11) {
309
+ var formatMessage = _ref11.formatMessage;
319
310
  return [{
320
311
  id: 'table',
321
312
  title: formatMessage(_messages.toolbarInsertBlockMessages.table),
@@ -10,7 +10,6 @@ var _tableMap = require("@atlaskit/editor-tables/table-map");
10
10
  var _styles = require("@atlaskit/editor-common/styles");
11
11
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
12
  var _utils = require("../pm-plugins/table-resizing/utils");
13
- var _metadata = require("./metadata");
14
13
  var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
15
14
  var _misc = require("../pm-plugins/table-resizing/utils/misc");
16
15
  var _scaleTable = require("../pm-plugins/table-resizing/utils/scale-table");
@@ -32,14 +31,6 @@ var updateColumnWidths = function updateColumnWidths(resizeState, table, start)
32
31
  var attrs = updatedCellsAttrs[cellPos] || _objectSpread({}, table.nodeAt(cellPos).attrs);
33
32
  var colspan = attrs.colspan || 1;
34
33
  if (attrs.colwidth && attrs.colwidth.length > colspan) {
35
- tr = (0, _metadata.setMeta)({
36
- type: 'UPDATE_COLUMN_WIDTHS',
37
- problem: 'COLWIDTHS_BEFORE_UPDATE',
38
- data: {
39
- colwidths: attrs.colwidth,
40
- colspan: colspan
41
- }
42
- })(tr);
43
34
  attrs.colwidth = attrs.colwidth.slice(0, colspan);
44
35
  }
45
36
 
@@ -58,14 +49,6 @@ var updateColumnWidths = function updateColumnWidths(resizeState, table, start)
58
49
  });
59
50
  colwidths[colspanIndex] = width;
60
51
  if (colwidths.length > colspan) {
61
- tr = (0, _metadata.setMeta)({
62
- type: 'UPDATE_COLUMN_WIDTHS',
63
- problem: 'COLWIDTHS_AFTER_UPDATE',
64
- data: {
65
- colwidths: colwidths,
66
- colspan: colspan
67
- }
68
- })(tr);
69
52
  colwidths = colwidths.slice(0, colspan);
70
53
  }
71
54
  updatedCellsAttrs[cellPos] = _objectSpread(_objectSpread({}, attrs), {}, {
@@ -11,7 +11,6 @@ var _prosemirrorState = require("prosemirror-state");
11
11
  var _tableMap = require("@atlaskit/editor-tables/table-map");
12
12
  var _utils = require("@atlaskit/editor-tables/utils");
13
13
  var _steps = require("@atlaskit/adf-schema/steps");
14
- var _metadata = require("./metadata");
15
14
  var _split = require("./split");
16
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -140,25 +139,17 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
140
139
  }
141
140
  }
142
141
  if (!rows.length) {
143
- return (0, _metadata.setMeta)({
144
- type: 'DELETE_COLUMNS',
145
- problem: 'EMPTY_TABLE'
146
- })(tr);
142
+ return tr;
147
143
  }
148
144
  var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
149
145
  var fixedTable = fixRowSpans(newTable);
150
146
  if (fixedTable === null) {
151
- return (0, _metadata.setMeta)({
152
- type: 'DELETE_COLUMNS',
153
- problem: 'FIX_ROWSPANS'
154
- })(tr);
147
+ return tr;
155
148
  }
156
149
  var cursorPos = getNextCursorPos(newTable, columnsToDelete);
157
- return (0, _metadata.setMeta)({
158
- type: 'DELETE_COLUMNS'
159
- })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
150
+ return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
160
151
  // move cursor to the left of the deleted columns if possible, otherwise - to the first column
161
- .setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.pos + cursorPos))));
152
+ .setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.pos + cursorPos)));
162
153
  };
163
154
  };
164
155
  function getNextCursorPos(table, deletedColumns) {
@@ -11,7 +11,6 @@ var _prosemirrorState = require("prosemirror-state");
11
11
  var _tableMap = require("@atlaskit/editor-tables/table-map");
12
12
  var _utils = require("@atlaskit/editor-tables/utils");
13
13
  var _merge = require("./merge");
14
- var _metadata = require("./metadata");
15
14
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
16
  var deleteRows = function deleteRows(rect) {
@@ -108,25 +107,17 @@ var deleteRows = function deleteRows(rect) {
108
107
  _loop(rowIndex);
109
108
  }
110
109
  if (!rows.length) {
111
- return (0, _metadata.setMeta)({
112
- type: 'DELETE_ROWS',
113
- problem: 'EMPTY_TABLE'
114
- })(tr);
110
+ return tr;
115
111
  }
116
112
  var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
117
113
  var fixedTable = (0, _merge.mergeEmptyColumns)(newTable);
118
114
  if (fixedTable === null) {
119
- return (0, _metadata.setMeta)({
120
- type: 'DELETE_ROWS',
121
- problem: 'REMOVE_EMPTY_COLUMNS'
122
- })(tr);
115
+ return tr;
123
116
  }
124
117
  var cursorPos = getNextCursorPos(newTable, rowsToDelete);
125
- return (0, _metadata.setMeta)({
126
- type: 'DELETE_ROWS'
127
- })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
118
+ return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
128
119
  // move cursor before the deleted rows if possible, otherwise - to the first row
129
- .setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.pos + cursorPos))));
120
+ .setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.pos + cursorPos)));
130
121
  };
131
122
  };
132
123
  exports.deleteRows = deleteRows;
@@ -4,28 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.removeExtraneousColumnWidths = exports.fixTables = exports.fixAutoSizedTable = exports.fireAnalytics = void 0;
7
+ exports.removeExtraneousColumnWidths = exports.fixTables = exports.fixAutoSizedTable = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _styles = require("@atlaskit/editor-common/styles");
10
10
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
11
- var _utils = require("@atlaskit/editor-common/utils");
12
- var _utils2 = require("../pm-plugins/table-resizing/utils");
11
+ var _utils = require("../pm-plugins/table-resizing/utils");
13
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
13
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
- var fireAnalytics = function fireAnalytics() {
16
- var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
- return (0, _utils.sendLogs)({
18
- events: [{
19
- name: 'atlaskit.fabric.editor.fixtable',
20
- product: 'atlaskit',
21
- properties: properties,
22
- serverTime: new Date().getTime(),
23
- server: 'local',
24
- user: '-'
25
- }]
26
- });
27
- };
28
- exports.fireAnalytics = fireAnalytics;
29
14
  var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, reportInvalidTableCellSpanAttrs) {
30
15
  var colspan = _ref.colspan,
31
16
  rowspan = _ref.rowspan,
@@ -81,9 +66,6 @@ var removeExtraneousColumnWidths = function removeExtraneousColumnWidths(node, b
81
66
  return cell;
82
67
  });
83
68
  if (hasProblems) {
84
- fireAnalytics({
85
- message: 'removeExtraneousColumnWidths'
86
- });
87
69
  return true;
88
70
  }
89
71
  return false;
@@ -123,7 +105,7 @@ var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, tableRef, ta
123
105
  return acc + current;
124
106
  }, 0);
125
107
  var tableLayout = getLayoutBasedOnWidth(totalContentWidth);
126
- var maxLayoutSize = (0, _utils2.getLayoutSize)(tableLayout, opts.containerWidth, {});
108
+ var maxLayoutSize = (0, _utils.getLayoutSize)(tableLayout, opts.containerWidth, {});
127
109
 
128
110
  // Content width will generally not meet the constraints of the layout
129
111
  // whether it be below or above, so we scale our columns widths
@@ -169,9 +151,9 @@ function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
169
151
  var colspan = Number(currentCol.getAttribute('colspan') || 1);
170
152
  for (var span = 0; span < colspan; span++) {
171
153
  var colIdx = col + span;
172
- var cells = (0, _utils2.getCellsRefsInColumn)(colIdx, tableNode, tableStart, domAtPos);
173
- var colWidth = (0, _utils2.calculateColumnWidth)(cells, function (_, col) {
174
- return (0, _utils2.contentWidth)(col, tableRef).width;
154
+ var cells = (0, _utils.getCellsRefsInColumn)(colIdx, tableNode, tableStart, domAtPos);
155
+ var colWidth = (0, _utils.calculateColumnWidth)(cells, function (_, col) {
156
+ return (0, _utils.contentWidth)(col, tableRef).width;
175
157
  });
176
158
  cols[colIdx] = Math.max(colWidth, _styles.tableCellMinWidth);
177
159
  }
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "deleteRows", {
21
21
  return _deleteRows.deleteRows;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "fireAnalytics", {
25
- enumerable: true,
26
- get: function get() {
27
- return _fixTables.fireAnalytics;
28
- }
29
- });
30
24
  Object.defineProperty(exports, "fixAutoSizedTable", {
31
25
  enumerable: true,
32
26
  get: function get() {
@@ -57,12 +51,6 @@ Object.defineProperty(exports, "replaceSelectedTable", {
57
51
  return _replaceTable.replaceSelectedTable;
58
52
  }
59
53
  });
60
- Object.defineProperty(exports, "setMeta", {
61
- enumerable: true,
62
- get: function get() {
63
- return _metadata.setMeta;
64
- }
65
- });
66
54
  Object.defineProperty(exports, "updateColumnWidths", {
67
55
  enumerable: true,
68
56
  get: function get() {
@@ -74,5 +62,4 @@ var _merge = require("./merge");
74
62
  var _deleteColumns = require("./delete-columns");
75
63
  var _deleteRows = require("./delete-rows");
76
64
  var _columnWidth = require("./column-width");
77
- var _metadata = require("./metadata");
78
65
  var _replaceTable = require("./replace-table");
@@ -13,7 +13,6 @@ var _prosemirrorState = require("prosemirror-state");
13
13
  var _tableMap = require("@atlaskit/editor-tables/table-map");
14
14
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
15
15
  var _utils = require("@atlaskit/editor-tables/utils");
16
- var _metadata = require("./metadata");
17
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
18
  // re-creates table node with merged cells
@@ -60,10 +59,7 @@ function mergeCells(tr) {
60
59
  }
61
60
  var rowspan = rect.bottom - rect.top;
62
61
  if (rowspan < 1) {
63
- return (0, _metadata.setMeta)({
64
- type: 'MERGE_CELLS',
65
- problem: 'NEGATIVE_ROWSPAN'
66
- })(tr);
62
+ return tr;
67
63
  }
68
64
  // update colspan and rowspan of the merged cell to span the selection
69
65
  var attrs = addColSpan(_objectSpread(_objectSpread({}, cell.attrs), {}, {
@@ -91,10 +87,7 @@ function mergeCells(tr) {
91
87
  if (_rowspan && _rowspan + _i - 1 >= rows.length) {
92
88
  rowChanged = true;
93
89
  if (_rowspan < 2) {
94
- return (0, _metadata.setMeta)({
95
- type: 'MERGE_CELLS',
96
- problem: 'NEGATIVE_ROWSPAN'
97
- })(tr);
90
+ return tr;
98
91
  }
99
92
  cells.push(_cell.type.createChecked(_objectSpread(_objectSpread({}, _cell.attrs), {}, {
100
93
  rowspan: _rowspan - 1
@@ -112,22 +105,14 @@ function mergeCells(tr) {
112
105
 
113
106
  // empty tables? cancel merging like nothing happened
114
107
  if (!rows.length) {
115
- return (0, _metadata.setMeta)({
116
- type: 'MERGE_CELLS',
117
- problem: 'EMPTY_TABLE'
118
- })(tr);
108
+ return tr;
119
109
  }
120
110
  var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
121
111
  var fixedTable = mergeEmptyColumns(newTable);
122
112
  if (fixedTable === null) {
123
- return (0, _metadata.setMeta)({
124
- type: 'MERGE_CELLS',
125
- problem: 'REMOVE_EMPTY_COLUMNS'
126
- })(tr);
113
+ return tr;
127
114
  }
128
- return (0, _metadata.setMeta)({
129
- type: 'MERGE_CELLS'
130
- })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable).setSelection(_prosemirrorState.Selection.near(tr.doc.resolve((mergedCellPos || 0) + table.start))));
115
+ return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable).setSelection(_prosemirrorState.Selection.near(tr.doc.resolve((mergedCellPos || 0) + table.start)));
131
116
  }
132
117
  function canMergeCells(tr) {
133
118
  var selection = tr.selection;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,6 @@
1
1
  // #region Imports
2
2
 
3
- import { Selection, TextSelection } from 'prosemirror-state';
3
+ import { TextSelection } from 'prosemirror-state';
4
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
5
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
6
  import { selectionCell, findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, removeTable, selectColumn as selectColumnTransform, selectRow as selectRowTransform, setCellAttrs, isTableSelected } from '@atlaskit/editor-tables/utils';
@@ -270,9 +270,8 @@ export const setMultipleCellAttrs = (attrs, targetCellPosition) => (state, dispa
270
270
  cursorPos = cell.pos;
271
271
  }
272
272
  if (tr.docChanged && cursorPos !== undefined) {
273
- const $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
274
273
  if (dispatch) {
275
- dispatch(tr.setSelection(Selection.near($pos)));
274
+ dispatch(tr);
276
275
  }
277
276
  return true;
278
277
  }
@@ -11,7 +11,6 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
11
11
  import { IconTable } from '@atlaskit/editor-common/icons';
12
12
  import { pluginConfig } from './create-plugin-config';
13
13
  import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
14
- import { createPlugin as createTableSafariDelayedDomSelectionSyncingWorkaroundPlugin } from './pm-plugins/safari-delayed-dom-selection-syncing-workaround';
15
14
  import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
16
15
  import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
17
16
  import { keymapPlugin } from './pm-plugins/keymap';
@@ -29,7 +28,7 @@ import LayoutButton from './ui/LayoutButton';
29
28
  import { isLayoutSupported } from './utils';
30
29
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
31
30
  const defaultGetEditorFeatureFlags = () => ({});
32
- const tablesPlugin = options => {
31
+ const tablesPlugin = (options, api) => {
33
32
  const editorViewRef = {
34
33
  current: null
35
34
  };
@@ -53,6 +52,23 @@ const tablesPlugin = options => {
53
52
  };
54
53
  return {
55
54
  name: 'table',
55
+ actions: {
56
+ insertTable: analyticsPayload => (state, dispatch) => {
57
+ var _api$dependencies$con, _api$dependencies, _api$dependencies$con2, _api$dependencies$con3;
58
+ const node = createTable({
59
+ schema: state.schema
60
+ });
61
+ return (_api$dependencies$con = api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$con2 = _api$dependencies.contentInsertion) === null || _api$dependencies$con2 === void 0 ? void 0 : (_api$dependencies$con3 = _api$dependencies$con2.actions) === null || _api$dependencies$con3 === void 0 ? void 0 : _api$dependencies$con3.insert({
62
+ state,
63
+ dispatch,
64
+ node,
65
+ options: {
66
+ selectNodeInserted: false,
67
+ analyticsPayload
68
+ }
69
+ })) !== null && _api$dependencies$con !== void 0 ? _api$dependencies$con : false;
70
+ }
71
+ },
56
72
  nodes() {
57
73
  return [{
58
74
  name: 'table',
@@ -84,7 +100,9 @@ const tablesPlugin = options => {
84
100
  tableOptions,
85
101
  editorAnalyticsAPI,
86
102
  getEditorFeatureFlags
87
- } = options || {};
103
+ } = options || {
104
+ editorAnalyticsAPI: api === null || api === void 0 ? void 0 : api.dependencies.analytics.actions
105
+ };
88
106
  return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
89
107
  }
90
108
  }, {
@@ -164,21 +182,6 @@ const tablesPlugin = options => {
164
182
  }
165
183
  }];
166
184
 
167
- // workaround for prosemirrors delayed dom selection syncing during pointer drag
168
- // causing issues with table selections in Safari
169
- // https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
170
-
171
- // NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
172
- // https://github.com/ProseMirror/prosemirror-view/pull/116
173
- if (browser.safari) {
174
- plugins.push({
175
- name: 'tableSafariDelayedDomSelectionSyncingWorkaround',
176
- plugin: () => {
177
- return createTableSafariDelayedDomSelectionSyncingWorkaroundPlugin();
178
- }
179
- });
180
- }
181
-
182
185
  // Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
183
186
  // https://github.com/ProseMirror/prosemirror/issues/934
184
187
  if (browser.safari) {
@@ -296,21 +299,6 @@ const tablesPlugin = options => {
296
299
  }));
297
300
  },
298
301
  pluginsOptions: {
299
- // TODO: ED-14676 This is not the final API design
300
- // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
301
- createNodeHandler: ({
302
- nodeName,
303
- schema
304
- }) => {
305
- // An EditorPlugin may manage more than one node.
306
- if (nodeName !== 'table') {
307
- return null;
308
- }
309
- const table = createTable({
310
- schema
311
- });
312
- return table;
313
- },
314
302
  quickInsert: ({
315
303
  formatMessage
316
304
  }) => [{
@@ -2,7 +2,6 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
2
2
  import { tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
4
4
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
5
- import { setMeta } from './metadata';
6
5
  import { getResizeState, normaliseTableLayout } from '../pm-plugins/table-resizing/utils/resize-state';
7
6
  import { getTableMaxWidth } from '../pm-plugins/table-resizing/utils/misc';
8
7
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
@@ -26,14 +25,6 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
26
25
  };
27
26
  const colspan = attrs.colspan || 1;
28
27
  if (attrs.colwidth && attrs.colwidth.length > colspan) {
29
- tr = setMeta({
30
- type: 'UPDATE_COLUMN_WIDTHS',
31
- problem: 'COLWIDTHS_BEFORE_UPDATE',
32
- data: {
33
- colwidths: attrs.colwidth,
34
- colspan
35
- }
36
- })(tr);
37
28
  attrs.colwidth = attrs.colwidth.slice(0, colspan);
38
29
  }
39
30
 
@@ -50,14 +41,6 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
50
41
  }, _ => 0);
51
42
  colwidths[colspanIndex] = width;
52
43
  if (colwidths.length > colspan) {
53
- tr = setMeta({
54
- type: 'UPDATE_COLUMN_WIDTHS',
55
- problem: 'COLWIDTHS_AFTER_UPDATE',
56
- data: {
57
- colwidths,
58
- colspan
59
- }
60
- })(tr);
61
44
  colwidths = colwidths.slice(0, colspan);
62
45
  }
63
46
  updatedCellsAttrs[cellPos] = {
@@ -2,7 +2,6 @@ import { Selection } from 'prosemirror-state';
2
2
  import { TableMap } from '@atlaskit/editor-tables/table-map';
3
3
  import { findTable } from '@atlaskit/editor-tables/utils';
4
4
  import { AddColumnStep } from '@atlaskit/adf-schema/steps';
5
- import { setMeta } from './metadata';
6
5
  import { splitCellsInColumns } from './split';
7
6
  const deleteColumnsCustomStep = rect => tr => {
8
7
  const table = findTable(tr.selection);
@@ -124,25 +123,17 @@ const deleteColumnsLegacy = rect => tr => {
124
123
  }
125
124
  }
126
125
  if (!rows.length) {
127
- return setMeta({
128
- type: 'DELETE_COLUMNS',
129
- problem: 'EMPTY_TABLE'
130
- })(tr);
126
+ return tr;
131
127
  }
132
128
  const newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
133
129
  const fixedTable = fixRowSpans(newTable);
134
130
  if (fixedTable === null) {
135
- return setMeta({
136
- type: 'DELETE_COLUMNS',
137
- problem: 'FIX_ROWSPANS'
138
- })(tr);
131
+ return tr;
139
132
  }
140
133
  const cursorPos = getNextCursorPos(newTable, columnsToDelete);
141
- return setMeta({
142
- type: 'DELETE_COLUMNS'
143
- })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
134
+ return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
144
135
  // move cursor to the left of the deleted columns if possible, otherwise - to the first column
145
- .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))));
136
+ .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
146
137
  };
147
138
  function getNextCursorPos(table, deletedColumns) {
148
139
  const minColumn = Math.min(...deletedColumns);
@@ -2,7 +2,6 @@ import { Selection } from 'prosemirror-state';
2
2
  import { TableMap } from '@atlaskit/editor-tables/table-map';
3
3
  import { findTable } from '@atlaskit/editor-tables/utils';
4
4
  import { mergeEmptyColumns } from './merge';
5
- import { setMeta } from './metadata';
6
5
  export const deleteRows = (rect, isHeaderRowRequired = false) => tr => {
7
6
  const table = findTable(tr.selection);
8
7
  if (!table) {
@@ -90,25 +89,17 @@ export const deleteRows = (rect, isHeaderRowRequired = false) => tr => {
90
89
  }
91
90
  }
92
91
  if (!rows.length) {
93
- return setMeta({
94
- type: 'DELETE_ROWS',
95
- problem: 'EMPTY_TABLE'
96
- })(tr);
92
+ return tr;
97
93
  }
98
94
  const newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
99
95
  const fixedTable = mergeEmptyColumns(newTable);
100
96
  if (fixedTable === null) {
101
- return setMeta({
102
- type: 'DELETE_ROWS',
103
- problem: 'REMOVE_EMPTY_COLUMNS'
104
- })(tr);
97
+ return tr;
105
98
  }
106
99
  const cursorPos = getNextCursorPos(newTable, rowsToDelete);
107
- return setMeta({
108
- type: 'DELETE_ROWS'
109
- })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
100
+ return tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
110
101
  // move cursor before the deleted rows if possible, otherwise - to the first row
111
- .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))));
102
+ .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
112
103
  };
113
104
  function getNextCursorPos(table, deletedRows) {
114
105
  const minRow = Math.min(...deletedRows);