@atlaskit/editor-plugin-table 1.1.0 → 1.1.2

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 (284) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +0 -2
  3. package/dist/cjs/plugins/table/commands/clear.js +4 -16
  4. package/dist/cjs/plugins/table/commands/collapse.js +0 -6
  5. package/dist/cjs/plugins/table/commands/go-to-next-cell.js +7 -18
  6. package/dist/cjs/plugins/table/commands/hover.js +7 -37
  7. package/dist/cjs/plugins/table/commands/index.js +0 -8
  8. package/dist/cjs/plugins/table/commands/insert.js +17 -56
  9. package/dist/cjs/plugins/table/commands/misc.js +36 -132
  10. package/dist/cjs/plugins/table/commands/referentiality.js +0 -4
  11. package/dist/cjs/plugins/table/commands/selection.js +21 -87
  12. package/dist/cjs/plugins/table/commands/sort.js +2 -23
  13. package/dist/cjs/plugins/table/commands/split-cell.js +3 -11
  14. package/dist/cjs/plugins/table/commands/toggle.js +8 -34
  15. package/dist/cjs/plugins/table/commands-with-analytics.js +50 -139
  16. package/dist/cjs/plugins/table/create-plugin-config.js +0 -6
  17. package/dist/cjs/plugins/table/event-handlers.js +58 -160
  18. package/dist/cjs/plugins/table/handlers.js +10 -39
  19. package/dist/cjs/plugins/table/index.js +47 -91
  20. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -41
  21. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +82 -188
  22. package/dist/cjs/plugins/table/nodeviews/table.js +12 -70
  23. package/dist/cjs/plugins/table/nodeviews/tableCell.js +15 -39
  24. package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +3 -15
  25. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +0 -18
  26. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -27
  27. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -20
  28. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -3
  29. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +0 -3
  30. package/dist/cjs/plugins/table/pm-plugins/keymap.js +2 -15
  31. package/dist/cjs/plugins/table/pm-plugins/main.js +20 -72
  32. package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +25 -42
  33. package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +0 -2
  34. package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -8
  35. package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +4 -23
  36. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +0 -5
  37. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +0 -5
  38. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -13
  39. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +56 -138
  40. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +0 -2
  41. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -30
  42. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +0 -6
  43. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +0 -5
  44. package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +13 -44
  45. package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +12 -42
  46. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -52
  47. package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +0 -4
  48. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -10
  49. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +0 -2
  50. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin.js +5 -19
  51. package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +0 -10
  52. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -15
  53. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -28
  54. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/content-width.js +3 -23
  55. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -46
  56. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +0 -9
  57. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -36
  58. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +1 -4
  59. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -71
  60. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -82
  61. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -36
  62. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +0 -2
  63. package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +0 -5
  64. package/dist/cjs/plugins/table/reducer.js +0 -24
  65. package/dist/cjs/plugins/table/toolbar.js +14 -94
  66. package/dist/cjs/plugins/table/transforms/column-width.js +12 -45
  67. package/dist/cjs/plugins/table/transforms/delete-columns.js +11 -76
  68. package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -42
  69. package/dist/cjs/plugins/table/transforms/fix-tables.js +24 -61
  70. package/dist/cjs/plugins/table/transforms/index.js +0 -7
  71. package/dist/cjs/plugins/table/transforms/merge.js +14 -90
  72. package/dist/cjs/plugins/table/transforms/metadata.js +0 -5
  73. package/dist/cjs/plugins/table/transforms/replace-table.js +2 -13
  74. package/dist/cjs/plugins/table/transforms/split.js +18 -32
  75. package/dist/cjs/plugins/table/types.js +0 -11
  76. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -51
  77. package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +0 -12
  78. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -145
  79. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +12 -35
  80. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +0 -11
  81. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -12
  82. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -16
  83. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +19 -89
  84. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -31
  85. package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -22
  86. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +25 -80
  87. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +16 -64
  88. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -47
  89. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -48
  90. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -43
  91. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +33 -74
  92. package/dist/cjs/plugins/table/ui/common-styles.js +6 -19
  93. package/dist/cjs/plugins/table/ui/consts.js +3 -8
  94. package/dist/cjs/plugins/table/ui/messages.js +0 -3
  95. package/dist/cjs/plugins/table/ui/ui-styles.js +0 -32
  96. package/dist/cjs/plugins/table/utils/analytics.js +4 -19
  97. package/dist/cjs/plugins/table/utils/collapse.js +4 -21
  98. package/dist/cjs/plugins/table/utils/column-controls.js +25 -61
  99. package/dist/cjs/plugins/table/utils/decoration.js +46 -114
  100. package/dist/cjs/plugins/table/utils/dom.js +4 -51
  101. package/dist/cjs/plugins/table/utils/get-allow-add-column-custom-step.js +0 -2
  102. package/dist/cjs/plugins/table/utils/index.js +0 -10
  103. package/dist/cjs/plugins/table/utils/nodes.js +5 -48
  104. package/dist/cjs/plugins/table/utils/paste.js +22 -47
  105. package/dist/cjs/plugins/table/utils/row-controls.js +6 -67
  106. package/dist/cjs/plugins/table/utils/selection.js +3 -36
  107. package/dist/cjs/plugins/table/utils/table.js +0 -11
  108. package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +0 -4
  109. package/dist/cjs/plugins/table-plugin.js +0 -3
  110. package/dist/cjs/version.json +1 -1
  111. package/dist/es2019/plugins/table/commands/clear.js +3 -8
  112. package/dist/es2019/plugins/table/commands/collapse.js +0 -3
  113. package/dist/es2019/plugins/table/commands/go-to-next-cell.js +4 -7
  114. package/dist/es2019/plugins/table/commands/hover.js +7 -17
  115. package/dist/es2019/plugins/table/commands/insert.js +16 -36
  116. package/dist/es2019/plugins/table/commands/misc.js +37 -67
  117. package/dist/es2019/plugins/table/commands/selection.js +7 -62
  118. package/dist/es2019/plugins/table/commands/sort.js +0 -12
  119. package/dist/es2019/plugins/table/commands/split-cell.js +0 -4
  120. package/dist/es2019/plugins/table/commands/toggle.js +13 -15
  121. package/dist/es2019/plugins/table/commands-with-analytics.js +4 -14
  122. package/dist/es2019/plugins/table/event-handlers.js +14 -62
  123. package/dist/es2019/plugins/table/handlers.js +16 -26
  124. package/dist/es2019/plugins/table/index.js +12 -25
  125. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -40
  126. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +27 -100
  127. package/dist/es2019/plugins/table/nodeviews/table.js +3 -33
  128. package/dist/es2019/plugins/table/nodeviews/tableCell.js +7 -16
  129. package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  130. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  131. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +4 -13
  132. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +0 -3
  133. package/dist/es2019/plugins/table/pm-plugins/keymap.js +2 -3
  134. package/dist/es2019/plugins/table/pm-plugins/main.js +19 -43
  135. package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +2 -6
  136. package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  137. package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +0 -12
  138. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  139. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +55 -130
  140. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-state.js +2 -9
  141. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  142. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +20 -39
  143. package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +7 -15
  144. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -27
  145. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -4
  146. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin.js +2 -5
  147. package/dist/es2019/plugins/table/pm-plugins/table-resizing/reducer.js +8 -8
  148. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  149. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -11
  150. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/content-width.js +4 -21
  151. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -22
  152. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +10 -18
  153. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +29 -59
  154. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +54 -51
  155. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +9 -14
  156. package/dist/es2019/plugins/table/reducer.js +26 -30
  157. package/dist/es2019/plugins/table/toolbar.js +5 -48
  158. package/dist/es2019/plugins/table/transforms/column-width.js +16 -28
  159. package/dist/es2019/plugins/table/transforms/delete-columns.js +17 -58
  160. package/dist/es2019/plugins/table/transforms/delete-rows.js +8 -25
  161. package/dist/es2019/plugins/table/transforms/fix-tables.js +25 -42
  162. package/dist/es2019/plugins/table/transforms/merge.js +22 -70
  163. package/dist/es2019/plugins/table/transforms/metadata.js +3 -2
  164. package/dist/es2019/plugins/table/transforms/replace-table.js +0 -2
  165. package/dist/es2019/plugins/table/transforms/split.js +16 -19
  166. package/dist/es2019/plugins/table/types.js +2 -4
  167. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +2 -16
  168. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +8 -54
  169. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +4 -13
  170. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +0 -2
  171. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +2 -11
  172. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +13 -49
  173. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +0 -8
  174. package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +16 -24
  175. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +3 -31
  176. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +2 -29
  177. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +0 -12
  178. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +6 -12
  179. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +0 -9
  180. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -19
  181. package/dist/es2019/plugins/table/ui/common-styles.js +6 -5
  182. package/dist/es2019/plugins/table/ui/consts.js +4 -3
  183. package/dist/es2019/plugins/table/ui/ui-styles.js +0 -10
  184. package/dist/es2019/plugins/table/utils/analytics.js +0 -8
  185. package/dist/es2019/plugins/table/utils/collapse.js +3 -14
  186. package/dist/es2019/plugins/table/utils/column-controls.js +22 -37
  187. package/dist/es2019/plugins/table/utils/decoration.js +13 -51
  188. package/dist/es2019/plugins/table/utils/dom.js +3 -19
  189. package/dist/es2019/plugins/table/utils/nodes.js +2 -15
  190. package/dist/es2019/plugins/table/utils/paste.js +17 -22
  191. package/dist/es2019/plugins/table/utils/row-controls.js +12 -45
  192. package/dist/es2019/plugins/table/utils/selection.js +0 -21
  193. package/dist/es2019/plugins/table/utils/table.js +0 -2
  194. package/dist/es2019/version.json +1 -1
  195. package/dist/esm/plugins/table/commands/clear.js +3 -8
  196. package/dist/esm/plugins/table/commands/collapse.js +0 -3
  197. package/dist/esm/plugins/table/commands/go-to-next-cell.js +6 -9
  198. package/dist/esm/plugins/table/commands/hover.js +8 -18
  199. package/dist/esm/plugins/table/commands/insert.js +16 -36
  200. package/dist/esm/plugins/table/commands/misc.js +39 -78
  201. package/dist/esm/plugins/table/commands/selection.js +21 -78
  202. package/dist/esm/plugins/table/commands/sort.js +2 -14
  203. package/dist/esm/plugins/table/commands/split-cell.js +3 -8
  204. package/dist/esm/plugins/table/commands/toggle.js +11 -20
  205. package/dist/esm/plugins/table/commands-with-analytics.js +50 -85
  206. package/dist/esm/plugins/table/create-plugin-config.js +0 -3
  207. package/dist/esm/plugins/table/event-handlers.js +58 -123
  208. package/dist/esm/plugins/table/handlers.js +11 -29
  209. package/dist/esm/plugins/table/index.js +47 -60
  210. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -44
  211. package/dist/esm/plugins/table/nodeviews/TableComponent.js +82 -181
  212. package/dist/esm/plugins/table/nodeviews/table.js +12 -52
  213. package/dist/esm/plugins/table/nodeviews/tableCell.js +15 -33
  214. package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  215. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  216. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -19
  217. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -13
  218. package/dist/esm/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -1
  219. package/dist/esm/plugins/table/pm-plugins/keymap.js +2 -3
  220. package/dist/esm/plugins/table/pm-plugins/main.js +20 -47
  221. package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +25 -37
  222. package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  223. package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +3 -15
  224. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  225. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +58 -147
  226. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -27
  227. package/dist/esm/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  228. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +14 -37
  229. package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +12 -24
  230. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -36
  231. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -6
  232. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin.js +5 -8
  233. package/dist/esm/plugins/table/pm-plugins/table-resizing/reducer.js +0 -7
  234. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  235. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -12
  236. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/content-width.js +5 -22
  237. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -23
  238. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -23
  239. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -60
  240. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -55
  241. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -24
  242. package/dist/esm/plugins/table/reducer.js +0 -20
  243. package/dist/esm/plugins/table/toolbar.js +13 -63
  244. package/dist/esm/plugins/table/transforms/column-width.js +12 -32
  245. package/dist/esm/plugins/table/transforms/delete-columns.js +11 -62
  246. package/dist/esm/plugins/table/transforms/delete-rows.js +4 -30
  247. package/dist/esm/plugins/table/transforms/fix-tables.js +24 -49
  248. package/dist/esm/plugins/table/transforms/merge.js +16 -75
  249. package/dist/esm/plugins/table/transforms/metadata.js +3 -2
  250. package/dist/esm/plugins/table/transforms/replace-table.js +2 -6
  251. package/dist/esm/plugins/table/transforms/split.js +18 -29
  252. package/dist/esm/plugins/table/types.js +0 -6
  253. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +10 -31
  254. package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +0 -2
  255. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -126
  256. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +13 -24
  257. package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +0 -2
  258. package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -7
  259. package/dist/esm/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -13
  260. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +19 -68
  261. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -14
  262. package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -18
  263. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +25 -57
  264. package/dist/esm/plugins/table/ui/LayoutButton/index.js +16 -47
  265. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -35
  266. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -38
  267. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -29
  268. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +33 -62
  269. package/dist/esm/plugins/table/ui/common-styles.js +6 -7
  270. package/dist/esm/plugins/table/ui/consts.js +4 -3
  271. package/dist/esm/plugins/table/ui/ui-styles.js +0 -12
  272. package/dist/esm/plugins/table/utils/analytics.js +4 -13
  273. package/dist/esm/plugins/table/utils/collapse.js +4 -15
  274. package/dist/esm/plugins/table/utils/column-controls.js +25 -41
  275. package/dist/esm/plugins/table/utils/decoration.js +46 -88
  276. package/dist/esm/plugins/table/utils/dom.js +4 -20
  277. package/dist/esm/plugins/table/utils/nodes.js +5 -18
  278. package/dist/esm/plugins/table/utils/paste.js +24 -29
  279. package/dist/esm/plugins/table/utils/row-controls.js +6 -46
  280. package/dist/esm/plugins/table/utils/selection.js +3 -26
  281. package/dist/esm/plugins/table/utils/table.js +0 -2
  282. package/dist/esm/version.json +1 -1
  283. package/package.json +2 -2
  284. package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
@@ -17,7 +17,6 @@ export default class TableCellNodeView {
17
17
  const {
18
18
  mouseMoveOptimization
19
19
  } = getEditorFeatureFlags();
20
-
21
20
  if (mouseMoveOptimization && observer) {
22
21
  this.contentDOM.id = uuid();
23
22
  this.mouseMoveOptimization = mouseMoveOptimization;
@@ -25,56 +24,48 @@ export default class TableCellNodeView {
25
24
  observer.observe(this.contentDOM);
26
25
  }
27
26
  }
28
-
29
27
  updateNodeView(node) {
30
28
  if (this.node.type !== node.type) {
31
29
  return false;
32
30
  }
33
-
34
31
  const attrs = getCellDomAttrs(this.node);
35
32
  const nextAttrs = getCellDomAttrs(node);
36
33
  const {
37
34
  colspan,
38
35
  rowspan
39
- } = getCellAttrs(this.dom); // need to rerender when colspan/rowspan in dom are different from the node attrs
40
- // this can happen when undoing merge cells
36
+ } = getCellAttrs(this.dom);
41
37
 
38
+ // need to rerender when colspan/rowspan in dom are different from the node attrs
39
+ // this can happen when undoing merge cells
42
40
  if (colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) || rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)) {
43
41
  return false;
44
- } // added + changed attributes
45
-
42
+ }
46
43
 
44
+ // added + changed attributes
47
45
  const addedAttrs = Object.entries(nextAttrs).filter(([key, value]) => attrs[key] !== value);
48
46
  const removedAttrs = Object.keys(attrs).filter(key => !nextAttrs.hasOwnProperty(key));
49
-
50
47
  if (addedAttrs.length || removedAttrs.length) {
51
48
  addedAttrs.forEach(([key, value]) => this.dom.setAttribute(key, value || ''));
52
49
  removedAttrs.forEach(key => this.dom.removeAttribute(key));
53
50
  return true;
54
- } // Return true to not re-render this node view
55
-
51
+ }
56
52
 
53
+ // Return true to not re-render this node view
57
54
  if (this.node.sameMarkup(node)) {
58
55
  return true;
59
56
  }
60
-
61
57
  return false;
62
58
  }
63
-
64
59
  update(node) {
65
60
  const didUpdate = this.updateNodeView(node);
66
-
67
61
  if (didUpdate) {
68
62
  this.node = node;
69
63
  }
70
-
71
64
  return didUpdate;
72
65
  }
73
-
74
66
  destroy() {
75
67
  if (this.mouseMoveOptimization && this.observer) {
76
68
  this.observer.unobserve(this.contentDOM);
77
69
  }
78
70
  }
79
-
80
71
  }
@@ -8,41 +8,34 @@ export const updateShadowListForStickyStyles = (heightStyle, shadows) => {
8
8
  }
9
9
  });
10
10
  };
11
+
11
12
  /**
12
13
  * Update overflow shadows for a given wrapper & table.
13
14
  * if `overflowShadowOptimization` is enabled, this will exit early.
14
15
  */
15
-
16
16
  export const updateOverflowShadows = getEditorFeatureFlags => (editorState, wrapper, table, rightShadows, leftShadows) => {
17
17
  var _getEditorFeatureFlag;
18
-
19
18
  if (((_getEditorFeatureFlag = getEditorFeatureFlags()) === null || _getEditorFeatureFlag === void 0 ? void 0 : _getEditorFeatureFlag.tableOverflowShadowsOptimization) === true) {
20
19
  return false;
21
- } // Right shadow
22
-
23
-
20
+ }
21
+ // Right shadow
24
22
  if (table && wrapper) {
25
23
  const stickyRow = wrapper.querySelector('tr.sticky');
26
24
  const stickyCell = stickyRow && stickyRow.firstElementChild;
27
-
28
25
  if (rightShadows) {
29
26
  const diff = table.offsetWidth - wrapper.offsetWidth;
30
-
31
27
  for (let i = 0; i < rightShadows.length; i++) {
32
28
  const rightShadow = rightShadows[i];
33
29
  rightShadow.style.display = diff > 0 && diff > wrapper.scrollLeft ? 'block' : 'none';
34
-
35
30
  if (rightShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
36
31
  rightShadow.style.height = `${stickyCell.clientHeight + 1}px`;
37
32
  }
38
33
  }
39
34
  }
40
-
41
35
  if (leftShadows) {
42
36
  for (let i = 0; i < leftShadows.length; i++) {
43
37
  const leftShadow = leftShadows[i];
44
38
  leftShadow.style.display = wrapper.scrollLeft > 0 ? 'block' : 'none';
45
-
46
39
  if (leftShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
47
40
  leftShadow.style.height = `${stickyCell.clientHeight + 1}px`;
48
41
  }
@@ -14,7 +14,6 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState) => {
14
14
  });
15
15
  } else if (tr.selectionSet) {
16
16
  const isTransactionFromMouseClick = !tr.docChanged && tr.selectionSet && tr.getMeta('pointer');
17
-
18
17
  if (isTransactionFromMouseClick || oldState.selection instanceof CellSelection) {
19
18
  return maybeUpdateColumnControlsSelectedDecoration({
20
19
  decorationSet,
@@ -22,7 +21,6 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState) => {
22
21
  });
23
22
  }
24
23
  }
25
-
26
24
  return decorationSet;
27
25
  };
28
26
  export const createPlugin = () => {
@@ -32,16 +30,13 @@ export const createPlugin = () => {
32
30
  apply: (tr, decorationSet, oldState) => {
33
31
  let pluginState = decorationSet;
34
32
  const meta = tr.getMeta(tablePluginKey);
35
-
36
33
  if (meta && meta.data && meta.data.decorationSet) {
37
34
  pluginState = meta.data.decorationSet;
38
35
  }
39
-
40
36
  if (tr.docChanged || tr.selectionSet) {
41
37
  pluginState = pluginState.map(tr.mapping, tr.doc);
42
38
  return handleDocOrSelectionChanged(tr, pluginState, oldState);
43
39
  }
44
-
45
40
  return pluginState;
46
41
  }
47
42
  },
@@ -3,14 +3,12 @@ import { findTable } from '@atlaskit/editor-tables/utils';
3
3
  import { TableDecorations } from '../../../types';
4
4
  import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../../utils/decoration';
5
5
  import { composeDecorations } from './compose-decorations';
6
+ const isColumnSelected = tr => tr.selection instanceof CellSelection && tr.selection.isColSelection();
6
7
 
7
- const isColumnSelected = tr => tr.selection instanceof CellSelection && tr.selection.isColSelection(); // @see: https://product-fabric.atlassian.net/browse/ED-3796
8
-
9
-
8
+ // @see: https://product-fabric.atlassian.net/browse/ED-3796
10
9
  const removeControlsHoverDecoration = ({
11
10
  decorationSet
12
11
  }) => decorationSet.remove(findControlsHoverDecoration(decorationSet));
13
-
14
12
  const maybeUpdateColumnSelectedDecoration = ({
15
13
  decorationSet,
16
14
  tr
@@ -18,30 +16,24 @@ const maybeUpdateColumnSelectedDecoration = ({
18
16
  if (!isColumnSelected(tr)) {
19
17
  return decorationSet;
20
18
  }
21
-
22
19
  return updateDecorations(tr.doc, decorationSet, createColumnSelectedDecoration(tr), TableDecorations.COLUMN_SELECTED);
23
20
  };
24
-
25
21
  const maybeUpdateColumnControlsDecoration = ({
26
22
  decorationSet,
27
23
  tr
28
24
  }) => {
29
25
  const table = findTable(tr.selection);
30
-
31
26
  if (!table) {
32
27
  return decorationSet;
33
28
  }
34
-
35
29
  return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
36
- }; // @see: https://product-fabric.atlassian.net/browse/ED-7304
37
-
30
+ };
38
31
 
32
+ // @see: https://product-fabric.atlassian.net/browse/ED-7304
39
33
  const removeColumnControlsSelectedDecoration = ({
40
34
  decorationSet
41
35
  }) => decorationSet.remove(findColumnControlSelectedDecoration(decorationSet));
42
-
43
36
  const hasColumnSelectedDecorations = decorationSet => !!findColumnControlSelectedDecoration(decorationSet).length;
44
-
45
37
  export const maybeUpdateColumnControlsSelectedDecoration = ({
46
38
  decorationSet,
47
39
  tr
@@ -49,7 +41,6 @@ export const maybeUpdateColumnControlsSelectedDecoration = ({
49
41
  if (!hasColumnSelectedDecorations(decorationSet)) {
50
42
  return decorationSet;
51
43
  }
52
-
53
44
  return removeColumnControlsSelectedDecoration({
54
45
  decorationSet,
55
46
  tr
@@ -2,17 +2,14 @@ import { TableDecorations } from '../../../types';
2
2
  import { createResizeHandleDecoration, updateDecorations } from '../../../utils/decoration';
3
3
  import { composeDecorations } from './compose-decorations';
4
4
  const emptyDecorations = [[], []];
5
-
6
5
  const updateColumnResizeHandle = columnResizesDecorations => ({
7
6
  decorationSet,
8
7
  tr
9
8
  }) => updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE);
10
-
11
9
  const updateLastCellElement = lastCellElementsDecorations => ({
12
10
  decorationSet,
13
11
  tr
14
12
  }) => updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT);
15
-
16
13
  export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex) => ({
17
14
  tr,
18
15
  decorationSet
@@ -6,7 +6,6 @@ import { triggerUnlessTableHeader, createTable, goToNextCell, moveCursorBackward
6
6
  import { addRowAroundSelection, emptyMultipleCellsWithAnalytics, deleteTableIfSelectedWithAnalytics } from '../commands-with-analytics';
7
7
  import { addColumnAfter, addColumnBefore } from '../commands/insert';
8
8
  import { withEditorAnalyticsAPI } from '../utils/analytics';
9
-
10
9
  const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
11
10
  action: ACTION.INSERTED,
12
11
  actionSubject: ACTION_SUBJECT.DOCUMENT,
@@ -16,15 +15,15 @@ const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
16
15
  },
17
16
  eventType: EVENT_TYPE.TRACK
18
17
  })(editorAnalyticsAPI)(createTable());
19
-
20
18
  export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI) {
21
19
  const list = {};
22
20
  keymaps.bindKeymapWithCommand(keymaps.nextCell.common, goToNextCell(editorAnalyticsAPI)(1), list);
23
21
  keymaps.bindKeymapWithCommand(keymaps.previousCell.common, goToNextCell(editorAnalyticsAPI)(-1), list);
24
22
  keymaps.bindKeymapWithCommand(keymaps.toggleTable.common, createTableWithAnalytics(editorAnalyticsAPI), list);
25
23
  keymaps.bindKeymapWithCommand(keymaps.backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
26
- keymaps.bindKeymapWithCommand(keymaps.backspace.common, moveCursorBackward, list); // Add row/column shortcuts
24
+ keymaps.bindKeymapWithCommand(keymaps.backspace.common, moveCursorBackward, list);
27
25
 
26
+ // Add row/column shortcuts
28
27
  keymaps.bindKeymapWithCommand(keymaps.addRowBefore.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
29
28
  keymaps.bindKeymapWithCommand(keymaps.addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
30
29
  keymaps.bindKeymapWithCommand(keymaps.addColumnBefore.common, triggerUnlessTableHeader(addColumnBefore(getEditorContainerWidth)), list);
@@ -26,7 +26,6 @@ let isFullWidthModeEnabled;
26
26
  let wasFullWidthModeEnabled;
27
27
  export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI) => {
28
28
  var _window;
29
-
30
29
  isBreakoutEnabled = breakoutEnabled;
31
30
  isFullWidthModeEnabled = fullWidthModeEnabled;
32
31
  wasFullWidthModeEnabled = previousFullWidthModeEnabled;
@@ -45,39 +44,33 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
45
44
  if (!entry.target.id) {
46
45
  return;
47
46
  }
48
-
49
47
  elementContentRects[entry.target.id] = entry.contentRect;
50
48
  });
51
49
  }) : undefined;
52
50
  const tableCellNodeview = {
53
51
  tableCell: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer),
54
52
  tableHeader: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer)
55
- }; // Used to prevent invalid table cell spans being reported more than once per editor/document
53
+ };
56
54
 
55
+ // Used to prevent invalid table cell spans being reported more than once per editor/document
57
56
  const invalidTableIds = [];
58
57
  let editorViewRef = null;
59
-
60
58
  const getCurrentEditorState = () => {
61
59
  const editorView = editorViewRef;
62
-
63
60
  if (!editorView) {
64
61
  return null;
65
62
  }
66
-
67
63
  return editorView.state;
68
64
  };
69
-
70
65
  return new SafePlugin({
71
66
  state: state,
72
67
  key: pluginKey,
73
68
  appendTransaction: (transactions, oldState, newState) => {
74
69
  const tr = transactions.find(tr => tr.getMeta('uiEvent') === 'cut');
75
-
76
70
  function reportInvalidTableCellSpanAttrs(invalidNodeAttr) {
77
71
  if (invalidTableIds.find(id => id === invalidNodeAttr.tableLocalId)) {
78
72
  return;
79
73
  }
80
-
81
74
  invalidTableIds.push(invalidNodeAttr.tableLocalId);
82
75
  dispatchAnalyticsEvent({
83
76
  action: ACTION.INVALID_DOCUMENT_ENCOUNTERED,
@@ -91,13 +84,11 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
91
84
  }
92
85
  });
93
86
  }
94
-
95
87
  if (tr) {
96
88
  // "fixTables" removes empty rows as we don't allow that in schema
97
89
  const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI);
98
90
  return fixTables(updatedTr) || updatedTr;
99
91
  }
100
-
101
92
  if (transactions.find(tr => tr.docChanged)) {
102
93
  return fixTables(newState.tr, reportInvalidTableCellSpanAttrs);
103
94
  }
@@ -117,34 +108,26 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
117
108
  const pluginState = getPluginState(state);
118
109
  let tableRef;
119
110
  let tableNode;
120
-
121
111
  if (pluginState.editorHasFocus) {
122
112
  const parent = findParentDomRefOfType(state.schema.nodes.table, domAtPos)(selection);
123
-
124
113
  if (parent) {
125
114
  tableRef = parent.querySelector('table') || undefined;
126
115
  }
127
-
128
116
  tableNode = findTable(state.selection);
129
117
  }
130
-
131
118
  if (pluginState.tableRef !== tableRef) {
132
119
  setTableRef(tableRef)(state, dispatch);
133
120
  }
134
-
135
121
  if (pluginState.tableNode !== tableNode) {
136
122
  updateResizeHandles(tableRef);
137
123
  }
138
-
139
124
  if (pluginState.editorHasFocus && pluginState.tableRef) {
140
125
  const {
141
126
  $cursor
142
127
  } = state.selection;
143
-
144
128
  if ($cursor) {
145
129
  // Only update bold when it's a cursor
146
130
  const tableCellHeader = findParentNodeOfType(state.schema.nodes.tableHeader)(state.selection);
147
-
148
131
  if (tableCellHeader) {
149
132
  addBoldInEmptyHeaderCells(tableCellHeader)(state, dispatch);
150
133
  }
@@ -161,70 +144,64 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
161
144
  props: {
162
145
  transformPasted(slice) {
163
146
  const editorState = getCurrentEditorState();
164
-
165
147
  if (!editorState) {
166
148
  return slice;
167
149
  }
168
-
169
150
  const {
170
151
  schema
171
- } = editorState; // if we're pasting to outside a table or outside a table
152
+ } = editorState;
153
+
154
+ // if we're pasting to outside a table or outside a table
172
155
  // header, ensure that we apply any table headers to the first
173
156
  // row of content we see, if required
174
-
175
157
  if (!insideTable(editorState) && isHeaderRowRequired(editorState)) {
176
158
  slice = transformSliceToAddTableHeaders(slice, schema);
177
159
  }
160
+ slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
178
161
 
179
- slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema); // We do this separately, so it also applies to drag/drop events
162
+ // We do this separately, so it also applies to drag/drop events
180
163
  // This needs to go before `transformSliceToRemoveOpenExpand`
164
+ slice = transformSliceToRemoveOpenLayoutNodes(slice, schema);
181
165
 
182
- slice = transformSliceToRemoveOpenLayoutNodes(slice, schema); // If a partial paste of expand, paste only the content
166
+ // If a partial paste of expand, paste only the content
183
167
  // This needs to go before `transformSliceToRemoveOpenTable`
184
-
185
168
  slice = transformSliceToRemoveOpenExpand(slice, schema);
186
- /** If a partial paste of table, paste only table's content */
187
169
 
170
+ /** If a partial paste of table, paste only table's content */
188
171
  slice = transformSliceToRemoveOpenTable(slice, schema);
189
- /** If a partial paste of bodied extension, paste only text */
190
172
 
173
+ /** If a partial paste of bodied extension, paste only text */
191
174
  slice = transformSliceToRemoveOpenBodiedExtension(slice, schema);
192
175
  slice = transformSliceToCorrectEmptyTableCells(slice, schema);
193
-
194
176
  if (!pluginConfig.allowColumnResizing) {
195
177
  slice = transformSliceToRemoveColumnsWidths(slice, schema);
196
- } // If we don't allow background on cells, we need to remove it
197
- // from the paste slice
198
-
178
+ }
199
179
 
180
+ // If we don't allow background on cells, we need to remove it
181
+ // from the paste slice
200
182
  if (!pluginConfig.allowBackgroundColor) {
201
183
  slice = transformSliceRemoveCellBackgroundColor(slice, schema);
202
184
  }
203
-
204
185
  return slice;
205
186
  },
206
-
207
187
  handleClick: ({
208
188
  state,
209
189
  dispatch
210
190
  }, _pos, event) => {
211
191
  const decorationSet = decorationsPluginKey.getState(state);
212
-
213
192
  if (findControlsHoverDecoration(decorationSet).length) {
214
193
  clearHoverSelection()(state, dispatch);
215
- } // ED-6069: workaround for Chrome given a regression introduced in prosemirror-view@1.6.8
194
+ }
195
+
196
+ // ED-6069: workaround for Chrome given a regression introduced in prosemirror-view@1.6.8
216
197
  // Returning true prevents that updateSelection() is getting called in the commit below:
217
198
  // @see https://github.com/ProseMirror/prosemirror-view/commit/33fe4a8b01584f6b4103c279033dcd33e8047b95
218
-
219
-
220
199
  if (browser.chrome && event.target) {
221
200
  const targetClassList = event.target.classList;
222
-
223
201
  if (targetClassList.contains(ClassName.CONTROLS_BUTTON) || targetClassList.contains(ClassName.CONTEXTUAL_MENU_BUTTON)) {
224
202
  return true;
225
203
  }
226
204
  }
227
-
228
205
  return false;
229
206
  },
230
207
  handleScrollToSelection: view => {
@@ -242,15 +219,14 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
242
219
  dispatch
243
220
  }, from, to, text) => {
244
221
  const tr = replaceSelectedTable(state, text, INPUT_METHOD.KEYBOARD, editorAnalyticsAPI);
245
-
246
222
  if (tr.selectionSet) {
247
223
  dispatch(tr);
248
224
  return true;
249
225
  }
250
-
251
226
  return false;
252
227
  },
253
- nodeViews: { //temporary flag to test tableCell optimisation
228
+ nodeViews: {
229
+ //temporary flag to test tableCell optimisation
254
230
  ...tableCellNodeview,
255
231
  table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, {
256
232
  isBreakoutEnabled,
@@ -10,7 +10,6 @@ export const {
10
10
  mapping: (tr, pluginState) => {
11
11
  if (tr.docChanged) {
12
12
  let updatedTargetCell = {};
13
-
14
13
  if (pluginState.targetCellPosition) {
15
14
  const {
16
15
  pos,
@@ -20,9 +19,7 @@ export const {
20
19
  targetCellPosition: deleted ? undefined : pos
21
20
  };
22
21
  }
23
-
24
22
  let updatedTablePos = {};
25
-
26
23
  if (pluginState.tablePos) {
27
24
  const {
28
25
  pos,
@@ -32,13 +29,12 @@ export const {
32
29
  tablePos: deleted ? undefined : pos
33
30
  };
34
31
  }
35
-
36
- return { ...pluginState,
32
+ return {
33
+ ...pluginState,
37
34
  ...updatedTargetCell,
38
35
  ...updatedTablePos
39
36
  };
40
37
  }
41
-
42
38
  return pluginState;
43
39
  },
44
40
  onDocChanged: handleDocOrSelectionChanged,
@@ -9,6 +9,7 @@ export const createPlugin = () => {
9
9
  // to delay drag selections
10
10
  // - to ensure it is cleaned up when the mouseup
11
11
  // event is not fired in a previous mousedown event
12
+
12
13
  // Because we are manually wiping the view.mouseDown,
13
14
  // we manage this custom cleanup ourselves
14
15
  let prevMouseDownDone = null;
@@ -22,13 +23,16 @@ export const createPlugin = () => {
22
23
  // DOM selection syncing during pointer drag.
23
24
  //
24
25
  // https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
26
+
25
27
  // NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
26
28
  // https://github.com/ProseMirror/prosemirror-view/pull/116
29
+
27
30
  // This fix removes the selectionToDOM from the view
28
31
  // prior to selectionToDOM being called.
29
32
  // selectionToDOM checks if there is an "active"
30
33
  // mouseDown, and if so, it delays running logic
31
34
  // which causes the table selections issue.
35
+
32
36
  // The handleDOMEvents are called before ProseMirror
33
37
  // events fired on the editable DOM element.
34
38
  // This means the view.mouseView will not yet be
@@ -40,21 +44,22 @@ export const createPlugin = () => {
40
44
  // prepend a task which will clear the mouseDown from
41
45
  // the view. We do this using a setTimout with no
42
46
  // interval.
47
+
43
48
  if (prevMouseDownDone) {
44
49
  // avoid memory leaks when the mouseup event is not fired
45
50
  // in a previous mousedown event
46
51
  prevMouseDownDone();
47
52
  }
48
-
49
53
  setTimeout(() => {
50
54
  // the ts-ignores here are required due to the
51
55
  // view.mouseDown being an internal which is
52
56
  // not part of the views type signature
57
+
53
58
  // @ts-ignore
54
59
  if (view.mouseDown) {
55
60
  // @ts-ignore
56
- prevMouseDownDone = view.mouseDown.done.bind(view.mouseDown); // @ts-ignore
57
-
61
+ prevMouseDownDone = view.mouseDown.done.bind(view.mouseDown);
62
+ // @ts-ignore
58
63
  view.mouseDown = null;
59
64
  }
60
65
  });
@@ -17,13 +17,10 @@ export const createPlugin = () => {
17
17
  }),
18
18
  apply: (tr, value) => {
19
19
  const renderSpan = tr.getMeta(tableSafariDeleteCompositionTextIssueWorkaroundKey);
20
-
21
20
  if (typeof renderSpan === 'undefined') {
22
21
  return value;
23
22
  }
24
-
25
23
  let decorations;
26
-
27
24
  if (renderSpan) {
28
25
  // Find position of the first text node in case it has multiple text nodes created by Japanese IME
29
26
  const {
@@ -38,7 +35,6 @@ export const createPlugin = () => {
38
35
  } else {
39
36
  decorations = DecorationSet.empty;
40
37
  }
41
-
42
38
  return {
43
39
  renderSpan,
44
40
  decorations
@@ -52,13 +48,10 @@ export const createPlugin = () => {
52
48
  if ((event === null || event === void 0 ? void 0 : event.inputType) !== 'deleteCompositionText') {
53
49
  return false;
54
50
  }
55
-
56
51
  const selection = window.getSelection();
57
-
58
52
  if (!selection || selection.rangeCount <= 0 || selection.type !== 'Range') {
59
53
  return false;
60
54
  }
61
-
62
55
  const range = selection.getRangeAt(0);
63
56
  const {
64
57
  startContainer,
@@ -71,7 +64,6 @@ export const createPlugin = () => {
71
64
  * and will think that we meant to delete those elements. This fix forces the resulting node to not be empty.
72
65
  * The condition here checks to see if the entire text node is about to be swapped inside of an element
73
66
  */
74
-
75
67
  if (startContainer.nodeType === Node.TEXT_NODE && startContainer === endContainer && startOffset === 0 && endOffset === startContainer.length) {
76
68
  const {
77
69
  tr
@@ -79,20 +71,16 @@ export const createPlugin = () => {
79
71
  tr.setMeta(tableSafariDeleteCompositionTextIssueWorkaroundKey, true);
80
72
  view.dispatch(tr);
81
73
  }
82
-
83
74
  return false;
84
75
  },
85
76
  input: (view, event) => {
86
77
  if ((event === null || event === void 0 ? void 0 : event.inputType) !== 'deleteCompositionText') {
87
78
  return false;
88
79
  }
89
-
90
80
  const selection = window.getSelection();
91
-
92
81
  if (!selection) {
93
82
  return false;
94
83
  }
95
-
96
84
  const {
97
85
  tr
98
86
  } = view.state;
@@ -1,25 +1,21 @@
1
1
  export const getTree = tr => {
2
2
  // pm renders into tbody, owned by react
3
3
  const tbody = tr.parentElement;
4
-
5
4
  if (!tbody) {
6
5
  return null;
7
- } // rendered by react
8
-
6
+ }
9
7
 
8
+ // rendered by react
10
9
  const table = tbody.parentElement;
11
-
12
10
  if (!table) {
13
11
  return null;
14
- } // rendered by react
15
-
12
+ }
16
13
 
14
+ // rendered by react
17
15
  const wrapper = table.parentElement;
18
-
19
16
  if (!wrapper) {
20
17
  return null;
21
18
  }
22
-
23
19
  return {
24
20
  wrapper: wrapper,
25
21
  table: table
@@ -29,6 +25,5 @@ export const getTop = element => {
29
25
  if (!element || element instanceof Window) {
30
26
  return 0;
31
27
  }
32
-
33
28
  return element.getBoundingClientRect().top;
34
29
  };