@atlaskit/editor-plugin-media 0.2.0 → 0.3.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 (328) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/commands/captions.js +59 -0
  3. package/dist/cjs/commands/helpers.js +127 -0
  4. package/dist/cjs/commands/index.js +24 -0
  5. package/dist/cjs/commands/linking.js +181 -0
  6. package/dist/cjs/index.js +8 -1
  7. package/dist/cjs/media-plugin-options.js +5 -0
  8. package/dist/cjs/next-plugin-type.js +5 -0
  9. package/dist/cjs/nodeviews/mediaGroup.js +376 -0
  10. package/dist/cjs/nodeviews/mediaInline.js +288 -0
  11. package/dist/cjs/nodeviews/mediaNodeUpdater.js +739 -0
  12. package/dist/cjs/nodeviews/mediaNodeView/index.js +177 -0
  13. package/dist/cjs/nodeviews/mediaNodeView/media.js +242 -0
  14. package/dist/cjs/nodeviews/mediaSingle.js +629 -0
  15. package/dist/cjs/nodeviews/messages.js +14 -0
  16. package/dist/cjs/nodeviews/styles.js +46 -0
  17. package/dist/cjs/nodeviews/types.js +5 -0
  18. package/dist/cjs/picker-facade.js +192 -0
  19. package/dist/cjs/plugin.js +293 -0
  20. package/dist/cjs/pm-plugins/alt-text/actions.js +5 -0
  21. package/dist/cjs/pm-plugins/alt-text/commands.js +59 -0
  22. package/dist/cjs/pm-plugins/alt-text/index.js +36 -0
  23. package/dist/cjs/pm-plugins/alt-text/keymap.js +15 -0
  24. package/dist/cjs/pm-plugins/alt-text/messages.js +44 -0
  25. package/dist/cjs/pm-plugins/alt-text/reducer.js +32 -0
  26. package/dist/cjs/pm-plugins/alt-text/types.js +5 -0
  27. package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +209 -0
  28. package/dist/cjs/pm-plugins/keymap-media-single.js +163 -0
  29. package/dist/cjs/pm-plugins/keymap.js +88 -0
  30. package/dist/cjs/pm-plugins/linking/actions.js +13 -0
  31. package/dist/cjs/pm-plugins/linking/index.js +65 -0
  32. package/dist/cjs/pm-plugins/linking/keymap.js +14 -0
  33. package/dist/cjs/pm-plugins/linking/reducer.js +43 -0
  34. package/dist/cjs/pm-plugins/linking/types.js +5 -0
  35. package/dist/cjs/pm-plugins/main.js +813 -0
  36. package/dist/cjs/pm-plugins/media-editor-plugin-factory.js +8 -0
  37. package/dist/cjs/pm-plugins/mediaTaskManager.js +101 -0
  38. package/dist/cjs/pm-plugins/plugin-key.js +8 -0
  39. package/dist/cjs/pm-plugins/types.js +5 -0
  40. package/dist/cjs/toolbar/alt-text.js +80 -0
  41. package/dist/cjs/toolbar/commands.js +236 -0
  42. package/dist/cjs/toolbar/filePreviewItem.js +66 -0
  43. package/dist/cjs/toolbar/imageBorder.js +20 -0
  44. package/dist/cjs/toolbar/index.js +523 -0
  45. package/dist/cjs/toolbar/linking-toolbar-appearance.js +100 -0
  46. package/dist/cjs/toolbar/linking.js +96 -0
  47. package/dist/cjs/toolbar/utils.js +110 -0
  48. package/dist/cjs/ui/CaptionPlaceholder/index.js +27 -0
  49. package/dist/cjs/ui/CaptionPlaceholder/messages.js +14 -0
  50. package/dist/cjs/ui/ImageBorder/index.js +226 -0
  51. package/dist/cjs/ui/ImageBorder/messages.js +49 -0
  52. package/dist/cjs/ui/ImageBorder/styles.js +52 -0
  53. package/dist/cjs/ui/Media/DropPlaceholder.js +38 -0
  54. package/dist/cjs/ui/Media/drop-placeholder-messages.js +14 -0
  55. package/dist/cjs/ui/MediaLinkingToolbar.js +196 -0
  56. package/dist/cjs/ui/MediaPicker/BrowserWrapper.js +40 -0
  57. package/dist/cjs/ui/MediaPicker/ClipboardWrapper.js +39 -0
  58. package/dist/cjs/ui/MediaPicker/DropzoneWrapper.js +51 -0
  59. package/dist/cjs/ui/MediaPicker/PickerFacadeProvider.js +151 -0
  60. package/dist/cjs/ui/MediaPicker/index.js +103 -0
  61. package/dist/cjs/ui/PixelEntry/constants.js +7 -0
  62. package/dist/cjs/ui/PixelEntry/index.js +185 -0
  63. package/dist/cjs/ui/PixelEntry/messages.js +54 -0
  64. package/dist/cjs/ui/PixelEntry/styles.js +19 -0
  65. package/dist/cjs/ui/PixelEntry/types.js +5 -0
  66. package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +16 -0
  67. package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +541 -0
  68. package/dist/cjs/ui/ResizableMediaSingle/index.js +422 -0
  69. package/dist/cjs/ui/ResizableMediaSingle/styled.js +14 -0
  70. package/dist/cjs/ui/ResizableMediaSingle/styles.js +17 -0
  71. package/dist/cjs/ui/ResizableMediaSingle/types.js +5 -0
  72. package/dist/cjs/ui/ToolbarMedia/index.js +42 -0
  73. package/dist/cjs/ui/ToolbarMedia/toolbar-media-messages.js +14 -0
  74. package/dist/cjs/ui/media-linking-toolbar-messages.js +14 -0
  75. package/dist/cjs/utils/analytics.js +53 -0
  76. package/dist/cjs/utils/check-media-type.js +56 -0
  77. package/dist/cjs/utils/current-media-node.js +41 -0
  78. package/dist/cjs/utils/is-image.js +9 -0
  79. package/dist/cjs/utils/media-common.js +181 -0
  80. package/dist/cjs/utils/media-files.js +297 -0
  81. package/dist/cjs/utils/media-single.js +181 -0
  82. package/dist/es2019/commands/captions.js +47 -0
  83. package/dist/es2019/commands/helpers.js +113 -0
  84. package/dist/es2019/commands/index.js +1 -0
  85. package/dist/es2019/commands/linking.js +169 -0
  86. package/dist/es2019/index.js +1 -1
  87. package/dist/es2019/media-plugin-options.js +1 -0
  88. package/dist/es2019/next-plugin-type.js +1 -0
  89. package/dist/es2019/nodeviews/mediaGroup.js +314 -0
  90. package/dist/es2019/nodeviews/mediaInline.js +201 -0
  91. package/dist/es2019/nodeviews/mediaNodeUpdater.js +384 -0
  92. package/dist/es2019/nodeviews/mediaNodeView/index.js +149 -0
  93. package/dist/es2019/nodeviews/mediaNodeView/media.js +182 -0
  94. package/dist/es2019/nodeviews/mediaSingle.js +511 -0
  95. package/dist/es2019/nodeviews/messages.js +8 -0
  96. package/dist/es2019/nodeviews/styles.js +46 -0
  97. package/dist/es2019/nodeviews/types.js +1 -0
  98. package/dist/es2019/picker-facade.js +146 -0
  99. package/dist/es2019/plugin.js +284 -0
  100. package/dist/es2019/pm-plugins/alt-text/actions.js +1 -0
  101. package/dist/es2019/pm-plugins/alt-text/commands.js +42 -0
  102. package/dist/es2019/pm-plugins/alt-text/index.js +33 -0
  103. package/dist/es2019/pm-plugins/alt-text/keymap.js +9 -0
  104. package/dist/es2019/pm-plugins/alt-text/messages.js +38 -0
  105. package/dist/es2019/pm-plugins/alt-text/reducer.js +26 -0
  106. package/dist/es2019/pm-plugins/alt-text/types.js +1 -0
  107. package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +228 -0
  108. package/dist/es2019/pm-plugins/keymap-media-single.js +172 -0
  109. package/dist/es2019/pm-plugins/keymap.js +84 -0
  110. package/dist/es2019/pm-plugins/linking/actions.js +7 -0
  111. package/dist/es2019/pm-plugins/linking/index.js +56 -0
  112. package/dist/es2019/pm-plugins/linking/keymap.js +8 -0
  113. package/dist/es2019/pm-plugins/linking/reducer.js +37 -0
  114. package/dist/es2019/pm-plugins/linking/types.js +1 -0
  115. package/dist/es2019/pm-plugins/main.js +695 -0
  116. package/dist/es2019/pm-plugins/media-editor-plugin-factory.js +2 -0
  117. package/dist/es2019/pm-plugins/mediaTaskManager.js +64 -0
  118. package/dist/es2019/pm-plugins/plugin-key.js +2 -0
  119. package/dist/es2019/pm-plugins/types.js +1 -0
  120. package/dist/es2019/toolbar/alt-text.js +72 -0
  121. package/dist/es2019/toolbar/commands.js +212 -0
  122. package/dist/es2019/toolbar/filePreviewItem.js +54 -0
  123. package/dist/es2019/toolbar/imageBorder.js +15 -0
  124. package/dist/es2019/toolbar/index.js +538 -0
  125. package/dist/es2019/toolbar/linking-toolbar-appearance.js +90 -0
  126. package/dist/es2019/toolbar/linking.js +98 -0
  127. package/dist/es2019/toolbar/utils.js +86 -0
  128. package/dist/es2019/ui/CaptionPlaceholder/index.js +25 -0
  129. package/dist/es2019/ui/CaptionPlaceholder/messages.js +8 -0
  130. package/dist/es2019/ui/ImageBorder/index.js +213 -0
  131. package/dist/es2019/ui/ImageBorder/messages.js +43 -0
  132. package/dist/es2019/ui/ImageBorder/styles.js +126 -0
  133. package/dist/es2019/ui/Media/DropPlaceholder.js +47 -0
  134. package/dist/es2019/ui/Media/drop-placeholder-messages.js +8 -0
  135. package/dist/es2019/ui/MediaLinkingToolbar.js +190 -0
  136. package/dist/es2019/ui/MediaPicker/BrowserWrapper.js +31 -0
  137. package/dist/es2019/ui/MediaPicker/ClipboardWrapper.js +32 -0
  138. package/dist/es2019/ui/MediaPicker/DropzoneWrapper.js +42 -0
  139. package/dist/es2019/ui/MediaPicker/PickerFacadeProvider.js +85 -0
  140. package/dist/es2019/ui/MediaPicker/index.js +82 -0
  141. package/dist/es2019/ui/PixelEntry/constants.js +1 -0
  142. package/dist/es2019/ui/PixelEntry/index.js +170 -0
  143. package/dist/es2019/ui/PixelEntry/messages.js +48 -0
  144. package/dist/es2019/ui/PixelEntry/styles.js +51 -0
  145. package/dist/es2019/ui/PixelEntry/types.js +1 -0
  146. package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +9 -0
  147. package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +454 -0
  148. package/dist/es2019/ui/ResizableMediaSingle/index.js +344 -0
  149. package/dist/es2019/ui/ResizableMediaSingle/styled.js +9 -0
  150. package/dist/es2019/ui/ResizableMediaSingle/styles.js +14 -0
  151. package/dist/es2019/ui/ResizableMediaSingle/types.js +1 -0
  152. package/dist/es2019/ui/ToolbarMedia/index.js +37 -0
  153. package/dist/es2019/ui/ToolbarMedia/toolbar-media-messages.js +8 -0
  154. package/dist/es2019/ui/media-linking-toolbar-messages.js +8 -0
  155. package/dist/es2019/utils/analytics.js +51 -0
  156. package/dist/es2019/utils/check-media-type.js +19 -0
  157. package/dist/es2019/utils/current-media-node.js +35 -0
  158. package/dist/es2019/utils/is-image.js +3 -0
  159. package/dist/es2019/utils/media-common.js +189 -0
  160. package/dist/es2019/utils/media-files.js +321 -0
  161. package/dist/es2019/utils/media-single.js +176 -0
  162. package/dist/esm/commands/captions.js +53 -0
  163. package/dist/esm/commands/helpers.js +120 -0
  164. package/dist/esm/commands/index.js +1 -0
  165. package/dist/esm/commands/linking.js +174 -0
  166. package/dist/esm/index.js +1 -1
  167. package/dist/esm/media-plugin-options.js +1 -0
  168. package/dist/esm/next-plugin-type.js +1 -0
  169. package/dist/esm/nodeviews/mediaGroup.js +369 -0
  170. package/dist/esm/nodeviews/mediaInline.js +278 -0
  171. package/dist/esm/nodeviews/mediaNodeUpdater.js +732 -0
  172. package/dist/esm/nodeviews/mediaNodeView/index.js +170 -0
  173. package/dist/esm/nodeviews/mediaNodeView/media.js +233 -0
  174. package/dist/esm/nodeviews/mediaSingle.js +622 -0
  175. package/dist/esm/nodeviews/messages.js +8 -0
  176. package/dist/esm/nodeviews/styles.js +39 -0
  177. package/dist/esm/nodeviews/types.js +1 -0
  178. package/dist/esm/picker-facade.js +186 -0
  179. package/dist/esm/plugin.js +282 -0
  180. package/dist/esm/pm-plugins/alt-text/actions.js +1 -0
  181. package/dist/esm/pm-plugins/alt-text/commands.js +52 -0
  182. package/dist/esm/pm-plugins/alt-text/index.js +31 -0
  183. package/dist/esm/pm-plugins/alt-text/keymap.js +9 -0
  184. package/dist/esm/pm-plugins/alt-text/messages.js +38 -0
  185. package/dist/esm/pm-plugins/alt-text/reducer.js +25 -0
  186. package/dist/esm/pm-plugins/alt-text/types.js +1 -0
  187. package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +206 -0
  188. package/dist/esm/pm-plugins/keymap-media-single.js +158 -0
  189. package/dist/esm/pm-plugins/keymap.js +81 -0
  190. package/dist/esm/pm-plugins/linking/actions.js +7 -0
  191. package/dist/esm/pm-plugins/linking/index.js +59 -0
  192. package/dist/esm/pm-plugins/linking/keymap.js +8 -0
  193. package/dist/esm/pm-plugins/linking/reducer.js +36 -0
  194. package/dist/esm/pm-plugins/linking/types.js +1 -0
  195. package/dist/esm/pm-plugins/main.js +798 -0
  196. package/dist/esm/pm-plugins/media-editor-plugin-factory.js +2 -0
  197. package/dist/esm/pm-plugins/mediaTaskManager.js +94 -0
  198. package/dist/esm/pm-plugins/plugin-key.js +2 -0
  199. package/dist/esm/pm-plugins/types.js +1 -0
  200. package/dist/esm/toolbar/alt-text.js +70 -0
  201. package/dist/esm/toolbar/commands.js +229 -0
  202. package/dist/esm/toolbar/filePreviewItem.js +56 -0
  203. package/dist/esm/toolbar/imageBorder.js +14 -0
  204. package/dist/esm/toolbar/index.js +513 -0
  205. package/dist/esm/toolbar/linking-toolbar-appearance.js +91 -0
  206. package/dist/esm/toolbar/linking.js +88 -0
  207. package/dist/esm/toolbar/utils.js +103 -0
  208. package/dist/esm/ui/CaptionPlaceholder/index.js +20 -0
  209. package/dist/esm/ui/CaptionPlaceholder/messages.js +8 -0
  210. package/dist/esm/ui/ImageBorder/index.js +218 -0
  211. package/dist/esm/ui/ImageBorder/messages.js +43 -0
  212. package/dist/esm/ui/ImageBorder/styles.js +42 -0
  213. package/dist/esm/ui/Media/DropPlaceholder.js +31 -0
  214. package/dist/esm/ui/Media/drop-placeholder-messages.js +8 -0
  215. package/dist/esm/ui/MediaLinkingToolbar.js +188 -0
  216. package/dist/esm/ui/MediaPicker/BrowserWrapper.js +33 -0
  217. package/dist/esm/ui/MediaPicker/ClipboardWrapper.js +32 -0
  218. package/dist/esm/ui/MediaPicker/DropzoneWrapper.js +44 -0
  219. package/dist/esm/ui/MediaPicker/PickerFacadeProvider.js +145 -0
  220. package/dist/esm/ui/MediaPicker/index.js +96 -0
  221. package/dist/esm/ui/PixelEntry/constants.js +1 -0
  222. package/dist/esm/ui/PixelEntry/index.js +174 -0
  223. package/dist/esm/ui/PixelEntry/messages.js +48 -0
  224. package/dist/esm/ui/PixelEntry/styles.js +12 -0
  225. package/dist/esm/ui/PixelEntry/types.js +1 -0
  226. package/dist/esm/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +9 -0
  227. package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +535 -0
  228. package/dist/esm/ui/ResizableMediaSingle/index.js +417 -0
  229. package/dist/esm/ui/ResizableMediaSingle/styled.js +7 -0
  230. package/dist/esm/ui/ResizableMediaSingle/styles.js +7 -0
  231. package/dist/esm/ui/ResizableMediaSingle/types.js +1 -0
  232. package/dist/esm/ui/ToolbarMedia/index.js +35 -0
  233. package/dist/esm/ui/ToolbarMedia/toolbar-media-messages.js +8 -0
  234. package/dist/esm/ui/media-linking-toolbar-messages.js +8 -0
  235. package/dist/esm/utils/analytics.js +47 -0
  236. package/dist/esm/utils/check-media-type.js +49 -0
  237. package/dist/esm/utils/current-media-node.js +35 -0
  238. package/dist/esm/utils/is-image.js +3 -0
  239. package/dist/esm/utils/media-common.js +175 -0
  240. package/dist/esm/utils/media-files.js +291 -0
  241. package/dist/esm/utils/media-single.js +172 -0
  242. package/dist/types/commands/captions.d.ts +5 -0
  243. package/dist/types/commands/helpers.d.ts +15 -0
  244. package/dist/types/commands/index.d.ts +1 -0
  245. package/dist/types/commands/linking.d.ts +9 -0
  246. package/dist/types/index.d.ts +2 -1
  247. package/dist/types/media-plugin-options.d.ts +17 -0
  248. package/dist/types/next-plugin-type.d.ts +33 -0
  249. package/dist/types/nodeviews/__mocks__/mediaNodeUpdater.d.ts +24 -0
  250. package/dist/types/nodeviews/mediaGroup.d.ts +33 -0
  251. package/dist/types/nodeviews/mediaInline.d.ts +50 -0
  252. package/dist/types/nodeviews/mediaNodeUpdater.d.ts +45 -0
  253. package/dist/types/nodeviews/mediaNodeView/index.d.ts +28 -0
  254. package/dist/types/nodeviews/mediaNodeView/media.d.ts +44 -0
  255. package/dist/types/nodeviews/mediaSingle.d.ts +62 -0
  256. package/dist/types/nodeviews/messages.d.ts +7 -0
  257. package/dist/types/nodeviews/styles.d.ts +16 -0
  258. package/dist/types/nodeviews/types.d.ts +42 -0
  259. package/dist/types/picker-facade.d.ts +44 -0
  260. package/dist/types/plugin.d.ts +7 -0
  261. package/dist/types/pm-plugins/alt-text/actions.d.ts +10 -0
  262. package/dist/types/pm-plugins/alt-text/commands.d.ts +4 -0
  263. package/dist/types/pm-plugins/alt-text/index.d.ts +7 -0
  264. package/dist/types/pm-plugins/alt-text/keymap.d.ts +4 -0
  265. package/dist/types/pm-plugins/alt-text/messages.d.ts +37 -0
  266. package/dist/types/pm-plugins/alt-text/reducer.d.ts +4 -0
  267. package/dist/types/pm-plugins/alt-text/types.d.ts +3 -0
  268. package/dist/types/pm-plugins/alt-text/ui/AltTextEdit.d.ts +41 -0
  269. package/dist/types/pm-plugins/keymap-media-single.d.ts +3 -0
  270. package/dist/types/pm-plugins/keymap.d.ts +6 -0
  271. package/dist/types/pm-plugins/linking/actions.d.ts +20 -0
  272. package/dist/types/pm-plugins/linking/index.d.ts +10 -0
  273. package/dist/types/pm-plugins/linking/keymap.d.ts +3 -0
  274. package/dist/types/pm-plugins/linking/reducer.d.ts +4 -0
  275. package/dist/types/pm-plugins/linking/types.d.ts +12 -0
  276. package/dist/types/pm-plugins/main.d.ts +120 -0
  277. package/dist/types/pm-plugins/media-editor-plugin-factory.d.ts +3 -0
  278. package/dist/types/pm-plugins/mediaTaskManager.d.ts +9 -0
  279. package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
  280. package/dist/types/pm-plugins/types.d.ts +65 -0
  281. package/dist/types/toolbar/alt-text.d.ts +13 -0
  282. package/dist/types/toolbar/commands.d.ts +12 -0
  283. package/dist/types/toolbar/filePreviewItem.d.ts +9 -0
  284. package/dist/types/toolbar/imageBorder.d.ts +2 -0
  285. package/dist/types/toolbar/index.d.ts +6 -0
  286. package/dist/types/toolbar/linking-toolbar-appearance.d.ts +14 -0
  287. package/dist/types/toolbar/linking.d.ts +10 -0
  288. package/dist/types/toolbar/utils.d.ts +11 -0
  289. package/dist/types/types.d.ts +2 -1
  290. package/dist/types/ui/CaptionPlaceholder/index.d.ts +6 -0
  291. package/dist/types/ui/CaptionPlaceholder/messages.d.ts +7 -0
  292. package/dist/types/ui/ImageBorder/index.d.ts +11 -0
  293. package/dist/types/ui/ImageBorder/messages.d.ts +42 -0
  294. package/dist/types/ui/ImageBorder/styles.d.ts +15 -0
  295. package/dist/types/ui/Media/DropPlaceholder.d.ts +8 -0
  296. package/dist/types/ui/Media/drop-placeholder-messages.d.ts +7 -0
  297. package/dist/types/ui/MediaLinkingToolbar.d.ts +35 -0
  298. package/dist/types/ui/MediaPicker/BrowserWrapper.d.ts +11 -0
  299. package/dist/types/ui/MediaPicker/ClipboardWrapper.d.ts +10 -0
  300. package/dist/types/ui/MediaPicker/DropzoneWrapper.d.ts +13 -0
  301. package/dist/types/ui/MediaPicker/PickerFacadeProvider.d.ts +28 -0
  302. package/dist/types/ui/MediaPicker/index.d.ts +23 -0
  303. package/dist/types/ui/PixelEntry/constants.d.ts +1 -0
  304. package/dist/types/ui/PixelEntry/index.d.ts +8 -0
  305. package/dist/types/ui/PixelEntry/messages.d.ts +47 -0
  306. package/dist/types/ui/PixelEntry/styles.d.ts +8 -0
  307. package/dist/types/ui/PixelEntry/types.d.ts +58 -0
  308. package/dist/types/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.d.ts +3 -0
  309. package/dist/types/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +59 -0
  310. package/dist/types/ui/ResizableMediaSingle/index.d.ts +45 -0
  311. package/dist/types/ui/ResizableMediaSingle/styled.d.ts +2 -0
  312. package/dist/types/ui/ResizableMediaSingle/styles.d.ts +1 -0
  313. package/dist/types/ui/ResizableMediaSingle/types.d.ts +27 -0
  314. package/dist/types/ui/ToolbarMedia/index.d.ts +13 -0
  315. package/dist/types/ui/ToolbarMedia/toolbar-media-messages.d.ts +7 -0
  316. package/dist/types/ui/media-linking-toolbar-messages.d.ts +7 -0
  317. package/dist/types/utils/analytics.d.ts +3 -0
  318. package/dist/types/utils/check-media-type.d.ts +4 -0
  319. package/dist/types/utils/current-media-node.d.ts +9 -0
  320. package/dist/types/utils/is-image.d.ts +1 -0
  321. package/dist/types/utils/media-common.d.ts +20 -0
  322. package/dist/types/utils/media-files.d.ts +30 -0
  323. package/dist/types/utils/media-single.d.ts +20 -0
  324. package/package.json +32 -20
  325. package/report.api.md +430 -0
  326. package/dist/types-ts4.5/index.d.ts +0 -1
  327. package/dist/types-ts4.5/types.d.ts +0 -118
  328. package/tmp/api-report-tmp.d.ts +0 -9
@@ -0,0 +1,523 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.floatingToolbar = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _analytics = require("@atlaskit/editor-common/analytics");
13
+ var _card = require("@atlaskit/editor-common/card");
14
+ var _mediaSingle = require("@atlaskit/editor-common/media-single");
15
+ var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
16
+ var _state2 = require("@atlaskit/editor-prosemirror/state");
17
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
18
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
19
+ var _download = _interopRequireDefault(require("@atlaskit/icon/glyph/download"));
20
+ var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
21
+ var _mediaFilmstrip = require("@atlaskit/media-filmstrip");
22
+ var _mediaUi = require("@atlaskit/media-ui");
23
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
+ var _linking = require("../commands/linking");
25
+ var _styles = require("../nodeviews/styles");
26
+ var _altText = require("../pm-plugins/alt-text");
27
+ var _linking2 = require("../pm-plugins/linking");
28
+ var _pluginKey = require("../pm-plugins/plugin-key");
29
+ var _ImageBorder = _interopRequireDefault(require("../ui/ImageBorder"));
30
+ var _PixelEntry = require("../ui/PixelEntry");
31
+ var _currentMediaNode = require("../utils/current-media-node");
32
+ var _mediaSingle2 = require("../utils/media-single");
33
+ var _altText2 = require("./alt-text");
34
+ var _commands = require("./commands");
35
+ var _filePreviewItem = require("./filePreviewItem");
36
+ var _imageBorder = require("./imageBorder");
37
+ var _linking3 = require("./linking");
38
+ var _linkingToolbarAppearance = require("./linking-toolbar-appearance");
39
+ var _utils2 = require("./utils");
40
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
42
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
43
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
44
+ var remove = function remove(state, dispatch) {
45
+ if (dispatch) {
46
+ dispatch((0, _utils.removeSelectedNode)(state.tr));
47
+ }
48
+ return true;
49
+ };
50
+ var handleRemoveMediaGroup = function handleRemoveMediaGroup(state, dispatch) {
51
+ var tr = (0, _utils2.removeMediaGroupNode)(state);
52
+ if (dispatch) {
53
+ dispatch(tr);
54
+ }
55
+ return true;
56
+ };
57
+ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
58
+ var mediaGroup = state.schema.nodes.mediaGroup;
59
+ var items = [{
60
+ id: 'editor.media.view.switcher',
61
+ type: 'dropdown',
62
+ title: intl.formatMessage(_mediaUi.messages.changeView),
63
+ options: [{
64
+ id: 'editor.media.view.switcher.inline',
65
+ title: intl.formatMessage(_messages.cardMessages.inline),
66
+ selected: false,
67
+ disabled: false,
68
+ onClick: (0, _commands.changeMediaCardToInline)(editorAnalyticsAPI),
69
+ testId: 'inline-appearance'
70
+ }, {
71
+ id: 'editor.media.view.switcher.thumbnail',
72
+ title: intl.formatMessage(_mediaUi.messages.displayThumbnail),
73
+ selected: true,
74
+ disabled: false,
75
+ onClick: function onClick() {
76
+ return true;
77
+ },
78
+ testId: 'thumbnail-appearance'
79
+ }]
80
+ }, {
81
+ type: 'separator'
82
+ }, {
83
+ type: 'custom',
84
+ fallback: [],
85
+ render: function render() {
86
+ return /*#__PURE__*/_react.default.createElement(_filePreviewItem.FilePreviewItem, {
87
+ key: "editor.media.card.preview",
88
+ mediaPluginState: mediaPluginState,
89
+ intl: intl
90
+ });
91
+ }
92
+ }, {
93
+ type: 'separator'
94
+ }, {
95
+ id: 'editor.media.card.download',
96
+ type: 'button',
97
+ icon: _download.default,
98
+ onClick: function onClick() {
99
+ (0, _utils2.downloadMedia)(mediaPluginState);
100
+ return true;
101
+ },
102
+ title: intl.formatMessage(_mediaUi.messages.download)
103
+ }, {
104
+ type: 'separator'
105
+ }, {
106
+ type: 'copy-button',
107
+ items: [{
108
+ state: state,
109
+ formatMessage: intl.formatMessage,
110
+ nodeType: mediaGroup
111
+ }, {
112
+ type: 'separator'
113
+ }]
114
+ }, {
115
+ id: 'editor.media.delete',
116
+ type: 'button',
117
+ appearance: 'danger',
118
+ focusEditoronEnter: true,
119
+ icon: _remove.default,
120
+ onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, true),
121
+ onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, false),
122
+ onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, true),
123
+ onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, false),
124
+ title: intl.formatMessage(_messages.default.remove),
125
+ onClick: handleRemoveMediaGroup,
126
+ testId: 'media-toolbar-remove-button'
127
+ }];
128
+ return items;
129
+ };
130
+ var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
131
+ var mediaInline = state.schema.nodes.mediaInline;
132
+ var items = [{
133
+ id: 'editor.media.view.switcher',
134
+ type: 'dropdown',
135
+ title: intl.formatMessage(_mediaUi.messages.changeView),
136
+ options: [{
137
+ id: 'editor.media.view.switcher.inline',
138
+ title: intl.formatMessage(_messages.cardMessages.inline),
139
+ selected: true,
140
+ disabled: false,
141
+ onClick: function onClick() {
142
+ return true;
143
+ },
144
+ testId: 'inline-appearance'
145
+ }, {
146
+ id: 'editor.media.view.switcher.thumbnail',
147
+ title: intl.formatMessage(_mediaUi.messages.displayThumbnail),
148
+ selected: false,
149
+ disabled: false,
150
+ onClick: (0, _commands.changeInlineToMediaCard)(editorAnalyticsAPI),
151
+ testId: 'thumbnail-appearance'
152
+ }]
153
+ }, {
154
+ type: 'separator'
155
+ }, {
156
+ type: 'custom',
157
+ fallback: [],
158
+ render: function render() {
159
+ return /*#__PURE__*/_react.default.createElement(_filePreviewItem.FilePreviewItem, {
160
+ key: "editor.media.card.preview",
161
+ mediaPluginState: mediaPluginState,
162
+ intl: intl
163
+ });
164
+ }
165
+ }, {
166
+ type: 'separator'
167
+ }, {
168
+ id: 'editor.media.card.download',
169
+ type: 'button',
170
+ icon: _download.default,
171
+ onClick: function onClick() {
172
+ (0, _utils2.downloadMedia)(mediaPluginState);
173
+ return true;
174
+ },
175
+ title: intl.formatMessage(_mediaUi.messages.download)
176
+ }, {
177
+ type: 'separator'
178
+ }, {
179
+ type: 'copy-button',
180
+ items: [{
181
+ state: state,
182
+ formatMessage: intl.formatMessage,
183
+ nodeType: mediaInline
184
+ }, {
185
+ type: 'separator'
186
+ }]
187
+ }, {
188
+ id: 'editor.media.delete',
189
+ type: 'button',
190
+ appearance: 'danger',
191
+ focusEditoronEnter: true,
192
+ icon: _remove.default,
193
+ onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
194
+ onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
195
+ onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
196
+ onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
197
+ title: intl.formatMessage(_messages.default.remove),
198
+ onClick: _commands.removeInlineCard,
199
+ testId: 'media-toolbar-remove-button'
200
+ }];
201
+ return items;
202
+ };
203
+ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
204
+ var _pluginInjectionApi$d;
205
+ var mediaSingle = state.schema.nodes.mediaSingle;
206
+ var allowResizing = options.allowResizing,
207
+ allowLinking = options.allowLinking,
208
+ allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
209
+ allowResizingInTables = options.allowResizingInTables,
210
+ allowAltTextOnImages = options.allowAltTextOnImages;
211
+ var toolbarButtons = [];
212
+ var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
213
+ hoverDecoration = _ref.hoverDecoration;
214
+ if ((0, _imageBorder.shouldShowImageBorder)(state)) {
215
+ toolbarButtons.push({
216
+ type: 'custom',
217
+ fallback: [],
218
+ render: function render(editorView) {
219
+ if (!editorView) {
220
+ return null;
221
+ }
222
+ var dispatch = editorView.dispatch,
223
+ state = editorView.state;
224
+ var borderMark = (0, _currentMediaNode.currentMediaNodeBorderMark)(state);
225
+ return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
226
+ toggleBorder: function toggleBorder() {
227
+ var _pluginInjectionApi$a;
228
+ (0, _commands.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(state, dispatch);
229
+ },
230
+ setBorder: function setBorder(attrs) {
231
+ var _pluginInjectionApi$a2;
232
+ (0, _commands.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(attrs)(state, dispatch);
233
+ },
234
+ borderMark: borderMark,
235
+ intl: intl
236
+ });
237
+ }
238
+ });
239
+ toolbarButtons.push({
240
+ type: 'separator'
241
+ });
242
+ }
243
+ if (allowAdvancedToolBarOptions) {
244
+ var _pluginInjectionApi$a3;
245
+ var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width;
246
+ var isChangingLayoutDisabled = false;
247
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience')) {
248
+ var _widthPlugin$sharedSt;
249
+ var contentWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
250
+ var selectedNode = (0, _utils2.getSelectedMediaSingle)(state);
251
+ var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
252
+ if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
253
+ isChangingLayoutDisabled = true;
254
+ }
255
+ }
256
+ var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
257
+ toolbarButtons = [].concat((0, _toConsumableArray2.default)(toolbarButtons), (0, _toConsumableArray2.default)(layoutButtons));
258
+ if (layoutButtons.length) {
259
+ toolbarButtons.push({
260
+ type: 'separator'
261
+ });
262
+ }
263
+
264
+ // Pixel Entry Toolbar Support
265
+ var selection = state.selection;
266
+ var isWithinTable = (0, _utils.hasParentNodeOfType)([state.schema.nodes.table])(selection);
267
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') && allowResizing && (!isWithinTable || allowResizingInTables === true)) {
268
+ var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
269
+ var sizeInput = {
270
+ type: 'custom',
271
+ fallback: [],
272
+ render: function render(editorView) {
273
+ var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
274
+ if (!editorView || !selectedMediaSingleNode) {
275
+ return null;
276
+ }
277
+ var state = editorView.state,
278
+ dispatch = editorView.dispatch;
279
+ var contentWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || _editorSharedStyles.akEditorDefaultLayoutWidth;
280
+ var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
281
+ if (!selectedMediaNode) {
282
+ return null;
283
+ }
284
+ var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
285
+ mediaSingleWidth = _selectedMediaSingleN.width,
286
+ widthType = _selectedMediaSingleN.widthType,
287
+ layout = _selectedMediaSingleN.layout;
288
+ var _selectedMediaNode$at = selectedMediaNode.attrs,
289
+ mediaWidth = _selectedMediaNode$at.width,
290
+ mediaHeight = _selectedMediaNode$at.height;
291
+ var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
292
+ var maxWidth = maxWidthForNestedNode || _editorSharedStyles.akEditorFullWidthLayoutWidth;
293
+ var isVideoFile = (0, _mediaSingle2.isVideo)(selectedMediaNode.attrs.__fileMimeType);
294
+ var minWidth = (0, _mediaSingle.calcMinWidth)(isVideoFile, maxWidthForNestedNode || contentWidth);
295
+ var isLegacy = widthType !== 'pixel';
296
+ var pixelWidthFromElement = (0, _utils2.getPixelWidthOfElement)(editorView, selectedMediaSingleNode.pos + 1,
297
+ // get pos of media node
298
+ mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH);
299
+ var pixelWidth = isLegacy ? pixelWidthFromElement : mediaSingleWidth;
300
+ return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
301
+ intl: intl,
302
+ width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
303
+ showMigration: !pluginState.isResizing && isLegacy,
304
+ mediaWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
305
+ mediaHeight: mediaHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
306
+ minWidth: minWidth,
307
+ maxWidth: maxWidth,
308
+ onChange: function onChange(valid) {
309
+ if (valid) {
310
+ hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
311
+ } else {
312
+ hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
313
+ }
314
+ },
315
+ onSubmit: function onSubmit(_ref2) {
316
+ var _pluginInjectionApi$a4;
317
+ var width = _ref2.width,
318
+ validation = _ref2.validation;
319
+ var newLayout = (0, _utils2.calcNewLayout)(width, layout, contentWidth, options.fullWidthEnabled);
320
+ (0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
321
+ },
322
+ onMigrate: function onMigrate() {
323
+ var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
324
+ width: pixelWidthFromElement,
325
+ widthType: 'pixel'
326
+ }));
327
+ tr.setMeta('scrollIntoView', false);
328
+ tr.setSelection(_state2.NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
329
+ dispatch(tr);
330
+ }
331
+ });
332
+ }
333
+ };
334
+ if (pluginState.isResizing) {
335
+ // If the image is resizing
336
+ // then return pixel entry component or full width label as the only toolbar item
337
+ if (!selectedMediaSingleNode) {
338
+ return [];
339
+ }
340
+ var layout = selectedMediaSingleNode.node.attrs.layout;
341
+ if (layout === 'full-width') {
342
+ var fullWidthLabel = {
343
+ type: 'custom',
344
+ fallback: [],
345
+ render: function render() {
346
+ return /*#__PURE__*/_react.default.createElement(_PixelEntry.FullWidthDisplay, {
347
+ intl: intl
348
+ });
349
+ }
350
+ };
351
+ return [fullWidthLabel];
352
+ }
353
+ return [sizeInput];
354
+ }
355
+ toolbarButtons.push(sizeInput);
356
+ toolbarButtons.push({
357
+ type: 'separator'
358
+ });
359
+ }
360
+ if (allowLinking && (0, _linking3.shouldShowMediaLinkToolbar)(state)) {
361
+ toolbarButtons.push({
362
+ type: 'custom',
363
+ fallback: [],
364
+ render: function render(editorView, idx) {
365
+ if (editorView !== null && editorView !== void 0 && editorView.state) {
366
+ var editLink = function editLink() {
367
+ if (editorView) {
368
+ var _state = editorView.state,
369
+ dispatch = editorView.dispatch;
370
+ (0, _linking.showLinkingToolbar)(_state, dispatch);
371
+ }
372
+ };
373
+ var openLink = function openLink() {
374
+ if (editorView) {
375
+ var _pluginInjectionApi$a5;
376
+ var tr = editorView.state.tr,
377
+ dispatch = editorView.dispatch;
378
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
379
+ eventType: _analytics.EVENT_TYPE.TRACK,
380
+ action: _analytics.ACTION.VISITED,
381
+ actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
382
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.LINK
383
+ })(tr);
384
+ dispatch(tr);
385
+ return true;
386
+ }
387
+ };
388
+ return /*#__PURE__*/_react.default.createElement(_linkingToolbarAppearance.LinkToolbarAppearance, {
389
+ key: idx,
390
+ editorState: editorView.state,
391
+ intl: intl,
392
+ mediaLinkingState: mediaLinkingState,
393
+ onAddLink: editLink,
394
+ onEditLink: editLink,
395
+ onOpenLink: openLink
396
+ });
397
+ }
398
+ return null;
399
+ }
400
+ });
401
+ }
402
+ }
403
+ if (allowAltTextOnImages) {
404
+ var _pluginInjectionApi$a6;
405
+ toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions), {
406
+ type: 'separator'
407
+ });
408
+ }
409
+ var removeButton = {
410
+ id: 'editor.media.delete',
411
+ type: 'button',
412
+ appearance: 'danger',
413
+ focusEditoronEnter: true,
414
+ icon: _remove.default,
415
+ onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
416
+ onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
417
+ onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
418
+ onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
419
+ title: intl.formatMessage(_messages.default.remove),
420
+ onClick: remove,
421
+ testId: 'media-toolbar-remove-button'
422
+ };
423
+ var items = [].concat((0, _toConsumableArray2.default)(toolbarButtons), [{
424
+ type: 'copy-button',
425
+ items: [{
426
+ state: state,
427
+ formatMessage: intl.formatMessage,
428
+ nodeType: mediaSingle
429
+ }, {
430
+ type: 'separator'
431
+ }]
432
+ }, removeButton]);
433
+ return items;
434
+ };
435
+ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state, intl) {
436
+ var _pluginInjectionApi$d2;
437
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
438
+ var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
439
+ var _state$schema$nodes = state.schema.nodes,
440
+ media = _state$schema$nodes.media,
441
+ mediaInline = _state$schema$nodes.mediaInline,
442
+ mediaSingle = _state$schema$nodes.mediaSingle,
443
+ mediaGroup = _state$schema$nodes.mediaGroup;
444
+ var altTextValidator = options.altTextValidator,
445
+ allowLinking = options.allowLinking,
446
+ allowAltTextOnImages = options.allowAltTextOnImages,
447
+ providerFactory = options.providerFactory,
448
+ allowMediaInline = options.allowMediaInline,
449
+ allowResizing = options.allowResizing,
450
+ getEditorFeatureFlags = options.getEditorFeatureFlags;
451
+ var mediaPluginState = _pluginKey.stateKey.getState(state);
452
+ var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
453
+ var _ref3 = (_pluginInjectionApi$d2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d2 !== void 0 ? _pluginInjectionApi$d2 : {},
454
+ hoverDecoration = _ref3.hoverDecoration;
455
+ if (!mediaPluginState) {
456
+ return;
457
+ }
458
+ var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
459
+ var baseToolbar = {
460
+ title: 'Media floating controls',
461
+ nodeType: nodeType,
462
+ getDomRef: function getDomRef() {
463
+ return mediaPluginState.element;
464
+ }
465
+ };
466
+ if (allowLinking && mediaLinkingState && mediaLinkingState.visible && (0, _linking3.shouldShowMediaLinkToolbar)(state)) {
467
+ var linkingToolbar = (0, _linking3.getLinkingToolbar)(baseToolbar, mediaLinkingState, state, intl, pluginInjectionApi, providerFactory);
468
+ if (linkingToolbar) {
469
+ return linkingToolbar;
470
+ }
471
+ }
472
+ if (allowAltTextOnImages) {
473
+ var mediaAltTextPluginState = (0, _altText.getPluginState)(state);
474
+ if (mediaAltTextPluginState.isAltTextEditorOpen) {
475
+ var _pluginInjectionApi$f;
476
+ return (0, _altText2.getAltTextToolbar)(baseToolbar, {
477
+ altTextValidator: altTextValidator,
478
+ forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
479
+ });
480
+ }
481
+ }
482
+ var items = [];
483
+ var parentMediaGroupNode = (0, _utils.findParentNodeOfType)(mediaGroup)(state.selection);
484
+ var selectedNodeType;
485
+ if (state.selection instanceof _state2.NodeSelection) {
486
+ selectedNodeType = state.selection.node.type;
487
+ }
488
+ if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
489
+ var _pluginInjectionApi$a7;
490
+ var mediaOffset = state.selection.$from.parentOffset + 1;
491
+ baseToolbar.getDomRef = function () {
492
+ var _mediaPluginState$ele;
493
+ var selector = (0, _mediaFilmstrip.mediaFilmstripItemDOMSelector)(mediaOffset);
494
+ return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
495
+ };
496
+ items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions);
497
+ } else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
498
+ var _pluginInjectionApi$a8;
499
+ baseToolbar.getDomRef = function () {
500
+ var _mediaPluginState$ele2;
501
+ var element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(".".concat(_styles.MediaInlineNodeSelector));
502
+ return element || mediaPluginState.element;
503
+ };
504
+ items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions);
505
+ } else {
506
+ baseToolbar.getDomRef = function () {
507
+ var _mediaPluginState$ele3;
508
+ var element = (_mediaPluginState$ele3 = mediaPluginState.element) === null || _mediaPluginState$ele3 === void 0 ? void 0 : _mediaPluginState$ele3.querySelector(".".concat(_styles.MediaSingleNodeSelector));
509
+ return element || mediaPluginState.element;
510
+ };
511
+ items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags);
512
+ }
513
+ var toolbarConfig = _objectSpread(_objectSpread({}, baseToolbar), {}, {
514
+ items: items,
515
+ scrollable: true
516
+ });
517
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') && allowResizing) {
518
+ return _objectSpread(_objectSpread({}, toolbarConfig), {}, {
519
+ width: mediaPluginState.isResizing ? undefined : (0, _utils2.getMaxToolbarWidth)()
520
+ });
521
+ }
522
+ return toolbarConfig;
523
+ };
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.LinkToolbarAppearance = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _react2 = require("@emotion/react");
13
+ var _adfSchema = require("@atlaskit/adf-schema");
14
+ var _keymaps = require("@atlaskit/editor-common/keymaps");
15
+ var _messages = require("@atlaskit/editor-common/messages");
16
+ var _ui = require("@atlaskit/editor-common/ui");
17
+ var _link = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/link"));
18
+ var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
19
+ var _pluginKey = require("../pm-plugins/plugin-key");
20
+ var _checkMediaType = require("../utils/check-media-type");
21
+ var _currentMediaNode = require("../utils/current-media-node");
22
+ var _templateObject;
23
+ /** @jsx jsx */
24
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
+ // need this wrapper, need to have 4px between items.
27
+ var wrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n margin-right: ", ";\n"])), "var(--ds-space-050, 4px)");
28
+ var LinkToolbarAppearance = exports.LinkToolbarAppearance = function LinkToolbarAppearance(_ref) {
29
+ var editorState = _ref.editorState,
30
+ mediaLinkingState = _ref.mediaLinkingState,
31
+ intl = _ref.intl,
32
+ onAddLink = _ref.onAddLink,
33
+ onEditLink = _ref.onEditLink,
34
+ onOpenLink = _ref.onOpenLink;
35
+ var _useState = (0, _react.useState)(true),
36
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
37
+ showLinkingControls = _useState2[0],
38
+ setShowLinkingControls = _useState2[1];
39
+ (0, _react.useEffect)(function () {
40
+ var _stateKey$getState;
41
+ var mediaNode = (0, _currentMediaNode.currentMediaNode)(editorState);
42
+ if (!mediaNode) {
43
+ setShowLinkingControls(false);
44
+ return;
45
+ }
46
+ var mediaClientConfig = (_stateKey$getState = _pluginKey.stateKey.getState(editorState)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.mediaClientConfig;
47
+ if (!mediaClientConfig) {
48
+ setShowLinkingControls(false);
49
+ return;
50
+ }
51
+ (0, _checkMediaType.checkMediaType)(mediaNode, mediaClientConfig).then(function (mediaType) {
52
+ setShowLinkingControls(mediaType === 'external' || mediaType === 'image');
53
+ });
54
+ }, [editorState]);
55
+ if (!showLinkingControls) {
56
+ return null;
57
+ }
58
+ if (mediaLinkingState && mediaLinkingState.editable) {
59
+ var isValidUrl = (0, _adfSchema.isSafeUrl)(mediaLinkingState.link);
60
+ var title = intl.formatMessage(_messages.linkToolbarMessages.editLink);
61
+ var linkTitle = intl.formatMessage(isValidUrl ? _messages.linkMessages.openLink : _messages.linkToolbarMessages.unableToOpenLink);
62
+ return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("div", {
63
+ css: wrapper
64
+ }, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
65
+ onClick: onEditLink,
66
+ title: title,
67
+ tooltipContent: (0, _react2.jsx)(_keymaps.ToolTipContent, {
68
+ description: title,
69
+ keymap: _keymaps.addLink
70
+ }),
71
+ testId: "edit-link-button"
72
+ }, title)), (0, _react2.jsx)("div", {
73
+ css: wrapper
74
+ }, (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null)), (0, _react2.jsx)(_ui.FloatingToolbarButton, {
75
+ target: "_blank",
76
+ href: isValidUrl ? mediaLinkingState.link : undefined,
77
+ disabled: !isValidUrl,
78
+ onClick: onOpenLink,
79
+ title: linkTitle,
80
+ icon: (0, _react2.jsx)(_shortcut.default, {
81
+ label: linkTitle
82
+ }),
83
+ className: "hyperlink-open-link"
84
+ }), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
85
+ } else {
86
+ var _title = intl.formatMessage(_messages.linkToolbarMessages.addLink);
87
+ return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
88
+ testId: "add-link-button",
89
+ onClick: onAddLink,
90
+ title: _title,
91
+ tooltipContent: (0, _react2.jsx)(_keymaps.ToolTipContent, {
92
+ description: _title,
93
+ keymap: _keymaps.addLink
94
+ }),
95
+ icon: (0, _react2.jsx)(_link.default, {
96
+ label: _title
97
+ })
98
+ }), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
99
+ }
100
+ };