@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,384 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import uuidV4 from 'uuid/v4';
3
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
+ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
5
+ import { getAttrsFromUrl, getMediaClient, isImageRepresentationReady, isMediaBlobUrl } from '@atlaskit/media-client';
6
+ import { replaceExternalMedia, updateAllMediaSingleNodesAttrs, updateCurrentMediaNodeAttrs, updateMediaSingleNodeAttrs } from '../commands/helpers';
7
+ export class MediaNodeUpdater {
8
+ constructor(props) {
9
+ // Updates the node with contextId if it doesn't have one already
10
+ // TODO [MS-2258]: remove updateContextId in order to only use updateMediaSingleFileAttrs
11
+ _defineProperty(this, "updateContextId", async () => {
12
+ const attrs = this.getAttrs();
13
+ if (!attrs || attrs.type !== 'file') {
14
+ return;
15
+ }
16
+ const {
17
+ id
18
+ } = attrs;
19
+ const objectId = await this.getObjectId();
20
+ updateAllMediaSingleNodesAttrs(id, {
21
+ __contextId: objectId
22
+ })(this.props.view.state, this.props.view.dispatch);
23
+ });
24
+ _defineProperty(this, "updateNodeContextId", async getPos => {
25
+ const attrs = this.getAttrs();
26
+ if ((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file') {
27
+ return;
28
+ }
29
+ const objectId = await this.getObjectId();
30
+ updateCurrentMediaNodeAttrs({
31
+ __contextId: objectId
32
+ }, {
33
+ node: this.props.node,
34
+ getPos
35
+ })(this.props.view.state, this.props.view.dispatch);
36
+ });
37
+ _defineProperty(this, "hasFileAttributesDefined", attrs => {
38
+ return attrs && attrs.type === 'file' && attrs.__fileName && attrs.__fileMimeType && attrs.__fileSize && attrs.__contextId;
39
+ });
40
+ _defineProperty(this, "getNewFileAttrsForNode", async () => {
41
+ const attrs = this.getAttrs();
42
+ const mediaProvider = await this.props.mediaProvider;
43
+ if (!mediaProvider || !mediaProvider.uploadParams || !attrs || attrs.type !== 'file' || this.hasFileAttributesDefined(attrs)) {
44
+ return;
45
+ }
46
+ const mediaClientConfig = mediaProvider.viewMediaClientConfig;
47
+ const mediaClient = getMediaClient(mediaClientConfig);
48
+ let fileState;
49
+ const {
50
+ id,
51
+ collection: collectionName
52
+ } = attrs;
53
+ try {
54
+ fileState = await mediaClient.file.getCurrentState(id, {
55
+ collectionName
56
+ });
57
+ if (fileState.status === 'error') {
58
+ return;
59
+ }
60
+ } catch (err) {
61
+ return;
62
+ }
63
+ const contextId = this.getNodeContextId() || (await this.getObjectId());
64
+ const {
65
+ name,
66
+ mimeType,
67
+ size
68
+ } = fileState;
69
+ const newAttrs = {
70
+ __fileName: name,
71
+ __fileMimeType: mimeType,
72
+ __fileSize: size,
73
+ __contextId: contextId
74
+ };
75
+ if (!hasPrivateAttrsChanged(attrs, newAttrs)) {
76
+ return;
77
+ }
78
+ return newAttrs;
79
+ });
80
+ _defineProperty(this, "updateMediaSingleFileAttrs", async () => {
81
+ const newAttrs = await this.getNewFileAttrsForNode();
82
+ const {
83
+ id
84
+ } = this.getAttrs();
85
+ if (id && newAttrs) {
86
+ updateAllMediaSingleNodesAttrs(id, newAttrs)(this.props.view.state, this.props.view.dispatch);
87
+ }
88
+ });
89
+ _defineProperty(this, "updateNodeAttrs", async getPos => {
90
+ const newAttrs = await this.getNewFileAttrsForNode();
91
+ if (newAttrs) {
92
+ updateCurrentMediaNodeAttrs(newAttrs, {
93
+ node: this.props.node,
94
+ getPos
95
+ })(this.props.view.state, this.props.view.dispatch);
96
+ }
97
+ });
98
+ _defineProperty(this, "getAttrs", () => {
99
+ const {
100
+ attrs
101
+ } = this.props.node;
102
+ if (attrs) {
103
+ return attrs;
104
+ }
105
+ return undefined;
106
+ });
107
+ _defineProperty(this, "getObjectId", async () => {
108
+ const contextIdentifierProvider = await this.props.contextIdentifierProvider;
109
+ return (contextIdentifierProvider === null || contextIdentifierProvider === void 0 ? void 0 : contextIdentifierProvider.objectId) || null;
110
+ });
111
+ _defineProperty(this, "uploadExternalMedia", async getPos => {
112
+ const {
113
+ node
114
+ } = this.props;
115
+ const mediaProvider = await this.props.mediaProvider;
116
+ if (node && mediaProvider) {
117
+ const uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
118
+ if (!uploadMediaClientConfig || !node.attrs.url) {
119
+ return;
120
+ }
121
+ const mediaClient = getMediaClient(uploadMediaClientConfig);
122
+ const collection = mediaProvider.uploadParams && mediaProvider.uploadParams.collection;
123
+ try {
124
+ const uploader = await mediaClient.file.uploadExternal(node.attrs.url, collection);
125
+ const {
126
+ uploadableFileUpfrontIds,
127
+ dimensions
128
+ } = uploader;
129
+ const pos = getPos();
130
+ if (typeof pos !== 'number') {
131
+ return;
132
+ }
133
+ replaceExternalMedia(pos + 1, {
134
+ id: uploadableFileUpfrontIds.id,
135
+ collection,
136
+ height: dimensions.height,
137
+ width: dimensions.width,
138
+ occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
139
+ })(this.props.view.state, this.props.view.dispatch);
140
+ } catch (e) {
141
+ //keep it as external media
142
+ if (this.props.dispatchAnalyticsEvent) {
143
+ this.props.dispatchAnalyticsEvent({
144
+ action: ACTION.UPLOAD_EXTERNAL_FAIL,
145
+ actionSubject: ACTION_SUBJECT.EDITOR,
146
+ eventType: EVENT_TYPE.OPERATIONAL
147
+ });
148
+ }
149
+ }
150
+ }
151
+ });
152
+ _defineProperty(this, "getNodeContextId", () => {
153
+ const attrs = this.getAttrs();
154
+ if (!attrs || attrs.type !== 'file') {
155
+ return null;
156
+ }
157
+ return attrs.__contextId || null;
158
+ });
159
+ _defineProperty(this, "updateDimensions", dimensions => {
160
+ updateAllMediaSingleNodesAttrs(dimensions.id, {
161
+ height: dimensions.height,
162
+ width: dimensions.width
163
+ })(this.props.view.state, this.props.view.dispatch);
164
+ });
165
+ _defineProperty(this, "hasDifferentContextId", async () => {
166
+ const nodeContextId = this.getNodeContextId();
167
+ const currentContextId = await this.getObjectId();
168
+ if (nodeContextId && currentContextId && nodeContextId !== currentContextId) {
169
+ return true;
170
+ }
171
+ return false;
172
+ });
173
+ _defineProperty(this, "isNodeFromDifferentCollection", async () => {
174
+ const mediaProvider = await this.props.mediaProvider;
175
+ if (!mediaProvider || !mediaProvider.uploadParams) {
176
+ return false;
177
+ }
178
+ const currentCollectionName = mediaProvider.uploadParams.collection;
179
+ const attrs = this.getAttrs();
180
+ if (!attrs || attrs.type !== 'file') {
181
+ return false;
182
+ }
183
+ const {
184
+ collection: nodeCollection,
185
+ __contextId
186
+ } = attrs;
187
+ const contextId = __contextId || (await this.getObjectId());
188
+ if (contextId && currentCollectionName !== nodeCollection) {
189
+ return true;
190
+ }
191
+ return false;
192
+ });
193
+ _defineProperty(this, "copyNodeFromBlobUrl", async getPos => {
194
+ const attrs = this.getAttrs();
195
+ if (!attrs || attrs.type !== 'external') {
196
+ return;
197
+ }
198
+ const {
199
+ url
200
+ } = attrs;
201
+ const mediaAttrs = getAttrsFromUrl(url);
202
+ if (!mediaAttrs) {
203
+ return;
204
+ }
205
+ const mediaProvider = await this.props.mediaProvider;
206
+ if (!mediaProvider || !mediaProvider.uploadParams) {
207
+ return;
208
+ }
209
+ const currentCollectionName = mediaProvider.uploadParams.collection;
210
+ const {
211
+ contextId,
212
+ id,
213
+ collection,
214
+ height,
215
+ width,
216
+ mimeType,
217
+ name,
218
+ size
219
+ } = mediaAttrs;
220
+ const uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
221
+ if (!uploadMediaClientConfig || !uploadMediaClientConfig.getAuthFromContext) {
222
+ return;
223
+ }
224
+ const mediaClient = getMediaClient(uploadMediaClientConfig);
225
+ const auth = await uploadMediaClientConfig.getAuthFromContext(contextId);
226
+ const source = {
227
+ id,
228
+ collection,
229
+ authProvider: () => Promise.resolve(auth)
230
+ };
231
+ const destination = {
232
+ collection: currentCollectionName,
233
+ authProvider: uploadMediaClientConfig.authProvider,
234
+ occurrenceKey: uuidV4()
235
+ };
236
+ const mediaFile = await mediaClient.file.copyFile(source, destination);
237
+ const pos = getPos();
238
+ if (typeof pos !== 'number') {
239
+ return;
240
+ }
241
+ replaceExternalMedia(pos + 1, {
242
+ id: mediaFile.id,
243
+ collection: currentCollectionName,
244
+ height,
245
+ width,
246
+ __fileName: name,
247
+ __fileMimeType: mimeType,
248
+ __fileSize: size
249
+ })(this.props.view.state, this.props.view.dispatch);
250
+ });
251
+ // Copies the pasted node into the current collection using a getPos handler
252
+ _defineProperty(this, "copyNodeFromPos", async (getPos, traceContext) => {
253
+ const attrs = this.getAttrs();
254
+ if ((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file') {
255
+ return;
256
+ }
257
+ const copiedAttrs = await this.copyFile(attrs.id, attrs.collection, traceContext);
258
+ if (!copiedAttrs) {
259
+ return;
260
+ }
261
+ updateCurrentMediaNodeAttrs(copiedAttrs, {
262
+ node: this.props.node,
263
+ getPos
264
+ })(this.props.view.state, this.props.view.dispatch);
265
+ });
266
+ // Copies the pasted node into the current collection
267
+ _defineProperty(this, "copyNode", async traceContext => {
268
+ const attrs = this.getAttrs();
269
+ const {
270
+ view
271
+ } = this.props;
272
+ if ((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file') {
273
+ return;
274
+ }
275
+ const copiedAttrs = await this.copyFile(attrs.id, attrs.collection, traceContext);
276
+ if (!copiedAttrs) {
277
+ return;
278
+ }
279
+ updateMediaSingleNodeAttrs(attrs.id, copiedAttrs)(view.state, view.dispatch);
280
+ });
281
+ _defineProperty(this, "copyFile", async (id, collection, traceContext) => {
282
+ const mediaProvider = await this.props.mediaProvider;
283
+ if (!(mediaProvider !== null && mediaProvider !== void 0 && mediaProvider.uploadParams)) {
284
+ return;
285
+ }
286
+ const nodeContextId = this.getNodeContextId();
287
+ const uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
288
+ if (!(uploadMediaClientConfig !== null && uploadMediaClientConfig !== void 0 && uploadMediaClientConfig.getAuthFromContext) || !nodeContextId) {
289
+ return;
290
+ }
291
+ const mediaClient = getMediaClient(uploadMediaClientConfig);
292
+ const auth = await uploadMediaClientConfig.getAuthFromContext(nodeContextId);
293
+ const objectId = await this.getObjectId();
294
+ const source = {
295
+ id,
296
+ collection,
297
+ authProvider: () => Promise.resolve(auth)
298
+ };
299
+ const currentCollectionName = mediaProvider.uploadParams.collection;
300
+ const destination = {
301
+ collection: currentCollectionName,
302
+ authProvider: uploadMediaClientConfig.authProvider,
303
+ occurrenceKey: uuidV4()
304
+ };
305
+ const mediaFile = await mediaClient.file.copyFile(source, destination, undefined, traceContext);
306
+ return {
307
+ id: mediaFile.id,
308
+ collection: currentCollectionName,
309
+ __contextId: objectId
310
+ };
311
+ });
312
+ this.props = props;
313
+ }
314
+ isMediaBlobUrl() {
315
+ const attrs = this.getAttrs();
316
+ return !!(attrs && attrs.type === 'external' && isMediaBlobUrl(attrs.url));
317
+ }
318
+ async getRemoteDimensions() {
319
+ const mediaProvider = await this.props.mediaProvider;
320
+ const {
321
+ mediaOptions
322
+ } = this.props;
323
+ const attrs = this.getAttrs();
324
+ if (!mediaProvider || !attrs) {
325
+ return false;
326
+ }
327
+ const {
328
+ height,
329
+ width
330
+ } = attrs;
331
+ if (attrs.type === 'external' || !attrs.id) {
332
+ return false;
333
+ }
334
+ const {
335
+ id,
336
+ collection
337
+ } = attrs;
338
+ if (height && width) {
339
+ return false;
340
+ }
341
+
342
+ // can't fetch remote dimensions on mobile, so we'll default them
343
+ if (mediaOptions && !mediaOptions.allowRemoteDimensionsFetch) {
344
+ return {
345
+ id,
346
+ height: DEFAULT_IMAGE_HEIGHT,
347
+ width: DEFAULT_IMAGE_WIDTH
348
+ };
349
+ }
350
+ const viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
351
+ const mediaClient = getMediaClient(viewMediaClientConfig);
352
+ const currentState = await mediaClient.file.getCurrentState(id, {
353
+ collectionName: collection
354
+ });
355
+ if (!isImageRepresentationReady(currentState)) {
356
+ return false;
357
+ }
358
+ const imageMetadata = await mediaClient.getImageMetadata(id, {
359
+ collection
360
+ });
361
+ if (!imageMetadata || !imageMetadata.original) {
362
+ return false;
363
+ }
364
+ return {
365
+ id,
366
+ height: imageMetadata.original.height || DEFAULT_IMAGE_HEIGHT,
367
+ width: imageMetadata.original.width || DEFAULT_IMAGE_WIDTH
368
+ };
369
+ }
370
+ async handleExternalMedia(getPos) {
371
+ if (this.isMediaBlobUrl()) {
372
+ try {
373
+ await this.copyNodeFromBlobUrl(getPos);
374
+ } catch (e) {
375
+ await this.uploadExternalMedia(getPos);
376
+ }
377
+ } else {
378
+ await this.uploadExternalMedia(getPos);
379
+ }
380
+ }
381
+ }
382
+ const hasPrivateAttrsChanged = (currentAttrs, newAttrs) => {
383
+ return currentAttrs.__fileName !== newAttrs.__fileName || currentAttrs.__fileMimeType !== newAttrs.__fileMimeType || currentAttrs.__fileSize !== newAttrs.__fileSize || currentAttrs.__contextId !== newAttrs.__contextId;
384
+ };
@@ -0,0 +1,149 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import React from 'react';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
5
+ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
6
+ import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
+ import { getAttrsFromUrl } from '@atlaskit/media-client';
8
+ import { isMediaBlobUrlFromAttrs } from '../../utils/media-common';
9
+ import MediaNode from './media';
10
+ const MediaNodeWithProviders = ({
11
+ pluginInjectionApi,
12
+ innerComponent
13
+ }) => {
14
+ const {
15
+ widthState
16
+ } = useSharedPluginState(pluginInjectionApi, ['width']);
17
+ return innerComponent({
18
+ width: widthState
19
+ });
20
+ };
21
+ function isMediaDecorationSpec(decoration) {
22
+ return decoration.spec.type !== undefined && decoration.spec.selected !== undefined;
23
+ }
24
+ class MediaNodeView extends SelectionBasedNodeView {
25
+ constructor(...args) {
26
+ super(...args);
27
+ _defineProperty(this, "isSelected", false);
28
+ _defineProperty(this, "renderMediaNodeWithState", (mediaProvider, contextIdentifierProvider) => {
29
+ return ({
30
+ width: editorWidth
31
+ }) => {
32
+ const getPos = this.getPos;
33
+ const {
34
+ mediaOptions
35
+ } = this.reactComponentProps;
36
+ const attrs = this.getAttrs();
37
+ const url = attrs.type === 'external' ? attrs.url : '';
38
+ let {
39
+ width,
40
+ height
41
+ } = attrs;
42
+ if (this.isMediaBlobUrl()) {
43
+ const urlAttrs = getAttrsFromUrl(url);
44
+ if (urlAttrs) {
45
+ const {
46
+ width: urlWidth,
47
+ height: urlHeight
48
+ } = urlAttrs;
49
+ width = width || urlWidth;
50
+ height = height || urlHeight;
51
+ }
52
+ }
53
+ width = width || DEFAULT_IMAGE_WIDTH;
54
+ height = height || DEFAULT_IMAGE_HEIGHT;
55
+ const maxDimensions = {
56
+ width: `${editorWidth.width}px`,
57
+ height: `${height / width * editorWidth.width}px`
58
+ };
59
+ const originalDimensions = {
60
+ width,
61
+ height
62
+ };
63
+ return /*#__PURE__*/React.createElement(MediaNode, {
64
+ view: this.view,
65
+ node: this.node,
66
+ getPos: getPos,
67
+ selected: this.nodeInsideSelection(),
68
+ originalDimensions: originalDimensions,
69
+ maxDimensions: maxDimensions,
70
+ url: url,
71
+ mediaProvider: mediaProvider,
72
+ contextIdentifierProvider: contextIdentifierProvider,
73
+ mediaOptions: mediaOptions
74
+ });
75
+ };
76
+ });
77
+ _defineProperty(this, "renderMediaNodeWithProviders", ({
78
+ mediaProvider,
79
+ contextIdentifierProvider
80
+ }) => {
81
+ const {
82
+ pluginInjectionApi
83
+ } = this.reactComponentProps;
84
+ return /*#__PURE__*/React.createElement(MediaNodeWithProviders, {
85
+ pluginInjectionApi: pluginInjectionApi,
86
+ innerComponent: this.renderMediaNodeWithState(mediaProvider, contextIdentifierProvider)
87
+ });
88
+ });
89
+ }
90
+ createDomRef() {
91
+ const domRef = document.createElement('div');
92
+ if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
93
+ // workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
94
+ // see also: https://github.com/ProseMirror/prosemirror/issues/884
95
+ domRef.contentEditable = 'true';
96
+ }
97
+ return domRef;
98
+ }
99
+ viewShouldUpdate(nextNode, decorations) {
100
+ const hasMediaNodeSelectedDecoration = decorations.some(decoration => isMediaDecorationSpec(decoration) && decoration.spec.type === 'media' && decoration.spec.selected);
101
+ if (this.isSelected !== hasMediaNodeSelectedDecoration) {
102
+ this.isSelected = hasMediaNodeSelectedDecoration;
103
+ return true;
104
+ }
105
+ if (this.node.attrs !== nextNode.attrs) {
106
+ return true;
107
+ }
108
+ return super.viewShouldUpdate(nextNode, decorations);
109
+ }
110
+ stopEvent(event) {
111
+ // Don't trap right click events on media node
112
+ if (['mousedown', 'contextmenu'].indexOf(event.type) !== -1) {
113
+ const mouseEvent = event;
114
+ if (mouseEvent.button === 2) {
115
+ return true;
116
+ }
117
+ }
118
+ return false;
119
+ }
120
+ getAttrs() {
121
+ const {
122
+ attrs
123
+ } = this.node;
124
+ return attrs;
125
+ }
126
+ isMediaBlobUrl() {
127
+ const attrs = this.getAttrs();
128
+ return isMediaBlobUrlFromAttrs(attrs);
129
+ }
130
+ render() {
131
+ const {
132
+ providerFactory
133
+ } = this.reactComponentProps;
134
+ return /*#__PURE__*/React.createElement(WithProviders, {
135
+ providers: ['mediaProvider', 'contextIdentifierProvider'],
136
+ providerFactory: providerFactory,
137
+ renderNode: this.renderMediaNodeWithProviders
138
+ });
139
+ }
140
+ }
141
+ export const ReactMediaNode = (portalProviderAPI, eventDispatcher, providerFactory, mediaOptions = {}, pluginInjectionApi) => (node, view, getPos) => {
142
+ const hasIntlContext = true;
143
+ return new MediaNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
144
+ eventDispatcher,
145
+ providerFactory,
146
+ mediaOptions,
147
+ pluginInjectionApi
148
+ }, undefined, undefined, undefined, hasIntlContext).init();
149
+ };