@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,739 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MediaNodeUpdater = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _v = _interopRequireDefault(require("uuid/v4"));
14
+ var _analytics = require("@atlaskit/editor-common/analytics");
15
+ var _mediaSingle = require("@atlaskit/editor-common/media-single");
16
+ var _mediaClient = require("@atlaskit/media-client");
17
+ var _helpers = require("../commands/helpers");
18
+ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
19
+ function MediaNodeUpdater(props) {
20
+ var _this = this;
21
+ (0, _classCallCheck2.default)(this, MediaNodeUpdater);
22
+ // Updates the node with contextId if it doesn't have one already
23
+ // TODO [MS-2258]: remove updateContextId in order to only use updateMediaSingleFileAttrs
24
+ (0, _defineProperty2.default)(this, "updateContextId", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
25
+ var attrs, id, objectId;
26
+ return _regenerator.default.wrap(function _callee$(_context) {
27
+ while (1) switch (_context.prev = _context.next) {
28
+ case 0:
29
+ attrs = _this.getAttrs();
30
+ if (!(!attrs || attrs.type !== 'file')) {
31
+ _context.next = 3;
32
+ break;
33
+ }
34
+ return _context.abrupt("return");
35
+ case 3:
36
+ id = attrs.id;
37
+ _context.next = 6;
38
+ return _this.getObjectId();
39
+ case 6:
40
+ objectId = _context.sent;
41
+ (0, _helpers.updateAllMediaSingleNodesAttrs)(id, {
42
+ __contextId: objectId
43
+ })(_this.props.view.state, _this.props.view.dispatch);
44
+ case 8:
45
+ case "end":
46
+ return _context.stop();
47
+ }
48
+ }, _callee);
49
+ })));
50
+ (0, _defineProperty2.default)(this, "updateNodeContextId", /*#__PURE__*/function () {
51
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(getPos) {
52
+ var attrs, objectId;
53
+ return _regenerator.default.wrap(function _callee2$(_context2) {
54
+ while (1) switch (_context2.prev = _context2.next) {
55
+ case 0:
56
+ attrs = _this.getAttrs();
57
+ if (!((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file')) {
58
+ _context2.next = 3;
59
+ break;
60
+ }
61
+ return _context2.abrupt("return");
62
+ case 3:
63
+ _context2.next = 5;
64
+ return _this.getObjectId();
65
+ case 5:
66
+ objectId = _context2.sent;
67
+ (0, _helpers.updateCurrentMediaNodeAttrs)({
68
+ __contextId: objectId
69
+ }, {
70
+ node: _this.props.node,
71
+ getPos: getPos
72
+ })(_this.props.view.state, _this.props.view.dispatch);
73
+ case 7:
74
+ case "end":
75
+ return _context2.stop();
76
+ }
77
+ }, _callee2);
78
+ }));
79
+ return function (_x) {
80
+ return _ref2.apply(this, arguments);
81
+ };
82
+ }());
83
+ (0, _defineProperty2.default)(this, "hasFileAttributesDefined", function (attrs) {
84
+ return attrs && attrs.type === 'file' && attrs.__fileName && attrs.__fileMimeType && attrs.__fileSize && attrs.__contextId;
85
+ });
86
+ (0, _defineProperty2.default)(this, "getNewFileAttrsForNode", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
87
+ var attrs, mediaProvider, mediaClientConfig, mediaClient, fileState, id, collectionName, contextId, _fileState, name, mimeType, size, newAttrs;
88
+ return _regenerator.default.wrap(function _callee3$(_context3) {
89
+ while (1) switch (_context3.prev = _context3.next) {
90
+ case 0:
91
+ attrs = _this.getAttrs();
92
+ _context3.next = 3;
93
+ return _this.props.mediaProvider;
94
+ case 3:
95
+ mediaProvider = _context3.sent;
96
+ if (!(!mediaProvider || !mediaProvider.uploadParams || !attrs || attrs.type !== 'file' || _this.hasFileAttributesDefined(attrs))) {
97
+ _context3.next = 6;
98
+ break;
99
+ }
100
+ return _context3.abrupt("return");
101
+ case 6:
102
+ mediaClientConfig = mediaProvider.viewMediaClientConfig;
103
+ mediaClient = (0, _mediaClient.getMediaClient)(mediaClientConfig);
104
+ id = attrs.id, collectionName = attrs.collection;
105
+ _context3.prev = 9;
106
+ _context3.next = 12;
107
+ return mediaClient.file.getCurrentState(id, {
108
+ collectionName: collectionName
109
+ });
110
+ case 12:
111
+ fileState = _context3.sent;
112
+ if (!(fileState.status === 'error')) {
113
+ _context3.next = 15;
114
+ break;
115
+ }
116
+ return _context3.abrupt("return");
117
+ case 15:
118
+ _context3.next = 20;
119
+ break;
120
+ case 17:
121
+ _context3.prev = 17;
122
+ _context3.t0 = _context3["catch"](9);
123
+ return _context3.abrupt("return");
124
+ case 20:
125
+ _context3.t1 = _this.getNodeContextId();
126
+ if (_context3.t1) {
127
+ _context3.next = 25;
128
+ break;
129
+ }
130
+ _context3.next = 24;
131
+ return _this.getObjectId();
132
+ case 24:
133
+ _context3.t1 = _context3.sent;
134
+ case 25:
135
+ contextId = _context3.t1;
136
+ _fileState = fileState, name = _fileState.name, mimeType = _fileState.mimeType, size = _fileState.size;
137
+ newAttrs = {
138
+ __fileName: name,
139
+ __fileMimeType: mimeType,
140
+ __fileSize: size,
141
+ __contextId: contextId
142
+ };
143
+ if (hasPrivateAttrsChanged(attrs, newAttrs)) {
144
+ _context3.next = 30;
145
+ break;
146
+ }
147
+ return _context3.abrupt("return");
148
+ case 30:
149
+ return _context3.abrupt("return", newAttrs);
150
+ case 31:
151
+ case "end":
152
+ return _context3.stop();
153
+ }
154
+ }, _callee3, null, [[9, 17]]);
155
+ })));
156
+ (0, _defineProperty2.default)(this, "updateMediaSingleFileAttrs", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
157
+ var newAttrs, _ref5, id;
158
+ return _regenerator.default.wrap(function _callee4$(_context4) {
159
+ while (1) switch (_context4.prev = _context4.next) {
160
+ case 0:
161
+ _context4.next = 2;
162
+ return _this.getNewFileAttrsForNode();
163
+ case 2:
164
+ newAttrs = _context4.sent;
165
+ _ref5 = _this.getAttrs(), id = _ref5.id;
166
+ if (id && newAttrs) {
167
+ (0, _helpers.updateAllMediaSingleNodesAttrs)(id, newAttrs)(_this.props.view.state, _this.props.view.dispatch);
168
+ }
169
+ case 5:
170
+ case "end":
171
+ return _context4.stop();
172
+ }
173
+ }, _callee4);
174
+ })));
175
+ (0, _defineProperty2.default)(this, "updateNodeAttrs", /*#__PURE__*/function () {
176
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(getPos) {
177
+ var newAttrs;
178
+ return _regenerator.default.wrap(function _callee5$(_context5) {
179
+ while (1) switch (_context5.prev = _context5.next) {
180
+ case 0:
181
+ _context5.next = 2;
182
+ return _this.getNewFileAttrsForNode();
183
+ case 2:
184
+ newAttrs = _context5.sent;
185
+ if (newAttrs) {
186
+ (0, _helpers.updateCurrentMediaNodeAttrs)(newAttrs, {
187
+ node: _this.props.node,
188
+ getPos: getPos
189
+ })(_this.props.view.state, _this.props.view.dispatch);
190
+ }
191
+ case 4:
192
+ case "end":
193
+ return _context5.stop();
194
+ }
195
+ }, _callee5);
196
+ }));
197
+ return function (_x2) {
198
+ return _ref6.apply(this, arguments);
199
+ };
200
+ }());
201
+ (0, _defineProperty2.default)(this, "getAttrs", function () {
202
+ var attrs = _this.props.node.attrs;
203
+ if (attrs) {
204
+ return attrs;
205
+ }
206
+ return undefined;
207
+ });
208
+ (0, _defineProperty2.default)(this, "getObjectId", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
209
+ var contextIdentifierProvider;
210
+ return _regenerator.default.wrap(function _callee6$(_context6) {
211
+ while (1) switch (_context6.prev = _context6.next) {
212
+ case 0:
213
+ _context6.next = 2;
214
+ return _this.props.contextIdentifierProvider;
215
+ case 2:
216
+ contextIdentifierProvider = _context6.sent;
217
+ return _context6.abrupt("return", (contextIdentifierProvider === null || contextIdentifierProvider === void 0 ? void 0 : contextIdentifierProvider.objectId) || null);
218
+ case 4:
219
+ case "end":
220
+ return _context6.stop();
221
+ }
222
+ }, _callee6);
223
+ })));
224
+ (0, _defineProperty2.default)(this, "uploadExternalMedia", /*#__PURE__*/function () {
225
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(getPos) {
226
+ var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
227
+ return _regenerator.default.wrap(function _callee7$(_context7) {
228
+ while (1) switch (_context7.prev = _context7.next) {
229
+ case 0:
230
+ node = _this.props.node;
231
+ _context7.next = 3;
232
+ return _this.props.mediaProvider;
233
+ case 3:
234
+ mediaProvider = _context7.sent;
235
+ if (!(node && mediaProvider)) {
236
+ _context7.next = 24;
237
+ break;
238
+ }
239
+ uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
240
+ if (!(!uploadMediaClientConfig || !node.attrs.url)) {
241
+ _context7.next = 8;
242
+ break;
243
+ }
244
+ return _context7.abrupt("return");
245
+ case 8:
246
+ mediaClient = (0, _mediaClient.getMediaClient)(uploadMediaClientConfig);
247
+ collection = mediaProvider.uploadParams && mediaProvider.uploadParams.collection;
248
+ _context7.prev = 10;
249
+ _context7.next = 13;
250
+ return mediaClient.file.uploadExternal(node.attrs.url, collection);
251
+ case 13:
252
+ uploader = _context7.sent;
253
+ uploadableFileUpfrontIds = uploader.uploadableFileUpfrontIds, dimensions = uploader.dimensions;
254
+ pos = getPos();
255
+ if (!(typeof pos !== 'number')) {
256
+ _context7.next = 18;
257
+ break;
258
+ }
259
+ return _context7.abrupt("return");
260
+ case 18:
261
+ (0, _helpers.replaceExternalMedia)(pos + 1, {
262
+ id: uploadableFileUpfrontIds.id,
263
+ collection: collection,
264
+ height: dimensions.height,
265
+ width: dimensions.width,
266
+ occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
267
+ })(_this.props.view.state, _this.props.view.dispatch);
268
+ _context7.next = 24;
269
+ break;
270
+ case 21:
271
+ _context7.prev = 21;
272
+ _context7.t0 = _context7["catch"](10);
273
+ //keep it as external media
274
+ if (_this.props.dispatchAnalyticsEvent) {
275
+ _this.props.dispatchAnalyticsEvent({
276
+ action: _analytics.ACTION.UPLOAD_EXTERNAL_FAIL,
277
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
278
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
279
+ });
280
+ }
281
+ case 24:
282
+ case "end":
283
+ return _context7.stop();
284
+ }
285
+ }, _callee7, null, [[10, 21]]);
286
+ }));
287
+ return function (_x3) {
288
+ return _ref8.apply(this, arguments);
289
+ };
290
+ }());
291
+ (0, _defineProperty2.default)(this, "getNodeContextId", function () {
292
+ var attrs = _this.getAttrs();
293
+ if (!attrs || attrs.type !== 'file') {
294
+ return null;
295
+ }
296
+ return attrs.__contextId || null;
297
+ });
298
+ (0, _defineProperty2.default)(this, "updateDimensions", function (dimensions) {
299
+ (0, _helpers.updateAllMediaSingleNodesAttrs)(dimensions.id, {
300
+ height: dimensions.height,
301
+ width: dimensions.width
302
+ })(_this.props.view.state, _this.props.view.dispatch);
303
+ });
304
+ (0, _defineProperty2.default)(this, "hasDifferentContextId", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
305
+ var nodeContextId, currentContextId;
306
+ return _regenerator.default.wrap(function _callee8$(_context8) {
307
+ while (1) switch (_context8.prev = _context8.next) {
308
+ case 0:
309
+ nodeContextId = _this.getNodeContextId();
310
+ _context8.next = 3;
311
+ return _this.getObjectId();
312
+ case 3:
313
+ currentContextId = _context8.sent;
314
+ if (!(nodeContextId && currentContextId && nodeContextId !== currentContextId)) {
315
+ _context8.next = 6;
316
+ break;
317
+ }
318
+ return _context8.abrupt("return", true);
319
+ case 6:
320
+ return _context8.abrupt("return", false);
321
+ case 7:
322
+ case "end":
323
+ return _context8.stop();
324
+ }
325
+ }, _callee8);
326
+ })));
327
+ (0, _defineProperty2.default)(this, "isNodeFromDifferentCollection", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
328
+ var mediaProvider, currentCollectionName, attrs, nodeCollection, __contextId, contextId;
329
+ return _regenerator.default.wrap(function _callee9$(_context9) {
330
+ while (1) switch (_context9.prev = _context9.next) {
331
+ case 0:
332
+ _context9.next = 2;
333
+ return _this.props.mediaProvider;
334
+ case 2:
335
+ mediaProvider = _context9.sent;
336
+ if (!(!mediaProvider || !mediaProvider.uploadParams)) {
337
+ _context9.next = 5;
338
+ break;
339
+ }
340
+ return _context9.abrupt("return", false);
341
+ case 5:
342
+ currentCollectionName = mediaProvider.uploadParams.collection;
343
+ attrs = _this.getAttrs();
344
+ if (!(!attrs || attrs.type !== 'file')) {
345
+ _context9.next = 9;
346
+ break;
347
+ }
348
+ return _context9.abrupt("return", false);
349
+ case 9:
350
+ nodeCollection = attrs.collection, __contextId = attrs.__contextId;
351
+ _context9.t0 = __contextId;
352
+ if (_context9.t0) {
353
+ _context9.next = 15;
354
+ break;
355
+ }
356
+ _context9.next = 14;
357
+ return _this.getObjectId();
358
+ case 14:
359
+ _context9.t0 = _context9.sent;
360
+ case 15:
361
+ contextId = _context9.t0;
362
+ if (!(contextId && currentCollectionName !== nodeCollection)) {
363
+ _context9.next = 18;
364
+ break;
365
+ }
366
+ return _context9.abrupt("return", true);
367
+ case 18:
368
+ return _context9.abrupt("return", false);
369
+ case 19:
370
+ case "end":
371
+ return _context9.stop();
372
+ }
373
+ }, _callee9);
374
+ })));
375
+ (0, _defineProperty2.default)(this, "copyNodeFromBlobUrl", /*#__PURE__*/function () {
376
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(getPos) {
377
+ var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, auth, source, destination, mediaFile, pos;
378
+ return _regenerator.default.wrap(function _callee10$(_context10) {
379
+ while (1) switch (_context10.prev = _context10.next) {
380
+ case 0:
381
+ attrs = _this.getAttrs();
382
+ if (!(!attrs || attrs.type !== 'external')) {
383
+ _context10.next = 3;
384
+ break;
385
+ }
386
+ return _context10.abrupt("return");
387
+ case 3:
388
+ url = attrs.url;
389
+ mediaAttrs = (0, _mediaClient.getAttrsFromUrl)(url);
390
+ if (mediaAttrs) {
391
+ _context10.next = 7;
392
+ break;
393
+ }
394
+ return _context10.abrupt("return");
395
+ case 7:
396
+ _context10.next = 9;
397
+ return _this.props.mediaProvider;
398
+ case 9:
399
+ mediaProvider = _context10.sent;
400
+ if (!(!mediaProvider || !mediaProvider.uploadParams)) {
401
+ _context10.next = 12;
402
+ break;
403
+ }
404
+ return _context10.abrupt("return");
405
+ case 12:
406
+ currentCollectionName = mediaProvider.uploadParams.collection;
407
+ contextId = mediaAttrs.contextId, id = mediaAttrs.id, collection = mediaAttrs.collection, height = mediaAttrs.height, width = mediaAttrs.width, mimeType = mediaAttrs.mimeType, name = mediaAttrs.name, size = mediaAttrs.size;
408
+ uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
409
+ if (!(!uploadMediaClientConfig || !uploadMediaClientConfig.getAuthFromContext)) {
410
+ _context10.next = 17;
411
+ break;
412
+ }
413
+ return _context10.abrupt("return");
414
+ case 17:
415
+ mediaClient = (0, _mediaClient.getMediaClient)(uploadMediaClientConfig);
416
+ _context10.next = 20;
417
+ return uploadMediaClientConfig.getAuthFromContext(contextId);
418
+ case 20:
419
+ auth = _context10.sent;
420
+ source = {
421
+ id: id,
422
+ collection: collection,
423
+ authProvider: function authProvider() {
424
+ return Promise.resolve(auth);
425
+ }
426
+ };
427
+ destination = {
428
+ collection: currentCollectionName,
429
+ authProvider: uploadMediaClientConfig.authProvider,
430
+ occurrenceKey: (0, _v.default)()
431
+ };
432
+ _context10.next = 25;
433
+ return mediaClient.file.copyFile(source, destination);
434
+ case 25:
435
+ mediaFile = _context10.sent;
436
+ pos = getPos();
437
+ if (!(typeof pos !== 'number')) {
438
+ _context10.next = 29;
439
+ break;
440
+ }
441
+ return _context10.abrupt("return");
442
+ case 29:
443
+ (0, _helpers.replaceExternalMedia)(pos + 1, {
444
+ id: mediaFile.id,
445
+ collection: currentCollectionName,
446
+ height: height,
447
+ width: width,
448
+ __fileName: name,
449
+ __fileMimeType: mimeType,
450
+ __fileSize: size
451
+ })(_this.props.view.state, _this.props.view.dispatch);
452
+ case 30:
453
+ case "end":
454
+ return _context10.stop();
455
+ }
456
+ }, _callee10);
457
+ }));
458
+ return function (_x4) {
459
+ return _ref11.apply(this, arguments);
460
+ };
461
+ }());
462
+ // Copies the pasted node into the current collection using a getPos handler
463
+ (0, _defineProperty2.default)(this, "copyNodeFromPos", /*#__PURE__*/function () {
464
+ var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(getPos, traceContext) {
465
+ var attrs, copiedAttrs;
466
+ return _regenerator.default.wrap(function _callee11$(_context11) {
467
+ while (1) switch (_context11.prev = _context11.next) {
468
+ case 0:
469
+ attrs = _this.getAttrs();
470
+ if (!((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file')) {
471
+ _context11.next = 3;
472
+ break;
473
+ }
474
+ return _context11.abrupt("return");
475
+ case 3:
476
+ _context11.next = 5;
477
+ return _this.copyFile(attrs.id, attrs.collection, traceContext);
478
+ case 5:
479
+ copiedAttrs = _context11.sent;
480
+ if (copiedAttrs) {
481
+ _context11.next = 8;
482
+ break;
483
+ }
484
+ return _context11.abrupt("return");
485
+ case 8:
486
+ (0, _helpers.updateCurrentMediaNodeAttrs)(copiedAttrs, {
487
+ node: _this.props.node,
488
+ getPos: getPos
489
+ })(_this.props.view.state, _this.props.view.dispatch);
490
+ case 9:
491
+ case "end":
492
+ return _context11.stop();
493
+ }
494
+ }, _callee11);
495
+ }));
496
+ return function (_x5, _x6) {
497
+ return _ref12.apply(this, arguments);
498
+ };
499
+ }());
500
+ // Copies the pasted node into the current collection
501
+ (0, _defineProperty2.default)(this, "copyNode", /*#__PURE__*/function () {
502
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(traceContext) {
503
+ var attrs, view, copiedAttrs;
504
+ return _regenerator.default.wrap(function _callee12$(_context12) {
505
+ while (1) switch (_context12.prev = _context12.next) {
506
+ case 0:
507
+ attrs = _this.getAttrs();
508
+ view = _this.props.view;
509
+ if (!((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file')) {
510
+ _context12.next = 4;
511
+ break;
512
+ }
513
+ return _context12.abrupt("return");
514
+ case 4:
515
+ _context12.next = 6;
516
+ return _this.copyFile(attrs.id, attrs.collection, traceContext);
517
+ case 6:
518
+ copiedAttrs = _context12.sent;
519
+ if (copiedAttrs) {
520
+ _context12.next = 9;
521
+ break;
522
+ }
523
+ return _context12.abrupt("return");
524
+ case 9:
525
+ (0, _helpers.updateMediaSingleNodeAttrs)(attrs.id, copiedAttrs)(view.state, view.dispatch);
526
+ case 10:
527
+ case "end":
528
+ return _context12.stop();
529
+ }
530
+ }, _callee12);
531
+ }));
532
+ return function (_x7) {
533
+ return _ref13.apply(this, arguments);
534
+ };
535
+ }());
536
+ (0, _defineProperty2.default)(this, "copyFile", /*#__PURE__*/function () {
537
+ var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(id, collection, traceContext) {
538
+ var mediaProvider, nodeContextId, uploadMediaClientConfig, mediaClient, auth, objectId, source, currentCollectionName, destination, mediaFile;
539
+ return _regenerator.default.wrap(function _callee13$(_context13) {
540
+ while (1) switch (_context13.prev = _context13.next) {
541
+ case 0:
542
+ _context13.next = 2;
543
+ return _this.props.mediaProvider;
544
+ case 2:
545
+ mediaProvider = _context13.sent;
546
+ if (mediaProvider !== null && mediaProvider !== void 0 && mediaProvider.uploadParams) {
547
+ _context13.next = 5;
548
+ break;
549
+ }
550
+ return _context13.abrupt("return");
551
+ case 5:
552
+ nodeContextId = _this.getNodeContextId();
553
+ uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
554
+ if (!(!(uploadMediaClientConfig !== null && uploadMediaClientConfig !== void 0 && uploadMediaClientConfig.getAuthFromContext) || !nodeContextId)) {
555
+ _context13.next = 9;
556
+ break;
557
+ }
558
+ return _context13.abrupt("return");
559
+ case 9:
560
+ mediaClient = (0, _mediaClient.getMediaClient)(uploadMediaClientConfig);
561
+ _context13.next = 12;
562
+ return uploadMediaClientConfig.getAuthFromContext(nodeContextId);
563
+ case 12:
564
+ auth = _context13.sent;
565
+ _context13.next = 15;
566
+ return _this.getObjectId();
567
+ case 15:
568
+ objectId = _context13.sent;
569
+ source = {
570
+ id: id,
571
+ collection: collection,
572
+ authProvider: function authProvider() {
573
+ return Promise.resolve(auth);
574
+ }
575
+ };
576
+ currentCollectionName = mediaProvider.uploadParams.collection;
577
+ destination = {
578
+ collection: currentCollectionName,
579
+ authProvider: uploadMediaClientConfig.authProvider,
580
+ occurrenceKey: (0, _v.default)()
581
+ };
582
+ _context13.next = 21;
583
+ return mediaClient.file.copyFile(source, destination, undefined, traceContext);
584
+ case 21:
585
+ mediaFile = _context13.sent;
586
+ return _context13.abrupt("return", {
587
+ id: mediaFile.id,
588
+ collection: currentCollectionName,
589
+ __contextId: objectId
590
+ });
591
+ case 23:
592
+ case "end":
593
+ return _context13.stop();
594
+ }
595
+ }, _callee13);
596
+ }));
597
+ return function (_x8, _x9, _x10) {
598
+ return _ref14.apply(this, arguments);
599
+ };
600
+ }());
601
+ this.props = props;
602
+ }
603
+ (0, _createClass2.default)(MediaNodeUpdater, [{
604
+ key: "isMediaBlobUrl",
605
+ value: function isMediaBlobUrl() {
606
+ var attrs = this.getAttrs();
607
+ return !!(attrs && attrs.type === 'external' && (0, _mediaClient.isMediaBlobUrl)(attrs.url));
608
+ }
609
+ }, {
610
+ key: "getRemoteDimensions",
611
+ value: function () {
612
+ var _getRemoteDimensions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
613
+ var mediaProvider, mediaOptions, attrs, height, width, id, collection, viewMediaClientConfig, mediaClient, currentState, imageMetadata;
614
+ return _regenerator.default.wrap(function _callee14$(_context14) {
615
+ while (1) switch (_context14.prev = _context14.next) {
616
+ case 0:
617
+ _context14.next = 2;
618
+ return this.props.mediaProvider;
619
+ case 2:
620
+ mediaProvider = _context14.sent;
621
+ mediaOptions = this.props.mediaOptions;
622
+ attrs = this.getAttrs();
623
+ if (!(!mediaProvider || !attrs)) {
624
+ _context14.next = 7;
625
+ break;
626
+ }
627
+ return _context14.abrupt("return", false);
628
+ case 7:
629
+ height = attrs.height, width = attrs.width;
630
+ if (!(attrs.type === 'external' || !attrs.id)) {
631
+ _context14.next = 10;
632
+ break;
633
+ }
634
+ return _context14.abrupt("return", false);
635
+ case 10:
636
+ id = attrs.id, collection = attrs.collection;
637
+ if (!(height && width)) {
638
+ _context14.next = 13;
639
+ break;
640
+ }
641
+ return _context14.abrupt("return", false);
642
+ case 13:
643
+ if (!(mediaOptions && !mediaOptions.allowRemoteDimensionsFetch)) {
644
+ _context14.next = 15;
645
+ break;
646
+ }
647
+ return _context14.abrupt("return", {
648
+ id: id,
649
+ height: _mediaSingle.DEFAULT_IMAGE_HEIGHT,
650
+ width: _mediaSingle.DEFAULT_IMAGE_WIDTH
651
+ });
652
+ case 15:
653
+ viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
654
+ mediaClient = (0, _mediaClient.getMediaClient)(viewMediaClientConfig);
655
+ _context14.next = 19;
656
+ return mediaClient.file.getCurrentState(id, {
657
+ collectionName: collection
658
+ });
659
+ case 19:
660
+ currentState = _context14.sent;
661
+ if ((0, _mediaClient.isImageRepresentationReady)(currentState)) {
662
+ _context14.next = 22;
663
+ break;
664
+ }
665
+ return _context14.abrupt("return", false);
666
+ case 22:
667
+ _context14.next = 24;
668
+ return mediaClient.getImageMetadata(id, {
669
+ collection: collection
670
+ });
671
+ case 24:
672
+ imageMetadata = _context14.sent;
673
+ if (!(!imageMetadata || !imageMetadata.original)) {
674
+ _context14.next = 27;
675
+ break;
676
+ }
677
+ return _context14.abrupt("return", false);
678
+ case 27:
679
+ return _context14.abrupt("return", {
680
+ id: id,
681
+ height: imageMetadata.original.height || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
682
+ width: imageMetadata.original.width || _mediaSingle.DEFAULT_IMAGE_WIDTH
683
+ });
684
+ case 28:
685
+ case "end":
686
+ return _context14.stop();
687
+ }
688
+ }, _callee14, this);
689
+ }));
690
+ function getRemoteDimensions() {
691
+ return _getRemoteDimensions.apply(this, arguments);
692
+ }
693
+ return getRemoteDimensions;
694
+ }()
695
+ }, {
696
+ key: "handleExternalMedia",
697
+ value: function () {
698
+ var _handleExternalMedia = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(getPos) {
699
+ return _regenerator.default.wrap(function _callee15$(_context15) {
700
+ while (1) switch (_context15.prev = _context15.next) {
701
+ case 0:
702
+ if (!this.isMediaBlobUrl()) {
703
+ _context15.next = 12;
704
+ break;
705
+ }
706
+ _context15.prev = 1;
707
+ _context15.next = 4;
708
+ return this.copyNodeFromBlobUrl(getPos);
709
+ case 4:
710
+ _context15.next = 10;
711
+ break;
712
+ case 6:
713
+ _context15.prev = 6;
714
+ _context15.t0 = _context15["catch"](1);
715
+ _context15.next = 10;
716
+ return this.uploadExternalMedia(getPos);
717
+ case 10:
718
+ _context15.next = 14;
719
+ break;
720
+ case 12:
721
+ _context15.next = 14;
722
+ return this.uploadExternalMedia(getPos);
723
+ case 14:
724
+ case "end":
725
+ return _context15.stop();
726
+ }
727
+ }, _callee15, this, [[1, 6]]);
728
+ }));
729
+ function handleExternalMedia(_x11) {
730
+ return _handleExternalMedia.apply(this, arguments);
731
+ }
732
+ return handleExternalMedia;
733
+ }()
734
+ }]);
735
+ return MediaNodeUpdater;
736
+ }();
737
+ var hasPrivateAttrsChanged = function hasPrivateAttrsChanged(currentAttrs, newAttrs) {
738
+ return currentAttrs.__fileName !== newAttrs.__fileName || currentAttrs.__fileMimeType !== newAttrs.__fileMimeType || currentAttrs.__fileSize !== newAttrs.__fileSize || currentAttrs.__contextId !== newAttrs.__contextId;
739
+ };