@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,186 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ import { isImagePreview } from '@atlaskit/media-picker';
7
+ var PickerFacade = /*#__PURE__*/function () {
8
+ function PickerFacade(pickerType, config, pickerConfig, analyticsName) {
9
+ var _this = this;
10
+ _classCallCheck(this, PickerFacade);
11
+ _defineProperty(this, "onDragListeners", []);
12
+ _defineProperty(this, "onStartListeners", []);
13
+ _defineProperty(this, "eventListeners", {});
14
+ _defineProperty(this, "handleUploadPreviewUpdate", function (event) {
15
+ var file = event.file,
16
+ preview = event.preview;
17
+
18
+ //check if upload-error was called before upload-preview-update
19
+ var isErroredFile = _this.erroredFiles.has(file.id);
20
+ var _ref = isImagePreview(preview) ? preview : {
21
+ dimensions: undefined,
22
+ scaleFactor: undefined
23
+ },
24
+ dimensions = _ref.dimensions,
25
+ scaleFactor = _ref.scaleFactor;
26
+ var state = {
27
+ id: file.id,
28
+ fileName: file.name,
29
+ fileSize: file.size,
30
+ fileMimeType: file.type,
31
+ collection: file.collectionName,
32
+ dimensions: dimensions,
33
+ scaleFactor: scaleFactor,
34
+ status: isErroredFile ? 'error' : undefined
35
+ };
36
+ _this.eventListeners[file.id] = [];
37
+ _this.onStartListeners.forEach(function (cb) {
38
+ return cb(state, function (evt) {
39
+ return _this.subscribeStateChanged(file, evt);
40
+ }, _this.analyticsName || _this.pickerType);
41
+ });
42
+ });
43
+ _defineProperty(this, "subscribeStateChanged", function (file, onStateChanged) {
44
+ var subscribers = _this.eventListeners[file.id];
45
+ if (!subscribers) {
46
+ return;
47
+ }
48
+ subscribers.push(onStateChanged);
49
+ });
50
+ _defineProperty(this, "handleUploadError", function (_ref2) {
51
+ var error = _ref2.error,
52
+ fileId = _ref2.fileId;
53
+ var listeners = _this.eventListeners[fileId];
54
+ _this.erroredFiles.add(fileId);
55
+ if (!listeners) {
56
+ return;
57
+ }
58
+ listeners.forEach(function (cb) {
59
+ return cb({
60
+ id: fileId,
61
+ status: 'error',
62
+ error: error && {
63
+ description: error.description,
64
+ name: error.name
65
+ }
66
+ });
67
+ });
68
+
69
+ // remove listeners
70
+ delete _this.eventListeners[fileId];
71
+ });
72
+ _defineProperty(this, "handleMobileUploadEnd", function (event) {
73
+ var file = event.file;
74
+ var listeners = _this.eventListeners[file.id];
75
+ if (!listeners) {
76
+ return;
77
+ }
78
+ listeners.forEach(function (cb) {
79
+ return cb({
80
+ id: file.id,
81
+ status: 'mobile-upload-end',
82
+ fileMimeType: file.type,
83
+ collection: file.collectionName,
84
+ publicId: file.publicId
85
+ });
86
+ });
87
+ });
88
+ _defineProperty(this, "handleReady", function (event) {
89
+ var file = event.file;
90
+ var listeners = _this.eventListeners[file.id];
91
+ if (!listeners) {
92
+ return;
93
+ }
94
+ listeners.forEach(function (cb) {
95
+ return cb({
96
+ id: file.id,
97
+ status: 'ready'
98
+ });
99
+ });
100
+
101
+ // remove listeners
102
+ delete _this.eventListeners[file.id];
103
+ });
104
+ this.config = config;
105
+ this.pickerConfig = pickerConfig;
106
+ this.pickerType = pickerType;
107
+ this.analyticsName = analyticsName;
108
+ this.erroredFiles = new Set();
109
+ }
110
+ _createClass(PickerFacade, [{
111
+ key: "init",
112
+ value: function () {
113
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
114
+ var picker;
115
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
116
+ while (1) switch (_context.prev = _context.next) {
117
+ case 0:
118
+ if (this.pickerType === 'customMediaPicker') {
119
+ picker = this.picker = this.pickerConfig;
120
+ }
121
+ if (picker) {
122
+ _context.next = 3;
123
+ break;
124
+ }
125
+ return _context.abrupt("return", this);
126
+ case 3:
127
+ picker.on('upload-preview-update', this.handleUploadPreviewUpdate);
128
+ picker.on('upload-end', this.handleReady);
129
+ picker.on('upload-error', this.handleUploadError);
130
+ picker.on('mobile-upload-end', this.handleMobileUploadEnd);
131
+ return _context.abrupt("return", this);
132
+ case 8:
133
+ case "end":
134
+ return _context.stop();
135
+ }
136
+ }, _callee, this);
137
+ }));
138
+ function init() {
139
+ return _init.apply(this, arguments);
140
+ }
141
+ return init;
142
+ }()
143
+ }, {
144
+ key: "type",
145
+ get: function get() {
146
+ return this.pickerType;
147
+ }
148
+ }, {
149
+ key: "mediaPicker",
150
+ get: function get() {
151
+ return this.picker;
152
+ }
153
+ }, {
154
+ key: "destroy",
155
+ value: function destroy() {
156
+ var picker = this.picker;
157
+ if (!picker) {
158
+ return;
159
+ }
160
+ picker.removeAllListeners('upload-preview-update');
161
+ picker.removeAllListeners('upload-end');
162
+ picker.removeAllListeners('upload-error');
163
+ this.onStartListeners = [];
164
+ this.onDragListeners = [];
165
+ }
166
+ }, {
167
+ key: "setUploadParams",
168
+ value: function setUploadParams(params) {
169
+ if (this.picker) {
170
+ this.picker.setUploadParams(params);
171
+ }
172
+ }
173
+ }, {
174
+ key: "onNewMedia",
175
+ value: function onNewMedia(cb) {
176
+ this.onStartListeners.push(cb);
177
+ }
178
+ }, {
179
+ key: "onDrag",
180
+ value: function onDrag(cb) {
181
+ this.onDragListeners.push(cb);
182
+ }
183
+ }]);
184
+ return PickerFacade;
185
+ }();
186
+ export { PickerFacade as default };
@@ -0,0 +1,282 @@
1
+ import React from 'react';
2
+ import { media, mediaGroup, mediaInline, mediaSingleSpec } from '@atlaskit/adf-schema';
3
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { IconImages } from '@atlaskit/editor-common/quick-insert';
7
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
+ import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
9
+ import { getMediaFeatureFlag } from '@atlaskit/media-common';
10
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
+ import { ReactMediaGroupNode } from './nodeviews/mediaGroup';
12
+ import { ReactMediaInlineNode } from './nodeviews/mediaInline';
13
+ import { ReactMediaNode } from './nodeviews/mediaNodeView';
14
+ import { ReactMediaSingleNode } from './nodeviews/mediaSingle';
15
+ import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
16
+ import keymapMediaAltTextPlugin from './pm-plugins/alt-text/keymap';
17
+ import keymapPlugin from './pm-plugins/keymap';
18
+ import keymapMediaSinglePlugin from './pm-plugins/keymap-media-single';
19
+ import linkingPlugin from './pm-plugins/linking';
20
+ import keymapLinkingPlugin from './pm-plugins/linking/keymap';
21
+ import { stateKey } from './pm-plugins/main';
22
+ import { createPlugin, stateKey as pluginKey } from './pm-plugins/main';
23
+ import { floatingToolbar as _floatingToolbar } from './toolbar';
24
+ import { MediaPickerComponents } from './ui/MediaPicker';
25
+ import ToolbarMedia from './ui/ToolbarMedia';
26
+ import { insertMediaAsMediaSingle as _insertMediaAsMediaSingle } from './utils/media-single';
27
+ export { insertMediaSingleNode } from './utils/media-single';
28
+ var MediaPickerFunctionalComponent = function MediaPickerFunctionalComponent(_ref) {
29
+ var api = _ref.api,
30
+ editorDomElement = _ref.editorDomElement,
31
+ appearance = _ref.appearance;
32
+ var _useSharedPluginState = useSharedPluginState(api, ['media']),
33
+ mediaState = _useSharedPluginState.mediaState;
34
+ if (!mediaState) {
35
+ return null;
36
+ }
37
+ return /*#__PURE__*/React.createElement(MediaPickerComponents, {
38
+ editorDomElement: editorDomElement,
39
+ mediaState: mediaState,
40
+ appearance: appearance,
41
+ api: api
42
+ });
43
+ };
44
+ export var mediaPlugin = function mediaPlugin(_ref2) {
45
+ var _api$featureFlags;
46
+ var _ref2$config = _ref2.config,
47
+ options = _ref2$config === void 0 ? {} : _ref2$config,
48
+ api = _ref2.api;
49
+ var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
50
+ return {
51
+ name: 'media',
52
+ getSharedState: function getSharedState(editorState) {
53
+ if (!editorState) {
54
+ return null;
55
+ }
56
+ return stateKey.getState(editorState) || null;
57
+ },
58
+ actions: {
59
+ insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod) {
60
+ var _api$analytics;
61
+ return _insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
62
+ }
63
+ },
64
+ nodes: function nodes() {
65
+ var _ref3 = options || {},
66
+ _ref3$allowMediaGroup = _ref3.allowMediaGroup,
67
+ allowMediaGroup = _ref3$allowMediaGroup === void 0 ? true : _ref3$allowMediaGroup,
68
+ _ref3$allowMediaSingl = _ref3.allowMediaSingle,
69
+ allowMediaSingle = _ref3$allowMediaSingl === void 0 ? false : _ref3$allowMediaSingl,
70
+ allowCaptions = _ref3.allowCaptions,
71
+ mediaFeatureFlags = _ref3.featureFlags;
72
+ var allowMediaInline = getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
73
+ var withCaption = getMediaFeatureFlag('captions', mediaFeatureFlags);
74
+
75
+ // temporary mapping - we will support captions feature flag until
76
+ // confluence removes the feature flag support in their code base and
77
+ // utilizes allowCaptions media prop instead
78
+ var mappedAllowCaptions = allowCaptions ? allowCaptions : withCaption;
79
+ var mediaSingleOption = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
80
+ withCaption: mappedAllowCaptions,
81
+ withExtendedWidthTypes: true
82
+ } : {
83
+ withCaption: mappedAllowCaptions,
84
+ withExtendedWidthTypes: false
85
+ };
86
+ var mediaSingleNode = mediaSingleSpec(mediaSingleOption);
87
+ return [{
88
+ name: 'mediaGroup',
89
+ node: mediaGroup
90
+ }, {
91
+ name: 'mediaSingle',
92
+ node: mediaSingleNode
93
+ }, {
94
+ name: 'media',
95
+ node: media
96
+ }, {
97
+ name: 'mediaInline',
98
+ node: mediaInline
99
+ }].filter(function (node) {
100
+ if (node.name === 'mediaGroup') {
101
+ return allowMediaGroup;
102
+ }
103
+ if (node.name === 'mediaSingle') {
104
+ return allowMediaSingle;
105
+ }
106
+ if (node.name === 'mediaInline') {
107
+ return allowMediaInline;
108
+ }
109
+ return true;
110
+ });
111
+ },
112
+ pmPlugins: function pmPlugins() {
113
+ var pmPlugins = [{
114
+ name: 'media',
115
+ plugin: function plugin(_ref4) {
116
+ var schema = _ref4.schema,
117
+ dispatch = _ref4.dispatch,
118
+ getIntl = _ref4.getIntl,
119
+ eventDispatcher = _ref4.eventDispatcher,
120
+ providerFactory = _ref4.providerFactory,
121
+ errorReporter = _ref4.errorReporter,
122
+ portalProviderAPI = _ref4.portalProviderAPI,
123
+ reactContext = _ref4.reactContext,
124
+ dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
125
+ return createPlugin(schema, {
126
+ providerFactory: providerFactory,
127
+ nodeViews: {
128
+ mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options, api),
129
+ mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options),
130
+ media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api),
131
+ mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory, api)
132
+ },
133
+ errorReporter: errorReporter,
134
+ uploadErrorHandler: options && options.uploadErrorHandler,
135
+ waitForMediaUpload: options && options.waitForMediaUpload,
136
+ customDropzoneContainer: options && options.customDropzoneContainer,
137
+ customMediaPicker: options && options.customMediaPicker,
138
+ allowResizing: !!(options && options.allowResizing)
139
+ }, reactContext, getIntl, api, dispatch, options, featureFlags.newInsertionBehaviour);
140
+ }
141
+ }, {
142
+ name: 'mediaKeymap',
143
+ plugin: function plugin() {
144
+ var _api$analytics2;
145
+ return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions);
146
+ }
147
+ }];
148
+ if (options && options.allowMediaSingle) {
149
+ pmPlugins.push({
150
+ name: 'mediaSingleKeymap',
151
+ plugin: function plugin(_ref5) {
152
+ var schema = _ref5.schema;
153
+ return keymapMediaSinglePlugin(schema);
154
+ }
155
+ });
156
+ }
157
+ if (options && options.allowAltTextOnImages) {
158
+ pmPlugins.push({
159
+ name: 'mediaAltText',
160
+ plugin: createMediaAltTextPlugin
161
+ });
162
+ pmPlugins.push({
163
+ name: 'mediaAltTextKeymap',
164
+ plugin: function plugin(_ref6) {
165
+ var _api$analytics3;
166
+ var schema = _ref6.schema;
167
+ return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
168
+ }
169
+ });
170
+ }
171
+ if (options && options.allowLinking) {
172
+ pmPlugins.push({
173
+ name: 'mediaLinking',
174
+ plugin: function plugin(_ref7) {
175
+ var dispatch = _ref7.dispatch;
176
+ return linkingPlugin(dispatch);
177
+ }
178
+ });
179
+ pmPlugins.push({
180
+ name: 'mediaLinkingKeymap',
181
+ plugin: function plugin(_ref8) {
182
+ var schema = _ref8.schema;
183
+ return keymapLinkingPlugin(schema);
184
+ }
185
+ });
186
+ }
187
+ pmPlugins.push({
188
+ name: 'mediaSelectionHandler',
189
+ plugin: function plugin() {
190
+ var mediaSelectionHandlerPlugin = new SafePlugin({
191
+ key: new PluginKey('mediaSelectionHandlerPlugin'),
192
+ props: {
193
+ handleScrollToSelection: function handleScrollToSelection(view) {
194
+ var selection = view.state.selection;
195
+ if (!(selection instanceof NodeSelection) || selection.node.type.name !== 'media') {
196
+ return false;
197
+ }
198
+ var _view$domAtPos = view.domAtPos(selection.from),
199
+ node = _view$domAtPos.node,
200
+ offset = _view$domAtPos.offset;
201
+ if (
202
+ // Is the media element mounted already?
203
+ offset === node.childNodes.length) {
204
+ // Media is not ready, so stop the scroll request
205
+ return true;
206
+ }
207
+
208
+ // Media is ready, keep the scrolling request
209
+ return false;
210
+ }
211
+ }
212
+ });
213
+ return mediaSelectionHandlerPlugin;
214
+ }
215
+ });
216
+ return pmPlugins;
217
+ },
218
+ contentComponent: function contentComponent(_ref9) {
219
+ var editorView = _ref9.editorView,
220
+ appearance = _ref9.appearance;
221
+ return /*#__PURE__*/React.createElement(MediaPickerFunctionalComponent, {
222
+ editorDomElement: editorView.dom,
223
+ appearance: appearance,
224
+ api: api
225
+ });
226
+ },
227
+ secondaryToolbarComponent: function secondaryToolbarComponent(_ref10) {
228
+ var editorView = _ref10.editorView,
229
+ eventDispatcher = _ref10.eventDispatcher,
230
+ disabled = _ref10.disabled;
231
+ return /*#__PURE__*/React.createElement(ToolbarMedia, {
232
+ isDisabled: disabled,
233
+ isReducedSpacing: true,
234
+ api: api
235
+ });
236
+ },
237
+ pluginsOptions: {
238
+ quickInsert: function quickInsert(_ref11) {
239
+ var formatMessage = _ref11.formatMessage;
240
+ return [{
241
+ id: 'media',
242
+ title: formatMessage(messages.mediaFiles),
243
+ description: formatMessage(messages.mediaFilesDescription),
244
+ priority: 400,
245
+ keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
246
+ icon: function icon() {
247
+ return /*#__PURE__*/React.createElement(IconImages, null);
248
+ },
249
+ action: function action(insert, state) {
250
+ var _api$analytics4;
251
+ var pluginState = pluginKey.getState(state);
252
+ pluginState === null || pluginState === void 0 || pluginState.showMediaPicker();
253
+ var tr = insert('');
254
+ api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || _api$analytics4.actions.attachAnalyticsEvent({
255
+ action: ACTION.OPENED,
256
+ actionSubject: ACTION_SUBJECT.PICKER,
257
+ actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
258
+ attributes: {
259
+ inputMethod: INPUT_METHOD.QUICK_INSERT
260
+ },
261
+ eventType: EVENT_TYPE.UI
262
+ })(tr);
263
+ return tr;
264
+ }
265
+ }];
266
+ },
267
+ floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
268
+ return _floatingToolbar(state, intl, {
269
+ providerFactory: providerFactory,
270
+ allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
271
+ allowResizing: options && options.allowResizing,
272
+ allowResizingInTables: options && options.allowResizingInTables,
273
+ allowLinking: options && options.allowLinking,
274
+ allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
275
+ allowAltTextOnImages: options && options.allowAltTextOnImages,
276
+ altTextValidator: options && options.altTextValidator,
277
+ fullWidthEnabled: options && options.fullWidthEnabled
278
+ }, api);
279
+ }
280
+ }
281
+ };
282
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
6
+ import { getMediaNodeFromSelection, isSelectionMediaSingleNode } from '../../utils/media-common';
7
+ import { createCommand } from './index';
8
+ var createCommandWithAnalytics = function createCommandWithAnalytics(actionType, action, transform) {
9
+ return function (editorAnalyticsAPI) {
10
+ return withAnalytics(editorAnalyticsAPI, {
11
+ action: actionType,
12
+ actionSubject: ACTION_SUBJECT.MEDIA,
13
+ actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
14
+ eventType: EVENT_TYPE.TRACK
15
+ })(createCommand(action, transform));
16
+ };
17
+ };
18
+ export var closeMediaAltTextMenu = createCommand(function (state) {
19
+ if (isSelectionMediaSingleNode(state)) {
20
+ return {
21
+ type: 'closeMediaAltTextMenu'
22
+ };
23
+ }
24
+ return false;
25
+ });
26
+ export var openMediaAltTextMenu = createCommandWithAnalytics(ACTION.OPENED, function (state) {
27
+ if (isSelectionMediaSingleNode(state)) {
28
+ return {
29
+ type: 'openMediaAltTextMenu'
30
+ };
31
+ }
32
+ return false;
33
+ }, function (tr) {
34
+ return tr.setMeta('scrollIntoView', false);
35
+ });
36
+ export var updateAltText = function updateAltText(newAltText) {
37
+ return createCommand(function (state) {
38
+ return isSelectionMediaSingleNode(state) ? {
39
+ type: 'updateAltText'
40
+ } : false;
41
+ }, function (tr, state) {
42
+ var mediaNode = getMediaNodeFromSelection(state);
43
+ var pos = tr.selection.from + 1;
44
+ if (mediaNode) {
45
+ tr.setMeta('scrollIntoView', false);
46
+ tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
47
+ alt: newAltText
48
+ }));
49
+ }
50
+ return tr;
51
+ });
52
+ };
@@ -0,0 +1,31 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { pluginFactory } from '@atlaskit/editor-common/utils';
3
+ import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
4
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import reducer from './reducer';
6
+ export var pluginKey = new PluginKey('mediaAltTextPlugin');
7
+ var _pluginFactory = pluginFactory(pluginKey, reducer, {
8
+ onSelectionChanged: function onSelectionChanged(tr, newState) {
9
+ // dont close alt text for undo/redo transactions (if it comes from prosemirror-history)
10
+ if (tr.getMeta(pmHistoryPluginKey)) {
11
+ return newState;
12
+ }
13
+ return {
14
+ isAltTextEditorOpen: false
15
+ };
16
+ }
17
+ }),
18
+ createPluginState = _pluginFactory.createPluginState,
19
+ createCommand = _pluginFactory.createCommand,
20
+ getPluginState = _pluginFactory.getPluginState;
21
+ export var createPlugin = function createPlugin(_ref) {
22
+ var dispatch = _ref.dispatch,
23
+ providerFactory = _ref.providerFactory;
24
+ return new SafePlugin({
25
+ state: createPluginState(dispatch, {
26
+ isAltTextEditorOpen: false
27
+ }),
28
+ key: pluginKey
29
+ });
30
+ };
31
+ export { createCommand, getPluginState };
@@ -0,0 +1,9 @@
1
+ import { addAltText, bindKeymapWithCommand, escape } from '@atlaskit/editor-common/keymaps';
2
+ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
+ import { closeMediaAltTextMenu, openMediaAltTextMenu } from './commands';
4
+ export default function keymapPlugin(schema, editorAnalyticsAPI) {
5
+ var list = {};
6
+ bindKeymapWithCommand(addAltText.common, openMediaAltTextMenu(editorAnalyticsAPI), list);
7
+ bindKeymapWithCommand(escape.common, closeMediaAltTextMenu, list);
8
+ return keymap(list);
9
+ }
@@ -0,0 +1,38 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ altText: {
4
+ id: 'fabric.editor.addAltText',
5
+ defaultMessage: 'Alt text',
6
+ description: 'Add an alt text for this image'
7
+ },
8
+ editAltText: {
9
+ id: 'fabric.editor.editAltText',
10
+ defaultMessage: 'Edit alt text',
11
+ description: 'Edit an alt text for this image'
12
+ },
13
+ back: {
14
+ id: 'fabric.editor.closeAltTextEdit',
15
+ defaultMessage: 'Back',
16
+ description: 'Back to toolbar'
17
+ },
18
+ clear: {
19
+ id: 'fabric.editor.clearAltTextEdit',
20
+ defaultMessage: 'Clear alt text',
21
+ description: 'Clear alt text'
22
+ },
23
+ placeholder: {
24
+ id: 'fabric.editor.placeholderAltText',
25
+ defaultMessage: 'Describe this image with alt text',
26
+ description: 'Describe this image with alt text'
27
+ },
28
+ supportText: {
29
+ id: 'fabric.editor.supportAltText',
30
+ defaultMessage: 'Alt text is useful for people using screen readers because of visual limitations.',
31
+ description: 'Alt text is useful for people using screen readers because of visual limitations.'
32
+ },
33
+ validationMessage: {
34
+ id: 'fabric.editor.alttext.validation',
35
+ defaultMessage: 'Please remove any special characters in alt text.',
36
+ description: 'Please remove any special characters in alt text. '
37
+ }
38
+ });
@@ -0,0 +1,25 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ export default (function (state, action) {
5
+ switch (action.type) {
6
+ case 'updateAltText':
7
+ {
8
+ return _objectSpread({}, state);
9
+ }
10
+ case 'openMediaAltTextMenu':
11
+ {
12
+ return _objectSpread(_objectSpread({}, state), {}, {
13
+ isAltTextEditorOpen: true
14
+ });
15
+ }
16
+ case 'closeMediaAltTextMenu':
17
+ {
18
+ return _objectSpread(_objectSpread({}, state), {}, {
19
+ isAltTextEditorOpen: false
20
+ });
21
+ }
22
+ default:
23
+ return state;
24
+ }
25
+ });
@@ -0,0 +1 @@
1
+ export {};