@atlaskit/editor-core 171.0.1 → 172.0.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 (300) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/codemods/172.0.0-transform-smartlinks-prop.ts +8 -0
  3. package/codemods/__tests__/rename-smartlinks-prop.ts +204 -0
  4. package/codemods/migrates/rename-smartlinks-prop.ts +56 -0
  5. package/dist/cjs/create-editor/ReactEditorView.js +13 -4
  6. package/dist/cjs/create-editor/create-plugins-list.js +21 -12
  7. package/dist/cjs/editor.js +8 -23
  8. package/dist/cjs/labs/next/internal/hooks/use-editor/index.js +6 -1
  9. package/dist/cjs/labs/next/presets/default.js +1 -1
  10. package/dist/cjs/nodeviews/context-adapter.js +2 -2
  11. package/dist/cjs/plugins/analytics/plugin.js +24 -11
  12. package/dist/cjs/plugins/base/index.js +3 -3
  13. package/dist/cjs/plugins/base/pm-plugins/disable-spell-checking.js +84 -0
  14. package/dist/cjs/plugins/card/index.js +1 -1
  15. package/dist/cjs/plugins/card/toolbar.js +11 -5
  16. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +5 -1
  17. package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +7 -7
  18. package/dist/cjs/plugins/clipboard/pm-plugins/main.js +4 -2
  19. package/dist/cjs/plugins/code-block/actions.js +13 -0
  20. package/dist/cjs/plugins/code-block/index.js +7 -0
  21. package/dist/cjs/plugins/code-block/nodeviews/code-block.js +2 -4
  22. package/dist/cjs/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +132 -0
  23. package/dist/cjs/plugins/code-block/pm-plugins/main.js +1 -23
  24. package/dist/cjs/plugins/code-block/styles.js +3 -36
  25. package/dist/cjs/plugins/code-block/toolbar.js +9 -0
  26. package/dist/cjs/plugins/code-block/ui/class-names.js +1 -2
  27. package/dist/cjs/plugins/copy-button/commands.js +40 -20
  28. package/dist/cjs/plugins/copy-button/toolbar.js +51 -0
  29. package/dist/cjs/plugins/copy-button/utils.js +16 -38
  30. package/dist/cjs/plugins/expand/toolbar.js +8 -2
  31. package/dist/cjs/plugins/extension/toolbar.js +5 -1
  32. package/dist/cjs/plugins/extension/ui/Extension/Extension/styles.js +1 -1
  33. package/dist/cjs/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
  34. package/dist/cjs/plugins/extension/ui/Extension/styles.js +2 -4
  35. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +29 -18
  36. package/dist/cjs/plugins/feedback-dialog/index.js +2 -2
  37. package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -20
  38. package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +7 -32
  39. package/dist/cjs/plugins/hyperlink/Toolbar.js +146 -135
  40. package/dist/cjs/plugins/hyperlink/index.js +4 -4
  41. package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/index.js +50 -0
  42. package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +38 -0
  43. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +50 -5
  44. package/dist/cjs/plugins/indentation/commands/index.js +35 -7
  45. package/dist/cjs/plugins/indentation/commands/utils.js +11 -7
  46. package/dist/cjs/plugins/indentation/pm-plugins/keymap.js +5 -3
  47. package/dist/cjs/plugins/layout/toolbar.js +3 -1
  48. package/dist/cjs/plugins/media/toolbar/index.js +13 -5
  49. package/dist/cjs/plugins/mentions/analytics.js +5 -5
  50. package/dist/cjs/plugins/panel/toolbar.js +3 -3
  51. package/dist/cjs/plugins/paste/edge-cases/index.js +16 -3
  52. package/dist/cjs/plugins/paste/handlers.js +25 -2
  53. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +16 -3
  54. package/dist/cjs/plugins/paste/pm-plugins/main.js +22 -3
  55. package/dist/cjs/plugins/status/analytics.js +3 -3
  56. package/dist/cjs/plugins/table/toolbar.js +2 -2
  57. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +43 -32
  58. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +33 -13
  59. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +122 -0
  60. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +8 -2
  61. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +2 -2
  62. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +7 -1
  63. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +40 -19
  64. package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +10 -0
  65. package/dist/cjs/types/browser.js +6 -0
  66. package/dist/cjs/ui/Addon/click-area-helper.js +40 -19
  67. package/dist/cjs/ui/Appearance/Comment/Comment.js +2 -2
  68. package/dist/cjs/ui/ContentStyles/index.js +1 -3
  69. package/dist/cjs/ui/DropList/index.js +215 -0
  70. package/dist/cjs/ui/Dropdown/index.js +2 -5
  71. package/dist/cjs/ui/DropdownMenu/index.js +140 -86
  72. package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +25 -14
  73. package/dist/cjs/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +2 -2
  74. package/dist/cjs/ui/ElementBrowser/components/ElementList/utils.js +28 -1
  75. package/dist/cjs/ui/ElementBrowser/constants.js +2 -7
  76. package/dist/cjs/ui/Layer/index.js +245 -0
  77. package/dist/cjs/ui/Layer/internal/helpers.js +70 -0
  78. package/dist/cjs/ui/PortalProvider/index.js +7 -26
  79. package/dist/cjs/version-wrapper.js +1 -1
  80. package/dist/cjs/version.json +1 -1
  81. package/dist/es2019/create-editor/ReactEditorView.js +15 -4
  82. package/dist/es2019/create-editor/create-plugins-list.js +21 -11
  83. package/dist/es2019/editor.js +9 -23
  84. package/dist/es2019/labs/next/internal/hooks/use-editor/index.js +6 -1
  85. package/dist/es2019/labs/next/presets/default.js +1 -1
  86. package/dist/es2019/nodeviews/context-adapter.js +2 -2
  87. package/dist/es2019/plugins/analytics/plugin.js +19 -4
  88. package/dist/es2019/plugins/base/index.js +3 -3
  89. package/dist/es2019/plugins/base/pm-plugins/disable-spell-checking.js +70 -0
  90. package/dist/es2019/plugins/card/index.js +1 -1
  91. package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -2
  92. package/dist/es2019/plugins/card/toolbar.js +10 -5
  93. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +5 -1
  94. package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +7 -7
  95. package/dist/es2019/plugins/clipboard/pm-plugins/main.js +1 -2
  96. package/dist/es2019/plugins/code-block/actions.js +12 -0
  97. package/dist/es2019/plugins/code-block/index.js +4 -0
  98. package/dist/es2019/plugins/code-block/nodeviews/code-block.js +1 -1
  99. package/dist/es2019/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +112 -0
  100. package/dist/es2019/plugins/code-block/pm-plugins/main.js +1 -21
  101. package/dist/es2019/plugins/code-block/styles.js +2 -159
  102. package/dist/es2019/plugins/code-block/toolbar.js +8 -0
  103. package/dist/es2019/plugins/code-block/ui/class-names.js +1 -2
  104. package/dist/es2019/plugins/copy-button/commands.js +35 -15
  105. package/dist/es2019/plugins/copy-button/toolbar.js +29 -0
  106. package/dist/es2019/plugins/copy-button/utils.js +15 -27
  107. package/dist/es2019/plugins/expand/toolbar.js +4 -1
  108. package/dist/es2019/plugins/extension/toolbar.js +4 -1
  109. package/dist/es2019/plugins/extension/ui/Extension/Extension/styles.js +1 -1
  110. package/dist/es2019/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
  111. package/dist/es2019/plugins/extension/ui/Extension/styles.js +1 -3
  112. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +27 -15
  113. package/dist/es2019/plugins/feedback-dialog/index.js +1 -1
  114. package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -19
  115. package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +14 -29
  116. package/dist/es2019/plugins/hyperlink/Toolbar.js +11 -5
  117. package/dist/es2019/plugins/hyperlink/index.js +4 -4
  118. package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +24 -0
  119. package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +28 -0
  120. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +50 -9
  121. package/dist/es2019/plugins/indentation/commands/index.js +24 -9
  122. package/dist/es2019/plugins/indentation/commands/utils.js +8 -3
  123. package/dist/es2019/plugins/indentation/pm-plugins/keymap.js +5 -4
  124. package/dist/es2019/plugins/layout/toolbar.js +2 -1
  125. package/dist/es2019/plugins/media/toolbar/index.js +10 -3
  126. package/dist/es2019/plugins/mentions/analytics.js +1 -1
  127. package/dist/es2019/plugins/panel/toolbar.js +1 -1
  128. package/dist/es2019/plugins/paste/edge-cases/index.js +15 -3
  129. package/dist/es2019/plugins/paste/handlers.js +27 -2
  130. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +12 -3
  131. package/dist/es2019/plugins/paste/pm-plugins/main.js +24 -4
  132. package/dist/es2019/plugins/status/analytics.js +1 -1
  133. package/dist/es2019/plugins/table/toolbar.js +1 -1
  134. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +10 -10
  135. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +23 -4
  136. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +104 -0
  137. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +8 -2
  138. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +2 -2
  139. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +7 -1
  140. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +38 -16
  141. package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +9 -0
  142. package/dist/es2019/types/browser.js +2 -0
  143. package/dist/es2019/ui/Addon/click-area-helper.js +37 -18
  144. package/dist/es2019/ui/Appearance/Comment/Comment.js +2 -2
  145. package/dist/es2019/ui/ContentStyles/index.js +5 -9
  146. package/dist/es2019/ui/DropList/index.js +186 -0
  147. package/dist/es2019/ui/Dropdown/index.js +2 -6
  148. package/dist/es2019/ui/DropdownMenu/index.js +124 -75
  149. package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +11 -22
  150. package/dist/es2019/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +3 -3
  151. package/dist/es2019/ui/ElementBrowser/components/ElementList/utils.js +26 -2
  152. package/dist/es2019/ui/ElementBrowser/constants.js +1 -4
  153. package/dist/es2019/ui/Layer/index.js +195 -0
  154. package/dist/es2019/ui/Layer/internal/helpers.js +62 -0
  155. package/dist/es2019/ui/PortalProvider/index.js +5 -23
  156. package/dist/es2019/version-wrapper.js +1 -1
  157. package/dist/es2019/version.json +1 -1
  158. package/dist/esm/create-editor/ReactEditorView.js +13 -4
  159. package/dist/esm/create-editor/create-plugins-list.js +21 -12
  160. package/dist/esm/editor.js +9 -23
  161. package/dist/esm/labs/next/internal/hooks/use-editor/index.js +6 -1
  162. package/dist/esm/labs/next/presets/default.js +1 -1
  163. package/dist/esm/nodeviews/context-adapter.js +2 -2
  164. package/dist/esm/plugins/analytics/plugin.js +24 -11
  165. package/dist/esm/plugins/base/index.js +3 -3
  166. package/dist/esm/plugins/base/pm-plugins/disable-spell-checking.js +72 -0
  167. package/dist/esm/plugins/card/index.js +1 -1
  168. package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -2
  169. package/dist/esm/plugins/card/toolbar.js +11 -5
  170. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +5 -1
  171. package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +7 -7
  172. package/dist/esm/plugins/clipboard/pm-plugins/main.js +1 -2
  173. package/dist/esm/plugins/code-block/actions.js +12 -0
  174. package/dist/esm/plugins/code-block/index.js +6 -0
  175. package/dist/esm/plugins/code-block/nodeviews/code-block.js +2 -4
  176. package/dist/esm/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +112 -0
  177. package/dist/esm/plugins/code-block/pm-plugins/main.js +1 -20
  178. package/dist/esm/plugins/code-block/styles.js +4 -32
  179. package/dist/esm/plugins/code-block/toolbar.js +8 -0
  180. package/dist/esm/plugins/code-block/ui/class-names.js +1 -2
  181. package/dist/esm/plugins/copy-button/commands.js +35 -15
  182. package/dist/esm/plugins/copy-button/toolbar.js +31 -0
  183. package/dist/esm/plugins/copy-button/utils.js +14 -29
  184. package/dist/esm/plugins/expand/toolbar.js +6 -2
  185. package/dist/esm/plugins/extension/toolbar.js +4 -1
  186. package/dist/esm/plugins/extension/ui/Extension/Extension/styles.js +1 -1
  187. package/dist/esm/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
  188. package/dist/esm/plugins/extension/ui/Extension/styles.js +3 -4
  189. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +28 -16
  190. package/dist/esm/plugins/feedback-dialog/index.js +1 -1
  191. package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -21
  192. package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -27
  193. package/dist/esm/plugins/hyperlink/Toolbar.js +144 -135
  194. package/dist/esm/plugins/hyperlink/index.js +4 -4
  195. package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +26 -0
  196. package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +28 -0
  197. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +46 -5
  198. package/dist/esm/plugins/indentation/commands/index.js +30 -9
  199. package/dist/esm/plugins/indentation/commands/utils.js +12 -8
  200. package/dist/esm/plugins/indentation/pm-plugins/keymap.js +5 -4
  201. package/dist/esm/plugins/layout/toolbar.js +2 -1
  202. package/dist/esm/plugins/media/toolbar/index.js +12 -5
  203. package/dist/esm/plugins/mentions/analytics.js +1 -1
  204. package/dist/esm/plugins/panel/toolbar.js +1 -1
  205. package/dist/esm/plugins/paste/edge-cases/index.js +15 -3
  206. package/dist/esm/plugins/paste/handlers.js +23 -2
  207. package/dist/esm/plugins/paste/pm-plugins/analytics.js +13 -3
  208. package/dist/esm/plugins/paste/pm-plugins/main.js +23 -4
  209. package/dist/esm/plugins/status/analytics.js +1 -1
  210. package/dist/esm/plugins/table/toolbar.js +1 -1
  211. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +37 -31
  212. package/dist/esm/plugins/toolbar-lists-indentation/index.js +32 -13
  213. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +105 -0
  214. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +8 -2
  215. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +2 -2
  216. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +7 -1
  217. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +38 -20
  218. package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +9 -0
  219. package/dist/esm/types/browser.js +2 -0
  220. package/dist/esm/ui/Addon/click-area-helper.js +37 -18
  221. package/dist/esm/ui/Appearance/Comment/Comment.js +2 -2
  222. package/dist/esm/ui/ContentStyles/index.js +2 -4
  223. package/dist/esm/ui/DropList/index.js +203 -0
  224. package/dist/esm/ui/Dropdown/index.js +2 -6
  225. package/dist/esm/ui/DropdownMenu/index.js +134 -88
  226. package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +27 -17
  227. package/dist/esm/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +3 -3
  228. package/dist/esm/ui/ElementBrowser/components/ElementList/utils.js +26 -2
  229. package/dist/esm/ui/ElementBrowser/constants.js +1 -4
  230. package/dist/esm/ui/Layer/index.js +228 -0
  231. package/dist/esm/ui/Layer/internal/helpers.js +62 -0
  232. package/dist/esm/ui/PortalProvider/index.js +7 -26
  233. package/dist/esm/version-wrapper.js +1 -1
  234. package/dist/esm/version.json +1 -1
  235. package/dist/types/labs/next/presets/default.d.ts +2 -0
  236. package/dist/types/plugins/analytics/plugin.d.ts +5 -1
  237. package/dist/types/plugins/analytics/types/cut-copy-events.d.ts +2 -0
  238. package/dist/types/plugins/analytics/types/general-events.d.ts +1 -0
  239. package/dist/types/plugins/analytics/types/paste-events.d.ts +1 -0
  240. package/dist/types/plugins/base/index.d.ts +1 -1
  241. package/dist/types/plugins/base/pm-plugins/{fix-chrome-spell-checking.d.ts → disable-spell-checking.d.ts} +0 -0
  242. package/dist/types/plugins/card/index.d.ts +2 -7
  243. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +2 -1
  244. package/dist/types/plugins/card/toolbar.d.ts +3 -5
  245. package/dist/types/plugins/card/types.d.ts +2 -0
  246. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +4 -1
  247. package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +2 -1
  248. package/dist/types/plugins/clipboard/pm-plugins/main.d.ts +3 -0
  249. package/dist/types/plugins/code-block/nodeviews/code-block.d.ts +1 -1
  250. package/dist/types/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +11 -0
  251. package/dist/types/plugins/code-block/styles.d.ts +0 -1
  252. package/dist/types/plugins/code-block/ui/class-names.d.ts +0 -1
  253. package/dist/types/plugins/copy-button/commands.d.ts +2 -2
  254. package/dist/types/plugins/copy-button/toolbar.d.ts +7 -0
  255. package/dist/types/plugins/copy-button/utils.d.ts +7 -6
  256. package/dist/types/plugins/floating-toolbar/types.d.ts +1 -2
  257. package/dist/types/plugins/hyperlink/Toolbar.d.ts +2 -1
  258. package/dist/types/plugins/hyperlink/index.d.ts +2 -2
  259. package/dist/types/plugins/hyperlink/types.d.ts +30 -0
  260. package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/index.d.ts +7 -0
  261. package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.d.ts +2 -0
  262. package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +4 -3
  263. package/dist/types/plugins/indentation/commands/index.d.ts +6 -2
  264. package/dist/types/plugins/indentation/commands/utils.d.ts +8 -2
  265. package/dist/types/plugins/paste/edge-cases/index.d.ts +3 -2
  266. package/dist/types/plugins/paste/handlers.d.ts +1 -0
  267. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +7 -1
  268. package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +5 -0
  269. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +2 -1
  270. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +14 -0
  271. package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +2 -0
  272. package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +2 -0
  273. package/dist/types/types/browser.d.ts +10 -0
  274. package/dist/types/types/editor-props.d.ts +6 -5
  275. package/dist/types/types/feature-flags.d.ts +29 -24
  276. package/dist/types/types/index.d.ts +1 -0
  277. package/dist/types/ui/Addon/click-area-helper.d.ts +10 -0
  278. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  279. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  280. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  281. package/dist/types/ui/DropList/index.d.ts +22 -0
  282. package/dist/types/ui/Dropdown/index.d.ts +2 -1
  283. package/dist/types/ui/DropdownMenu/index.d.ts +0 -1
  284. package/dist/types/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.d.ts +1 -1
  285. package/dist/types/ui/ElementBrowser/components/ElementList/utils.d.ts +1 -0
  286. package/dist/types/ui/ElementBrowser/constants.d.ts +1 -3
  287. package/dist/types/ui/Layer/index.d.ts +47 -0
  288. package/dist/types/ui/Layer/internal/helpers.d.ts +5 -0
  289. package/package.json +23 -18
  290. package/dist/cjs/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -37
  291. package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +0 -195
  292. package/dist/cjs/utils/check-if-mobile-bridge.js +0 -19
  293. package/dist/es2019/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -22
  294. package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +0 -152
  295. package/dist/es2019/utils/check-if-mobile-bridge.js +0 -12
  296. package/dist/esm/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -24
  297. package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +0 -178
  298. package/dist/esm/utils/check-if-mobile-bridge.js +0 -12
  299. package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +0 -48
  300. package/dist/types/utils/check-if-mobile-bridge.d.ts +0 -1
@@ -18,7 +18,7 @@ import { getUiComponent } from './create-editor';
18
18
  import EditorActions from './actions';
19
19
  import { ReactEditorView } from './create-editor';
20
20
  import EditorContext from './ui/EditorContext';
21
- import { PortalProvider, PortalProviderWithThemeProviders, PortalRenderer } from './ui/PortalProvider';
21
+ import { PortalProviderWithThemeProviders, PortalRenderer } from './ui/PortalProvider';
22
22
  import { nextMajorVersion } from './version-wrapper';
23
23
  import { ContextAdapter } from './nodeviews/context-adapter';
24
24
  import measurements from './utils/performance/measure-enum';
@@ -27,7 +27,6 @@ import { fireAnalyticsEvent, EVENT_TYPE, ACTION_SUBJECT, ACTION } from './plugin
27
27
  import ErrorBoundary from './create-editor/ErrorBoundary';
28
28
  import { createFeatureFlagsFromProps } from './plugins/feature-flags-context/feature-flags-from-props';
29
29
  import { RenderTracking } from './utils/performance/components/RenderTracking';
30
- import { checkIfMobileBridge } from './utils/check-if-mobile-bridge';
31
30
  const fullHeight = css`
32
31
  height: 100%;
33
32
  `;
@@ -323,8 +322,8 @@ export default class Editor extends React.Component {
323
322
  message: 'To integrate inline comments use experimental annotationProvider – <Editor annotationProviders={{ provider }} />',
324
323
  type: 'removed'
325
324
  },
326
- allowDynamicTextSizing: {
327
- message: 'Dynamic text sizing has been unshipped since 2020. The prop is no longer needed.',
325
+ smartLinks: {
326
+ message: 'To use smartLinks, pass the same object into the smartlinks key of linking - <Editor linking={{ smartLinks: {existing object} }}.',
328
327
  type: 'removed'
329
328
  }
330
329
  };
@@ -362,6 +361,8 @@ export default class Editor extends React.Component {
362
361
  }
363
362
 
364
363
  handleProviders(props) {
364
+ var _linking$smartLinks;
365
+
365
366
  const {
366
367
  emojiProvider,
367
368
  mentionProvider,
@@ -377,7 +378,8 @@ export default class Editor extends React.Component {
377
378
  autoformattingProvider,
378
379
  searchProvider,
379
380
  UNSAFE_cards,
380
- smartLinks
381
+ smartLinks,
382
+ linking
381
383
  } = props;
382
384
  const {
383
385
  extensionProvider,
@@ -394,7 +396,7 @@ export default class Editor extends React.Component {
394
396
  this.providerFactory.setProvider('searchProvider', searchProvider);
395
397
  this.providerFactory.setProvider('presenceProvider', presenceProvider);
396
398
  this.providerFactory.setProvider('macroProvider', macroProvider);
397
- const cardProvider = smartLinks && smartLinks.provider || UNSAFE_cards && UNSAFE_cards.provider;
399
+ const cardProvider = (linking === null || linking === void 0 ? void 0 : (_linking$smartLinks = linking.smartLinks) === null || _linking$smartLinks === void 0 ? void 0 : _linking$smartLinks.provider) || smartLinks && smartLinks.provider || UNSAFE_cards && UNSAFE_cards.provider;
398
400
 
399
401
  if (cardProvider) {
400
402
  this.providerFactory.setProvider('cardProvider', cardProvider);
@@ -428,22 +430,6 @@ export default class Editor extends React.Component {
428
430
  const renderTracking = (_this$props$performan3 = this.props.performanceTracking) === null || _this$props$performan3 === void 0 ? void 0 : (_this$props$performan4 = _this$props$performan3.renderTracking) === null || _this$props$performan4 === void 0 ? void 0 : _this$props$performan4.editor;
429
431
  const renderTrackingEnabled = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.enabled;
430
432
  const useShallow = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.useShallow;
431
- /**
432
- * The PortalProviderWithThemeProviders renders portals with atlaskit
433
- * and the deprecated styled components theme providers.
434
- *
435
- * Without this the node views react trees;
436
- * - do not have access to the atlaskit theme via the `useGlobalTheme` hook
437
- * - do not have access to the theme when using the `styled`${({theme}) => theme.}` api.
438
- *
439
- * Added for a mobile regression, which needed to be fixed on master.
440
- * Once this makes it's way to develop, we should consider making it the default
441
- * behaviour.
442
- *
443
- * https://product-fabric.atlassian.net/browse/ED-14204
444
- */
445
-
446
- const EnvironmentDrivenPortalProvider = checkIfMobileBridge() ? PortalProviderWithThemeProviders : PortalProvider;
447
433
  return jsx(FabricEditorAnalyticsContext, {
448
434
  data: {
449
435
  packageName: name,
@@ -467,7 +453,7 @@ export default class Editor extends React.Component {
467
453
  css: fullHeight
468
454
  }, jsx(EditorContext, {
469
455
  editorActions: this.editorActions
470
- }, jsx(ContextAdapter, null, jsx(EnvironmentDrivenPortalProvider, {
456
+ }, jsx(ContextAdapter, null, jsx(PortalProviderWithThemeProviders, {
471
457
  onAnalyticsEvent: this.handleAnalyticsEvent,
472
458
  useAnalyticsContext: this.props.UNSAFE_useAnalyticsContext,
473
459
  render: portalProviderAPI => jsx(Fragment, null, jsx(ReactEditorView, {
@@ -40,7 +40,11 @@ function useCreateEditor(config) {
40
40
 
41
41
  setEditorSharedConfig(editorSharedConfig => {
42
42
  if (!editorSharedConfig) {
43
- measureRender(measurements.PROSEMIRROR_RENDERED, (duration, startTime) => {
43
+ measureRender(measurements.PROSEMIRROR_RENDERED, ({
44
+ duration,
45
+ startTime,
46
+ distortedDuration
47
+ }) => {
44
48
  if (sharedConfig && sharedConfig.dispatch) {
45
49
  sharedConfig.dispatch(analyticsEventKey, {
46
50
  payload: {
@@ -48,6 +52,7 @@ function useCreateEditor(config) {
48
52
  actionSubject: ACTION_SUBJECT.EDITOR,
49
53
  attributes: {
50
54
  duration,
55
+ distortedDuration,
51
56
  startTime,
52
57
  nodes: getNodesCount(sharedConfig.editorView.state.doc),
53
58
  ttfb: getResponseEndTime()
@@ -48,7 +48,7 @@ export function createDefaultPreset(options) {
48
48
  preset.add([annotationPlugin, options.annotationProviders]);
49
49
  }
50
50
 
51
- preset.add([hyperlinkPlugin, options.cardOptions]);
51
+ preset.add([hyperlinkPlugin, options.hyperlinkOptions]);
52
52
  preset.add([textFormattingPlugin, options.textFormatting]);
53
53
  preset.add(widthPlugin);
54
54
  preset.add([quickInsertPlugin, options.quickInsert]);
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import { Context as CardContext } from '@atlaskit/smart-card';
4
+ import { SmartCardContext } from '@atlaskit/link-provider';
5
5
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
6
6
 
7
7
  function useContextMemoized(reactContext) {
@@ -20,7 +20,7 @@ function useContextMemoized(reactContext) {
20
20
  export const ContextAdapter = ({
21
21
  children
22
22
  }) => {
23
- const card = useContextMemoized(CardContext);
23
+ const card = useContextMemoized(SmartCardContext);
24
24
  const analytics = useContextMemoized(AnalyticsReactContext);
25
25
  return /*#__PURE__*/React.createElement(LegacyContextAdapter, {
26
26
  card: card,
@@ -37,9 +37,19 @@ function createPlugin(options) {
37
37
  // that has an analytics event.
38
38
  if (hasRequiredPerformanceAPIs && tr.docChanged && payload.action !== ACTION.INSERTED && payload.action !== ACTION.DELETED) {
39
39
  const measureName = `${payload.actionSubject}:${payload.action}:${payload.actionSubjectId}`;
40
- measureRender(measureName, duration => {
40
+ measureRender( // NOTE this name could be resulting in misleading data -- where if multiple payloads are
41
+ // received before a render completes -- the measurement value will be inaccurate (this is
42
+ // due to measureRender requiring unique measureNames)
43
+ measureName, ({
44
+ duration,
45
+ distortedDuration
46
+ }) => {
41
47
  fireAnalyticsEvent(pluginState.createAnalyticsEvent)({
42
- payload: extendPayload(payload, duration),
48
+ payload: extendPayload({
49
+ payload,
50
+ duration,
51
+ distortedDuration
52
+ }),
43
53
  channel
44
54
  });
45
55
  });
@@ -103,10 +113,15 @@ const analyticsPlugin = options => ({
103
113
 
104
114
  });
105
115
 
106
- export function extendPayload(payload, duration) {
116
+ export function extendPayload({
117
+ payload,
118
+ duration,
119
+ distortedDuration
120
+ }) {
107
121
  return { ...payload,
108
122
  attributes: { ...payload.attributes,
109
- duration
123
+ duration,
124
+ distortedDuration
110
125
  },
111
126
  eventType: EVENT_TYPE.OPERATIONAL
112
127
  };
@@ -5,7 +5,7 @@ import { doc, paragraph, text } from '@atlaskit/adf-schema';
5
5
  import filterStepsPlugin from './pm-plugins/filter-steps';
6
6
  import focusHandlerPlugin from './pm-plugins/focus-handler';
7
7
  import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
8
- import fixChromeSpellCheckingPlugin from './pm-plugins/fix-chrome-spell-checking';
8
+ import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
9
9
  import contextIdentifierPlugin from './pm-plugins/context-identifier';
10
10
  import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
11
11
  import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
@@ -102,8 +102,8 @@ const basePlugin = options => ({
102
102
  }
103
103
 
104
104
  plugins.push({
105
- name: 'fixChromeSpellCheckingPlugin',
106
- plugin: () => fixChromeSpellCheckingPlugin()
105
+ name: 'disableSpellcheckingPlugin',
106
+ plugin: () => disableSpellcheckingPlugin()
107
107
  });
108
108
  return plugins;
109
109
  },
@@ -0,0 +1,70 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from 'prosemirror-state';
3
+ import { getFeatureFlags } from '../../feature-flags-context';
4
+ import { browser as browserEnv } from '@atlaskit/editor-common/utils';
5
+
6
+ function getCurrentBrowserAndVersion() {
7
+ switch (true) {
8
+ case browserEnv.chrome === true:
9
+ return {
10
+ browser: 'chrome',
11
+ version: browserEnv.chrome_version
12
+ };
13
+
14
+ case browserEnv.ie === true:
15
+ return {
16
+ browser: 'ie',
17
+ version: browserEnv.ie_version
18
+ };
19
+
20
+ case browserEnv.gecko === true:
21
+ return {
22
+ browser: 'gecko',
23
+ version: browserEnv.gecko_version
24
+ };
25
+
26
+ case browserEnv.safari === true:
27
+ return {
28
+ browser: 'safari',
29
+ version: browserEnv.safari_version
30
+ };
31
+ }
32
+
33
+ return undefined;
34
+ }
35
+
36
+ export default (() => new SafePlugin({
37
+ key: new PluginKey('disableSpellchecking'),
38
+ props: {
39
+ attributes: editorState => {
40
+ const featureFlags = getFeatureFlags(editorState) || undefined;
41
+
42
+ if (!featureFlags) {
43
+ return;
44
+ }
45
+
46
+ const browserConfigFeatureFlag = featureFlags.disableSpellcheckByBrowser;
47
+ const userCurrentBrowserAndVersion = getCurrentBrowserAndVersion();
48
+
49
+ if (!userCurrentBrowserAndVersion || !browserConfigFeatureFlag) {
50
+ return;
51
+ }
52
+
53
+ const browserVersionDisableRange = browserConfigFeatureFlag[userCurrentBrowserAndVersion.browser];
54
+
55
+ if (!browserVersionDisableRange || !browserEnv[userCurrentBrowserAndVersion.browser]) {
56
+ return;
57
+ }
58
+
59
+ const shouldDisableSpellcheck = !!browserVersionDisableRange.maximum ? userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum && userCurrentBrowserAndVersion.version <= browserVersionDisableRange.maximum : browserEnv[userCurrentBrowserAndVersion.browser] && userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum;
60
+
61
+ if (shouldDisableSpellcheck) {
62
+ return {
63
+ spellcheck: 'false'
64
+ };
65
+ }
66
+
67
+ return;
68
+ }
69
+ }
70
+ }));
@@ -62,7 +62,7 @@ const cardPlugin = options => {
62
62
  },
63
63
 
64
64
  pluginsOptions: {
65
- floatingToolbar: floatingToolbar(options, options.platform)
65
+ floatingToolbar: floatingToolbar(options, options.platform, options.linkPicker)
66
66
  }
67
67
  };
68
68
  };
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React from 'react';
4
- import { Card as SmartCard } from '@atlaskit/smart-card';
4
+ import { Card as SmartCard, EmbedResizeMessageListener } from '@atlaskit/smart-card';
5
5
  import PropTypes from 'prop-types';
6
6
  import rafSchedule from 'raf-schd';
7
7
  import { Card } from './genericCard';
@@ -15,7 +15,6 @@ import { createDisplayGrid } from '../../../plugins/grid';
15
15
  import WithPluginState from '../../../ui/WithPluginState';
16
16
  import { pluginKey as widthPluginKey } from '../../width';
17
17
  import { floatingLayouts, isRichMediaInsideOfBlockNode } from '../../../utils/rich-media-utils';
18
- import { EmbedResizeMessageListener } from '@atlaskit/smart-card';
19
18
  import { pluginKey as tableResizePluginKey } from '../../table/pm-plugins/table-resizing';
20
19
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
21
20
  export class EmbedCardComponent extends React.PureComponent {
@@ -19,6 +19,7 @@ import { messages } from './messages';
19
19
  import buildLayoutButtons from '../../ui/MediaAndEmbedsToolbar';
20
20
  import { buildVisitedLinkPayload } from '../../utils/linking-utils';
21
21
  import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
22
+ import { getCopyButtonConfig, showCopyButton } from '../copy-button/toolbar';
22
23
  export const removeCard = (state, dispatch) => {
23
24
  if (!(state.selection instanceof NodeSelection)) {
24
25
  return false;
@@ -95,6 +96,9 @@ const generateDeleteButton = (node, state, intl) => {
95
96
  title: intl.formatMessage(commonMessages.remove),
96
97
  onClick: removeCard
97
98
  };
99
+ const copyButton = [...(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, node.type), {
100
+ type: 'separator'
101
+ }] : [])];
98
102
 
99
103
  if (node.type === inlineCard) {
100
104
  const unlinkButtonWithSeparator = [{
@@ -106,13 +110,13 @@ const generateDeleteButton = (node, state, intl) => {
106
110
  }, {
107
111
  type: 'separator'
108
112
  }];
109
- return [...unlinkButtonWithSeparator, removeButton];
113
+ return [...unlinkButtonWithSeparator, ...copyButton, removeButton];
110
114
  }
111
115
 
112
- return [removeButton];
116
+ return [...copyButton, removeButton];
113
117
  };
114
118
 
115
- const generateToolbarItems = (state, intl, providerFactory, cardOptions, platform) => node => {
119
+ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platform, linkPicker) => node => {
116
120
  const {
117
121
  url
118
122
  } = titleUrlPairFromNode(node);
@@ -137,6 +141,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platfor
137
141
  if (pluginState.showLinkingToolbar && platform !== 'mobile') {
138
142
  return [buildEditLinkToolbar({
139
143
  providerFactory,
144
+ linkPicker,
140
145
  node
141
146
  })];
142
147
  } else {
@@ -203,7 +208,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, platfor
203
208
  }
204
209
  };
205
210
 
206
- export const floatingToolbar = (cardOptions, platform) => {
211
+ export const floatingToolbar = (cardOptions, platform, linkPickerOptions) => {
207
212
  return (state, intl, providerFactory) => {
208
213
  const {
209
214
  inlineCard,
@@ -249,7 +254,7 @@ export const floatingToolbar = (cardOptions, platform) => {
249
254
 
250
255
  return element;
251
256
  },
252
- items: generateToolbarItems(state, intl, providerFactory, cardOptions, platform),
257
+ items: generateToolbarItems(state, intl, providerFactory, cardOptions, platform, linkPickerOptions),
253
258
  ...(pluginState.showLinkingToolbar ? editLinkToolbarConfig : {})
254
259
  };
255
260
  };
@@ -27,6 +27,7 @@ export class EditLinkToolbar extends React.Component {
27
27
 
28
28
  render() {
29
29
  const {
30
+ linkPickerOptions,
30
31
  providerFactory,
31
32
  url,
32
33
  text,
@@ -35,6 +36,7 @@ export class EditLinkToolbar extends React.Component {
35
36
  } = this.props;
36
37
  return /*#__PURE__*/React.createElement(HyperlinkToolbar, {
37
38
  view: view,
39
+ linkPickerOptions: linkPickerOptions,
38
40
  providerFactory: providerFactory,
39
41
  displayUrl: url,
40
42
  displayText: text,
@@ -65,7 +67,8 @@ export const editLink = (state, dispatch) => {
65
67
  };
66
68
  export const buildEditLinkToolbar = ({
67
69
  providerFactory,
68
- node
70
+ node,
71
+ linkPicker
69
72
  }) => {
70
73
  return {
71
74
  type: 'custom',
@@ -79,6 +82,7 @@ export const buildEditLinkToolbar = ({
79
82
  return /*#__PURE__*/React.createElement(EditLinkToolbar, {
80
83
  key: idx,
81
84
  view: view,
85
+ linkPickerOptions: linkPicker,
82
86
  providerFactory: providerFactory,
83
87
  url: displayInfo.url,
84
88
  text: displayInfo.title || '',
@@ -37,8 +37,8 @@ export class LinkToolbarAppearance extends React.Component {
37
37
  }
38
38
  }
39
39
 
40
- const isSmartLinkSupportedInParent = isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
41
- const tooltip = isSmartLinkSupportedInParent ? undefined : parentNodeName(editorState, intl);
40
+ const isBlockCardLinkSupportedInParent = isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
41
+ const isEmbedCardLinkSupportedInParent = allowEmbeds ? isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance) : false;
42
42
  const embedOption = allowEmbeds && preview && {
43
43
  appearance: 'embed',
44
44
  title: intl.formatMessage(messages.embed),
@@ -46,8 +46,8 @@ export class LinkToolbarAppearance extends React.Component {
46
46
  selected: currentAppearance === 'embed',
47
47
  hidden: false,
48
48
  testId: 'embed-appearance',
49
- disabled: !isSmartLinkSupportedInParent,
50
- tooltip
49
+ disabled: !isEmbedCardLinkSupportedInParent,
50
+ tooltip: isEmbedCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
51
51
  };
52
52
  const options = [{
53
53
  title: intl.formatMessage(messages.url),
@@ -66,8 +66,8 @@ export class LinkToolbarAppearance extends React.Component {
66
66
  onClick: setSelectedCardAppearance('block'),
67
67
  selected: currentAppearance === 'block',
68
68
  testId: 'block-appearance',
69
- disabled: !isSmartLinkSupportedInParent,
70
- tooltip
69
+ disabled: !isBlockCardLinkSupportedInParent,
70
+ tooltip: isBlockCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
71
71
  }];
72
72
 
73
73
  const dispatchCommand = fn => {
@@ -128,7 +128,7 @@ _defineProperty(LinkToolbarAppearance, "contextTypes", {
128
128
  contextAdapter: PropTypes.object
129
129
  });
130
130
 
131
- const parentNodeName = (state, intl) => {
131
+ const getUnavailableMessage = (state, intl) => {
132
132
  try {
133
133
  const parentNode = state.selection.$from.node(1);
134
134
  const parentName = intl.formatMessage(nodeNames[parentNode.type.name]);
@@ -107,8 +107,7 @@ export const sendClipboardAnalytics = (view, dispatchAnalyticsEvent, action) =>
107
107
 
108
108
  return false;
109
109
  };
110
-
111
- const getAnalyticsPayload = (state, action) => {
110
+ export const getAnalyticsPayload = (state, action) => {
112
111
  const {
113
112
  selection,
114
113
  doc
@@ -1,6 +1,7 @@
1
1
  import { findParentNodeOfType, findSelectedNodeOfType, removeSelectedNode, removeParentNodeOfType, isNodeSelection } from 'prosemirror-utils';
2
2
  import { NodeSelection } from 'prosemirror-state';
3
3
  import { pluginKey } from './plugin-key';
4
+ import { copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
4
5
  import { ACTIONS } from './pm-plugins/actions';
5
6
  import { copyToClipboard } from '../../utils/clipboard';
6
7
  import { addAnalytics } from '../analytics/utils';
@@ -75,6 +76,7 @@ export const copyContentToClipboard = (state, dispatch) => {
75
76
  type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
76
77
  data: true
77
78
  });
79
+ copyToClipboardTr.setMeta(copySelectionPluginKey, 'remove-selection');
78
80
 
79
81
  if (dispatch) {
80
82
  dispatch(copyToClipboardTr);
@@ -95,10 +97,20 @@ export const resetCopiedState = (state, dispatch) => {
95
97
  type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
96
98
  data: false
97
99
  });
100
+ resetCopiedStateTr.setMeta(copySelectionPluginKey, 'remove-selection');
98
101
 
99
102
  if (dispatch) {
100
103
  dispatch(resetCopiedStateTr);
101
104
  }
105
+ } else {
106
+ const clearSelectionStateTransaction = state.tr;
107
+ clearSelectionStateTransaction.setMeta(copySelectionPluginKey, 'remove-selection'); // note: dispatch should always be defined when called from the
108
+ // floating toolbar. Howver the Command type which floating toolbar uses
109
+ // (and resetCopiedState) uses suggests it's optional.
110
+
111
+ if (dispatch) {
112
+ dispatch(clearSelectionStateTransaction);
113
+ }
102
114
  }
103
115
 
104
116
  return true;
@@ -4,6 +4,7 @@ import { createPlugin } from './pm-plugins/main';
4
4
  import { getToolbarConfig } from './toolbar';
5
5
  import keymap from './pm-plugins/keymaps';
6
6
  import ideUX from './pm-plugins/ide-ux';
7
+ import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
7
8
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '../analytics';
8
9
  import { IconCode } from '../quick-insert/assets';
9
10
  import { messages } from '../block-type/messages';
@@ -36,6 +37,9 @@ const codeBlockPlugin = options => ({
36
37
  plugin: ({
37
38
  schema
38
39
  }) => keymap(schema)
40
+ }, {
41
+ name: 'codeBlockCopySelection',
42
+ plugin: () => codeBlockCopySelectionPlugin()
39
43
  }];
40
44
  },
41
45
 
@@ -134,4 +134,4 @@ export class CodeBlockView {
134
134
  }
135
135
 
136
136
  }
137
- export const codeBlockNodeView = () => (node, view, getPos) => new CodeBlockView(node, view, getPos);
137
+ export const codeBlockNodeView = (node, view, getPos) => new CodeBlockView(node, view, getPos);
@@ -0,0 +1,112 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from 'prosemirror-state';
3
+ import { Decoration, DecorationSet } from 'prosemirror-view';
4
+ import { getSelectedNodeOrNodeParentByNodeType } from '../../copy-button/utils';
5
+ export const copySelectionPluginKey = new PluginKey('codeBlockCopySelectionPlugin');
6
+
7
+ function getSelectionDecorationStartAndEnd({
8
+ state,
9
+ transaction
10
+ }) {
11
+ const codeBlockNode = getSelectedNodeOrNodeParentByNodeType({
12
+ nodeType: state.schema.nodes.codeBlock,
13
+ selection: transaction.selection
14
+ });
15
+
16
+ if (!codeBlockNode) {
17
+ return {
18
+ decorationStartAndEnd: undefined
19
+ };
20
+ }
21
+
22
+ const decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
23
+ return {
24
+ decorationStartAndEnd
25
+ };
26
+ }
27
+
28
+ export function codeBlockCopySelectionPlugin() {
29
+ return new SafePlugin({
30
+ key: copySelectionPluginKey,
31
+ state: {
32
+ init() {
33
+ return {
34
+ decorationStartAndEnd: undefined
35
+ };
36
+ },
37
+
38
+ apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
39
+ switch (transaction.getMeta(copySelectionPluginKey)) {
40
+ case 'show-selection':
41
+ {
42
+ return getSelectionDecorationStartAndEnd({
43
+ state: newState,
44
+ transaction
45
+ });
46
+ }
47
+
48
+ case 'remove-selection':
49
+ return {
50
+ decorationStartAndEnd: undefined
51
+ };
52
+
53
+ default:
54
+ // The contents of the code block can change while the selection is being shown
55
+ // (either from collab edits -- or from the user continuing to type while hovering
56
+ // the mouse over the copy button).
57
+ // This ensures the selection is updated in these cases.
58
+ if (currentCodeBlockCopySelectionPluginState.decorationStartAndEnd !== undefined) {
59
+ return getSelectionDecorationStartAndEnd({
60
+ state: newState,
61
+ transaction
62
+ });
63
+ }
64
+
65
+ return currentCodeBlockCopySelectionPluginState;
66
+ }
67
+ }
68
+
69
+ },
70
+ props: {
71
+ decorations(state) {
72
+ if (copySelectionPluginKey.getState(state).decorationStartAndEnd) {
73
+ const [start, end] = copySelectionPluginKey.getState(state).decorationStartAndEnd;
74
+ return DecorationSet.create(state.doc, [Decoration.inline(start, end, {
75
+ class: 'ProseMirror-fake-text-selection'
76
+ })]);
77
+ }
78
+
79
+ return DecorationSet.empty;
80
+ }
81
+
82
+ }
83
+ });
84
+ }
85
+ export function provideVisualFeedbackForCopyButton(state, dispatch) {
86
+ const tr = state.tr;
87
+ tr.setMeta(copySelectionPluginKey, 'show-selection'); // note: dispatch should always be defined when called from the
88
+ // floating toolbar. Howver the Command type which the floating toolbar
89
+ // uses suggests it's optional.
90
+ // Using the type here to protect against future refactors of the
91
+ // floating toolbar
92
+
93
+ if (dispatch) {
94
+ dispatch(tr);
95
+ }
96
+
97
+ return false;
98
+ }
99
+ export function removeVisualFeedbackForCopyButton(state, dispatch) {
100
+ const tr = state.tr;
101
+ tr.setMeta(copySelectionPluginKey, 'remove-selection'); // note: dispatch should always be defined when called from the
102
+ // floating toolbar. Howver the Command type which the floating toolbar
103
+ // uses suggests it's optional.
104
+ // Using the type here to protect against future refactors of the
105
+ // floating toolbar
106
+
107
+ if (dispatch) {
108
+ dispatch(tr);
109
+ }
110
+
111
+ return false;
112
+ }
@@ -1,24 +1,19 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { browser } from '@atlaskit/editor-common/utils';
3
3
  import { NodeSelection } from 'prosemirror-state';
4
- import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
5
4
  import { codeBlockNodeView } from '../nodeviews/code-block';
6
- import { highlightingCodeBlockNodeView } from '../nodeviews/highlighting-code-block';
7
5
  import { createSelectionClickHandler } from '../../selection/utils';
8
6
  import { pluginKey } from '../plugin-key';
9
7
  import { ACTIONS } from './actions';
10
8
  import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '../actions';
11
9
  import { findCodeBlock } from '../utils';
12
10
  import { codeBlockClassNames } from '../ui/class-names';
13
- import { getFeatureFlags } from '../../feature-flags-context';
14
11
  export const createPlugin = ({
15
12
  useLongPressSelection = false,
16
13
  getIntl,
17
14
  appearance,
18
15
  allowCompositionInputOverride = false
19
16
  }) => {
20
- const intl = getIntl();
21
- const codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
22
17
  const handleDOMEvents = {}; // ME-1599: Composition on mobile was causing the DOM observer to mutate the code block
23
18
  // incorrecly and lose content when pressing enter in the middle of a code block line.
24
19
 
@@ -102,22 +97,7 @@ export const createPlugin = ({
102
97
  key: pluginKey,
103
98
  props: {
104
99
  nodeViews: {
105
- codeBlock(node, view, getPos) {
106
- const featureFlags = getFeatureFlags(view.state); // The appearance being mobile indicates we are in an editor being
107
- // rendered by mobile bridge in a web view.
108
- // The tooltip is likely to have unexpected behaviour there, with being cut
109
- // off, so we disable it. This is also to keep the behaviour consistent with
110
- // the rendering in the mobile Native Renderer.
111
-
112
- const codeBidiWarningTooltipEnabled = appearance !== 'mobile';
113
- const createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? highlightingCodeBlockNodeView({
114
- codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
115
- codeBidiWarningLabel,
116
- codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
117
- }) : codeBlockNodeView();
118
- return createCodeBlockNodeView(node, view, getPos);
119
- }
120
-
100
+ codeBlock: codeBlockNodeView
121
101
  },
122
102
  handleClickOn: createSelectionClickHandler(['codeBlock'], target => !!(target.closest(`.${codeBlockClassNames.gutter}`) || target.classList.contains(codeBlockClassNames.content)), {
123
103
  useLongPressSelection