@atlaskit/editor-plugin-table 0.0.10 → 0.1.0

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 (213) hide show
  1. package/.eslintrc.js +35 -0
  2. package/CHANGELOG.md +23 -0
  3. package/commands/package.json +14 -0
  4. package/dist/cjs/plugins/table/commands/hover.js +4 -4
  5. package/dist/cjs/plugins/table/commands-with-analytics.js +59 -58
  6. package/dist/cjs/plugins/table/event-handlers.js +0 -1
  7. package/dist/cjs/plugins/table/index.js +54 -37
  8. package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +9 -1
  9. package/dist/cjs/plugins/table/toolbar.js +150 -22
  10. package/dist/cjs/plugins/table/transforms/fix-tables.js +7 -7
  11. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  12. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  13. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +3 -5
  14. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  15. package/dist/cjs/plugins/table/utils/column-controls.js +0 -1
  16. package/dist/cjs/plugins/table/utils/decoration.js +53 -4
  17. package/dist/cjs/plugins/table/utils/dom.js +0 -2
  18. package/dist/cjs/plugins/table/utils/paste.js +0 -1
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/plugins/table/commands/hover.js +4 -4
  21. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -9
  22. package/dist/es2019/plugins/table/event-handlers.js +1 -2
  23. package/dist/es2019/plugins/table/handlers.js +1 -2
  24. package/dist/es2019/plugins/table/index.js +23 -5
  25. package/dist/es2019/plugins/table/pm-plugins/keymap.js +1 -1
  26. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +1 -3
  27. package/dist/es2019/plugins/table/pm-plugins/table-resizing/index.js +2 -1
  28. package/dist/es2019/plugins/table/toolbar.js +133 -16
  29. package/dist/es2019/plugins/table/transforms/fix-tables.js +2 -4
  30. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  31. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  32. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
  33. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -2
  34. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +3 -5
  35. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  36. package/dist/es2019/plugins/table/utils/column-controls.js +0 -1
  37. package/dist/es2019/plugins/table/utils/decoration.js +60 -25
  38. package/dist/es2019/plugins/table/utils/dom.js +0 -2
  39. package/dist/es2019/plugins/table/utils/paste.js +1 -2
  40. package/dist/es2019/plugins/table/utils/row-controls.js +1 -2
  41. package/dist/es2019/version.json +1 -1
  42. package/dist/esm/plugins/table/commands/hover.js +4 -4
  43. package/dist/esm/plugins/table/commands-with-analytics.js +56 -55
  44. package/dist/esm/plugins/table/event-handlers.js +1 -2
  45. package/dist/esm/plugins/table/handlers.js +1 -2
  46. package/dist/esm/plugins/table/index.js +55 -38
  47. package/dist/esm/plugins/table/pm-plugins/keymap.js +1 -1
  48. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +1 -3
  49. package/dist/esm/plugins/table/pm-plugins/table-resizing/index.js +2 -1
  50. package/dist/esm/plugins/table/toolbar.js +139 -17
  51. package/dist/esm/plugins/table/transforms/fix-tables.js +2 -4
  52. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  53. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  54. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
  55. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -2
  56. package/dist/esm/plugins/table/ui/LayoutButton/index.js +3 -5
  57. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  58. package/dist/esm/plugins/table/utils/column-controls.js +0 -1
  59. package/dist/esm/plugins/table/utils/decoration.js +50 -4
  60. package/dist/esm/plugins/table/utils/dom.js +0 -2
  61. package/dist/esm/plugins/table/utils/paste.js +1 -2
  62. package/dist/esm/plugins/table/utils/row-controls.js +1 -2
  63. package/dist/esm/version.json +1 -1
  64. package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
  65. package/dist/types/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
  66. package/dist/types/plugins/table/toolbar.d.ts +2 -2
  67. package/dist/types/plugins/table/transforms/fix-tables.d.ts +1 -1
  68. package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
  69. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
  70. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
  71. package/dist/types-ts4.0/plugins/table/toolbar.d.ts +2 -2
  72. package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +1 -1
  73. package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +1 -1
  74. package/examples/config.jsonc +14 -0
  75. package/package.json +15 -11
  76. package/plugin-key/package.json +14 -0
  77. package/report.api.md +1 -1
  78. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/auto-size-documents.ts +0 -0
  79. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/basic-table.ts +0 -0
  80. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/empty-paragraph-underneath-table.ts +0 -0
  81. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/even-columns.ts +0 -0
  82. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/layout-documents.ts +0 -0
  83. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/merged-rows-and-cols-document.ts +0 -0
  84. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/nested-in-extension.ts +0 -0
  85. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/paragraph-and-table-adf.json +0 -0
  86. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/resize-documents.ts +0 -0
  87. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/scale.ts +0 -0
  88. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-inside-layout.ts +0 -0
  89. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-min-width-columns-document.ts +0 -0
  90. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-multiline-date.adf.json +0 -0
  91. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-text-and-empty-row.ts +0 -0
  92. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/auto-size.ts.snap +0 -0
  93. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/change-date-inside-table.ts.snap +0 -0
  94. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/copy-button.ts.snap +0 -0
  95. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-columns.ts.snap +0 -0
  96. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +0 -0
  97. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +0 -0
  98. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +0 -0
  99. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-rows.ts.snap +0 -0
  100. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-table-when-selected.ts.snap +0 -0
  101. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/deleting-empty-paragraph-under-table.ts.snap +0 -0
  102. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/even-columns.ts.snap +0 -0
  103. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-cell-header-with-strong-mark.ts.snap +0 -0
  104. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-row-inside-layout.ts.snap +0 -0
  105. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/layout.ts.snap +0 -0
  106. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/resize.ts.snap +0 -0
  107. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/scale.ts.snap +0 -0
  108. package/src/{plugins/table/__tests__ → __tests__}/integration/arrow-down-into-table.ts +0 -0
  109. package/src/{plugins/table/__tests__ → __tests__}/integration/auto-size.ts +0 -0
  110. package/src/{plugins/table/__tests__ → __tests__}/integration/block-node-selection.ts +1 -0
  111. package/src/{plugins/table/__tests__ → __tests__}/integration/cell-selection.ts +0 -0
  112. package/src/{plugins/table/__tests__ → __tests__}/integration/change-date-inside-table.ts +0 -0
  113. package/src/{plugins/table/__tests__ → __tests__}/integration/copy-button.ts +1 -1
  114. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-columns.ts +2 -2
  115. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-in-full-width.ts +1 -1
  116. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-with-empty-action.ts +1 -1
  117. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-row-with-empty-action.ts +1 -1
  118. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-rows.ts +2 -2
  119. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-table-when-selected.ts +0 -0
  120. package/src/{plugins/table/__tests__ → __tests__}/integration/deleting-empty-paragraph-under-table.ts +0 -0
  121. package/src/{plugins/table/__tests__ → __tests__}/integration/even-columns.ts +0 -0
  122. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-cell-header-with-strong-mark.ts +0 -0
  123. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-long-smart-link.ts +1 -0
  124. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-row-inside-layout.ts +0 -0
  125. package/src/{plugins/table/__tests__ → __tests__}/integration/layout.ts +0 -0
  126. package/src/{plugins/table/__tests__ → __tests__}/integration/resize-handler.ts +0 -0
  127. package/src/{plugins/table/__tests__ → __tests__}/integration/resize.ts +1 -1
  128. package/src/{plugins/table/__tests__ → __tests__}/integration/scale.ts +0 -0
  129. package/src/__tests__/integration/table-controls-selection.ts +71 -0
  130. package/src/__tests__/unit/analytics.ts +8 -9
  131. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/go-to-next-cell.ts +4 -4
  132. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/insert.ts +4 -4
  133. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/misc.ts +12 -6
  134. package/src/{plugins/table/__tests__ → __tests__}/unit/commands.ts +7 -7
  135. package/src/__tests__/unit/copy-button.ts +22 -0
  136. package/src/__tests__/unit/event-handlers.ts +120 -1
  137. package/src/{plugins/table/__tests__ → __tests__}/unit/get-toolbar-config.ts +8 -3
  138. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/OverflowShadowsObserver.ts +2 -2
  139. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/TableComponent.tsx +11 -11
  140. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/table.ts +5 -5
  141. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-controls.ts +2 -2
  142. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-resizing.ts +9 -6
  143. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/plugin.ts +5 -5
  144. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main-with-allow-collapse.ts +4 -4
  145. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main.ts +6 -6
  146. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -2
  147. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/sticky-headers/tableRow.tsx +16 -13
  148. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-local-id.ts +3 -6
  149. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/colgroup.ts +1 -1
  150. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/event-handlers.ts +3 -3
  151. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-selection-keymap.ts +3 -3
  152. package/src/{plugins/table/__tests__ → __tests__}/unit/toolbar.ts +5 -9
  153. package/src/{plugins/table/__tests__ → __tests__}/unit/utils/collapse.ts +2 -2
  154. package/src/{plugins/table/__tests__ → __tests__}/unit/utils/column-controls.ts +1 -1
  155. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -0
  156. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -0
  157. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -0
  158. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -0
  159. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -0
  160. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -0
  161. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -0
  162. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -0
  163. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -0
  164. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/cell-options-menu.ts +2 -0
  165. package/src/__tests__/visual-regression/copy-button.ts +181 -0
  166. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/index.ts +3 -1
  167. package/src/plugins/table/commands/hover.ts +4 -1
  168. package/src/plugins/table/commands-with-analytics.ts +12 -8
  169. package/src/plugins/table/event-handlers.ts +0 -1
  170. package/src/plugins/table/handlers.ts +0 -1
  171. package/src/plugins/table/index.tsx +28 -2
  172. package/src/plugins/table/pm-plugins/keymap.ts +1 -1
  173. package/src/plugins/table/pm-plugins/table-local-id.ts +0 -2
  174. package/src/plugins/table/pm-plugins/table-resizing/index.ts +1 -0
  175. package/src/plugins/table/{toolbar.ts → toolbar.tsx} +186 -14
  176. package/src/plugins/table/transforms/fix-tables.ts +2 -3
  177. package/src/plugins/table/ui/FloatingContextualButton/index.tsx +0 -1
  178. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +13 -10
  179. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -0
  180. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -0
  181. package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +0 -1
  182. package/src/plugins/table/ui/FloatingInsertButton/index.tsx +0 -1
  183. package/src/plugins/table/ui/LayoutButton/index.tsx +2 -4
  184. package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +1 -0
  185. package/src/plugins/table/utils/column-controls.ts +0 -1
  186. package/src/plugins/table/utils/decoration.ts +44 -5
  187. package/src/plugins/table/utils/dom.ts +0 -2
  188. package/src/plugins/table/utils/paste.ts +0 -1
  189. package/src/plugins/table/utils/row-controls.ts +0 -1
  190. package/types/package.json +5 -5
  191. package/ui/common-styles/package.json +14 -0
  192. package/ui/consts/package.json +14 -0
  193. package/dist/cjs/plugins/plugin-key.js +0 -17
  194. package/dist/cjs/plugins/table/todo-stubs.js +0 -10
  195. package/dist/cjs/types.js +0 -5
  196. package/dist/es2019/plugins/plugin-key.js +0 -3
  197. package/dist/es2019/plugins/table/todo-stubs.js +0 -1
  198. package/dist/es2019/types.js +0 -1
  199. package/dist/esm/plugins/plugin-key.js +0 -5
  200. package/dist/esm/plugins/table/todo-stubs.js +0 -1
  201. package/dist/esm/types.js +0 -1
  202. package/dist/types/plugins/plugin-key.d.ts +0 -4
  203. package/dist/types/plugins/table/todo-stubs.d.ts +0 -1
  204. package/dist/types/types.d.ts +0 -3
  205. package/dist/types-ts4.0/plugins/plugin-key.d.ts +0 -4
  206. package/dist/types-ts4.0/plugins/table/todo-stubs.d.ts +0 -1
  207. package/dist/types-ts4.0/types.d.ts +0 -3
  208. package/src/plugins/plugin-key.ts +0 -7
  209. package/src/plugins/table/__tests__/integration/table-controls-selection.ts +0 -70
  210. package/src/plugins/table/__tests__/unit/event-handlers.ts +0 -130
  211. package/src/plugins/table/todo-stubs.ts +0 -1
  212. package/src/types.ts +0 -3
  213. package/tmp/api-report-tmp.d.ts +0 -91
package/.eslintrc.js ADDED
@@ -0,0 +1,35 @@
1
+ module.exports = {
2
+ rules: {
3
+ // Ensure the table plugin is not coupled to editor-core and avoid circular dependencies
4
+ 'no-restricted-imports': [
5
+ 'error',
6
+ {
7
+ patterns: [
8
+ {
9
+ group: ['@atlaskit/editor-core/*', '@atlaskit/editor-core'],
10
+ message:
11
+ 'Importing editor-core is not allowed in editor-plugin-table. Consider using editor-common instead.',
12
+ },
13
+ ],
14
+ },
15
+ ],
16
+ },
17
+ // Disable restricted import for tests
18
+ overrides: [
19
+ {
20
+ files: ['**/__tests__/**/*.{js,ts,tsx}', 'examples/**/*.{js,ts,tsx}'],
21
+ rules: {
22
+ 'no-restricted-imports': [
23
+ 'off',
24
+ {
25
+ patterns: [
26
+ {
27
+ group: ['@atlaskit/editor-core/*', '@atlaskit/editor-core'],
28
+ },
29
+ ],
30
+ },
31
+ ],
32
+ },
33
+ },
34
+ ],
35
+ };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`90c44a68da2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/90c44a68da2) - Removed editor-core table plugin and replaced with new `editor-plugin-table` package. This change required adding copying new table changes from editor-core to the new table package, moving IconTable to shared package, and creating new entry-points from editor-plugin-table. `getPluginState` from `packages/editor/editor-plugin-table/src/plugins/table/pm-plugins/table-resizing` was also exported.
8
+
9
+ [ED-15674][ed15739] [ED-15633]
10
+
11
+ - [`1e1ac6d1d15`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1e1ac6d1d15) - [ED-15501] Removal of coupled table-resizing code in `editor-core` media and card plugin. This makes entry-point `/table-resizing` from `editor-plugin-table` unused so removed the entry-point.
12
+
13
+ ### Patch Changes
14
+
15
+ - [`29d7f84c649`](https://bitbucket.org/atlassian/atlassian-frontend/commits/29d7f84c649) - Removed styled-components peerDependency
16
+ - [`30e8425f7d6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/30e8425f7d6) - [ux] ED-15706 Reenable copy button on editor-plugin-table. Added property copyButton to floatingToolbarConfig.
17
+ - [`e9168851af4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e9168851af4) - This changes addresses a bug that occurs when a user is resizing tables and receives a TypeError (found on Sentry). This change adds a null check on columns existing in the growColumn and shrinkColumn functions so that we do not try to access a column that doesn't exist.
18
+ - [`ac8b10d645e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ac8b10d645e) - This change addresses a RangeError on `getRelativeDomCellWidths` found on Sentry. It sets the check for `colspan` to be strict equals to one as the value comes from the first table row's colspan DOM attribute and cannot be negative.
19
+
20
+ Reference: https://sentry.io/organizations/atlassian-2y/issues/3434914334/?project=5988900
21
+
22
+ - [`46703fdde00`](https://bitbucket.org/atlassian/atlassian-frontend/commits/46703fdde00) - This change addresses a bug that occurs when a user is clicking into an element inside the table and receives a RangeError (found on Sentry). This change adds bounds, NaN, and type checks when reading a cellIndex from tableMap so that we don't pass NaN or undefined to the call to nodeAt.
23
+ - [`edb93baa953`](https://bitbucket.org/atlassian/atlassian-frontend/commits/edb93baa953) - Moved sendLogs to editor-common. Re-exported in editor-core and import sendLogs from editor-common in editor-plugin-table package.
24
+ - Updated dependencies
25
+
3
26
  ## 0.0.10
4
27
 
5
28
  ### Patch Changes
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-table/commands",
3
+ "main": "../dist/cjs/plugins/table/commands/index.js",
4
+ "module": "../dist/esm/plugins/table/commands/index.js",
5
+ "module:es2019": "../dist/es2019/plugins/table/commands/index.js",
6
+ "types": "../dist/types/plugins/table/commands/index.d.ts",
7
+ "typesVersions": {
8
+ ">=4.0 <4.5": {
9
+ "*": [
10
+ "../dist/types-ts4.0/plugins/table/commands/index.d.ts"
11
+ ]
12
+ }
13
+ }
14
+ }
@@ -61,13 +61,13 @@ exports.hoverMergedCells = hoverMergedCells;
61
61
 
62
62
  var hoverColumns = function hoverColumns(hoveredColumns, isInDanger) {
63
63
  return (0, _pluginFactory.createCommand)(function (state) {
64
- var cells = (0, _utils.getCellsInColumn)(hoveredColumns)(state.selection);
64
+ var cells = (0, _utils.getCellsInColumn)(hoveredColumns)(state.tr.selection);
65
65
 
66
66
  if (!cells) {
67
67
  return false;
68
68
  }
69
69
 
70
- var decorations = (0, _utils2.createControlsHoverDecoration)(cells, 'column', isInDanger);
70
+ var decorations = (0, _utils2.createControlsHoverDecoration)(cells, 'column', state.tr, isInDanger);
71
71
  return {
72
72
  type: 'HOVER_COLUMNS',
73
73
  data: {
@@ -91,7 +91,7 @@ var hoverRows = function hoverRows(hoveredRows, isInDanger) {
91
91
  return false;
92
92
  }
93
93
 
94
- var decorations = (0, _utils2.createControlsHoverDecoration)(cells, 'row', isInDanger);
94
+ var decorations = (0, _utils2.createControlsHoverDecoration)(cells, 'row', state.tr, isInDanger);
95
95
  return {
96
96
  type: 'HOVER_ROWS',
97
97
  data: {
@@ -125,7 +125,7 @@ var hoverTable = function hoverTable(isInDanger, isSelected) {
125
125
  return false;
126
126
  }
127
127
 
128
- var decorations = (0, _utils2.createControlsHoverDecoration)(cells, 'table', isInDanger, isSelected);
128
+ var decorations = (0, _utils2.createControlsHoverDecoration)(cells, 'table', state.tr, isInDanger, isSelected);
129
129
  return {
130
130
  type: 'HOVER_TABLE',
131
131
  data: {
@@ -84,81 +84,83 @@ var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnalytics(e
84
84
  exports.emptyMultipleCellsWithAnalytics = emptyMultipleCellsWithAnalytics;
85
85
 
86
86
  var mergeCellsWithAnalytics = function mergeCellsWithAnalytics(editorAnalyticsAPI) {
87
- return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref2) {
88
- var selection = _ref2.selection;
89
-
90
- var _getSelectedCellInfo2 = (0, _utils2.getSelectedCellInfo)(selection),
91
- horizontalCells = _getSelectedCellInfo2.horizontalCells,
92
- verticalCells = _getSelectedCellInfo2.verticalCells,
93
- totalCells = _getSelectedCellInfo2.totalCells,
94
- totalRowCount = _getSelectedCellInfo2.totalRowCount,
95
- totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
96
-
97
- return {
98
- action: _analytics.TABLE_ACTION.MERGED,
99
- actionSubject: _analytics.ACTION_SUBJECT.TABLE,
100
- actionSubjectId: null,
101
- attributes: {
102
- inputMethod: _analytics.INPUT_METHOD.CONTEXT_MENU,
103
- // TODO: merge with floating toolbar once command is updated
104
- horizontalCells: horizontalCells,
105
- verticalCells: verticalCells,
106
- totalCells: totalCells,
107
- totalRowCount: totalRowCount,
108
- totalColumnCount: totalColumnCount
109
- },
110
- eventType: _analytics.EVENT_TYPE.TRACK
111
- };
112
- })(editorAnalyticsAPI)(function (state, dispatch) {
113
- if (dispatch) {
114
- dispatch((0, _transforms.mergeCells)(state.tr));
115
- }
116
-
117
- return true;
118
- });
119
- };
120
-
121
- exports.mergeCellsWithAnalytics = mergeCellsWithAnalytics;
122
-
123
- var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
124
- return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref3) {
125
- var selection = _ref3.selection;
126
-
127
- var _getSelectedCellInfo3 = (0, _utils2.getSelectedCellInfo)(selection),
128
- totalRowCount = _getSelectedCellInfo3.totalRowCount,
129
- totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
87
+ return function (inputMethod) {
88
+ return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref2) {
89
+ var selection = _ref2.selection;
130
90
 
131
- var cell = (0, _utils.findCellClosestToPos)(selection.$anchor);
91
+ var _getSelectedCellInfo2 = (0, _utils2.getSelectedCellInfo)(selection),
92
+ horizontalCells = _getSelectedCellInfo2.horizontalCells,
93
+ verticalCells = _getSelectedCellInfo2.verticalCells,
94
+ totalCells = _getSelectedCellInfo2.totalCells,
95
+ totalRowCount = _getSelectedCellInfo2.totalRowCount,
96
+ totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
132
97
 
133
- if (cell) {
134
- var _cell$node$attrs = cell.node.attrs,
135
- verticalCells = _cell$node$attrs.rowspan,
136
- horizontalCells = _cell$node$attrs.colspan;
137
98
  return {
138
- action: _analytics.TABLE_ACTION.SPLIT,
99
+ action: _analytics.TABLE_ACTION.MERGED,
139
100
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
140
101
  actionSubjectId: null,
141
102
  attributes: {
142
- inputMethod: _analytics.INPUT_METHOD.CONTEXT_MENU,
143
- // TODO: merge with floating toolbar once command is updated
103
+ inputMethod: inputMethod,
144
104
  horizontalCells: horizontalCells,
145
105
  verticalCells: verticalCells,
146
- totalCells: horizontalCells * verticalCells,
106
+ totalCells: totalCells,
147
107
  totalRowCount: totalRowCount,
148
108
  totalColumnCount: totalColumnCount
149
109
  },
150
110
  eventType: _analytics.EVENT_TYPE.TRACK
151
111
  };
152
- }
112
+ })(editorAnalyticsAPI)(function (state, dispatch) {
113
+ if (dispatch) {
114
+ dispatch((0, _transforms.mergeCells)(state.tr));
115
+ }
153
116
 
154
- return;
155
- })(editorAnalyticsAPI)(_splitCell.splitCell);
117
+ return true;
118
+ });
119
+ };
120
+ };
121
+
122
+ exports.mergeCellsWithAnalytics = mergeCellsWithAnalytics;
123
+
124
+ var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
125
+ return function (inputMethod) {
126
+ return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref3) {
127
+ var selection = _ref3.selection;
128
+
129
+ var _getSelectedCellInfo3 = (0, _utils2.getSelectedCellInfo)(selection),
130
+ totalRowCount = _getSelectedCellInfo3.totalRowCount,
131
+ totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
132
+
133
+ var cell = (0, _utils.findCellClosestToPos)(selection.$anchor);
134
+
135
+ if (cell) {
136
+ var _cell$node$attrs = cell.node.attrs,
137
+ verticalCells = _cell$node$attrs.rowspan,
138
+ horizontalCells = _cell$node$attrs.colspan;
139
+ return {
140
+ action: _analytics.TABLE_ACTION.SPLIT,
141
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
142
+ actionSubjectId: null,
143
+ attributes: {
144
+ inputMethod: inputMethod,
145
+ horizontalCells: horizontalCells,
146
+ verticalCells: verticalCells,
147
+ totalCells: horizontalCells * verticalCells,
148
+ totalRowCount: totalRowCount,
149
+ totalColumnCount: totalColumnCount
150
+ },
151
+ eventType: _analytics.EVENT_TYPE.TRACK
152
+ };
153
+ }
154
+
155
+ return;
156
+ })(editorAnalyticsAPI)(_splitCell.splitCell);
157
+ };
156
158
  };
157
159
 
158
160
  exports.splitCellWithAnalytics = splitCellWithAnalytics;
159
161
 
160
162
  var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
161
- return function (cellColor, targetCellPosition) {
163
+ return function (inputMethod, cellColor, targetCellPosition) {
162
164
  return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref4) {
163
165
  var selection = _ref4.selection;
164
166
 
@@ -174,8 +176,7 @@ var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
174
176
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
175
177
  actionSubjectId: null,
176
178
  attributes: {
177
- inputMethod: _analytics.INPUT_METHOD.CONTEXT_MENU,
178
- // TODO: merge with floating toolbar once command is updated
179
+ inputMethod: inputMethod,
179
180
  cellColor: (_adfSchema.tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
180
181
  horizontalCells: horizontalCells,
181
182
  verticalCells: verticalCells,
@@ -37,7 +37,6 @@ var _utils3 = require("./utils");
37
37
 
38
38
  var _getAllowAddColumnCustomStep = require("./utils/get-allow-add-column-custom-step");
39
39
 
40
- // import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
41
40
  var isFocusingCalendar = function isFocusingCalendar(event) {
42
41
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
43
42
  };
@@ -166,21 +166,38 @@ var tablesPlugin = function tablesPlugin(options) {
166
166
  }, {
167
167
  name: 'tableEditing',
168
168
  plugin: function plugin() {
169
- return (0, _pmPlugins.tableEditing)();
169
+ return (0, _pmPlugins.tableEditing)({
170
+ reportFixedTable: function reportFixedTable(_ref5) {
171
+ var _options$editorAnalyt;
172
+
173
+ var state = _ref5.state,
174
+ tr = _ref5.tr,
175
+ reason = _ref5.reason;
176
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
177
+ action: _analytics.TABLE_ACTION.FIXED,
178
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
179
+ actionSubjectId: null,
180
+ attributes: {
181
+ reason: reason
182
+ },
183
+ eventType: _analytics.EVENT_TYPE.TRACK
184
+ })(tr);
185
+ }
186
+ });
170
187
  }
171
188
  }, {
172
189
  name: 'tableStickyHeaders',
173
- plugin: function plugin(_ref5) {
174
- var dispatch = _ref5.dispatch,
175
- eventDispatcher = _ref5.eventDispatcher;
190
+ plugin: function plugin(_ref6) {
191
+ var dispatch = _ref6.dispatch,
192
+ eventDispatcher = _ref6.eventDispatcher;
176
193
  return options && options.tableOptions.stickyHeaders ? (0, _stickyHeaders.createPlugin)(dispatch, eventDispatcher, function () {
177
194
  return [];
178
195
  }, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
179
196
  }
180
197
  }, {
181
198
  name: 'tableLocalId',
182
- plugin: function plugin(_ref6) {
183
- var dispatch = _ref6.dispatch;
199
+ plugin: function plugin(_ref7) {
200
+ var dispatch = _ref7.dispatch;
184
201
  return (0, _tableLocalId.createPlugin)(dispatch);
185
202
  }
186
203
  }, {
@@ -225,12 +242,12 @@ var tablesPlugin = function tablesPlugin(options) {
225
242
 
226
243
  return plugins;
227
244
  },
228
- contentComponent: function contentComponent(_ref7) {
229
- var editorView = _ref7.editorView,
230
- popupsMountPoint = _ref7.popupsMountPoint,
231
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
232
- popupsScrollableElement = _ref7.popupsScrollableElement,
233
- dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent;
245
+ contentComponent: function contentComponent(_ref8) {
246
+ var editorView = _ref8.editorView,
247
+ popupsMountPoint = _ref8.popupsMountPoint,
248
+ popupsBoundariesElement = _ref8.popupsBoundariesElement,
249
+ popupsScrollableElement = _ref8.popupsScrollableElement,
250
+ dispatchAnalyticsEvent = _ref8.dispatchAnalyticsEvent;
234
251
  return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
235
252
  component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
236
253
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -241,25 +258,25 @@ var tablesPlugin = function tablesPlugin(options) {
241
258
  tableResizingPluginState: _tableResizing.pluginKey,
242
259
  stickyHeadersState: _stickyHeaders.pluginKey
243
260
  },
244
- render: function render(_ref8) {
245
- var resizingPluginState = _ref8.tableResizingPluginState,
246
- stickyHeadersState = _ref8.stickyHeadersState,
247
- tablePluginState = _ref8.tablePluginState;
261
+ render: function render(_ref9) {
262
+ var resizingPluginState = _ref9.tableResizingPluginState,
263
+ stickyHeadersState = _ref9.stickyHeadersState,
264
+ tablePluginState = _ref9.tablePluginState;
248
265
  var state = editorView.state;
249
266
  var isDragging = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
250
- var _ref9 = tablePluginState,
251
- tableNode = _ref9.tableNode,
252
- tablePos = _ref9.tablePos,
253
- targetCellPosition = _ref9.targetCellPosition,
254
- isContextualMenuOpen = _ref9.isContextualMenuOpen,
255
- layout = _ref9.layout,
256
- tableRef = _ref9.tableRef,
257
- pluginConfig = _ref9.pluginConfig,
258
- insertColumnButtonIndex = _ref9.insertColumnButtonIndex,
259
- insertRowButtonIndex = _ref9.insertRowButtonIndex,
260
- isHeaderColumnEnabled = _ref9.isHeaderColumnEnabled,
261
- isHeaderRowEnabled = _ref9.isHeaderRowEnabled,
262
- tableWrapperTarget = _ref9.tableWrapperTarget;
267
+ var _ref10 = tablePluginState,
268
+ tableNode = _ref10.tableNode,
269
+ tablePos = _ref10.tablePos,
270
+ targetCellPosition = _ref10.targetCellPosition,
271
+ isContextualMenuOpen = _ref10.isContextualMenuOpen,
272
+ layout = _ref10.layout,
273
+ tableRef = _ref10.tableRef,
274
+ pluginConfig = _ref10.pluginConfig,
275
+ insertColumnButtonIndex = _ref10.insertColumnButtonIndex,
276
+ insertRowButtonIndex = _ref10.insertRowButtonIndex,
277
+ isHeaderColumnEnabled = _ref10.isHeaderColumnEnabled,
278
+ isHeaderRowEnabled = _ref10.isHeaderRowEnabled,
279
+ tableWrapperTarget = _ref10.tableWrapperTarget;
263
280
  var allowControls = pluginConfig.allowControls;
264
281
  var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
265
282
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/_react.default.createElement(_FloatingContextualButton.default, {
@@ -324,9 +341,9 @@ var tablesPlugin = function tablesPlugin(options) {
324
341
  pluginsOptions: {
325
342
  // TODO: ED-14676 This is not the final API design
326
343
  // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
327
- createNodeHandler: function createNodeHandler(_ref10) {
328
- var nodeName = _ref10.nodeName,
329
- schema = _ref10.schema;
344
+ createNodeHandler: function createNodeHandler(_ref11) {
345
+ var nodeName = _ref11.nodeName,
346
+ schema = _ref11.schema;
330
347
 
331
348
  // An EditorPlugin may manage more than one node.
332
349
  if (nodeName !== 'table') {
@@ -338,8 +355,8 @@ var tablesPlugin = function tablesPlugin(options) {
338
355
  });
339
356
  return table;
340
357
  },
341
- quickInsert: function quickInsert(_ref11) {
342
- var formatMessage = _ref11.formatMessage;
358
+ quickInsert: function quickInsert(_ref12) {
359
+ var formatMessage = _ref12.formatMessage;
343
360
  return [{
344
361
  id: 'table',
345
362
  title: formatMessage(_messages.toolbarInsertBlockMessages.table),
@@ -351,12 +368,12 @@ var tablesPlugin = function tablesPlugin(options) {
351
368
  return /*#__PURE__*/_react.default.createElement(_icons.IconTable, null);
352
369
  },
353
370
  action: function action(insert, state) {
354
- var _options$editorAnalyt;
371
+ var _options$editorAnalyt2;
355
372
 
356
373
  var tr = insert((0, _utils2.createTable)({
357
374
  schema: state.schema
358
375
  }));
359
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
376
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
360
377
  action: _analytics.ACTION.INSERTED,
361
378
  actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
362
379
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
@@ -369,7 +386,7 @@ var tablesPlugin = function tablesPlugin(options) {
369
386
  }
370
387
  }];
371
388
  },
372
- floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
389
+ floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
373
390
  }
374
391
  };
375
392
  };
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "createPlugin", {
9
9
  return _plugin.createPlugin;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "getPluginState", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _pluginFactory.getPluginState;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "pluginKey", {
13
19
  enumerable: true,
14
20
  get: function get() {
@@ -26,4 +32,6 @@ var _plugin = require("./plugin");
26
32
 
27
33
  var _commands = require("./commands");
28
34
 
29
- var _pluginKey = require("./plugin-key");
35
+ var _pluginKey = require("./plugin-key");
36
+
37
+ var _pluginFactory = require("./plugin-factory");