@atlaskit/editor-core 187.8.3 → 187.8.10

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 (275) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/create-editor/ReactEditorViewInternal.js +4 -5
  3. package/dist/cjs/index.js +0 -6
  4. package/dist/cjs/plugins/annotation/commands/transform.js +2 -2
  5. package/dist/cjs/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
  6. package/dist/cjs/plugins/block-type/commands/block-type.js +2 -2
  7. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +4 -4
  8. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +2 -2
  9. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +5 -5
  10. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +2 -2
  11. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +2 -2
  12. package/dist/cjs/plugins/layout/pm-plugins/main.js +1 -1
  13. package/dist/cjs/plugins/list/actions/conversions.js +5 -5
  14. package/dist/cjs/plugins/list/actions/indent-list-items-selected.js +11 -11
  15. package/dist/cjs/plugins/list/actions/join-list-items-forward.js +6 -6
  16. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +6 -7
  17. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +3 -4
  18. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +3 -4
  19. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +2 -2
  20. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +2 -2
  21. package/dist/cjs/plugins/list/actions/merge-lists.js +3 -3
  22. package/dist/cjs/plugins/list/actions/outdent-list-items-selected.js +11 -11
  23. package/dist/cjs/plugins/list/actions/wrap-and-join-lists.js +2 -2
  24. package/dist/cjs/plugins/list/commands/indent-list.js +6 -7
  25. package/dist/cjs/plugins/list/commands/index.js +8 -10
  26. package/dist/cjs/plugins/list/commands/join-list-item-forward.js +5 -5
  27. package/dist/cjs/plugins/list/commands/listBackspace.js +13 -14
  28. package/dist/cjs/plugins/list/commands/outdent-list.js +4 -3
  29. package/dist/cjs/plugins/list/pm-plugins/main.js +5 -6
  30. package/dist/cjs/plugins/list/utils/analytics.js +1 -35
  31. package/dist/cjs/plugins/list/utils/indentation.js +2 -20
  32. package/dist/cjs/plugins/list/utils/node.js +2 -106
  33. package/dist/cjs/plugins/list/utils/selection.js +3 -54
  34. package/dist/cjs/plugins/tasks-and-decisions/commands.js +2 -2
  35. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +17 -18
  36. package/dist/cjs/plugins/text-color/commands/toggle-color.js +2 -2
  37. package/dist/cjs/plugins/text-formatting/commands/text-formatting.js +9 -9
  38. package/dist/cjs/plugins/text-formatting/commands/transform-to-code.js +2 -2
  39. package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting.js +2 -5
  40. package/dist/cjs/plugins/text-formatting/pm-plugins/input-rule.js +2 -2
  41. package/dist/cjs/plugins/text-formatting/pm-plugins/main.js +2 -1
  42. package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +2 -2
  43. package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +2 -3
  44. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
  45. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +2 -2
  46. package/dist/cjs/ui/Appearance/Comment/Comment.js +5 -6
  47. package/dist/cjs/ui/Appearance/Comment/Toolbar.js +2 -2
  48. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +2 -2
  49. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +5 -5
  50. package/dist/cjs/ui/Dropdown/index.js +1 -2
  51. package/dist/cjs/ui/styles.js +3 -5
  52. package/dist/cjs/utils/commands.js +3 -222
  53. package/dist/cjs/utils/document.js +1 -26
  54. package/dist/cjs/utils/index.js +0 -19
  55. package/dist/cjs/version-wrapper.js +1 -1
  56. package/dist/cjs/version.json +1 -1
  57. package/dist/es2019/create-editor/ReactEditorViewInternal.js +3 -6
  58. package/dist/es2019/index.js +1 -1
  59. package/dist/es2019/plugins/annotation/commands/transform.js +1 -1
  60. package/dist/es2019/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
  61. package/dist/es2019/plugins/block-type/commands/block-type.js +1 -1
  62. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +1 -1
  63. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +1 -1
  64. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +1 -1
  65. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +3 -5
  66. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +1 -1
  67. package/dist/es2019/plugins/layout/pm-plugins/main.js +1 -1
  68. package/dist/es2019/plugins/list/actions/conversions.js +2 -2
  69. package/dist/es2019/plugins/list/actions/indent-list-items-selected.js +2 -2
  70. package/dist/es2019/plugins/list/actions/join-list-items-forward.js +1 -1
  71. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +1 -2
  72. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +2 -2
  73. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +2 -2
  74. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +1 -1
  75. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +1 -1
  76. package/dist/es2019/plugins/list/actions/merge-lists.js +1 -1
  77. package/dist/es2019/plugins/list/actions/outdent-list-items-selected.js +3 -3
  78. package/dist/es2019/plugins/list/actions/wrap-and-join-lists.js +1 -1
  79. package/dist/es2019/plugins/list/commands/indent-list.js +3 -4
  80. package/dist/es2019/plugins/list/commands/index.js +4 -5
  81. package/dist/es2019/plugins/list/commands/join-list-item-forward.js +1 -1
  82. package/dist/es2019/plugins/list/commands/listBackspace.js +1 -2
  83. package/dist/es2019/plugins/list/commands/outdent-list.js +3 -2
  84. package/dist/es2019/plugins/list/pm-plugins/main.js +1 -1
  85. package/dist/es2019/plugins/list/utils/analytics.js +0 -36
  86. package/dist/es2019/plugins/list/utils/indentation.js +0 -18
  87. package/dist/es2019/plugins/list/utils/node.js +3 -89
  88. package/dist/es2019/plugins/list/utils/selection.js +1 -52
  89. package/dist/es2019/plugins/tasks-and-decisions/commands.js +1 -1
  90. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
  91. package/dist/es2019/plugins/text-color/commands/toggle-color.js +1 -1
  92. package/dist/es2019/plugins/text-formatting/commands/text-formatting.js +1 -1
  93. package/dist/es2019/plugins/text-formatting/commands/transform-to-code.js +1 -1
  94. package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting.js +2 -2
  95. package/dist/es2019/plugins/text-formatting/pm-plugins/input-rule.js +1 -1
  96. package/dist/es2019/plugins/text-formatting/pm-plugins/main.js +2 -1
  97. package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +1 -1
  98. package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +1 -2
  99. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
  100. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
  101. package/dist/es2019/ui/Appearance/Comment/Comment.js +6 -5
  102. package/dist/es2019/ui/Appearance/Comment/Toolbar.js +3 -2
  103. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +2 -3
  104. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +2 -2
  105. package/dist/es2019/ui/Dropdown/index.js +1 -2
  106. package/dist/es2019/ui/ElementBrowser/InsertMenu.js +1 -0
  107. package/dist/es2019/ui/styles.js +0 -5
  108. package/dist/es2019/utils/commands.js +2 -214
  109. package/dist/es2019/utils/document.js +1 -26
  110. package/dist/es2019/utils/index.js +1 -13
  111. package/dist/es2019/version-wrapper.js +1 -1
  112. package/dist/es2019/version.json +1 -1
  113. package/dist/esm/create-editor/ReactEditorViewInternal.js +3 -6
  114. package/dist/esm/index.js +1 -1
  115. package/dist/esm/plugins/annotation/commands/transform.js +1 -1
  116. package/dist/esm/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
  117. package/dist/esm/plugins/block-type/commands/block-type.js +1 -1
  118. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +1 -1
  119. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +1 -1
  120. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +1 -1
  121. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +3 -5
  122. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +1 -1
  123. package/dist/esm/plugins/layout/pm-plugins/main.js +1 -1
  124. package/dist/esm/plugins/list/actions/conversions.js +2 -2
  125. package/dist/esm/plugins/list/actions/indent-list-items-selected.js +2 -2
  126. package/dist/esm/plugins/list/actions/join-list-items-forward.js +1 -1
  127. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +1 -2
  128. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +2 -2
  129. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +2 -2
  130. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +1 -1
  131. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +1 -1
  132. package/dist/esm/plugins/list/actions/merge-lists.js +1 -1
  133. package/dist/esm/plugins/list/actions/outdent-list-items-selected.js +3 -3
  134. package/dist/esm/plugins/list/actions/wrap-and-join-lists.js +1 -1
  135. package/dist/esm/plugins/list/commands/indent-list.js +3 -4
  136. package/dist/esm/plugins/list/commands/index.js +4 -5
  137. package/dist/esm/plugins/list/commands/join-list-item-forward.js +1 -1
  138. package/dist/esm/plugins/list/commands/listBackspace.js +1 -2
  139. package/dist/esm/plugins/list/commands/outdent-list.js +3 -2
  140. package/dist/esm/plugins/list/pm-plugins/main.js +1 -1
  141. package/dist/esm/plugins/list/utils/analytics.js +0 -32
  142. package/dist/esm/plugins/list/utils/indentation.js +0 -17
  143. package/dist/esm/plugins/list/utils/node.js +3 -81
  144. package/dist/esm/plugins/list/utils/selection.js +3 -51
  145. package/dist/esm/plugins/tasks-and-decisions/commands.js +1 -1
  146. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
  147. package/dist/esm/plugins/text-color/commands/toggle-color.js +1 -1
  148. package/dist/esm/plugins/text-formatting/commands/text-formatting.js +1 -1
  149. package/dist/esm/plugins/text-formatting/commands/transform-to-code.js +1 -1
  150. package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting.js +2 -2
  151. package/dist/esm/plugins/text-formatting/pm-plugins/input-rule.js +1 -1
  152. package/dist/esm/plugins/text-formatting/pm-plugins/main.js +2 -1
  153. package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +1 -1
  154. package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +1 -2
  155. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
  156. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
  157. package/dist/esm/ui/Appearance/Comment/Comment.js +4 -5
  158. package/dist/esm/ui/Appearance/Comment/Toolbar.js +3 -2
  159. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +2 -3
  160. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +2 -2
  161. package/dist/esm/ui/Dropdown/index.js +1 -2
  162. package/dist/esm/ui/ElementBrowser/InsertMenu.js +1 -0
  163. package/dist/esm/ui/styles.js +2 -3
  164. package/dist/esm/utils/commands.js +2 -211
  165. package/dist/esm/utils/document.js +1 -26
  166. package/dist/esm/utils/index.js +1 -13
  167. package/dist/esm/version-wrapper.js +1 -1
  168. package/dist/esm/version.json +1 -1
  169. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -1
  170. package/dist/types/index.d.ts +1 -1
  171. package/dist/types/plugins/block-type/commands/block-type.d.ts +1 -2
  172. package/dist/types/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
  173. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +1 -1
  174. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  175. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +1 -1
  176. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +1 -1
  177. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
  178. package/dist/types/plugins/list/actions/join-list-items-forward.d.ts +1 -1
  179. package/dist/types/plugins/list/commands/indent-list.d.ts +2 -1
  180. package/dist/types/plugins/list/commands/index.d.ts +2 -1
  181. package/dist/types/plugins/list/commands/join-list-item-forward.d.ts +1 -1
  182. package/dist/types/plugins/list/commands/listBackspace.d.ts +1 -1
  183. package/dist/types/plugins/list/commands/outdent-list.d.ts +2 -1
  184. package/dist/types/plugins/list/utils/analytics.d.ts +2 -4
  185. package/dist/types/plugins/list/utils/indentation.d.ts +0 -5
  186. package/dist/types/plugins/list/utils/node.d.ts +2 -17
  187. package/dist/types/plugins/list/utils/selection.d.ts +1 -12
  188. package/dist/types/plugins/text-color/commands/toggle-color.d.ts +1 -1
  189. package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +2 -2
  190. package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +1 -1
  191. package/dist/types/types/editor-appearance-component.d.ts +4 -4
  192. package/dist/types/types/editor-instance.d.ts +1 -1
  193. package/dist/types/types/editor-props.d.ts +5 -8
  194. package/dist/types/ui/Appearance/Comment/Comment.d.ts +2 -2
  195. package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +1 -2
  196. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  197. package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
  198. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  199. package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +1 -1
  200. package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +1 -1
  201. package/dist/types/ui/ElementBrowser/types.d.ts +1 -1
  202. package/dist/types/ui/styles.d.ts +0 -1
  203. package/dist/types/utils/commands.d.ts +3 -42
  204. package/dist/types/utils/document.d.ts +0 -4
  205. package/dist/types/utils/index.d.ts +1 -5
  206. package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -1
  207. package/dist/types-ts4.5/index.d.ts +1 -1
  208. package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +1 -2
  209. package/dist/types-ts4.5/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
  210. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +1 -1
  211. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  212. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +1 -1
  213. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +1 -1
  214. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
  215. package/dist/types-ts4.5/plugins/list/actions/join-list-items-forward.d.ts +1 -1
  216. package/dist/types-ts4.5/plugins/list/commands/indent-list.d.ts +2 -1
  217. package/dist/types-ts4.5/plugins/list/commands/index.d.ts +2 -1
  218. package/dist/types-ts4.5/plugins/list/commands/join-list-item-forward.d.ts +1 -1
  219. package/dist/types-ts4.5/plugins/list/commands/listBackspace.d.ts +1 -1
  220. package/dist/types-ts4.5/plugins/list/commands/outdent-list.d.ts +2 -1
  221. package/dist/types-ts4.5/plugins/list/utils/analytics.d.ts +2 -4
  222. package/dist/types-ts4.5/plugins/list/utils/indentation.d.ts +0 -5
  223. package/dist/types-ts4.5/plugins/list/utils/node.d.ts +2 -17
  224. package/dist/types-ts4.5/plugins/list/utils/selection.d.ts +1 -12
  225. package/dist/types-ts4.5/plugins/text-color/commands/toggle-color.d.ts +1 -1
  226. package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +2 -2
  227. package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +1 -1
  228. package/dist/types-ts4.5/types/editor-appearance-component.d.ts +4 -4
  229. package/dist/types-ts4.5/types/editor-instance.d.ts +1 -1
  230. package/dist/types-ts4.5/types/editor-props.d.ts +5 -8
  231. package/dist/types-ts4.5/ui/Appearance/Comment/Comment.d.ts +2 -2
  232. package/dist/types-ts4.5/ui/Appearance/Comment/Toolbar.d.ts +1 -2
  233. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  234. package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +1 -1
  235. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  236. package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +1 -1
  237. package/dist/types-ts4.5/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +1 -1
  238. package/dist/types-ts4.5/ui/ElementBrowser/types.d.ts +1 -1
  239. package/dist/types-ts4.5/ui/styles.d.ts +0 -1
  240. package/dist/types-ts4.5/utils/commands.d.ts +3 -48
  241. package/dist/types-ts4.5/utils/document.d.ts +0 -4
  242. package/dist/types-ts4.5/utils/index.d.ts +1 -5
  243. package/package.json +3 -3
  244. package/report.api.md +2 -13
  245. package/tmp/api-report-tmp.d.ts +2 -10
  246. package/dist/cjs/plugins/list/utils/replace-content.js +0 -24
  247. package/dist/cjs/ui/Appearance/FullPage/messages.js +0 -25
  248. package/dist/cjs/ui/DropdownMenu/index.js +0 -31
  249. package/dist/cjs/ui/DropdownMenu/types.js +0 -5
  250. package/dist/cjs/ui/ToolbarArrowKeyNavigationProvider/index.js +0 -218
  251. package/dist/cjs/utils/prosemirror/autojoin.js +0 -68
  252. package/dist/es2019/plugins/list/utils/replace-content.js +0 -18
  253. package/dist/es2019/ui/Appearance/FullPage/messages.js +0 -18
  254. package/dist/es2019/ui/DropdownMenu/index.js +0 -18
  255. package/dist/es2019/ui/DropdownMenu/types.js +0 -1
  256. package/dist/es2019/ui/ToolbarArrowKeyNavigationProvider/index.js +0 -205
  257. package/dist/es2019/utils/prosemirror/autojoin.js +0 -57
  258. package/dist/esm/plugins/list/utils/replace-content.js +0 -17
  259. package/dist/esm/ui/Appearance/FullPage/messages.js +0 -18
  260. package/dist/esm/ui/DropdownMenu/index.js +0 -20
  261. package/dist/esm/ui/DropdownMenu/types.js +0 -1
  262. package/dist/esm/ui/ToolbarArrowKeyNavigationProvider/index.js +0 -205
  263. package/dist/esm/utils/prosemirror/autojoin.js +0 -63
  264. package/dist/types/plugins/list/utils/replace-content.d.ts +0 -8
  265. package/dist/types/ui/Appearance/FullPage/messages.d.ts +0 -18
  266. package/dist/types/ui/DropdownMenu/index.d.ts +0 -3
  267. package/dist/types/ui/DropdownMenu/types.d.ts +0 -1
  268. package/dist/types/ui/ToolbarArrowKeyNavigationProvider/index.d.ts +0 -31
  269. package/dist/types/utils/prosemirror/autojoin.d.ts +0 -13
  270. package/dist/types-ts4.5/plugins/list/utils/replace-content.d.ts +0 -8
  271. package/dist/types-ts4.5/ui/Appearance/FullPage/messages.d.ts +0 -18
  272. package/dist/types-ts4.5/ui/DropdownMenu/index.d.ts +0 -3
  273. package/dist/types-ts4.5/ui/DropdownMenu/types.d.ts +0 -1
  274. package/dist/types-ts4.5/ui/ToolbarArrowKeyNavigationProvider/index.d.ts +0 -31
  275. package/dist/types-ts4.5/utils/prosemirror/autojoin.d.ts +0 -13
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
11
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
- var _uiMenu = require("@atlaskit/editor-common/ui-menu");
13
- var _react = _interopRequireWildcard(require("react"));
14
- var _ToolbarArrowKeyNavigationProvider = require("../ToolbarArrowKeyNavigationProvider");
15
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
- 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
- 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
- var DropdownMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
20
- var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref), _ref));
21
- var keyDownHandlerContext = (0, _react.useContext)(_ToolbarArrowKeyNavigationProvider.KeyDownHandlerContext);
22
- //This context is to handle the tab, Arrow Right/Left key events for dropdown.
23
- //Default context has the void callbacks for above key events
24
- return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenu, (0, _extends2.default)({
25
- arrowKeyNavigationProviderOptions: _objectSpread(_objectSpread({}, props.arrowKeyNavigationProviderOptions), {}, {
26
- keyDownHandlerContext: keyDownHandlerContext
27
- })
28
- }, props));
29
- });
30
- var _default = DropdownMenu;
31
- exports.default = _default;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,218 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.ToolbarArrowKeyNavigationProvider = exports.KeyDownHandlerContext = void 0;
9
- var _react = require("@emotion/react");
10
- var _styles = require("../styles");
11
- var _react2 = _interopRequireWildcard(require("react"));
12
- var _ReactEditorViewInternal = require("../../create-editor/ReactEditorViewInternal");
13
- var _messages = _interopRequireDefault(require("../Appearance/FullPage/messages"));
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
- /** @jsx jsx */
17
- /* eslint-disable no-console */
18
-
19
- /*
20
- ** The context is used to handle the keydown events of submenus.
21
- ** Because the keyboard navigation is explicitly managed for main toolbar items
22
- ** Few key presses such as Tab,Arrow Right/Left need ot be handled here via context
23
- */
24
- var KeyDownHandlerContext = /*#__PURE__*/_react2.default.createContext({
25
- handleArrowLeft: function handleArrowLeft() {},
26
- handleArrowRight: function handleArrowRight() {},
27
- handleTab: function handleTab() {}
28
- });
29
-
30
- /**
31
- * This component is a wrapper of main toolbar which listens to keydown events of children
32
- * and handles left/right arrow key navigation for all focusable elements
33
- * @param
34
- * @returns
35
- */
36
- exports.KeyDownHandlerContext = KeyDownHandlerContext;
37
- var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigationProvider(_ref) {
38
- var children = _ref.children,
39
- editorView = _ref.editorView,
40
- childComponentSelector = _ref.childComponentSelector,
41
- handleEscape = _ref.handleEscape,
42
- disableArrowKeyNavigation = _ref.disableArrowKeyNavigation,
43
- isShortcutToFocusToolbar = _ref.isShortcutToFocusToolbar,
44
- editorAppearance = _ref.editorAppearance,
45
- useStickyToolbar = _ref.useStickyToolbar,
46
- intl = _ref.intl;
47
- var wrapperRef = (0, _react2.useRef)(null);
48
- var selectedItemIndex = (0, _react2.useRef)(0);
49
- var incrementIndex = (0, _react2.useCallback)(function (list) {
50
- var index = 0;
51
- if (document.activeElement) {
52
- index = list.indexOf(document.activeElement);
53
- index = (index + 1) % list.length;
54
- }
55
- selectedItemIndex.current = index;
56
- }, []);
57
- var decrementIndex = (0, _react2.useCallback)(function (list) {
58
- var index = 0;
59
- if (document.activeElement) {
60
- index = list.indexOf(document.activeElement);
61
- index = (list.length + index - 1) % list.length;
62
- }
63
- selectedItemIndex.current = index;
64
- }, []);
65
- var handleArrowRight = function handleArrowRight() {
66
- var _filteredFocusableEle;
67
- var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
68
- incrementIndex(filteredFocusableElements);
69
- (_filteredFocusableEle = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
70
- };
71
- var handleArrowLeft = function handleArrowLeft() {
72
- var _filteredFocusableEle2;
73
- var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
74
- decrementIndex(filteredFocusableElements);
75
- (_filteredFocusableEle2 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.focus();
76
- };
77
- var handleTab = function handleTab() {
78
- var _filteredFocusableEle3;
79
- var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
80
- (_filteredFocusableEle3 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.focus();
81
- };
82
- var handleTabLocal = function handleTabLocal() {
83
- var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
84
- filteredFocusableElements.forEach(function (element) {
85
- element.setAttribute('tabindex', '-1');
86
- });
87
- filteredFocusableElements[selectedItemIndex.current].setAttribute('tabindex', '0');
88
- };
89
- var focusAndScrollToElement = function focusAndScrollToElement(element) {
90
- var scrollToElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
91
- if (scrollToElement) {
92
- element === null || element === void 0 ? void 0 : element.scrollIntoView({
93
- behavior: 'smooth',
94
- block: 'center',
95
- inline: 'nearest'
96
- });
97
- }
98
- element.focus();
99
- };
100
- var submenuKeydownHandleContext = {
101
- handleArrowLeft: handleArrowLeft,
102
- handleArrowRight: handleArrowRight,
103
- handleTab: handleTab
104
- };
105
- (0, _react2.useLayoutEffect)(function () {
106
- if (!wrapperRef.current || disableArrowKeyNavigation) {
107
- return;
108
- }
109
- var element = wrapperRef.current;
110
-
111
- /**
112
- * To handle the key events on the list
113
- * @param event
114
- */
115
- var handleKeyDown = function handleKeyDown(event) {
116
- var _document$querySelect, _document$querySelect2, _wrapperRef$current;
117
- //To trap the focus inside the horizontal toolbar for left and right arrow keys
118
- var targetElement = event.target;
119
-
120
- //To filter out the events outside the child component
121
- if (!targetElement.closest("".concat(childComponentSelector))) {
122
- return;
123
- }
124
-
125
- //The key events are from child components such as dropdown menus / popups are ignored
126
- if ((_document$querySelect = document.querySelector('[data-role="droplistContent"], [data-test-id="color-picker-menu"], [data-emoji-picker-container="true"]')) !== null && _document$querySelect !== void 0 && _document$querySelect.contains(targetElement) || (_document$querySelect2 = document.querySelector('[data-test-id="color-picker-menu"]')) !== null && _document$querySelect2 !== void 0 && _document$querySelect2.contains(targetElement) || event.key === 'ArrowUp' || event.key === 'ArrowDown' || disableArrowKeyNavigation) {
127
- return;
128
- }
129
- var menuWrapper = document.querySelector('.menu-key-handler-wrapper');
130
- if (menuWrapper) {
131
- // if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
132
- return;
133
- }
134
- var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
135
- if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
136
- return;
137
- }
138
-
139
- //This is kind of hack to reset the current focused toolbar item
140
- //to handle some use cases such as Tab in/out of main toolbar
141
- if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
142
- selectedItemIndex.current = -1;
143
- } else {
144
- selectedItemIndex.current = filteredFocusableElements.indexOf(targetElement) > -1 ? filteredFocusableElements.indexOf(targetElement) : selectedItemIndex.current;
145
- }
146
-
147
- //do not scroll to focused element for sticky toolbar when navigating with arrows to avoid unnesessary scroll jump
148
- var allowScrollToElement = !(editorAppearance === 'comment' && !!useStickyToolbar);
149
- switch (event.key) {
150
- case 'ArrowRight':
151
- incrementIndex(filteredFocusableElements);
152
- focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
153
- event.preventDefault();
154
- break;
155
- case 'ArrowLeft':
156
- decrementIndex(filteredFocusableElements);
157
- focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
158
- event.preventDefault();
159
- break;
160
- case 'Tab':
161
- handleTabLocal();
162
- break;
163
- case 'Escape':
164
- handleEscape(event);
165
- break;
166
- default:
167
- }
168
- };
169
- var globalKeyDownHandler = function globalKeyDownHandler(event) {
170
- //To focus the first element in the toolbar
171
- if (isShortcutToFocusToolbar(event)) {
172
- var _filteredFocusableEle4, _filteredFocusableEle5;
173
- var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
174
- (_filteredFocusableEle4 = filteredFocusableElements[0]) === null || _filteredFocusableEle4 === void 0 ? void 0 : _filteredFocusableEle4.focus();
175
- (_filteredFocusableEle5 = filteredFocusableElements[0]) === null || _filteredFocusableEle5 === void 0 ? void 0 : _filteredFocusableEle5.scrollIntoView({
176
- behavior: 'smooth',
177
- block: 'center',
178
- inline: 'nearest'
179
- });
180
- }
181
- };
182
- element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
183
- var editorViewDom = editorView === null || editorView === void 0 ? void 0 : editorView.dom;
184
- if (isShortcutToFocusToolbar) {
185
- editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.addEventListener('keydown', globalKeyDownHandler);
186
- }
187
- return function () {
188
- element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
189
- if (isShortcutToFocusToolbar) {
190
- editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.removeEventListener('keydown', globalKeyDownHandler);
191
- }
192
- };
193
- }, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex, isShortcutToFocusToolbar, editorAppearance, useStickyToolbar]);
194
- return (0, _react.jsx)("div", {
195
- css: editorAppearance === 'comment' && _styles.centeredToolbarContainer,
196
- className: "custom-key-handler-wrapper",
197
- ref: wrapperRef,
198
- role: "toolbar",
199
- "aria-label": intl.formatMessage(_messages.default.toolbarLabel),
200
- "aria-controls": _ReactEditorViewInternal.EDIT_AREA_ID
201
- }, (0, _react.jsx)(KeyDownHandlerContext.Provider, {
202
- value: submenuKeydownHandleContext
203
- }, children));
204
- };
205
- exports.ToolbarArrowKeyNavigationProvider = ToolbarArrowKeyNavigationProvider;
206
- function getFocusableElements(rootNode) {
207
- if (!rootNode) {
208
- return [];
209
- }
210
- var focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"], div[tabindex="0"]') || [];
211
- return Array.from(focusableModalElements);
212
- }
213
- function getFilteredFocusableElements(rootNode) {
214
- //The focusable elements from child components such as dropdown menus / popups are ignored
215
- return getFocusableElements(rootNode).filter(function (elm) {
216
- return !elm.closest('[data-role="droplistContent"]') && !elm.closest('[data-emoji-picker-container="true"]') && !elm.closest('[data-test-id="color-picker-menu"]') && !elm.closest('.scroll-buttons');
217
- });
218
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.autoJoinTr = autoJoinTr;
7
- var _transform = require("@atlaskit/editor-prosemirror/transform");
8
- /**
9
- * Checks whether two adjacent nodes can be joined. If so, the document
10
- * will be updated to join those nodes. If not, the original transaction
11
- * remains untouched.
12
- *
13
- * Nodes are considered joinable if the `isJoinable` predicate returns true or,
14
- * if an array of strings was passed, if their node type name is in that array.
15
- *
16
- * Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L597-L610
17
- */
18
- function autoJoinTr(tr, isJoinable) {
19
- if (Array.isArray(isJoinable)) {
20
- var types = isJoinable;
21
- isJoinable = function isJoinable(node) {
22
- return types.indexOf(node.type.name) > -1;
23
- };
24
- }
25
- var ranges = [];
26
- for (var i = 0; i < tr.mapping.maps.length; i++) {
27
- var map = tr.mapping.maps[i];
28
- for (var j = 0; j < ranges.length; j++) {
29
- ranges[j] = map.map(ranges[j]);
30
- }
31
- map.forEach(function (_s, _e, from, to) {
32
- return ranges.push(from, to);
33
- });
34
- }
35
-
36
- // Figure out which joinable points exist inside those ranges,
37
- // by checking all node boundaries in their parent nodes.
38
- var joinable = [];
39
- for (var _i = 0; _i < ranges.length; _i += 2) {
40
- var from = ranges[_i];
41
- var to = ranges[_i + 1];
42
- var $from = tr.doc.resolve(from);
43
- var depth = $from.sharedDepth(to);
44
- var parent = $from.node(depth);
45
- for (var index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {
46
- var _after = parent.maybeChild(index);
47
- if (!_after) {
48
- break;
49
- }
50
- if (index && joinable.indexOf(pos) === -1) {
51
- var _before = parent.child(index - 1);
52
- if (_before.type === _after.type && isJoinable(_before, _after)) {
53
- joinable.push(pos);
54
- }
55
- }
56
- pos += _after.nodeSize;
57
- }
58
- }
59
- // Join the joinable points
60
- joinable.sort(function (a, b) {
61
- return a - b;
62
- });
63
- for (var _i2 = joinable.length - 1; _i2 >= 0; _i2--) {
64
- if ((0, _transform.canJoin)(tr.doc, joinable[_i2])) {
65
- tr.join(joinable[_i2]);
66
- }
67
- }
68
- }
@@ -1,18 +0,0 @@
1
- import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
2
- export const moveTargetIntoList = ({
3
- insertPosition,
4
- $target
5
- }) => {
6
- var _$target$nodeAfter;
7
- // take the text content of the paragraph and insert after the paragraph up until before the the cut
8
- const from = insertPosition;
9
- const to = $target.pos + (((_$target$nodeAfter = $target.nodeAfter) === null || _$target$nodeAfter === void 0 ? void 0 : _$target$nodeAfter.nodeSize) || 0); //$cut.pos + $cut.nodeAfter.nodeSize;
10
- const gapFrom = $target.posAtIndex(0, $target.depth + 1); // start pos of the child
11
- const gapTo = $target.doc.resolve(gapFrom).end(); // end pos of the paragraph
12
-
13
- if (gapTo - gapFrom === 0) {
14
- return new ReplaceStep(from, to, $target.doc.slice(insertPosition, $target.pos));
15
- }
16
- const step = new ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
17
- return step;
18
- };
@@ -1,18 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export default defineMessages({
3
- toolbarLabel: {
4
- id: 'fabric.editor.toolbarLabel',
5
- defaultMessage: 'Editor toolbar',
6
- description: 'Label for the ARIA region landmark'
7
- },
8
- pageActionsLabel: {
9
- id: 'fabric.editor.pageActionsLabel',
10
- defaultMessage: 'Page actions',
11
- description: 'Label for the ARIA region landmark'
12
- },
13
- editableContentLabel: {
14
- id: 'fabric.editor.editableContentLabel',
15
- defaultMessage: 'Editable content',
16
- description: 'Label for the ARIA region landmark'
17
- }
18
- });
@@ -1,18 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import { DropdownMenu as DropdownComponent } from '@atlaskit/editor-common/ui-menu';
3
- import React, { useContext } from 'react';
4
- import { KeyDownHandlerContext } from '../ToolbarArrowKeyNavigationProvider';
5
- const DropdownMenu = /*#__PURE__*/React.memo(({
6
- ...props
7
- }) => {
8
- const keyDownHandlerContext = useContext(KeyDownHandlerContext);
9
- //This context is to handle the tab, Arrow Right/Left key events for dropdown.
10
- //Default context has the void callbacks for above key events
11
- return /*#__PURE__*/React.createElement(DropdownComponent, _extends({
12
- arrowKeyNavigationProviderOptions: {
13
- ...props.arrowKeyNavigationProviderOptions,
14
- keyDownHandlerContext
15
- }
16
- }, props));
17
- });
18
- export default DropdownMenu;
@@ -1 +0,0 @@
1
- export {};
@@ -1,205 +0,0 @@
1
- /** @jsx jsx */
2
- /* eslint-disable no-console */
3
- import { jsx } from '@emotion/react';
4
- import { centeredToolbarContainer } from '../styles';
5
- import React, { useCallback, useLayoutEffect, useRef } from 'react';
6
- import { EDIT_AREA_ID } from '../../create-editor/ReactEditorViewInternal';
7
- import messages from '../Appearance/FullPage/messages';
8
- /*
9
- ** The context is used to handle the keydown events of submenus.
10
- ** Because the keyboard navigation is explicitly managed for main toolbar items
11
- ** Few key presses such as Tab,Arrow Right/Left need ot be handled here via context
12
- */
13
- export const KeyDownHandlerContext = /*#__PURE__*/React.createContext({
14
- handleArrowLeft: () => {},
15
- handleArrowRight: () => {},
16
- handleTab: () => {}
17
- });
18
-
19
- /**
20
- * This component is a wrapper of main toolbar which listens to keydown events of children
21
- * and handles left/right arrow key navigation for all focusable elements
22
- * @param
23
- * @returns
24
- */
25
- export const ToolbarArrowKeyNavigationProvider = ({
26
- children,
27
- editorView,
28
- childComponentSelector,
29
- handleEscape,
30
- disableArrowKeyNavigation,
31
- isShortcutToFocusToolbar,
32
- editorAppearance,
33
- useStickyToolbar,
34
- intl
35
- }) => {
36
- const wrapperRef = useRef(null);
37
- const selectedItemIndex = useRef(0);
38
- const incrementIndex = useCallback(list => {
39
- let index = 0;
40
- if (document.activeElement) {
41
- index = list.indexOf(document.activeElement);
42
- index = (index + 1) % list.length;
43
- }
44
- selectedItemIndex.current = index;
45
- }, []);
46
- const decrementIndex = useCallback(list => {
47
- let index = 0;
48
- if (document.activeElement) {
49
- index = list.indexOf(document.activeElement);
50
- index = (list.length + index - 1) % list.length;
51
- }
52
- selectedItemIndex.current = index;
53
- }, []);
54
- const handleArrowRight = () => {
55
- var _filteredFocusableEle;
56
- const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
57
- incrementIndex(filteredFocusableElements);
58
- (_filteredFocusableEle = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
59
- };
60
- const handleArrowLeft = () => {
61
- var _filteredFocusableEle2;
62
- const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
63
- decrementIndex(filteredFocusableElements);
64
- (_filteredFocusableEle2 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.focus();
65
- };
66
- const handleTab = () => {
67
- var _filteredFocusableEle3;
68
- const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
69
- (_filteredFocusableEle3 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.focus();
70
- };
71
- const handleTabLocal = () => {
72
- const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
73
- filteredFocusableElements.forEach(element => {
74
- element.setAttribute('tabindex', '-1');
75
- });
76
- filteredFocusableElements[selectedItemIndex.current].setAttribute('tabindex', '0');
77
- };
78
- const focusAndScrollToElement = (element, scrollToElement = true) => {
79
- if (scrollToElement) {
80
- element === null || element === void 0 ? void 0 : element.scrollIntoView({
81
- behavior: 'smooth',
82
- block: 'center',
83
- inline: 'nearest'
84
- });
85
- }
86
- element.focus();
87
- };
88
- const submenuKeydownHandleContext = {
89
- handleArrowLeft,
90
- handleArrowRight,
91
- handleTab
92
- };
93
- useLayoutEffect(() => {
94
- if (!wrapperRef.current || disableArrowKeyNavigation) {
95
- return;
96
- }
97
- const {
98
- current: element
99
- } = wrapperRef;
100
-
101
- /**
102
- * To handle the key events on the list
103
- * @param event
104
- */
105
- const handleKeyDown = event => {
106
- var _document$querySelect, _document$querySelect2, _wrapperRef$current;
107
- //To trap the focus inside the horizontal toolbar for left and right arrow keys
108
- const targetElement = event.target;
109
-
110
- //To filter out the events outside the child component
111
- if (!targetElement.closest(`${childComponentSelector}`)) {
112
- return;
113
- }
114
-
115
- //The key events are from child components such as dropdown menus / popups are ignored
116
- if ((_document$querySelect = document.querySelector('[data-role="droplistContent"], [data-test-id="color-picker-menu"], [data-emoji-picker-container="true"]')) !== null && _document$querySelect !== void 0 && _document$querySelect.contains(targetElement) || (_document$querySelect2 = document.querySelector('[data-test-id="color-picker-menu"]')) !== null && _document$querySelect2 !== void 0 && _document$querySelect2.contains(targetElement) || event.key === 'ArrowUp' || event.key === 'ArrowDown' || disableArrowKeyNavigation) {
117
- return;
118
- }
119
- const menuWrapper = document.querySelector('.menu-key-handler-wrapper');
120
- if (menuWrapper) {
121
- // if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
122
- return;
123
- }
124
- const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
125
- if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
126
- return;
127
- }
128
-
129
- //This is kind of hack to reset the current focused toolbar item
130
- //to handle some use cases such as Tab in/out of main toolbar
131
- if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
132
- selectedItemIndex.current = -1;
133
- } else {
134
- selectedItemIndex.current = filteredFocusableElements.indexOf(targetElement) > -1 ? filteredFocusableElements.indexOf(targetElement) : selectedItemIndex.current;
135
- }
136
-
137
- //do not scroll to focused element for sticky toolbar when navigating with arrows to avoid unnesessary scroll jump
138
- const allowScrollToElement = !(editorAppearance === 'comment' && !!useStickyToolbar);
139
- switch (event.key) {
140
- case 'ArrowRight':
141
- incrementIndex(filteredFocusableElements);
142
- focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
143
- event.preventDefault();
144
- break;
145
- case 'ArrowLeft':
146
- decrementIndex(filteredFocusableElements);
147
- focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
148
- event.preventDefault();
149
- break;
150
- case 'Tab':
151
- handleTabLocal();
152
- break;
153
- case 'Escape':
154
- handleEscape(event);
155
- break;
156
- default:
157
- }
158
- };
159
- const globalKeyDownHandler = event => {
160
- //To focus the first element in the toolbar
161
- if (isShortcutToFocusToolbar(event)) {
162
- var _filteredFocusableEle4, _filteredFocusableEle5;
163
- const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
164
- (_filteredFocusableEle4 = filteredFocusableElements[0]) === null || _filteredFocusableEle4 === void 0 ? void 0 : _filteredFocusableEle4.focus();
165
- (_filteredFocusableEle5 = filteredFocusableElements[0]) === null || _filteredFocusableEle5 === void 0 ? void 0 : _filteredFocusableEle5.scrollIntoView({
166
- behavior: 'smooth',
167
- block: 'center',
168
- inline: 'nearest'
169
- });
170
- }
171
- };
172
- element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
173
- const editorViewDom = editorView === null || editorView === void 0 ? void 0 : editorView.dom;
174
- if (isShortcutToFocusToolbar) {
175
- editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.addEventListener('keydown', globalKeyDownHandler);
176
- }
177
- return () => {
178
- element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
179
- if (isShortcutToFocusToolbar) {
180
- editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.removeEventListener('keydown', globalKeyDownHandler);
181
- }
182
- };
183
- }, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex, isShortcutToFocusToolbar, editorAppearance, useStickyToolbar]);
184
- return jsx("div", {
185
- css: editorAppearance === 'comment' && centeredToolbarContainer,
186
- className: "custom-key-handler-wrapper",
187
- ref: wrapperRef,
188
- role: "toolbar",
189
- "aria-label": intl.formatMessage(messages.toolbarLabel),
190
- "aria-controls": EDIT_AREA_ID
191
- }, jsx(KeyDownHandlerContext.Provider, {
192
- value: submenuKeydownHandleContext
193
- }, children));
194
- };
195
- function getFocusableElements(rootNode) {
196
- if (!rootNode) {
197
- return [];
198
- }
199
- const focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"], div[tabindex="0"]') || [];
200
- return Array.from(focusableModalElements);
201
- }
202
- function getFilteredFocusableElements(rootNode) {
203
- //The focusable elements from child components such as dropdown menus / popups are ignored
204
- return getFocusableElements(rootNode).filter(elm => !elm.closest('[data-role="droplistContent"]') && !elm.closest('[data-emoji-picker-container="true"]') && !elm.closest('[data-test-id="color-picker-menu"]') && !elm.closest('.scroll-buttons'));
205
- }
@@ -1,57 +0,0 @@
1
- import { canJoin } from '@atlaskit/editor-prosemirror/transform';
2
-
3
- /**
4
- * Checks whether two adjacent nodes can be joined. If so, the document
5
- * will be updated to join those nodes. If not, the original transaction
6
- * remains untouched.
7
- *
8
- * Nodes are considered joinable if the `isJoinable` predicate returns true or,
9
- * if an array of strings was passed, if their node type name is in that array.
10
- *
11
- * Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L597-L610
12
- */
13
- export function autoJoinTr(tr, isJoinable) {
14
- if (Array.isArray(isJoinable)) {
15
- let types = isJoinable;
16
- isJoinable = node => types.indexOf(node.type.name) > -1;
17
- }
18
- const ranges = [];
19
- for (let i = 0; i < tr.mapping.maps.length; i++) {
20
- const map = tr.mapping.maps[i];
21
- for (let j = 0; j < ranges.length; j++) {
22
- ranges[j] = map.map(ranges[j]);
23
- }
24
- map.forEach((_s, _e, from, to) => ranges.push(from, to));
25
- }
26
-
27
- // Figure out which joinable points exist inside those ranges,
28
- // by checking all node boundaries in their parent nodes.
29
- const joinable = [];
30
- for (let i = 0; i < ranges.length; i += 2) {
31
- const from = ranges[i];
32
- const to = ranges[i + 1];
33
- const $from = tr.doc.resolve(from);
34
- const depth = $from.sharedDepth(to);
35
- const parent = $from.node(depth);
36
- for (let index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {
37
- const after = parent.maybeChild(index);
38
- if (!after) {
39
- break;
40
- }
41
- if (index && joinable.indexOf(pos) === -1) {
42
- const before = parent.child(index - 1);
43
- if (before.type === after.type && isJoinable(before, after)) {
44
- joinable.push(pos);
45
- }
46
- }
47
- pos += after.nodeSize;
48
- }
49
- }
50
- // Join the joinable points
51
- joinable.sort((a, b) => a - b);
52
- for (let i = joinable.length - 1; i >= 0; i--) {
53
- if (canJoin(tr.doc, joinable[i])) {
54
- tr.join(joinable[i]);
55
- }
56
- }
57
- }