@atlaskit/editor-core 171.0.0 → 172.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/CHANGELOG.md +96 -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/table/ui/common-styles.js +1 -1
  58. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +43 -32
  59. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +33 -13
  60. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +122 -0
  61. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +18 -12
  62. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +10 -10
  63. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +7 -1
  64. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +40 -19
  65. package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +10 -0
  66. package/dist/cjs/types/browser.js +6 -0
  67. package/dist/cjs/ui/Addon/click-area-helper.js +40 -19
  68. package/dist/cjs/ui/Appearance/Comment/Comment.js +2 -2
  69. package/dist/cjs/ui/ContentStyles/index.js +1 -3
  70. package/dist/cjs/ui/DropList/index.js +215 -0
  71. package/dist/cjs/ui/Dropdown/index.js +2 -5
  72. package/dist/cjs/ui/DropdownMenu/index.js +140 -86
  73. package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +25 -14
  74. package/dist/cjs/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +2 -2
  75. package/dist/cjs/ui/ElementBrowser/components/ElementList/utils.js +28 -1
  76. package/dist/cjs/ui/ElementBrowser/constants.js +2 -7
  77. package/dist/cjs/ui/Layer/index.js +245 -0
  78. package/dist/cjs/ui/Layer/internal/helpers.js +70 -0
  79. package/dist/cjs/ui/PortalProvider/index.js +7 -26
  80. package/dist/cjs/version-wrapper.js +1 -1
  81. package/dist/cjs/version.json +1 -1
  82. package/dist/es2019/create-editor/ReactEditorView.js +15 -4
  83. package/dist/es2019/create-editor/create-plugins-list.js +21 -11
  84. package/dist/es2019/editor.js +9 -23
  85. package/dist/es2019/labs/next/internal/hooks/use-editor/index.js +6 -1
  86. package/dist/es2019/labs/next/presets/default.js +1 -1
  87. package/dist/es2019/nodeviews/context-adapter.js +2 -2
  88. package/dist/es2019/plugins/analytics/plugin.js +19 -4
  89. package/dist/es2019/plugins/base/index.js +3 -3
  90. package/dist/es2019/plugins/base/pm-plugins/disable-spell-checking.js +70 -0
  91. package/dist/es2019/plugins/card/index.js +1 -1
  92. package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -2
  93. package/dist/es2019/plugins/card/toolbar.js +10 -5
  94. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +5 -1
  95. package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +7 -7
  96. package/dist/es2019/plugins/clipboard/pm-plugins/main.js +1 -2
  97. package/dist/es2019/plugins/code-block/actions.js +12 -0
  98. package/dist/es2019/plugins/code-block/index.js +4 -0
  99. package/dist/es2019/plugins/code-block/nodeviews/code-block.js +1 -1
  100. package/dist/es2019/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +112 -0
  101. package/dist/es2019/plugins/code-block/pm-plugins/main.js +1 -21
  102. package/dist/es2019/plugins/code-block/styles.js +2 -159
  103. package/dist/es2019/plugins/code-block/toolbar.js +8 -0
  104. package/dist/es2019/plugins/code-block/ui/class-names.js +1 -2
  105. package/dist/es2019/plugins/copy-button/commands.js +35 -15
  106. package/dist/es2019/plugins/copy-button/toolbar.js +29 -0
  107. package/dist/es2019/plugins/copy-button/utils.js +15 -27
  108. package/dist/es2019/plugins/expand/toolbar.js +4 -1
  109. package/dist/es2019/plugins/extension/toolbar.js +4 -1
  110. package/dist/es2019/plugins/extension/ui/Extension/Extension/styles.js +1 -1
  111. package/dist/es2019/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
  112. package/dist/es2019/plugins/extension/ui/Extension/styles.js +1 -3
  113. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +27 -15
  114. package/dist/es2019/plugins/feedback-dialog/index.js +1 -1
  115. package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -19
  116. package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +14 -29
  117. package/dist/es2019/plugins/hyperlink/Toolbar.js +11 -5
  118. package/dist/es2019/plugins/hyperlink/index.js +4 -4
  119. package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +24 -0
  120. package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +28 -0
  121. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +50 -9
  122. package/dist/es2019/plugins/indentation/commands/index.js +24 -9
  123. package/dist/es2019/plugins/indentation/commands/utils.js +8 -3
  124. package/dist/es2019/plugins/indentation/pm-plugins/keymap.js +5 -4
  125. package/dist/es2019/plugins/layout/toolbar.js +2 -1
  126. package/dist/es2019/plugins/media/toolbar/index.js +10 -3
  127. package/dist/es2019/plugins/mentions/analytics.js +1 -1
  128. package/dist/es2019/plugins/panel/toolbar.js +1 -1
  129. package/dist/es2019/plugins/paste/edge-cases/index.js +15 -3
  130. package/dist/es2019/plugins/paste/handlers.js +27 -2
  131. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +12 -3
  132. package/dist/es2019/plugins/paste/pm-plugins/main.js +24 -4
  133. package/dist/es2019/plugins/status/analytics.js +1 -1
  134. package/dist/es2019/plugins/table/toolbar.js +1 -1
  135. package/dist/es2019/plugins/table/ui/common-styles.js +2 -0
  136. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +10 -10
  137. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +23 -4
  138. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +104 -0
  139. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +18 -12
  140. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +10 -10
  141. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +7 -1
  142. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +38 -16
  143. package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +9 -0
  144. package/dist/es2019/types/browser.js +2 -0
  145. package/dist/es2019/ui/Addon/click-area-helper.js +37 -18
  146. package/dist/es2019/ui/Appearance/Comment/Comment.js +2 -2
  147. package/dist/es2019/ui/ContentStyles/index.js +5 -9
  148. package/dist/es2019/ui/DropList/index.js +186 -0
  149. package/dist/es2019/ui/Dropdown/index.js +2 -6
  150. package/dist/es2019/ui/DropdownMenu/index.js +124 -75
  151. package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +11 -22
  152. package/dist/es2019/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +3 -3
  153. package/dist/es2019/ui/ElementBrowser/components/ElementList/utils.js +26 -2
  154. package/dist/es2019/ui/ElementBrowser/constants.js +1 -4
  155. package/dist/es2019/ui/Layer/index.js +195 -0
  156. package/dist/es2019/ui/Layer/internal/helpers.js +62 -0
  157. package/dist/es2019/ui/PortalProvider/index.js +5 -23
  158. package/dist/es2019/version-wrapper.js +1 -1
  159. package/dist/es2019/version.json +1 -1
  160. package/dist/esm/create-editor/ReactEditorView.js +13 -4
  161. package/dist/esm/create-editor/create-plugins-list.js +21 -12
  162. package/dist/esm/editor.js +9 -23
  163. package/dist/esm/labs/next/internal/hooks/use-editor/index.js +6 -1
  164. package/dist/esm/labs/next/presets/default.js +1 -1
  165. package/dist/esm/nodeviews/context-adapter.js +2 -2
  166. package/dist/esm/plugins/analytics/plugin.js +24 -11
  167. package/dist/esm/plugins/base/index.js +3 -3
  168. package/dist/esm/plugins/base/pm-plugins/disable-spell-checking.js +72 -0
  169. package/dist/esm/plugins/card/index.js +1 -1
  170. package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -2
  171. package/dist/esm/plugins/card/toolbar.js +11 -5
  172. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +5 -1
  173. package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +7 -7
  174. package/dist/esm/plugins/clipboard/pm-plugins/main.js +1 -2
  175. package/dist/esm/plugins/code-block/actions.js +12 -0
  176. package/dist/esm/plugins/code-block/index.js +6 -0
  177. package/dist/esm/plugins/code-block/nodeviews/code-block.js +2 -4
  178. package/dist/esm/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +112 -0
  179. package/dist/esm/plugins/code-block/pm-plugins/main.js +1 -20
  180. package/dist/esm/plugins/code-block/styles.js +4 -32
  181. package/dist/esm/plugins/code-block/toolbar.js +8 -0
  182. package/dist/esm/plugins/code-block/ui/class-names.js +1 -2
  183. package/dist/esm/plugins/copy-button/commands.js +35 -15
  184. package/dist/esm/plugins/copy-button/toolbar.js +31 -0
  185. package/dist/esm/plugins/copy-button/utils.js +14 -29
  186. package/dist/esm/plugins/expand/toolbar.js +6 -2
  187. package/dist/esm/plugins/extension/toolbar.js +4 -1
  188. package/dist/esm/plugins/extension/ui/Extension/Extension/styles.js +1 -1
  189. package/dist/esm/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
  190. package/dist/esm/plugins/extension/ui/Extension/styles.js +3 -4
  191. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +28 -16
  192. package/dist/esm/plugins/feedback-dialog/index.js +1 -1
  193. package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -21
  194. package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -27
  195. package/dist/esm/plugins/hyperlink/Toolbar.js +144 -135
  196. package/dist/esm/plugins/hyperlink/index.js +4 -4
  197. package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +26 -0
  198. package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +28 -0
  199. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +46 -5
  200. package/dist/esm/plugins/indentation/commands/index.js +30 -9
  201. package/dist/esm/plugins/indentation/commands/utils.js +12 -8
  202. package/dist/esm/plugins/indentation/pm-plugins/keymap.js +5 -4
  203. package/dist/esm/plugins/layout/toolbar.js +2 -1
  204. package/dist/esm/plugins/media/toolbar/index.js +12 -5
  205. package/dist/esm/plugins/mentions/analytics.js +1 -1
  206. package/dist/esm/plugins/panel/toolbar.js +1 -1
  207. package/dist/esm/plugins/paste/edge-cases/index.js +15 -3
  208. package/dist/esm/plugins/paste/handlers.js +23 -2
  209. package/dist/esm/plugins/paste/pm-plugins/analytics.js +13 -3
  210. package/dist/esm/plugins/paste/pm-plugins/main.js +23 -4
  211. package/dist/esm/plugins/status/analytics.js +1 -1
  212. package/dist/esm/plugins/table/toolbar.js +1 -1
  213. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  214. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +37 -31
  215. package/dist/esm/plugins/toolbar-lists-indentation/index.js +32 -13
  216. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +105 -0
  217. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +18 -12
  218. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +10 -10
  219. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +7 -1
  220. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +38 -20
  221. package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +9 -0
  222. package/dist/esm/types/browser.js +2 -0
  223. package/dist/esm/ui/Addon/click-area-helper.js +37 -18
  224. package/dist/esm/ui/Appearance/Comment/Comment.js +2 -2
  225. package/dist/esm/ui/ContentStyles/index.js +2 -4
  226. package/dist/esm/ui/DropList/index.js +203 -0
  227. package/dist/esm/ui/Dropdown/index.js +2 -6
  228. package/dist/esm/ui/DropdownMenu/index.js +134 -88
  229. package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +27 -17
  230. package/dist/esm/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +3 -3
  231. package/dist/esm/ui/ElementBrowser/components/ElementList/utils.js +26 -2
  232. package/dist/esm/ui/ElementBrowser/constants.js +1 -4
  233. package/dist/esm/ui/Layer/index.js +228 -0
  234. package/dist/esm/ui/Layer/internal/helpers.js +62 -0
  235. package/dist/esm/ui/PortalProvider/index.js +7 -26
  236. package/dist/esm/version-wrapper.js +1 -1
  237. package/dist/esm/version.json +1 -1
  238. package/dist/types/labs/next/presets/default.d.ts +2 -0
  239. package/dist/types/plugins/analytics/plugin.d.ts +5 -1
  240. package/dist/types/plugins/analytics/types/cut-copy-events.d.ts +2 -0
  241. package/dist/types/plugins/analytics/types/general-events.d.ts +1 -0
  242. package/dist/types/plugins/analytics/types/paste-events.d.ts +1 -0
  243. package/dist/types/plugins/base/index.d.ts +1 -1
  244. package/dist/types/plugins/base/pm-plugins/{fix-chrome-spell-checking.d.ts → disable-spell-checking.d.ts} +0 -0
  245. package/dist/types/plugins/card/index.d.ts +2 -7
  246. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +2 -1
  247. package/dist/types/plugins/card/toolbar.d.ts +3 -5
  248. package/dist/types/plugins/card/types.d.ts +2 -0
  249. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +4 -1
  250. package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +2 -1
  251. package/dist/types/plugins/clipboard/pm-plugins/main.d.ts +3 -0
  252. package/dist/types/plugins/code-block/nodeviews/code-block.d.ts +1 -1
  253. package/dist/types/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +11 -0
  254. package/dist/types/plugins/code-block/styles.d.ts +0 -1
  255. package/dist/types/plugins/code-block/ui/class-names.d.ts +0 -1
  256. package/dist/types/plugins/copy-button/commands.d.ts +2 -2
  257. package/dist/types/plugins/copy-button/toolbar.d.ts +7 -0
  258. package/dist/types/plugins/copy-button/utils.d.ts +7 -6
  259. package/dist/types/plugins/floating-toolbar/types.d.ts +1 -2
  260. package/dist/types/plugins/hyperlink/Toolbar.d.ts +2 -1
  261. package/dist/types/plugins/hyperlink/index.d.ts +2 -2
  262. package/dist/types/plugins/hyperlink/types.d.ts +30 -0
  263. package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/index.d.ts +7 -0
  264. package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.d.ts +2 -0
  265. package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +4 -3
  266. package/dist/types/plugins/indentation/commands/index.d.ts +6 -2
  267. package/dist/types/plugins/indentation/commands/utils.d.ts +8 -2
  268. package/dist/types/plugins/paste/edge-cases/index.d.ts +3 -2
  269. package/dist/types/plugins/paste/handlers.d.ts +1 -0
  270. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +7 -1
  271. package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +5 -0
  272. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +2 -1
  273. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +14 -0
  274. package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +2 -0
  275. package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +2 -0
  276. package/dist/types/types/browser.d.ts +10 -0
  277. package/dist/types/types/editor-props.d.ts +6 -5
  278. package/dist/types/types/feature-flags.d.ts +29 -24
  279. package/dist/types/types/index.d.ts +1 -0
  280. package/dist/types/ui/Addon/click-area-helper.d.ts +10 -0
  281. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  282. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  283. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  284. package/dist/types/ui/DropList/index.d.ts +22 -0
  285. package/dist/types/ui/Dropdown/index.d.ts +2 -1
  286. package/dist/types/ui/DropdownMenu/index.d.ts +0 -1
  287. package/dist/types/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.d.ts +1 -1
  288. package/dist/types/ui/ElementBrowser/components/ElementList/utils.d.ts +1 -0
  289. package/dist/types/ui/ElementBrowser/constants.d.ts +1 -3
  290. package/dist/types/ui/Layer/index.d.ts +47 -0
  291. package/dist/types/ui/Layer/internal/helpers.d.ts +5 -0
  292. package/package.json +23 -18
  293. package/dist/cjs/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -37
  294. package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +0 -195
  295. package/dist/cjs/utils/check-if-mobile-bridge.js +0 -19
  296. package/dist/es2019/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -22
  297. package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +0 -152
  298. package/dist/es2019/utils/check-if-mobile-bridge.js +0 -12
  299. package/dist/esm/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -24
  300. package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +0 -178
  301. package/dist/esm/utils/check-if-mobile-bridge.js +0 -12
  302. package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +0 -48
  303. package/dist/types/utils/check-if-mobile-bridge.d.ts +0 -1
@@ -0,0 +1,72 @@
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 (function () {
37
+ return new SafePlugin({
38
+ key: new PluginKey('disableSpellchecking'),
39
+ props: {
40
+ attributes: function attributes(editorState) {
41
+ var featureFlags = getFeatureFlags(editorState) || undefined;
42
+
43
+ if (!featureFlags) {
44
+ return;
45
+ }
46
+
47
+ var browserConfigFeatureFlag = featureFlags.disableSpellcheckByBrowser;
48
+ var userCurrentBrowserAndVersion = getCurrentBrowserAndVersion();
49
+
50
+ if (!userCurrentBrowserAndVersion || !browserConfigFeatureFlag) {
51
+ return;
52
+ }
53
+
54
+ var browserVersionDisableRange = browserConfigFeatureFlag[userCurrentBrowserAndVersion.browser];
55
+
56
+ if (!browserVersionDisableRange || !browserEnv[userCurrentBrowserAndVersion.browser]) {
57
+ return;
58
+ }
59
+
60
+ var shouldDisableSpellcheck = !!browserVersionDisableRange.maximum ? userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum && userCurrentBrowserAndVersion.version <= browserVersionDisableRange.maximum : browserEnv[userCurrentBrowserAndVersion.browser] && userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum;
61
+
62
+ if (shouldDisableSpellcheck) {
63
+ return {
64
+ spellcheck: 'false'
65
+ };
66
+ }
67
+
68
+ return;
69
+ }
70
+ }
71
+ });
72
+ });
@@ -62,7 +62,7 @@ var cardPlugin = function 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
  };
@@ -17,7 +17,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
17
17
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
18
 
19
19
  import React from 'react';
20
- import { Card as SmartCard } from '@atlaskit/smart-card';
20
+ import { Card as SmartCard, EmbedResizeMessageListener } from '@atlaskit/smart-card';
21
21
  import PropTypes from 'prop-types';
22
22
  import rafSchedule from 'raf-schd';
23
23
  import { Card } from './genericCard';
@@ -31,7 +31,6 @@ import { createDisplayGrid } from '../../../plugins/grid';
31
31
  import WithPluginState from '../../../ui/WithPluginState';
32
32
  import { pluginKey as widthPluginKey } from '../../width';
33
33
  import { floatingLayouts, isRichMediaInsideOfBlockNode } from '../../../utils/rich-media-utils';
34
- import { EmbedResizeMessageListener } from '@atlaskit/smart-card';
35
34
  import { pluginKey as tableResizePluginKey } from '../../table/pm-plugins/table-resizing';
36
35
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
37
36
  export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
@@ -26,6 +26,7 @@ import { messages } from './messages';
26
26
  import buildLayoutButtons from '../../ui/MediaAndEmbedsToolbar';
27
27
  import { buildVisitedLinkPayload } from '../../utils/linking-utils';
28
28
  import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
29
+ import { getCopyButtonConfig, showCopyButton } from '../copy-button/toolbar';
29
30
  export var removeCard = function removeCard(state, dispatch) {
30
31
  if (!(state.selection instanceof NodeSelection)) {
31
32
  return false;
@@ -102,6 +103,10 @@ var generateDeleteButton = function generateDeleteButton(node, state, intl) {
102
103
  onClick: removeCard
103
104
  };
104
105
 
106
+ var copyButton = _toConsumableArray(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, node.type), {
107
+ type: 'separator'
108
+ }] : []);
109
+
105
110
  if (node.type === inlineCard) {
106
111
  var unlinkButtonWithSeparator = [{
107
112
  id: 'editor.link.unlink',
@@ -112,13 +117,13 @@ var generateDeleteButton = function generateDeleteButton(node, state, intl) {
112
117
  }, {
113
118
  type: 'separator'
114
119
  }];
115
- return [].concat(unlinkButtonWithSeparator, [removeButton]);
120
+ return [].concat(unlinkButtonWithSeparator, _toConsumableArray(copyButton), [removeButton]);
116
121
  }
117
122
 
118
- return [removeButton];
123
+ return [].concat(_toConsumableArray(copyButton), [removeButton]);
119
124
  };
120
125
 
121
- var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, platform) {
126
+ var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, platform, linkPicker) {
122
127
  return function (node) {
123
128
  var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
124
129
  url = _titleUrlPairFromNode2.url;
@@ -144,6 +149,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
144
149
  if (pluginState.showLinkingToolbar && platform !== 'mobile') {
145
150
  return [buildEditLinkToolbar({
146
151
  providerFactory: providerFactory,
152
+ linkPicker: linkPicker,
147
153
  node: node
148
154
  })];
149
155
  } else {
@@ -211,7 +217,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
211
217
  };
212
218
  };
213
219
 
214
- export var floatingToolbar = function floatingToolbar(cardOptions, platform) {
220
+ export var floatingToolbar = function floatingToolbar(cardOptions, platform, linkPickerOptions) {
215
221
  return function (state, intl, providerFactory) {
216
222
  var _state$schema$nodes = state.schema.nodes,
217
223
  inlineCard = _state$schema$nodes.inlineCard,
@@ -256,7 +262,7 @@ export var floatingToolbar = function floatingToolbar(cardOptions, platform) {
256
262
 
257
263
  return element;
258
264
  },
259
- items: generateToolbarItems(state, intl, providerFactory, cardOptions, platform)
265
+ items: generateToolbarItems(state, intl, providerFactory, cardOptions, platform, linkPickerOptions)
260
266
  }, pluginState.showLinkingToolbar ? editLinkToolbarConfig : {});
261
267
  };
262
268
  };
@@ -52,6 +52,7 @@ export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
52
52
  var _this = this;
53
53
 
54
54
  var _this$props = this.props,
55
+ linkPickerOptions = _this$props.linkPickerOptions,
55
56
  providerFactory = _this$props.providerFactory,
56
57
  url = _this$props.url,
57
58
  text = _this$props.text,
@@ -59,6 +60,7 @@ export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
59
60
  _onSubmit = _this$props.onSubmit;
60
61
  return /*#__PURE__*/React.createElement(HyperlinkToolbar, {
61
62
  view: view,
63
+ linkPickerOptions: linkPickerOptions,
62
64
  providerFactory: providerFactory,
63
65
  displayUrl: url,
64
66
  displayText: text,
@@ -91,7 +93,8 @@ export var editLink = function editLink(state, dispatch) {
91
93
  };
92
94
  export var buildEditLinkToolbar = function buildEditLinkToolbar(_ref) {
93
95
  var providerFactory = _ref.providerFactory,
94
- node = _ref.node;
96
+ node = _ref.node,
97
+ linkPicker = _ref.linkPicker;
95
98
  return {
96
99
  type: 'custom',
97
100
  fallback: [],
@@ -104,6 +107,7 @@ export var buildEditLinkToolbar = function buildEditLinkToolbar(_ref) {
104
107
  return /*#__PURE__*/React.createElement(EditLinkToolbar, {
105
108
  key: idx,
106
109
  view: view,
110
+ linkPickerOptions: linkPicker,
107
111
  providerFactory: providerFactory,
108
112
  url: displayInfo.url,
109
113
  text: displayInfo.title || '',
@@ -59,8 +59,8 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
59
59
  }
60
60
  }
61
61
 
62
- var isSmartLinkSupportedInParent = isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
63
- var tooltip = isSmartLinkSupportedInParent ? undefined : parentNodeName(editorState, intl);
62
+ var isBlockCardLinkSupportedInParent = isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
63
+ var isEmbedCardLinkSupportedInParent = allowEmbeds ? isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance) : false;
64
64
  var embedOption = allowEmbeds && preview && {
65
65
  appearance: 'embed',
66
66
  title: intl.formatMessage(messages.embed),
@@ -68,8 +68,8 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
68
68
  selected: currentAppearance === 'embed',
69
69
  hidden: false,
70
70
  testId: 'embed-appearance',
71
- disabled: !isSmartLinkSupportedInParent,
72
- tooltip: tooltip
71
+ disabled: !isEmbedCardLinkSupportedInParent,
72
+ tooltip: isEmbedCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
73
73
  };
74
74
  var options = [{
75
75
  title: intl.formatMessage(messages.url),
@@ -90,8 +90,8 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
90
90
  onClick: setSelectedCardAppearance('block'),
91
91
  selected: currentAppearance === 'block',
92
92
  testId: 'block-appearance',
93
- disabled: !isSmartLinkSupportedInParent,
94
- tooltip: tooltip
93
+ disabled: !isBlockCardLinkSupportedInParent,
94
+ tooltip: isBlockCardLinkSupportedInParent ? undefined : getUnavailableMessage(editorState, intl)
95
95
  }];
96
96
 
97
97
  var dispatchCommand = function dispatchCommand(fn) {
@@ -159,7 +159,7 @@ _defineProperty(LinkToolbarAppearance, "contextTypes", {
159
159
  contextAdapter: PropTypes.object
160
160
  });
161
161
 
162
- var parentNodeName = function parentNodeName(state, intl) {
162
+ var getUnavailableMessage = function getUnavailableMessage(state, intl) {
163
163
  try {
164
164
  var parentNode = state.selection.$from.node(1);
165
165
  var parentName = intl.formatMessage(nodeNames[parentNode.type.name]);
@@ -120,8 +120,7 @@ export var sendClipboardAnalytics = function sendClipboardAnalytics(view, dispat
120
120
 
121
121
  return false;
122
122
  };
123
-
124
- var getAnalyticsPayload = function getAnalyticsPayload(state, action) {
123
+ export var getAnalyticsPayload = function getAnalyticsPayload(state, action) {
125
124
  var selection = state.selection,
126
125
  doc = state.doc;
127
126
  var selectionAnalyticsPayload = getNodeSelectionAnalyticsPayload(selection) || getRangeSelectionAnalyticsPayload(selection, doc) || getAllSelectionAnalyticsPayload(selection) || getCellSelectionAnalyticsPayload(state);
@@ -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';
@@ -67,6 +68,7 @@ export var copyContentToClipboard = function copyContentToClipboard(state, dispa
67
68
  type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
68
69
  data: true
69
70
  });
71
+ copyToClipboardTr.setMeta(copySelectionPluginKey, 'remove-selection');
70
72
 
71
73
  if (dispatch) {
72
74
  dispatch(copyToClipboardTr);
@@ -85,10 +87,20 @@ export var resetCopiedState = function resetCopiedState(state, dispatch) {
85
87
  type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
86
88
  data: false
87
89
  });
90
+ resetCopiedStateTr.setMeta(copySelectionPluginKey, 'remove-selection');
88
91
 
89
92
  if (dispatch) {
90
93
  dispatch(resetCopiedStateTr);
91
94
  }
95
+ } else {
96
+ var clearSelectionStateTransaction = state.tr;
97
+ clearSelectionStateTransaction.setMeta(copySelectionPluginKey, 'remove-selection'); // note: dispatch should always be defined when called from the
98
+ // floating toolbar. Howver the Command type which floating toolbar uses
99
+ // (and resetCopiedState) uses suggests it's optional.
100
+
101
+ if (dispatch) {
102
+ dispatch(clearSelectionStateTransaction);
103
+ }
92
104
  }
93
105
 
94
106
  return true;
@@ -10,6 +10,7 @@ import { createPlugin } from './pm-plugins/main';
10
10
  import { getToolbarConfig } from './toolbar';
11
11
  import keymap from './pm-plugins/keymaps';
12
12
  import ideUX from './pm-plugins/ide-ux';
13
+ import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
13
14
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '../analytics';
14
15
  import { IconCode } from '../quick-insert/assets';
15
16
  import { messages } from '../block-type/messages';
@@ -45,6 +46,11 @@ var codeBlockPlugin = function codeBlockPlugin(options) {
45
46
  var schema = _ref2.schema;
46
47
  return keymap(schema);
47
48
  }
49
+ }, {
50
+ name: 'codeBlockCopySelection',
51
+ plugin: function plugin() {
52
+ return codeBlockCopySelectionPlugin();
53
+ }
48
54
  }];
49
55
  },
50
56
  // Workaround for a firefox issue where dom selection is off sync
@@ -154,8 +154,6 @@ export var CodeBlockView = /*#__PURE__*/function () {
154
154
 
155
155
  return CodeBlockView;
156
156
  }();
157
- export var codeBlockNodeView = function codeBlockNodeView() {
158
- return function (node, view, getPos) {
159
- return new CodeBlockView(node, view, getPos);
160
- };
157
+ export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos) {
158
+ return new CodeBlockView(node, view, getPos);
161
159
  };
@@ -0,0 +1,112 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { PluginKey } from 'prosemirror-state';
4
+ import { Decoration, DecorationSet } from 'prosemirror-view';
5
+ import { getSelectedNodeOrNodeParentByNodeType } from '../../copy-button/utils';
6
+ export var copySelectionPluginKey = new PluginKey('codeBlockCopySelectionPlugin');
7
+
8
+ function getSelectionDecorationStartAndEnd(_ref) {
9
+ var state = _ref.state,
10
+ transaction = _ref.transaction;
11
+ var 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
+ var decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
23
+ return {
24
+ decorationStartAndEnd: decorationStartAndEnd
25
+ };
26
+ }
27
+
28
+ export function codeBlockCopySelectionPlugin() {
29
+ return new SafePlugin({
30
+ key: copySelectionPluginKey,
31
+ state: {
32
+ init: function init() {
33
+ return {
34
+ decorationStartAndEnd: undefined
35
+ };
36
+ },
37
+ apply: function apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
38
+ switch (transaction.getMeta(copySelectionPluginKey)) {
39
+ case 'show-selection':
40
+ {
41
+ return getSelectionDecorationStartAndEnd({
42
+ state: newState,
43
+ transaction: transaction
44
+ });
45
+ }
46
+
47
+ case 'remove-selection':
48
+ return {
49
+ decorationStartAndEnd: undefined
50
+ };
51
+
52
+ default:
53
+ // The contents of the code block can change while the selection is being shown
54
+ // (either from collab edits -- or from the user continuing to type while hovering
55
+ // the mouse over the copy button).
56
+ // This ensures the selection is updated in these cases.
57
+ if (currentCodeBlockCopySelectionPluginState.decorationStartAndEnd !== undefined) {
58
+ return getSelectionDecorationStartAndEnd({
59
+ state: newState,
60
+ transaction: transaction
61
+ });
62
+ }
63
+
64
+ return currentCodeBlockCopySelectionPluginState;
65
+ }
66
+ }
67
+ },
68
+ props: {
69
+ decorations: function decorations(state) {
70
+ if (copySelectionPluginKey.getState(state).decorationStartAndEnd) {
71
+ var _copySelectionPluginK = _slicedToArray(copySelectionPluginKey.getState(state).decorationStartAndEnd, 2),
72
+ _start = _copySelectionPluginK[0],
73
+ _end = _copySelectionPluginK[1];
74
+
75
+ return DecorationSet.create(state.doc, [Decoration.inline(_start, _end, {
76
+ class: 'ProseMirror-fake-text-selection'
77
+ })]);
78
+ }
79
+
80
+ return DecorationSet.empty;
81
+ }
82
+ }
83
+ });
84
+ }
85
+ export function provideVisualFeedbackForCopyButton(state, dispatch) {
86
+ var 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
+ var 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
+ }
@@ -7,16 +7,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
8
  import { browser } from '@atlaskit/editor-common/utils';
9
9
  import { NodeSelection } from 'prosemirror-state';
10
- import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
11
10
  import { codeBlockNodeView } from '../nodeviews/code-block';
12
- import { highlightingCodeBlockNodeView } from '../nodeviews/highlighting-code-block';
13
11
  import { createSelectionClickHandler } from '../../selection/utils';
14
12
  import { pluginKey } from '../plugin-key';
15
13
  import { ACTIONS } from './actions';
16
14
  import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '../actions';
17
15
  import { findCodeBlock } from '../utils';
18
16
  import { codeBlockClassNames } from '../ui/class-names';
19
- import { getFeatureFlags } from '../../feature-flags-context';
20
17
  export var createPlugin = function createPlugin(_ref) {
21
18
  var _ref$useLongPressSele = _ref.useLongPressSelection,
22
19
  useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele,
@@ -24,8 +21,6 @@ export var createPlugin = function createPlugin(_ref) {
24
21
  appearance = _ref.appearance,
25
22
  _ref$allowComposition = _ref.allowCompositionInputOverride,
26
23
  allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition;
27
- var intl = getIntl();
28
- var codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
29
24
  var handleDOMEvents = {}; // ME-1599: Composition on mobile was causing the DOM observer to mutate the code block
30
25
  // incorrecly and lose content when pressing enter in the middle of a code block line.
31
26
 
@@ -111,21 +106,7 @@ export var createPlugin = function createPlugin(_ref) {
111
106
  key: pluginKey,
112
107
  props: {
113
108
  nodeViews: {
114
- codeBlock: function codeBlock(node, view, getPos) {
115
- var featureFlags = getFeatureFlags(view.state); // The appearance being mobile indicates we are in an editor being
116
- // rendered by mobile bridge in a web view.
117
- // The tooltip is likely to have unexpected behaviour there, with being cut
118
- // off, so we disable it. This is also to keep the behaviour consistent with
119
- // the rendering in the mobile Native Renderer.
120
-
121
- var codeBidiWarningTooltipEnabled = appearance !== 'mobile';
122
- var createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? highlightingCodeBlockNodeView({
123
- codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
124
- codeBidiWarningLabel: codeBidiWarningLabel,
125
- codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
126
- }) : codeBlockNodeView();
127
- return createCodeBlockNodeView(node, view, getPos);
128
- }
109
+ codeBlock: codeBlockNodeView
129
110
  },
130
111
  handleClickOn: createSelectionClickHandler(['codeBlock'], function (target) {
131
112
  return !!(target.closest(".".concat(codeBlockClassNames.gutter)) || target.classList.contains(codeBlockClassNames.content));
@@ -1,41 +1,13 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
 
3
- var _templateObject, _templateObject2;
3
+ var _templateObject;
4
4
 
5
5
  import { css } from '@emotion/react';
6
- import { themed } from '@atlaskit/theme/components';
7
- import { borderRadius, fontSize, gridSize } from '@atlaskit/theme/constants';
8
- import { R75, N20, DN50, N30, DN20, N90, DN90, N400, DN400, N800, DN500 } from '@atlaskit/theme/colors';
9
- import { blockNodesVerticalMargin, akEditorTableCellMinWidth, akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, SelectionStyle, getSelectionStyles, akEditorCodeFontFamily, akEditorSelectedNodeClassName, overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
6
+ import { R75 } from '@atlaskit/theme/colors';
7
+ import { akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
10
8
  import { token } from '@atlaskit/tokens';
11
9
  import { codeBlockClassNames } from './ui/class-names';
12
10
  import { codeBlockSharedStyles } from '@atlaskit/editor-common/styles';
13
- export var highlightingCodeBlockStyles = function highlightingCodeBlockStyles(props) {
14
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror .code-block {\n position: relative;\n background-image: ", ";\n background-repeat: no-repeat;\n background-color: ", ";\n\n --ds--code--bg-color: transparent;\n\n background-attachment: local, scroll, scroll;\n background-size: 8px 100%, 8px 100%, 8px 100%;\n background-position: 100% 0, 100% 0, 0 0;\n font-family: ", ";\n border-radius: ", "px;\n margin: ", " 0 0 0;\n counter-reset: line;\n display: flex;\n min-width: ", "px;\n cursor: pointer;\n overflow-x: auto;\n\n .", " {\n /* https://bitbucket.org/atlassian/atlassian-frontend/src/develop/packages/design-system/code/src/themes/themeBuilder.ts#packages/design-system/code/src/themes/themeBuilder.ts-19:28 */\n flex-shrink: 0;\n text-align: right;\n background-color: ", ";\n padding: ", "px;\n color: ", ";\n\n span {\n display: block;\n line-height: 0;\n font-size: 0;\n\n &::before {\n display: inline-block;\n content: counter(line);\n counter-increment: line;\n font-size: ", ";\n line-height: 1.5rem;\n color: ", ";\n }\n }\n }\n\n .", " {\n position: absolute;\n z-index: 2;\n width: 100%;\n height: 100%;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n pointer-events: none;\n overflow: hidden;\n tab-size: 4;\n\n & [data-ds--code--code-block] {\n font-size: ", ";\n line-height: 1.5rem;\n }\n }\n\n .", " {\n position: relative;\n z-index: 1;\n display: flex;\n flex: 1;\n\n > code {\n flex-grow: 1;\n tab-size: 4;\n cursor: text;\n /* https://bitbucket.org/atlassian/atlassian-frontend/src/218202daeaf527262c21841e6f88fa058d349ad4/packages/design-system/code/src/themes/themeBuilder.ts#lines-12:17 */\n font-size: ", ";\n line-height: 1.5rem;\n border-radius: ", "px;\n margin: ", "px;\n white-space: pre;\n }\n\n &[data-debounce='true'] {\n .", " {\n display: none;\n }\n }\n\n &:not([data-debounce='true']) {\n > code:not([data-language='plaintext']):not([data-language='none']):not([data-language='']) {\n color: transparent;\n caret-color: ", ";\n }\n }\n }\n }\n\n .ProseMirror li > .code-block {\n margin: 0;\n }\n\n .ProseMirror .code-block.", ":not(.danger) {\n ", "\n }\n\n /* Danger when top level node */\n .ProseMirror .danger.code-block {\n box-shadow: 0 0 0 ", "px\n ", ";\n\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n\n /* Danger when nested node */\n .ProseMirror .danger .code-block {\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n"])), overflowShadow({
15
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
16
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
17
- background: themed({
18
- light: N20,
19
- dark: DN50
20
- })(props),
21
- width: '8px'
22
- }), themed({
23
- light: token('color.background.neutral', N20),
24
- dark: token('color.background.neutral', DN50)
25
- })(props), akEditorCodeFontFamily, borderRadius(), blockNodesVerticalMargin, akEditorTableCellMinWidth, codeBlockClassNames.gutter, themed({
26
- light: token('color.background.neutral', N30),
27
- dark: token('color.background.neutral', DN20)
28
- })(props), gridSize(), themed({
29
- light: token('color.text.subtlest', N90),
30
- dark: token('color.text.subtlest', DN90)
31
- })(props), relativeFontSizeToBase16(fontSize()), themed({
32
- light: token('color.text.subtle', N400),
33
- dark: token('color.text.subtle', DN400)
34
- })(props), codeBlockClassNames.highlighting, relativeFontSizeToBase16(fontSize()), codeBlockClassNames.content, relativeFontSizeToBase16(fontSize()), borderRadius(), gridSize(), codeBlockClassNames.highlighting, themed({
35
- light: token('color.text', N800),
36
- dark: token('color.text', DN500)
37
- })(props), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]), akEditorSelectedBorderSize, token('color.border.danger', akEditorDeleteBorder), codeBlockClassNames.gutter, token('color.blanket.danger', R75), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', akEditorDeleteBackground), codeBlockClassNames.gutter, token('color.blanket.danger', 'rgba(255, 143, 115, 0.5)'), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', 'rgba(255, 189, 173, 0.5)'));
38
- };
39
11
  export var codeBlockStyles = function codeBlockStyles(props) {
40
- return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ProseMirror {\n ", "\n }\n\n .ProseMirror li > .code-block {\n margin: 0;\n }\n\n .ProseMirror .code-block.", ":not(.danger) {\n ", "\n }\n\n /* Danger when top level node */\n .ProseMirror .danger.code-block {\n box-shadow: 0 0 0 ", "px ", ";\n\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n\n /* Danger when nested node */\n .ProseMirror .danger .code-block {\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n"])), codeBlockSharedStyles(props), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]), akEditorSelectedBorderSize, akEditorDeleteBorder, codeBlockClassNames.gutter, token('color.blanket.danger', R75), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', akEditorDeleteBackground), codeBlockClassNames.gutter, token('color.blanket.danger', 'rgba(255, 143, 115, 0.5)'), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', 'rgba(255, 189, 173, 0.5)'));
12
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", "\n }\n\n .ProseMirror li > .code-block {\n margin: 0;\n }\n\n .ProseMirror .code-block.", ":not(.danger) {\n ", "\n }\n\n /* Danger when top level node */\n .ProseMirror .danger.code-block {\n box-shadow: 0 0 0 ", "px ", ";\n\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n\n /* Danger when nested node */\n .ProseMirror .danger .code-block {\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n"])), codeBlockSharedStyles(props), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]), akEditorSelectedBorderSize, akEditorDeleteBorder, codeBlockClassNames.gutter, token('color.blanket.danger', R75), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', akEditorDeleteBackground), codeBlockClassNames.gutter, token('color.blanket.danger', 'rgba(255, 143, 115, 0.5)'), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', 'rgba(255, 189, 173, 0.5)'));
41
13
  };
@@ -4,6 +4,7 @@ import CopyIcon from '@atlaskit/icon/glyph/copy';
4
4
  import { findDomRefAtPos } from 'prosemirror-utils';
5
5
  import { removeCodeBlock, changeLanguage, copyContentToClipboard, resetCopiedState } from './actions';
6
6
  import commonMessages from '../../messages';
7
+ import { provideVisualFeedbackForCopyButton, removeVisualFeedbackForCopyButton } from './pm-plugins/codeBlockCopySelectionPlugin';
7
8
  import { hoverDecoration } from '../base/pm-plugins/decoration';
8
9
  import { pluginKey } from './plugin-key';
9
10
  import { createLanguageList, getLanguageIdentifier, DEFAULT_LANGUAGES } from './language-list';
@@ -69,9 +70,16 @@ export var getToolbarConfig = function getToolbarConfig() {
69
70
  type: 'button',
70
71
  appearance: 'subtle',
71
72
  icon: CopyIcon,
73
+ // note: copyContentToClipboard contains logic that also removes the
74
+ // visual feedback for the copy button
72
75
  onClick: copyContentToClipboard,
73
76
  title: formatMessage(codeBlockState.contentCopied ? commonMessages.copiedToClipboard : commonMessages.copyToClipboard),
77
+ onMouseEnter: provideVisualFeedbackForCopyButton,
78
+ // note: resetCopiedState contains logic that also removes the
79
+ // visual feedback for the copy button
74
80
  onMouseLeave: resetCopiedState,
81
+ onFocus: provideVisualFeedbackForCopyButton,
82
+ onBlur: removeVisualFeedbackForCopyButton,
75
83
  hideTooltipOnClick: false,
76
84
  disabled: codeBlockState.isNodeSelected,
77
85
  tabIndex: null
@@ -1,6 +1,5 @@
1
1
  import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
2
2
  export var codeBlockClassNames = {
3
3
  gutter: CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER,
4
- content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT,
5
- highlighting: 'code-highlighting'
4
+ content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT
6
5
  };
@@ -1,36 +1,56 @@
1
- import { findSelectedNodeOfType, findParentNodeOfType } from 'prosemirror-utils';
2
1
  import { pluginKey } from './pm-plugins/plugin-key';
3
2
  import { hoverDecoration } from '../base/pm-plugins/decoration';
4
- import { DOMSerializer } from 'prosemirror-model';
5
3
  import { copyHTMLToClipboard } from '../../utils/clipboard';
6
- export var copy = function copy(nodeType) {
4
+ import { getSelectedNodeOrNodeParentByNodeType, toDOM } from './utils';
5
+ import { addAnalytics, ACTION, INPUT_METHOD } from '../analytics';
6
+ import { getAnalyticsPayload } from '../clipboard/pm-plugins/main';
7
+ export var createToolbarCopyCommand = function createToolbarCopyCommand(nodeType) {
7
8
  return function (state, dispatch) {
8
9
  var tr = state.tr,
9
10
  schema = state.schema; // This command should only be triggered by the Copy button in the floating toolbar
10
11
  // which is only visible when selection is inside the target node
11
12
 
12
- var node = findSelectedNodeOfType(nodeType)(tr.selection);
13
-
14
- if (!node) {
15
- node = findParentNodeOfType(nodeType)(tr.selection);
16
- }
13
+ var node = getSelectedNodeOrNodeParentByNodeType({
14
+ nodeType: nodeType,
15
+ selection: tr.selection
16
+ });
17
17
 
18
18
  if (!node) {
19
19
  return false;
20
20
  }
21
21
 
22
- var domNode = DOMSerializer.fromSchema(schema).serializeNode(node.node);
23
- var div = document.createElement('div');
24
- div.appendChild(domNode); // The "0 0" refers to the start and end depth of the slice
25
- // since we're coping the block node only, it will always be 0 0
26
- // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
22
+ var domNode = toDOM(node.node, schema);
23
+
24
+ if (domNode) {
25
+ var div = document.createElement('div');
26
+ div.appendChild(domNode); // if copying inline content
27
+
28
+ if (node.node.type.inlineContent) {
29
+ // The "1 1" refers to the start and end depth of the slice
30
+ // since we're copying the text inside a paragraph, it will always be 1 1
31
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
32
+ div.firstChild.setAttribute('data-pm-slice', '1 1 []');
33
+ } else {
34
+ // The "0 0" refers to the start and end depth of the slice
35
+ // since we're copying the block node only, it will always be 0 0
36
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
37
+ div.firstChild.setAttribute('data-pm-slice', '0 0 []');
38
+ }
39
+
40
+ copyHTMLToClipboard(div.innerHTML);
41
+ }
27
42
 
28
- div.firstChild.setAttribute('data-pm-slice', '0 0 []');
29
- copyHTMLToClipboard(div.innerHTML);
30
43
  var copyToClipboardTr = tr;
31
44
  copyToClipboardTr.setMeta(pluginKey, {
32
45
  copied: true
33
46
  });
47
+ var analyticsPayload = getAnalyticsPayload(state, ACTION.COPIED);
48
+
49
+ if (analyticsPayload) {
50
+ analyticsPayload.attributes.inputMethod = INPUT_METHOD.FLOATING_TB;
51
+ analyticsPayload.attributes.nodeType = node.node.type.name;
52
+ addAnalytics(state, copyToClipboardTr, analyticsPayload);
53
+ }
34
54
 
35
55
  if (dispatch) {
36
56
  dispatch(copyToClipboardTr);