@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,182 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import React, { Component } from 'react';
3
+ import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
4
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
5
+ import { setNodeSelection, setTextSelection, withImageLoader } from '@atlaskit/editor-common/utils';
6
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
+ import { Card, CardLoading } from '@atlaskit/media-card';
8
+ import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
9
+ import { MediaCardWrapper } from '../styles';
10
+
11
+ // This is being used by DropPlaceholder now
12
+ export const MEDIA_HEIGHT = 125;
13
+ export const FILE_WIDTH = 156;
14
+ // eslint-disable-next-line @repo/internal/react/no-class-components
15
+ export class MediaNode extends Component {
16
+ constructor(_props) {
17
+ super(_props);
18
+ _defineProperty(this, "state", {});
19
+ _defineProperty(this, "setViewMediaClientConfig", async () => {
20
+ const mediaProvider = await this.props.mediaProvider;
21
+ if (mediaProvider) {
22
+ const viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
23
+ this.setState({
24
+ viewMediaClientConfig
25
+ });
26
+ }
27
+ });
28
+ _defineProperty(this, "selectMediaSingleFromCard", ({
29
+ event
30
+ }) => {
31
+ this.selectMediaSingle(event);
32
+ });
33
+ _defineProperty(this, "selectMediaSingle", event => {
34
+ const propPos = this.props.getPos();
35
+ if (typeof propPos !== 'number') {
36
+ return;
37
+ }
38
+
39
+ // We need to call "stopPropagation" here in order to prevent the browser from navigating to
40
+ // another URL if the media node is wrapped in a link mark.
41
+ event.stopPropagation();
42
+ const {
43
+ state
44
+ } = this.props.view;
45
+ if (event.shiftKey) {
46
+ // don't select text if there is current selection in a table (as this would override selected cells)
47
+ if (state.selection instanceof CellSelection) {
48
+ return;
49
+ }
50
+ setTextSelection(this.props.view, state.selection.from < propPos ? state.selection.from : propPos - 1,
51
+ // + 3 needed for offset of the media inside mediaSingle and cursor to make whole mediaSingle selected
52
+ state.selection.to > propPos ? state.selection.to : propPos + 2);
53
+ } else {
54
+ setNodeSelection(this.props.view, propPos - 1);
55
+ }
56
+ });
57
+ _defineProperty(this, "onFullscreenChange", fullscreen => {
58
+ var _this$mediaPluginStat;
59
+ (_this$mediaPluginStat = this.mediaPluginState) === null || _this$mediaPluginStat === void 0 ? void 0 : _this$mediaPluginStat.updateAndDispatch({
60
+ isFullscreen: fullscreen
61
+ });
62
+ });
63
+ _defineProperty(this, "handleNewNode", props => {
64
+ var _this$mediaPluginStat2;
65
+ const {
66
+ node
67
+ } = props;
68
+ (_this$mediaPluginStat2 = this.mediaPluginState) === null || _this$mediaPluginStat2 === void 0 ? void 0 : _this$mediaPluginStat2.handleMediaNodeMount(node, () => this.props.getPos());
69
+ });
70
+ const {
71
+ view
72
+ } = this.props;
73
+ this.mediaPluginState = mediaStateKey.getState(view.state);
74
+ }
75
+ shouldComponentUpdate(nextProps, nextState) {
76
+ const hasNewViewMediaClientConfig = !this.state.viewMediaClientConfig && nextState.viewMediaClientConfig;
77
+ if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.mediaProvider !== nextProps.mediaProvider || hasNewViewMediaClientConfig) {
78
+ return true;
79
+ }
80
+ return false;
81
+ }
82
+ async componentDidMount() {
83
+ this.handleNewNode(this.props);
84
+ const {
85
+ contextIdentifierProvider
86
+ } = this.props;
87
+ this.setState({
88
+ contextIdentifierProvider: await contextIdentifierProvider
89
+ });
90
+ await this.setViewMediaClientConfig();
91
+ }
92
+ componentWillUnmount() {
93
+ var _this$mediaPluginStat3;
94
+ const {
95
+ node
96
+ } = this.props;
97
+ (_this$mediaPluginStat3 = this.mediaPluginState) === null || _this$mediaPluginStat3 === void 0 ? void 0 : _this$mediaPluginStat3.handleMediaNodeUnmount(node);
98
+ }
99
+ componentDidUpdate(prevProps) {
100
+ var _this$mediaPluginStat5;
101
+ if (prevProps.node.attrs.id !== this.props.node.attrs.id) {
102
+ var _this$mediaPluginStat4;
103
+ (_this$mediaPluginStat4 = this.mediaPluginState) === null || _this$mediaPluginStat4 === void 0 ? void 0 : _this$mediaPluginStat4.handleMediaNodeUnmount(prevProps.node);
104
+ this.handleNewNode(this.props);
105
+ }
106
+ (_this$mediaPluginStat5 = this.mediaPluginState) === null || _this$mediaPluginStat5 === void 0 ? void 0 : _this$mediaPluginStat5.updateElement();
107
+ this.setViewMediaClientConfig();
108
+ }
109
+ render() {
110
+ const {
111
+ node,
112
+ selected,
113
+ originalDimensions,
114
+ isLoading,
115
+ maxDimensions,
116
+ mediaOptions
117
+ } = this.props;
118
+ const borderMark = node.marks.find(m => m.type.name === 'border');
119
+ const {
120
+ viewMediaClientConfig,
121
+ contextIdentifierProvider
122
+ } = this.state;
123
+ const {
124
+ id,
125
+ type,
126
+ collection,
127
+ url,
128
+ alt
129
+ } = node.attrs;
130
+ if (isLoading || type !== 'external' && !viewMediaClientConfig) {
131
+ return /*#__PURE__*/React.createElement(MediaCardWrapper, {
132
+ dimensions: originalDimensions
133
+ }, /*#__PURE__*/React.createElement(CardLoading, null));
134
+ }
135
+ const contextId = contextIdentifierProvider && contextIdentifierProvider.objectId;
136
+ const identifier = type === 'external' ? {
137
+ dataURI: url,
138
+ name: url,
139
+ mediaItemType: 'external-image'
140
+ } : {
141
+ id,
142
+ mediaItemType: 'file',
143
+ collectionName: collection
144
+ };
145
+
146
+ // mediaClientConfig is not needed for "external" case. So we have to cheat here.
147
+ // there is a possibility mediaClientConfig will be part of a identifier,
148
+ // so this might be not an issue
149
+ const mediaClientConfig = viewMediaClientConfig || {
150
+ authProvider: () => ({})
151
+ };
152
+ return /*#__PURE__*/React.createElement(MediaCardWrapper, {
153
+ dimensions: originalDimensions,
154
+ onContextMenu: this.selectMediaSingle,
155
+ borderWidth: borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.size,
156
+ selected: selected
157
+ }, /*#__PURE__*/React.createElement(AnalyticsContext, {
158
+ data: {
159
+ [MEDIA_CONTEXT]: {
160
+ border: !!borderMark
161
+ }
162
+ }
163
+ }, /*#__PURE__*/React.createElement(Card, {
164
+ mediaClientConfig: mediaClientConfig,
165
+ resizeMode: "stretchy-fit",
166
+ dimensions: maxDimensions,
167
+ originalDimensions: originalDimensions,
168
+ identifier: identifier,
169
+ selectable: true,
170
+ selected: selected,
171
+ disableOverlay: true,
172
+ onFullscreenChange: this.onFullscreenChange,
173
+ onClick: this.selectMediaSingleFromCard,
174
+ useInlinePlayer: mediaOptions && mediaOptions.allowLazyLoading,
175
+ isLazy: mediaOptions && mediaOptions.allowLazyLoading,
176
+ featureFlags: mediaOptions && mediaOptions.featureFlags,
177
+ contextId: contextId,
178
+ alt: alt
179
+ })));
180
+ }
181
+ }
182
+ export default withImageLoader(MediaNode);
@@ -0,0 +1,511 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ /** @jsx jsx */
4
+
5
+ import React, { Component } from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE } from '@atlaskit/editor-common/media-single';
9
+ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
10
+ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
11
+ import { MediaSingle } from '@atlaskit/editor-common/ui';
12
+ import { browser, isNodeSelectedOrInRange, setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
13
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
14
+ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
15
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
16
+ import { getAttrsFromUrl } from '@atlaskit/media-client';
17
+ import { getMediaFeatureFlag } from '@atlaskit/media-common';
18
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
+ import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
20
+ import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
21
+ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
22
+ import ResizableMediaSingle from '../ui/ResizableMediaSingle';
23
+ import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
24
+ import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
25
+ import { MediaNodeUpdater } from './mediaNodeUpdater';
26
+ import { figureWrapper, MediaSingleNodeSelector } from './styles';
27
+ // eslint-disable-next-line @repo/internal/react/no-class-components
28
+ export default class MediaSingleNode extends Component {
29
+ constructor(...args) {
30
+ super(...args);
31
+ _defineProperty(this, "state", {
32
+ width: undefined,
33
+ height: undefined,
34
+ viewMediaClientConfig: undefined,
35
+ isCopying: false
36
+ });
37
+ _defineProperty(this, "mediaSingleWrapperRef", /*#__PURE__*/React.createRef());
38
+ _defineProperty(this, "captionPlaceHolderRef", /*#__PURE__*/React.createRef());
39
+ _defineProperty(this, "createMediaNodeUpdater", props => {
40
+ const node = this.props.node.firstChild;
41
+ return new MediaNodeUpdater({
42
+ ...props,
43
+ isMediaSingle: true,
44
+ node: node ? node : this.props.node,
45
+ dispatchAnalyticsEvent: this.props.dispatchAnalyticsEvent
46
+ });
47
+ });
48
+ _defineProperty(this, "setViewMediaClientConfig", async props => {
49
+ const mediaProvider = await props.mediaProvider;
50
+ if (mediaProvider) {
51
+ const viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
52
+ this.setState({
53
+ viewMediaClientConfig
54
+ });
55
+ }
56
+ });
57
+ _defineProperty(this, "updateMediaNodeAttributes", async props => {
58
+ const mediaNodeUpdater = this.createMediaNodeUpdater(props);
59
+ const {
60
+ addPendingTask
61
+ } = this.props.mediaPluginState;
62
+
63
+ // we want the first child of MediaSingle (type "media")
64
+ const node = this.props.node.firstChild;
65
+ if (!node) {
66
+ return;
67
+ }
68
+ const updatedDimensions = await mediaNodeUpdater.getRemoteDimensions();
69
+ if (updatedDimensions) {
70
+ mediaNodeUpdater.updateDimensions(updatedDimensions);
71
+ }
72
+ if (node.attrs.type === 'external' && node.attrs.__external) {
73
+ const updatingNode = mediaNodeUpdater.handleExternalMedia(this.props.getPos);
74
+ addPendingTask(updatingNode);
75
+ await updatingNode;
76
+ return;
77
+ }
78
+ const contextId = mediaNodeUpdater.getNodeContextId();
79
+ if (!contextId) {
80
+ await mediaNodeUpdater.updateContextId();
81
+ }
82
+ const hasDifferentContextId = await mediaNodeUpdater.hasDifferentContextId();
83
+ if (hasDifferentContextId) {
84
+ this.setState({
85
+ isCopying: true
86
+ });
87
+ try {
88
+ const copyNode = mediaNodeUpdater.copyNode({
89
+ traceId: node.attrs.__mediaTraceId
90
+ });
91
+ addPendingTask(copyNode);
92
+ await copyNode;
93
+ } catch (e) {
94
+ // if copyNode fails, let's set isCopying false so we can show the eventual error
95
+ this.setState({
96
+ isCopying: false
97
+ });
98
+ }
99
+ }
100
+ });
101
+ _defineProperty(this, "selectMediaSingle", ({
102
+ event
103
+ }) => {
104
+ const propPos = this.props.getPos();
105
+ if (typeof propPos !== 'number') {
106
+ return;
107
+ }
108
+
109
+ // We need to call "stopPropagation" here in order to prevent the browser from navigating to
110
+ // another URL if the media node is wrapped in a link mark.
111
+ event.stopPropagation();
112
+ const {
113
+ state
114
+ } = this.props.view;
115
+ if (event.shiftKey) {
116
+ // don't select text if there is current selection in a table (as this would override selected cells)
117
+ if (state.selection instanceof CellSelection) {
118
+ return;
119
+ }
120
+ setTextSelection(this.props.view, state.selection.from < propPos ? state.selection.from : propPos,
121
+ // + 3 needed for offset of the media inside mediaSingle and cursor to make whole mediaSingle selected
122
+ state.selection.to > propPos ? state.selection.to : propPos + 3);
123
+ } else {
124
+ setNodeSelection(this.props.view, propPos);
125
+ }
126
+ });
127
+ _defineProperty(this, "updateSize", (width, layout) => {
128
+ const {
129
+ state,
130
+ dispatch
131
+ } = this.props.view;
132
+ const pos = this.props.getPos();
133
+ if (typeof pos === 'undefined') {
134
+ return;
135
+ }
136
+ const tr = state.tr.setNodeMarkup(pos, undefined, {
137
+ ...this.props.node.attrs,
138
+ layout,
139
+ width,
140
+ widthType: 'pixel'
141
+ });
142
+ tr.setMeta('scrollIntoView', false);
143
+ /**
144
+ * Any changes to attributes of a node count the node as "recreated" in Prosemirror[1]
145
+ * This makes it so Prosemirror resets the selection to the child i.e. "media" instead of "media-single"
146
+ * The recommended fix is to reset the selection.[2]
147
+ *
148
+ * [1] https://discuss.prosemirror.net/t/setnodemarkup-loses-current-nodeselection/976
149
+ * [2] https://discuss.prosemirror.net/t/setnodemarkup-and-deselect/3673
150
+ */
151
+ tr.setSelection(NodeSelection.create(tr.doc, pos));
152
+ return dispatch(tr);
153
+ });
154
+ // Workaround for iOS 16 Caption selection issue
155
+ // @see https://product-fabric.atlassian.net/browse/MEX-2012
156
+ _defineProperty(this, "onMediaSingleClicked", event => {
157
+ var _this$captionPlaceHol;
158
+ if (!browser.ios) {
159
+ return;
160
+ }
161
+ if (this.mediaSingleWrapperRef.current !== event.target) {
162
+ return;
163
+ }
164
+ (_this$captionPlaceHol = this.captionPlaceHolderRef.current) === null || _this$captionPlaceHol === void 0 ? void 0 : _this$captionPlaceHol.click();
165
+ });
166
+ _defineProperty(this, "clickPlaceholder", () => {
167
+ var _pluginInjectionApi$a;
168
+ const {
169
+ view,
170
+ getPos,
171
+ node,
172
+ pluginInjectionApi
173
+ } = this.props;
174
+ if (typeof getPos === 'boolean') {
175
+ return;
176
+ }
177
+ insertAndSelectCaptionFromMediaSinglePos(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(getPos(), node)(view.state, view.dispatch);
178
+ });
179
+ }
180
+ UNSAFE_componentWillReceiveProps(nextProps) {
181
+ if (nextProps.mediaProvider !== this.props.mediaProvider) {
182
+ this.setViewMediaClientConfig(nextProps);
183
+ }
184
+
185
+ // Forced updates not required on mobile
186
+ if (nextProps.isCopyPasteEnabled === false) {
187
+ return;
188
+ }
189
+
190
+ // We need to call this method on any prop change since attrs can get removed with collab editing
191
+ // the method internally checks if we already have all attrs
192
+ this.createMediaNodeUpdater(nextProps).updateMediaSingleFileAttrs();
193
+ }
194
+ async componentDidMount() {
195
+ const {
196
+ contextIdentifierProvider
197
+ } = this.props;
198
+ await Promise.all([this.setViewMediaClientConfig(this.props), this.updateMediaNodeAttributes(this.props)]);
199
+ this.setState({
200
+ contextIdentifierProvider: await contextIdentifierProvider
201
+ });
202
+ }
203
+ render() {
204
+ var _pluginInjectionApi$m;
205
+ const {
206
+ selected,
207
+ getPos,
208
+ node,
209
+ mediaOptions,
210
+ fullWidthMode,
211
+ view: {
212
+ state
213
+ },
214
+ view,
215
+ pluginInjectionApi,
216
+ width: containerWidth,
217
+ lineLength,
218
+ dispatchAnalyticsEvent
219
+ } = this.props;
220
+ const {
221
+ layout,
222
+ widthType,
223
+ width: mediaSingleWidthAttribute
224
+ } = node.attrs;
225
+ const childNode = node.firstChild;
226
+ const attrs = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs) || {};
227
+
228
+ // original width and height of child media node (scaled)
229
+ let {
230
+ width,
231
+ height
232
+ } = attrs;
233
+ if (attrs.type === 'external') {
234
+ if (isMediaBlobUrlFromAttrs(attrs)) {
235
+ const urlAttrs = getAttrsFromUrl(attrs.url);
236
+ if (urlAttrs) {
237
+ const {
238
+ width: urlWidth,
239
+ height: urlHeight
240
+ } = urlAttrs;
241
+ width = width || urlWidth;
242
+ height = height || urlHeight;
243
+ }
244
+ }
245
+ const {
246
+ width: stateWidth,
247
+ height: stateHeight
248
+ } = this.state;
249
+ if (width === null) {
250
+ width = stateWidth || DEFAULT_IMAGE_WIDTH;
251
+ }
252
+ if (height === null) {
253
+ height = stateHeight || DEFAULT_IMAGE_HEIGHT;
254
+ }
255
+ }
256
+ if (!width || !height) {
257
+ width = DEFAULT_IMAGE_WIDTH;
258
+ height = DEFAULT_IMAGE_HEIGHT;
259
+ }
260
+ const isSelected = selected();
261
+ const currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
262
+ const contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
263
+ const contentWidth = currentMaxWidth || lineLength;
264
+ const mediaSingleProps = {
265
+ layout,
266
+ width,
267
+ height,
268
+ containerWidth: containerWidth,
269
+ lineLength: contentWidth,
270
+ fullWidthMode,
271
+ hasFallbackContainer: false,
272
+ mediaSingleWidth: calcMediaSinglePixelWidth({
273
+ width: mediaSingleWidthAttribute,
274
+ widthType,
275
+ origWidth: width,
276
+ layout,
277
+ // This will only be used when calculating legacy media single width
278
+ // thus we use the legacy value (exclude table as container node)
279
+ contentWidth: contentWidthForLegacyExperience,
280
+ containerWidth,
281
+ gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
282
+ }),
283
+ allowCaptions: mediaOptions.allowCaptions
284
+ };
285
+ const resizableMediaSingleProps = {
286
+ view: view,
287
+ getPos: getPos,
288
+ updateSize: this.updateSize,
289
+ gridSize: 12,
290
+ viewMediaClientConfig: this.state.viewMediaClientConfig,
291
+ allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
292
+ selected: isSelected,
293
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
294
+ pluginInjectionApi: pluginInjectionApi,
295
+ ...mediaSingleProps
296
+ };
297
+ let canResize = !!this.props.mediaOptions.allowResizing;
298
+ if (!this.props.mediaOptions.allowResizingInTables) {
299
+ // If resizing not allowed in tables, check parents for tables
300
+ const pos = getPos();
301
+ if (pos) {
302
+ const $pos = state.doc.resolve(pos);
303
+ const {
304
+ table
305
+ } = state.schema.nodes;
306
+ const disabledNode = !!findParentNodeOfTypeClosestToPos($pos, [table]);
307
+ canResize = canResize && !disabledNode;
308
+ }
309
+ }
310
+ const shouldShowPlaceholder = (mediaOptions.allowCaptions || getMediaFeatureFlag('captions', mediaOptions.featureFlags)) && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
311
+ const MediaChildren = jsx("figure", {
312
+ ref: this.mediaSingleWrapperRef,
313
+ css: [figureWrapper],
314
+ className: MediaSingleNodeSelector,
315
+ onClick: this.onMediaSingleClicked
316
+ }, jsx("div", {
317
+ ref: this.props.forwardRef
318
+ }), shouldShowPlaceholder && jsx(CaptionPlaceholder, {
319
+ ref: this.captionPlaceHolderRef,
320
+ onClick: this.clickPlaceholder
321
+ }));
322
+ return canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
323
+ showLegacyNotification: widthType !== 'pixel'
324
+ }), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
325
+ lineLength: contentWidthForLegacyExperience,
326
+ pctWidth: mediaSingleWidthAttribute
327
+ }), MediaChildren) : jsx(MediaSingle, _extends({}, mediaSingleProps, {
328
+ pctWidth: mediaSingleWidthAttribute
329
+ }), MediaChildren);
330
+ }
331
+ }
332
+ _defineProperty(MediaSingleNode, "defaultProps", {
333
+ mediaOptions: {}
334
+ });
335
+ _defineProperty(MediaSingleNode, "displayName", 'MediaSingleNode');
336
+ const MediaSingleNodeWrapper = ({
337
+ pluginInjectionApi,
338
+ mediaProvider,
339
+ contextIdentifierProvider,
340
+ node,
341
+ getPos,
342
+ mediaOptions,
343
+ view,
344
+ fullWidthMode,
345
+ selected,
346
+ eventDispatcher,
347
+ dispatchAnalyticsEvent,
348
+ forwardRef
349
+ }) => {
350
+ const {
351
+ widthState,
352
+ mediaState
353
+ } = useSharedPluginState(pluginInjectionApi, ['width', 'media']);
354
+ return jsx(MediaSingleNode, {
355
+ width: widthState.width,
356
+ lineLength: widthState.lineLength,
357
+ node: node,
358
+ getPos: getPos,
359
+ mediaProvider: mediaProvider,
360
+ contextIdentifierProvider: contextIdentifierProvider,
361
+ mediaOptions: mediaOptions,
362
+ view: view,
363
+ fullWidthMode: fullWidthMode,
364
+ selected: selected,
365
+ eventDispatcher: eventDispatcher,
366
+ mediaPluginState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined,
367
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
368
+ forwardRef: forwardRef,
369
+ pluginInjectionApi: pluginInjectionApi
370
+ });
371
+ };
372
+ class MediaSingleNodeView extends ReactNodeView {
373
+ constructor(...args) {
374
+ super(...args);
375
+ _defineProperty(this, "lastOffsetLeft", 0);
376
+ _defineProperty(this, "forceViewUpdate", false);
377
+ _defineProperty(this, "selectionType", null);
378
+ _defineProperty(this, "checkAndUpdateSelectionType", () => {
379
+ const getPos = this.getPos;
380
+ const {
381
+ selection
382
+ } = this.view.state;
383
+
384
+ /**
385
+ * ED-19831
386
+ * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
387
+ * directly to confluence since this bug is now in production.
388
+ */
389
+ let pos;
390
+ try {
391
+ pos = getPos ? getPos() : undefined;
392
+ } catch (e) {
393
+ pos = undefined;
394
+ }
395
+ const isNodeSelected = isNodeSelectedOrInRange(selection.$anchor.pos, selection.$head.pos, pos, this.node.nodeSize);
396
+ this.selectionType = isNodeSelected;
397
+ return isNodeSelected;
398
+ });
399
+ _defineProperty(this, "isNodeSelected", () => {
400
+ this.checkAndUpdateSelectionType();
401
+ return this.selectionType !== null;
402
+ });
403
+ }
404
+ createDomRef() {
405
+ const domRef = document.createElement('div');
406
+ if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
407
+ // workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
408
+ // see also: https://github.com/ProseMirror/prosemirror/issues/884
409
+ domRef.contentEditable = 'true';
410
+ }
411
+ if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
412
+ domRef.classList.add('media-extended-resize-experience');
413
+ }
414
+ return domRef;
415
+ }
416
+ getContentDOM() {
417
+ const dom = document.createElement('div');
418
+ dom.classList.add(MEDIA_CONTENT_WRAP_CLASS_NAME);
419
+ return {
420
+ dom
421
+ };
422
+ }
423
+ viewShouldUpdate(nextNode) {
424
+ if (this.forceViewUpdate) {
425
+ this.forceViewUpdate = false;
426
+ return true;
427
+ }
428
+ if (this.node.attrs !== nextNode.attrs) {
429
+ return true;
430
+ }
431
+ if (this.selectionType !== this.checkAndUpdateSelectionType()) {
432
+ return true;
433
+ }
434
+ if (this.node.childCount !== nextNode.childCount) {
435
+ return true;
436
+ }
437
+ return super.viewShouldUpdate(nextNode);
438
+ }
439
+ getNodeMediaId(node) {
440
+ if (node.firstChild) {
441
+ return node.firstChild.attrs.id;
442
+ }
443
+ return undefined;
444
+ }
445
+ update(node, decorations, _innerDecorations, isValidUpdate) {
446
+ if (!isValidUpdate) {
447
+ isValidUpdate = (currentNode, newNode) => this.getNodeMediaId(currentNode) === this.getNodeMediaId(newNode);
448
+ }
449
+ return super.update(node, decorations, _innerDecorations, isValidUpdate);
450
+ }
451
+ render(props, forwardRef) {
452
+ const {
453
+ eventDispatcher,
454
+ fullWidthMode,
455
+ providerFactory,
456
+ mediaOptions,
457
+ dispatchAnalyticsEvent,
458
+ pluginInjectionApi
459
+ } = this.reactComponentProps;
460
+
461
+ // getPos is a boolean for marks, since this is a node we know it must be a function
462
+ const getPos = this.getPos;
463
+ return jsx(WithProviders, {
464
+ providers: ['mediaProvider', 'contextIdentifierProvider'],
465
+ providerFactory: providerFactory,
466
+ renderNode: ({
467
+ mediaProvider,
468
+ contextIdentifierProvider
469
+ }) => {
470
+ return jsx(MediaSingleNodeWrapper, {
471
+ pluginInjectionApi: pluginInjectionApi,
472
+ mediaProvider: mediaProvider,
473
+ contextIdentifierProvider: contextIdentifierProvider,
474
+ node: this.node,
475
+ getPos: getPos,
476
+ mediaOptions: mediaOptions,
477
+ view: this.view,
478
+ fullWidthMode: fullWidthMode,
479
+ selected: this.isNodeSelected,
480
+ eventDispatcher: eventDispatcher,
481
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
482
+ forwardRef: forwardRef
483
+ });
484
+ }
485
+ });
486
+ }
487
+ ignoreMutation() {
488
+ // DOM has changed; recalculate if we need to re-render
489
+ if (this.dom) {
490
+ const offsetLeft = this.dom.offsetLeft;
491
+ if (offsetLeft !== this.lastOffsetLeft) {
492
+ this.lastOffsetLeft = offsetLeft;
493
+ this.forceViewUpdate = true;
494
+ this.update(this.node, [], undefined, () => true);
495
+ }
496
+ }
497
+ return true;
498
+ }
499
+ }
500
+ export const ReactMediaSingleNode = (portalProviderAPI, eventDispatcher, providerFactory, pluginInjectionApi, dispatchAnalyticsEvent, mediaOptions = {}) => (node, view, getPos) => {
501
+ const hasIntlContext = true;
502
+ return new MediaSingleNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
503
+ eventDispatcher,
504
+ fullWidthMode: mediaOptions.fullWidthEnabled,
505
+ providerFactory,
506
+ mediaOptions,
507
+ dispatchAnalyticsEvent,
508
+ isCopyPasteEnabled: mediaOptions.isCopyPasteEnabled,
509
+ pluginInjectionApi
510
+ }, undefined, undefined, undefined, hasIntlContext).init();
511
+ };
@@ -0,0 +1,8 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export const messages = defineMessages({
3
+ mediaGroupDeleteLabel: {
4
+ id: 'fabric.editor.mediaGroupDeleteLabel',
5
+ defaultMessage: 'delete',
6
+ description: 'a label for an icon that deletes media'
7
+ }
8
+ });