@wordpress/media-editor 0.21.0 → 0.22.0

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 (339) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/components/media-editor/index.cjs +533 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +43 -57
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -7
  6. package/build/components/media-editor/use-save-media-editor.cjs +111 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +122 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +65 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +62 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +183 -257
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -7
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +119 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/build-modifiers.cjs +107 -88
  19. package/build/components/media-editor-modal/build-modifiers.cjs.map +1 -7
  20. package/build/components/media-editor-modal/index.cjs +112 -155
  21. package/build/components/media-editor-modal/index.cjs.map +1 -7
  22. package/build/components/media-editor-provider/index.cjs +32 -55
  23. package/build/components/media-editor-provider/index.cjs.map +1 -7
  24. package/build/components/media-form/index.cjs +76 -77
  25. package/build/components/media-form/index.cjs.map +1 -7
  26. package/build/components/media-preview/index.cjs +114 -114
  27. package/build/components/media-preview/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/index.cjs +181 -188
  29. package/build/components/rotation-ruler/index.cjs.map +1 -7
  30. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  31. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  32. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  33. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  34. package/build/image-editor/core/camera.cjs +257 -205
  35. package/build/image-editor/core/camera.cjs.map +1 -7
  36. package/build/image-editor/core/constants.cjs +127 -102
  37. package/build/image-editor/core/constants.cjs.map +1 -7
  38. package/build/image-editor/core/containment.cjs +275 -262
  39. package/build/image-editor/core/containment.cjs.map +1 -7
  40. package/build/image-editor/core/crop-rect.cjs +33 -44
  41. package/build/image-editor/core/crop-rect.cjs.map +1 -7
  42. package/build/image-editor/core/export/canvas-renderer.cjs +165 -135
  43. package/build/image-editor/core/export/canvas-renderer.cjs.map +1 -7
  44. package/build/image-editor/core/index.cjs +88 -61
  45. package/build/image-editor/core/interaction-controller.cjs +583 -646
  46. package/build/image-editor/core/interaction-controller.cjs.map +1 -7
  47. package/build/image-editor/core/math/rotation.cjs +26 -35
  48. package/build/image-editor/core/math/rotation.cjs.map +1 -7
  49. package/build/image-editor/core/math/sanitize.cjs +124 -80
  50. package/build/image-editor/core/math/sanitize.cjs.map +1 -7
  51. package/build/image-editor/core/setter-helpers.cjs +57 -60
  52. package/build/image-editor/core/setter-helpers.cjs.map +1 -7
  53. package/build/image-editor/core/source-region.cjs +220 -190
  54. package/build/image-editor/core/source-region.cjs.map +1 -7
  55. package/build/image-editor/core/state.cjs +278 -265
  56. package/build/image-editor/core/state.cjs.map +1 -7
  57. package/build/image-editor/core/stencil-math.cjs +193 -206
  58. package/build/image-editor/core/stencil-math.cjs.map +1 -7
  59. package/build/image-editor/core/transform-style.cjs +39 -48
  60. package/build/image-editor/core/transform-style.cjs.map +1 -7
  61. package/build/image-editor/core/transforms/pipeline.cjs +36 -38
  62. package/build/image-editor/core/transforms/pipeline.cjs.map +1 -7
  63. package/build/image-editor/core/types.cjs +4 -18
  64. package/build/image-editor/core/viewport-state.cjs +31 -45
  65. package/build/image-editor/core/viewport-state.cjs.map +1 -7
  66. package/build/image-editor/index.cjs +65 -64
  67. package/build/image-editor/react/components/cropper-provider.cjs +44 -45
  68. package/build/image-editor/react/components/cropper-provider.cjs.map +1 -7
  69. package/build/image-editor/react/components/cropper.cjs +583 -710
  70. package/build/image-editor/react/components/cropper.cjs.map +1 -7
  71. package/build/image-editor/react/components/index.cjs +22 -33
  72. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +135 -160
  73. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +1 -7
  74. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +28 -59
  75. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +1 -7
  76. package/build/image-editor/react/components/overlays/grid-overlay.cjs +58 -88
  77. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +1 -7
  78. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +361 -420
  79. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +1 -7
  80. package/build/image-editor/react/components/viewport-provider.cjs +21 -46
  81. package/build/image-editor/react/components/viewport-provider.cjs.map +1 -7
  82. package/build/image-editor/react/hooks/build-cropper-setters.cjs +76 -67
  83. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +1 -7
  84. package/build/image-editor/react/hooks/index.cjs +16 -31
  85. package/build/image-editor/react/hooks/use-aria-announcer.cjs +90 -146
  86. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +1 -7
  87. package/build/image-editor/react/hooks/use-cropper-controller.cjs +80 -0
  88. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +1 -0
  89. package/build/image-editor/react/hooks/use-interaction.cjs +179 -205
  90. package/build/image-editor/react/hooks/use-interaction.cjs.map +1 -7
  91. package/build/image-editor/react/hooks/use-transform-style.cjs +20 -34
  92. package/build/image-editor/react/hooks/use-transform-style.cjs.map +1 -7
  93. package/build/image-editor/react/hooks/use-viewport-state.cjs +36 -47
  94. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +1 -7
  95. package/build/image-editor/react/visually-hidden-style.cjs +21 -38
  96. package/build/image-editor/react/visually-hidden-style.cjs.map +1 -7
  97. package/build/index.cjs +45 -39
  98. package/build/lock-unlock.cjs +9 -35
  99. package/build/lock-unlock.cjs.map +1 -7
  100. package/build/private-apis.cjs +16 -37
  101. package/build/private-apis.cjs.map +1 -7
  102. package/build/state/aspect-ratio-presets.cjs +53 -0
  103. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  104. package/build/state/composite-reducer.cjs +134 -112
  105. package/build/state/composite-reducer.cjs.map +1 -7
  106. package/build/state/index.cjs +63 -47
  107. package/build/state/media-editor-state-provider.cjs +35 -48
  108. package/build/state/media-editor-state-provider.cjs.map +1 -7
  109. package/build/state/types.cjs +12 -31
  110. package/build/state/types.cjs.map +1 -7
  111. package/build/state/use-media-editor-state.cjs +261 -294
  112. package/build/state/use-media-editor-state.cjs.map +1 -7
  113. package/build/store/actions.cjs +17 -44
  114. package/build/store/actions.cjs.map +1 -7
  115. package/build/store/constants.cjs +8 -29
  116. package/build/store/constants.cjs.map +1 -7
  117. package/build/store/index.cjs +33 -40
  118. package/build/store/index.cjs.map +1 -7
  119. package/build/store/reducer.cjs +28 -50
  120. package/build/store/reducer.cjs.map +1 -7
  121. package/build/store/selectors.cjs +16 -41
  122. package/build/store/selectors.cjs.map +1 -7
  123. package/build/utils/get-media-type.cjs +18 -41
  124. package/build/utils/get-media-type.cjs.map +1 -7
  125. package/build/utils/index.cjs +9 -28
  126. package/build-module/components/media-editor/index.mjs +490 -673
  127. package/build-module/components/media-editor/index.mjs.map +1 -7
  128. package/build-module/components/media-editor/use-crop-options.mjs +38 -32
  129. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  130. package/build-module/components/media-editor/use-save-media-editor.mjs +89 -157
  131. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  132. package/build-module/components/media-editor-canvas/index.mjs +98 -96
  133. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  134. package/build-module/components/media-editor-crop-panel/index.mjs +43 -46
  135. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  136. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -45
  137. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  138. package/build-module/components/media-editor-image-controls/index.mjs +172 -237
  139. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  140. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +112 -137
  141. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  142. package/build-module/components/media-editor-modal/build-modifiers.mjs +103 -64
  143. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +1 -7
  144. package/build-module/components/media-editor-modal/index.mjs +88 -124
  145. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  146. package/build-module/components/media-editor-provider/index.mjs +26 -29
  147. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  148. package/build-module/components/media-form/index.mjs +68 -56
  149. package/build-module/components/media-form/index.mjs.map +1 -7
  150. package/build-module/components/media-preview/index.mjs +106 -90
  151. package/build-module/components/media-preview/index.mjs.map +1 -7
  152. package/build-module/components/rotation-ruler/index.mjs +161 -164
  153. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  154. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  155. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  156. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  157. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  158. package/build-module/image-editor/core/camera.mjs +245 -178
  159. package/build-module/image-editor/core/camera.mjs.map +1 -7
  160. package/build-module/image-editor/core/constants.mjs +110 -64
  161. package/build-module/image-editor/core/constants.mjs.map +1 -7
  162. package/build-module/image-editor/core/containment.mjs +265 -237
  163. package/build-module/image-editor/core/containment.mjs.map +1 -7
  164. package/build-module/image-editor/core/crop-rect.mjs +29 -20
  165. package/build-module/image-editor/core/crop-rect.mjs.map +1 -7
  166. package/build-module/image-editor/core/export/canvas-renderer.mjs +155 -105
  167. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +1 -7
  168. package/build-module/image-editor/core/index.mjs +5 -34
  169. package/build-module/image-editor/core/interaction-controller.mjs +579 -628
  170. package/build-module/image-editor/core/interaction-controller.mjs.map +1 -7
  171. package/build-module/image-editor/core/math/rotation.mjs +21 -10
  172. package/build-module/image-editor/core/math/rotation.mjs.map +1 -7
  173. package/build-module/image-editor/core/math/sanitize.mjs +116 -52
  174. package/build-module/image-editor/core/math/sanitize.mjs.map +1 -7
  175. package/build-module/image-editor/core/setter-helpers.mjs +52 -35
  176. package/build-module/image-editor/core/setter-helpers.mjs.map +1 -7
  177. package/build-module/image-editor/core/source-region.mjs +210 -160
  178. package/build-module/image-editor/core/source-region.mjs.map +1 -7
  179. package/build-module/image-editor/core/state.mjs +271 -243
  180. package/build-module/image-editor/core/state.mjs.map +1 -7
  181. package/build-module/image-editor/core/stencil-math.mjs +185 -178
  182. package/build-module/image-editor/core/stencil-math.mjs.map +1 -7
  183. package/build-module/image-editor/core/transform-style.mjs +34 -23
  184. package/build-module/image-editor/core/transform-style.mjs.map +1 -7
  185. package/build-module/image-editor/core/transforms/pipeline.mjs +29 -11
  186. package/build-module/image-editor/core/transforms/pipeline.mjs.map +1 -7
  187. package/build-module/image-editor/core/types.mjs +0 -1
  188. package/build-module/image-editor/core/viewport-state.mjs +26 -20
  189. package/build-module/image-editor/core/viewport-state.mjs.map +1 -7
  190. package/build-module/image-editor/index.mjs +3 -38
  191. package/build-module/image-editor/react/components/cropper-provider.mjs +38 -21
  192. package/build-module/image-editor/react/components/cropper-provider.mjs.map +1 -7
  193. package/build-module/image-editor/react/components/cropper.mjs +550 -686
  194. package/build-module/image-editor/react/components/cropper.mjs.map +1 -7
  195. package/build-module/image-editor/react/components/index.mjs +1 -7
  196. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +130 -135
  197. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +1 -7
  198. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +24 -35
  199. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +1 -7
  200. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +54 -64
  201. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +1 -7
  202. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +355 -407
  203. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +1 -7
  204. package/build-module/image-editor/react/components/viewport-provider.mjs +15 -22
  205. package/build-module/image-editor/react/components/viewport-provider.mjs.map +1 -7
  206. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +72 -43
  207. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +1 -7
  208. package/build-module/image-editor/react/hooks/index.mjs +2 -7
  209. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +83 -119
  210. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +1 -7
  211. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +75 -0
  212. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +1 -0
  213. package/build-module/image-editor/react/hooks/use-interaction.mjs +175 -183
  214. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +1 -7
  215. package/build-module/image-editor/react/hooks/use-transform-style.mjs +15 -9
  216. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +1 -7
  217. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +32 -26
  218. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +1 -7
  219. package/build-module/image-editor/react/visually-hidden-style.mjs +17 -14
  220. package/build-module/image-editor/react/visually-hidden-style.mjs.map +1 -7
  221. package/build-module/index.mjs +3 -10
  222. package/build-module/lock-unlock.mjs +5 -10
  223. package/build-module/lock-unlock.mjs.map +1 -7
  224. package/build-module/private-apis.mjs +8 -9
  225. package/build-module/private-apis.mjs.map +1 -7
  226. package/build-module/state/aspect-ratio-presets.mjs +48 -0
  227. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  228. package/build-module/state/composite-reducer.mjs +114 -90
  229. package/build-module/state/composite-reducer.mjs.map +1 -7
  230. package/build-module/state/index.mjs +5 -25
  231. package/build-module/state/media-editor-state-provider.mjs +29 -24
  232. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  233. package/build-module/state/types.mjs +8 -7
  234. package/build-module/state/types.mjs.map +1 -7
  235. package/build-module/state/use-media-editor-state.mjs +256 -286
  236. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  237. package/build-module/store/actions.mjs +12 -19
  238. package/build-module/store/actions.mjs.map +1 -7
  239. package/build-module/store/constants.mjs +4 -5
  240. package/build-module/store/constants.mjs.map +1 -7
  241. package/build-module/store/index.mjs +8 -9
  242. package/build-module/store/index.mjs.map +1 -7
  243. package/build-module/store/reducer.mjs +23 -26
  244. package/build-module/store/reducer.mjs.map +1 -7
  245. package/build-module/store/selectors.mjs +8 -13
  246. package/build-module/store/selectors.mjs.map +1 -7
  247. package/build-module/utils/get-media-type.mjs +14 -17
  248. package/build-module/utils/get-media-type.mjs.map +1 -7
  249. package/build-module/utils/index.mjs +1 -6
  250. package/build-style/style-rtl.css +41 -4
  251. package/build-style/style.css +41 -4
  252. package/build-types/components/media-editor/index.d.ts +4 -0
  253. package/build-types/components/media-editor/index.d.ts.map +1 -1
  254. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  255. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  256. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  257. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  258. package/build-types/components/media-editor-modal/build-modifiers.d.ts +6 -5
  259. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
  260. package/build-types/components/media-preview/index.d.ts.map +1 -1
  261. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  262. package/build-types/image-editor/core/constants.d.ts +0 -1
  263. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  264. package/build-types/image-editor/core/index.d.ts +1 -1
  265. package/build-types/image-editor/core/index.d.ts.map +1 -1
  266. package/build-types/image-editor/core/setter-helpers.d.ts +1 -1
  267. package/build-types/image-editor/core/types.d.ts +1 -1
  268. package/build-types/image-editor/index.d.ts +7 -6
  269. package/build-types/image-editor/index.d.ts.map +1 -1
  270. package/build-types/image-editor/react/components/cropper-provider.d.ts +2 -2
  271. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  272. package/build-types/image-editor/react/components/cropper.d.ts +5 -14
  273. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  274. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +2 -2
  275. package/build-types/image-editor/react/hooks/index.d.ts +2 -2
  276. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  277. package/build-types/image-editor/react/hooks/{use-cropper-reducer.d.ts → use-cropper-controller.d.ts} +12 -12
  278. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +1 -0
  279. package/build-types/state/aspect-ratio-presets.d.ts +7 -0
  280. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  281. package/build-types/state/composite-reducer.d.ts +1 -1
  282. package/build-types/state/composite-reducer.d.ts.map +1 -1
  283. package/build-types/state/index.d.ts +1 -0
  284. package/build-types/state/index.d.ts.map +1 -1
  285. package/build-types/state/types.d.ts +2 -1
  286. package/build-types/state/types.d.ts.map +1 -1
  287. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  288. package/package.json +21 -21
  289. package/src/components/media-editor/index.tsx +215 -162
  290. package/src/components/media-editor/style.scss +19 -0
  291. package/src/components/media-editor/use-crop-options.ts +5 -2
  292. package/src/components/media-editor/use-save-media-editor.ts +2 -6
  293. package/src/components/media-editor-canvas/index.tsx +16 -26
  294. package/src/components/media-editor-image-controls/index.tsx +4 -2
  295. package/src/components/media-editor-modal/build-modifiers.ts +13 -7
  296. package/src/components/media-editor-modal/style.scss +1 -1
  297. package/src/components/media-preview/index.tsx +66 -23
  298. package/src/components/media-preview/style.scss +16 -2
  299. package/src/components/rotation-ruler/style.scss +6 -2
  300. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  301. package/src/image-editor/README.md +8 -8
  302. package/src/image-editor/core/constants.ts +0 -13
  303. package/src/image-editor/core/index.ts +1 -5
  304. package/src/image-editor/core/setter-helpers.ts +1 -1
  305. package/src/image-editor/core/types.ts +1 -1
  306. package/src/image-editor/docs/architecture.md +1 -1
  307. package/src/image-editor/docs/recipes.md +3 -3
  308. package/src/image-editor/index.ts +7 -16
  309. package/src/image-editor/react/components/cropper-provider.tsx +5 -5
  310. package/src/image-editor/react/components/cropper.tsx +19 -27
  311. package/src/image-editor/react/hooks/build-cropper-setters.ts +2 -2
  312. package/src/image-editor/react/hooks/index.ts +2 -2
  313. package/src/image-editor/react/hooks/{use-cropper-reducer.ts → use-cropper-controller.ts} +11 -11
  314. package/src/state/aspect-ratio-presets.ts +18 -0
  315. package/src/state/composite-reducer.ts +2 -2
  316. package/src/state/index.ts +1 -0
  317. package/src/state/types.ts +2 -6
  318. package/src/state/use-media-editor-state.ts +7 -5
  319. package/build/image-editor/core/index.cjs.map +0 -7
  320. package/build/image-editor/core/types.cjs.map +0 -7
  321. package/build/image-editor/index.cjs.map +0 -7
  322. package/build/image-editor/react/components/index.cjs.map +0 -7
  323. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  324. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  325. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  326. package/build/index.cjs.map +0 -7
  327. package/build/state/index.cjs.map +0 -7
  328. package/build/utils/index.cjs.map +0 -7
  329. package/build-module/image-editor/core/index.mjs.map +0 -7
  330. package/build-module/image-editor/core/types.mjs.map +0 -7
  331. package/build-module/image-editor/index.mjs.map +0 -7
  332. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  333. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  334. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  335. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  336. package/build-module/index.mjs.map +0 -7
  337. package/build-module/state/index.mjs.map +0 -7
  338. package/build-module/utils/index.mjs.map +0 -7
  339. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
@@ -1,119 +1,119 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/components/media-preview/index.tsx
21
- var media_preview_exports = {};
22
- __export(media_preview_exports, {
23
- default: () => MediaPreview
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(media_preview_exports);
26
- var import_components = require("@wordpress/components");
27
- var import_element = require("@wordpress/element");
28
- var import_i18n = require("@wordpress/i18n");
29
- var import_media_editor_provider = require("../media-editor-provider/index.cjs");
30
- var import_utils = require("../../utils/index.cjs");
31
- var import_jsx_runtime = require("react/jsx-runtime");
32
- function MediaPreviewContent({
33
- mediaType,
34
- mediaUrl,
35
- altText,
36
- displayTitle,
37
- mimeType,
38
- onLoad,
39
- onError,
40
- loadingState
41
- }) {
42
- switch (mediaType.type) {
43
- case "image":
44
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
- "img",
46
- {
47
- className: loadingState === "loaded" ? "loaded" : "",
48
- src: mediaUrl,
49
- alt: altText || "",
50
- onLoad,
51
- onError
52
- }
53
- );
54
- case "video":
55
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("video", { src: mediaUrl, controls: true, onError, children: displayTitle });
56
- case "audio":
57
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("audio", { src: mediaUrl, controls: true, onError, children: displayTitle });
58
- default:
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-preview__file-info", children: [
60
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "media-editor-preview__file-name", children: displayTitle }),
61
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "media-editor-preview__mime-type", children: mimeType }),
62
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
- "a",
64
- {
65
- href: mediaUrl,
66
- target: "_blank",
67
- rel: "noopener",
68
- className: "media-editor-preview__download-link",
69
- children: (0, import_i18n.__)("View file")
70
- }
71
- )
72
- ] });
73
- }
6
+ let _wordpress_components = require("@wordpress/components");
7
+ let _wordpress_element = require("@wordpress/element");
8
+ let _wordpress_i18n = require("@wordpress/i18n");
9
+ let ___media_editor_provider_index_tsx = require("../media-editor-provider/index.cjs");
10
+ let ______utils_index_ts = require("../../utils/index.cjs");
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ // packages/media-editor/src/components/media-preview/index.tsx
13
+ function MediaPreviewFileInfo({ mediaUrl, displayTitle, mimeType }) {
14
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15
+ className: "media-editor-preview__file-info",
16
+ children: [
17
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18
+ className: "media-editor-preview__file-name",
19
+ children: displayTitle
20
+ }),
21
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
22
+ className: "media-editor-preview__mime-type",
23
+ children: mimeType
24
+ }),
25
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
26
+ href: mediaUrl,
27
+ target: "_blank",
28
+ rel: "noopener",
29
+ className: "media-editor-preview__download-link",
30
+ children: (0, _wordpress_i18n.__)("View file")
31
+ })
32
+ ]
33
+ });
74
34
  }
35
+ function MediaPreviewContent({ previewType, mediaUrl, altText, displayTitle, mimeType, onLoad, onError, loadingState }) {
36
+ switch (previewType) {
37
+ case "image": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
38
+ className: loadingState === "loaded" ? "loaded" : "",
39
+ src: mediaUrl,
40
+ alt: altText || "",
41
+ onLoad,
42
+ onError
43
+ });
44
+ case "video": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("video", {
45
+ src: mediaUrl,
46
+ controls: true,
47
+ onError,
48
+ children: displayTitle
49
+ });
50
+ case "audio": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("audio", {
51
+ src: mediaUrl,
52
+ controls: true,
53
+ onError,
54
+ children: displayTitle
55
+ });
56
+ case "pdf": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("object", {
57
+ className: "media-editor-preview__pdf",
58
+ data: `${mediaUrl}#view=Fit&zoom=page-fit`,
59
+ type: "application/pdf",
60
+ "aria-label": (0, _wordpress_i18n.__)("Embed of the selected PDF file."),
61
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaPreviewFileInfo, {
62
+ mediaUrl,
63
+ displayTitle,
64
+ mimeType
65
+ })
66
+ });
67
+ default: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaPreviewFileInfo, {
68
+ mediaUrl,
69
+ displayTitle,
70
+ mimeType
71
+ });
72
+ }
73
+ }
74
+ /**
75
+ * MediaPreview component displays the media file in the editor canvas.
76
+ * Supports images, videos, audio files, and generic file displays.
77
+ *
78
+ * @param props - Component props including click handlers and accessibility attributes.
79
+ * @return The MediaPreview component.
80
+ */
75
81
  function MediaPreview(props) {
76
- const [loadingState, setLoadingState] = (0, import_element.useState)("loading");
77
- const { media } = (0, import_media_editor_provider.useMediaEditorContext)();
78
- const {
79
- source_url: mediaUrl,
80
- mime_type: mimeType,
81
- alt_text: altText,
82
- title
83
- } = media || {};
84
- const mediaType = (0, import_utils.getMediaTypeFromMimeType)(mimeType);
85
- if (!mediaUrl) {
86
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor-preview media-editor-preview--empty", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (0, import_i18n.__)("No media file available.") }) });
87
- }
88
- if (loadingState === "error") {
89
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-preview media-editor-preview--error", children: [
90
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (0, import_i18n.__)("Failed to load media file.") }),
91
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "media-editor-preview__url", children: mediaUrl })
92
- ] });
93
- }
94
- const displayTitle = typeof title === "string" ? title : title?.rendered || title?.raw;
95
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
96
- "div",
97
- {
98
- ...props,
99
- className: `media-editor-preview media-editor-preview--${mediaType.type}`,
100
- children: [
101
- mediaType.type === "image" && loadingState === "loading" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor-preview__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }),
102
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
103
- MediaPreviewContent,
104
- {
105
- mediaType,
106
- mediaUrl,
107
- altText,
108
- displayTitle,
109
- mimeType,
110
- onLoad: () => setLoadingState("loaded"),
111
- onError: () => setLoadingState("error"),
112
- loadingState
113
- }
114
- )
115
- ]
116
- }
117
- );
82
+ const [loadingState, setLoadingState] = (0, _wordpress_element.useState)("loading");
83
+ const { media } = (0, ___media_editor_provider_index_tsx.useMediaEditorContext)();
84
+ const { source_url: mediaUrl, mime_type: mimeType, alt_text: altText, title } = media || {};
85
+ const mediaType = (0, ______utils_index_ts.getMediaTypeFromMimeType)(mimeType);
86
+ const previewType = mimeType === "application/pdf" && window.navigator.pdfViewerEnabled ? "pdf" : mediaType.type;
87
+ if (!mediaUrl) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
88
+ className: "media-editor-preview media-editor-preview--empty",
89
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: (0, _wordpress_i18n.__)("No media file available.") })
90
+ });
91
+ if (loadingState === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
92
+ className: "media-editor-preview media-editor-preview--error",
93
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: (0, _wordpress_i18n.__)("Failed to load media file.") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
94
+ className: "media-editor-preview__url",
95
+ children: mediaUrl
96
+ })]
97
+ });
98
+ const displayTitle = typeof title === "string" ? title : title?.rendered || title?.raw;
99
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
100
+ ...props,
101
+ className: `media-editor-preview media-editor-preview--${previewType}`,
102
+ children: [previewType === "image" && loadingState === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
103
+ className: "media-editor-preview__spinner",
104
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
105
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaPreviewContent, {
106
+ previewType,
107
+ mediaUrl,
108
+ altText,
109
+ displayTitle,
110
+ mimeType,
111
+ onLoad: () => setLoadingState("loaded"),
112
+ onError: () => setLoadingState("error"),
113
+ loadingState
114
+ })]
115
+ });
118
116
  }
119
- //# sourceMappingURL=index.cjs.map
117
+ exports.default = MediaPreview;
118
+
119
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/media-preview/index.tsx"],
4
- "sourcesContent": ["import { Spinner as WCSpinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\n\n/**\n * Props for MediaPreview component.\n */\nexport interface MediaPreviewProps {\n\t[ key: string ]: any; // TODO: Define specific props as needed, this will likely be for click handlers, accessibility attributes, etc.\n}\n\n/**\n * Props for MediaPreviewContent component.\n */\ninterface MediaPreviewContentProps {\n\tmediaType: { type: string };\n\tmediaUrl: string;\n\taltText?: string;\n\tdisplayTitle?: string;\n\tmimeType?: string;\n\tonLoad: () => void;\n\tonError: () => void;\n\tloadingState: 'loading' | 'loaded' | 'error';\n}\n\nfunction MediaPreviewContent( {\n\tmediaType,\n\tmediaUrl,\n\taltText,\n\tdisplayTitle,\n\tmimeType,\n\tonLoad,\n\tonError,\n\tloadingState,\n}: MediaPreviewContentProps ) {\n\tswitch ( mediaType.type ) {\n\t\tcase 'image':\n\t\t\treturn (\n\t\t\t\t<img\n\t\t\t\t\tclassName={ loadingState === 'loaded' ? 'loaded' : '' }\n\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\talt={ altText || '' }\n\t\t\t\t\tonLoad={ onLoad }\n\t\t\t\t\tonError={ onError }\n\t\t\t\t/>\n\t\t\t);\n\t\tcase 'video':\n\t\t\treturn (\n\t\t\t\t<video src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</video>\n\t\t\t);\n\t\tcase 'audio':\n\t\t\treturn (\n\t\t\t\t<audio src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</audio>\n\t\t\t);\n\t\tdefault:\n\t\t\treturn (\n\t\t\t\t<div className=\"media-editor-preview__file-info\">\n\t\t\t\t\t<p className=\"media-editor-preview__file-name\">\n\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t</p>\n\t\t\t\t\t<p className=\"media-editor-preview__mime-type\">\n\t\t\t\t\t\t{ mimeType }\n\t\t\t\t\t</p>\n\t\t\t\t\t{ /* eslint-disable-next-line react/jsx-no-target-blank */ }\n\t\t\t\t\t<a\n\t\t\t\t\t\thref={ mediaUrl }\n\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\trel=\"noopener\"\n\t\t\t\t\t\tclassName=\"media-editor-preview__download-link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'View file' ) }\n\t\t\t\t\t</a>\n\t\t\t\t</div>\n\t\t\t);\n\t}\n}\n\n/**\n * MediaPreview component displays the media file in the editor canvas.\n * Supports images, videos, audio files, and generic file displays.\n *\n * @param props - Component props including click handlers and accessibility attributes.\n * @return The MediaPreview component.\n */\nexport default function MediaPreview( props: MediaPreviewProps ) {\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'loading' | 'loaded' | 'error'\n\t>( 'loading' );\n\tconst { media } = useMediaEditorContext();\n\n\tconst {\n\t\tsource_url: mediaUrl,\n\t\tmime_type: mimeType,\n\t\talt_text: altText,\n\t\ttitle,\n\t} = media || {};\n\n\tconst mediaType = getMediaTypeFromMimeType( mimeType );\n\n\tif ( ! mediaUrl ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--empty\">\n\t\t\t\t<p>{ __( 'No media file available.' ) }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( loadingState === 'error' ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--error\">\n\t\t\t\t<p>{ __( 'Failed to load media file.' ) }</p>\n\t\t\t\t<p className=\"media-editor-preview__url\">{ mediaUrl }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst displayTitle =\n\t\ttypeof title === 'string' ? title : title?.rendered || title?.raw;\n\n\treturn (\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tclassName={ `media-editor-preview media-editor-preview--${ mediaType.type }` }\n\t\t>\n\t\t\t{ mediaType.type === 'image' && loadingState === 'loading' && (\n\t\t\t\t<div className=\"media-editor-preview__spinner\">\n\t\t\t\t\t<WCSpinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<MediaPreviewContent\n\t\t\t\tmediaType={ mediaType }\n\t\t\t\tmediaUrl={ mediaUrl }\n\t\t\t\taltText={ altText }\n\t\t\t\tdisplayTitle={ displayTitle }\n\t\t\t\tmimeType={ mimeType }\n\t\t\t\tonLoad={ () => setLoadingState( 'loaded' ) }\n\t\t\t\tonError={ () => setLoadingState( 'error' ) }\n\t\t\t\tloadingState={ loadingState }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqC;AACrC,qBAAyB;AACzB,kBAAmB;AACnB,mCAAsC;AACtC,mBAAyC;AAoCrC;AAbJ,SAAS,oBAAqB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,UAAS,UAAU,MAAO;AAAA,IACzB,KAAK;AACJ,aACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAY,iBAAiB,WAAW,WAAW;AAAA,UACnD,KAAM;AAAA,UACN,KAAM,WAAW;AAAA,UACjB;AAAA,UACA;AAAA;AAAA,MACD;AAAA,IAEF,KAAK;AACJ,aACC,4CAAC,WAAM,KAAM,UAAW,UAAQ,MAAC,SAC9B,wBACH;AAAA,IAEF,KAAK;AACJ,aACC,4CAAC,WAAM,KAAM,UAAW,UAAQ,MAAC,SAC9B,wBACH;AAAA,IAEF;AACC,aACC,6CAAC,SAAI,WAAU,mCACd;AAAA,oDAAC,OAAE,WAAU,mCACV,wBACH;AAAA,QACA,4CAAC,OAAE,WAAU,mCACV,oBACH;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACA,MAAO;AAAA,YACP,QAAO;AAAA,YACP,KAAI;AAAA,YACJ,WAAU;AAAA,YAER,8BAAI,WAAY;AAAA;AAAA,QACnB;AAAA,SACD;AAAA,EAEH;AACD;AASe,SAAR,aAA+B,OAA2B;AAChE,QAAM,CAAE,cAAc,eAAgB,QAAI,yBAEvC,SAAU;AACb,QAAM,EAAE,MAAM,QAAI,oDAAsB;AAExC,QAAM;AAAA,IACL,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,EACD,IAAI,SAAS,CAAC;AAEd,QAAM,gBAAY,uCAA0B,QAAS;AAErD,MAAK,CAAE,UAAW;AACjB,WACC,4CAAC,SAAI,WAAU,oDACd,sDAAC,OAAI,8BAAI,0BAA2B,GAAG,GACxC;AAAA,EAEF;AAEA,MAAK,iBAAiB,SAAU;AAC/B,WACC,6CAAC,SAAI,WAAU,oDACd;AAAA,kDAAC,OAAI,8BAAI,4BAA6B,GAAG;AAAA,MACzC,4CAAC,OAAE,WAAU,6BAA8B,oBAAU;AAAA,OACtD;AAAA,EAEF;AAEA,QAAM,eACL,OAAO,UAAU,WAAW,QAAQ,OAAO,YAAY,OAAO;AAE/D,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,WAAY,8CAA+C,UAAU,IAAK;AAAA,MAExE;AAAA,kBAAU,SAAS,WAAW,iBAAiB,aAChD,4CAAC,SAAI,WAAU,iCACd,sDAAC,kBAAAA,SAAA,EAAU,GACZ;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,QAAS,MAAM,gBAAiB,QAAS;AAAA,YACzC,SAAU,MAAM,gBAAiB,OAAQ;AAAA,YACzC;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;",
6
- "names": ["WCSpinner"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["__","useState","useMediaEditorContext","getMediaTypeFromMimeType","WCSpinner"],"sources":["../../../src/components/media-preview/index.tsx"],"sourcesContent":["import { Spinner as WCSpinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\n\n/**\n * Props for MediaPreview component.\n */\nexport interface MediaPreviewProps {\n\t[ key: string ]: any; // TODO: Define specific props as needed, this will likely be for click handlers, accessibility attributes, etc.\n}\n\n/**\n * Props for MediaPreviewContent component.\n */\ninterface MediaPreviewContentProps {\n\tpreviewType: string;\n\tmediaUrl: string;\n\taltText?: string;\n\tdisplayTitle?: string;\n\tmimeType?: string;\n\tonLoad: () => void;\n\tonError: () => void;\n\tloadingState: 'loading' | 'loaded' | 'error';\n}\n\ninterface MediaPreviewFileInfoProps {\n\tmediaUrl: string;\n\tdisplayTitle?: string;\n\tmimeType?: string;\n}\n\nfunction MediaPreviewFileInfo( {\n\tmediaUrl,\n\tdisplayTitle,\n\tmimeType,\n}: MediaPreviewFileInfoProps ) {\n\treturn (\n\t\t<div className=\"media-editor-preview__file-info\">\n\t\t\t<p className=\"media-editor-preview__file-name\">{ displayTitle }</p>\n\t\t\t<p className=\"media-editor-preview__mime-type\">{ mimeType }</p>\n\t\t\t{ /* eslint-disable-next-line react/jsx-no-target-blank */ }\n\t\t\t<a\n\t\t\t\thref={ mediaUrl }\n\t\t\t\ttarget=\"_blank\"\n\t\t\t\trel=\"noopener\"\n\t\t\t\tclassName=\"media-editor-preview__download-link\"\n\t\t\t>\n\t\t\t\t{ __( 'View file' ) }\n\t\t\t</a>\n\t\t</div>\n\t);\n}\n\nfunction MediaPreviewContent( {\n\tpreviewType,\n\tmediaUrl,\n\taltText,\n\tdisplayTitle,\n\tmimeType,\n\tonLoad,\n\tonError,\n\tloadingState,\n}: MediaPreviewContentProps ) {\n\tswitch ( previewType ) {\n\t\tcase 'image':\n\t\t\treturn (\n\t\t\t\t<img\n\t\t\t\t\tclassName={ loadingState === 'loaded' ? 'loaded' : '' }\n\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\talt={ altText || '' }\n\t\t\t\t\tonLoad={ onLoad }\n\t\t\t\t\tonError={ onError }\n\t\t\t\t/>\n\t\t\t);\n\t\tcase 'video':\n\t\t\treturn (\n\t\t\t\t<video src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</video>\n\t\t\t);\n\t\tcase 'audio':\n\t\t\treturn (\n\t\t\t\t<audio src={ mediaUrl } controls onError={ onError }>\n\t\t\t\t\t{ displayTitle }\n\t\t\t\t</audio>\n\t\t\t);\n\t\tcase 'pdf':\n\t\t\t// The browser renders the children instead of the PDF when it\n\t\t\t// can't display it, e.g. when the request fails.\n\t\t\treturn (\n\t\t\t\t<object\n\t\t\t\t\tclassName=\"media-editor-preview__pdf\"\n\t\t\t\t\t// Ask the viewer to fit the whole page rather than the\n\t\t\t\t\t// width. Chrome reads `view`, Firefox reads `zoom`, and\n\t\t\t\t\t// Safari ignores both.\n\t\t\t\t\tdata={ `${ mediaUrl }#view=Fit&zoom=page-fit` }\n\t\t\t\t\ttype=\"application/pdf\"\n\t\t\t\t\taria-label={ __( 'Embed of the selected PDF file.' ) }\n\t\t\t\t>\n\t\t\t\t\t<MediaPreviewFileInfo\n\t\t\t\t\t\tmediaUrl={ mediaUrl }\n\t\t\t\t\t\tdisplayTitle={ displayTitle }\n\t\t\t\t\t\tmimeType={ mimeType }\n\t\t\t\t\t/>\n\t\t\t\t</object>\n\t\t\t);\n\t\tdefault:\n\t\t\treturn (\n\t\t\t\t<MediaPreviewFileInfo\n\t\t\t\t\tmediaUrl={ mediaUrl }\n\t\t\t\t\tdisplayTitle={ displayTitle }\n\t\t\t\t\tmimeType={ mimeType }\n\t\t\t\t/>\n\t\t\t);\n\t}\n}\n\n/**\n * MediaPreview component displays the media file in the editor canvas.\n * Supports images, videos, audio files, and generic file displays.\n *\n * @param props - Component props including click handlers and accessibility attributes.\n * @return The MediaPreview component.\n */\nexport default function MediaPreview( props: MediaPreviewProps ) {\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'loading' | 'loaded' | 'error'\n\t>( 'loading' );\n\tconst { media } = useMediaEditorContext();\n\n\tconst {\n\t\tsource_url: mediaUrl,\n\t\tmime_type: mimeType,\n\t\talt_text: altText,\n\t\ttitle,\n\t} = media || {};\n\n\tconst mediaType = getMediaTypeFromMimeType( mimeType );\n\n\t// Without a built-in PDF viewer (e.g. on most mobile browsers), show\n\t// the file info instead of an embed that can't render.\n\tconst previewType =\n\t\tmimeType === 'application/pdf' && window.navigator.pdfViewerEnabled\n\t\t\t? 'pdf'\n\t\t\t: mediaType.type;\n\n\tif ( ! mediaUrl ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--empty\">\n\t\t\t\t<p>{ __( 'No media file available.' ) }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( loadingState === 'error' ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-preview media-editor-preview--error\">\n\t\t\t\t<p>{ __( 'Failed to load media file.' ) }</p>\n\t\t\t\t<p className=\"media-editor-preview__url\">{ mediaUrl }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst displayTitle =\n\t\ttypeof title === 'string' ? title : title?.rendered || title?.raw;\n\n\treturn (\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tclassName={ `media-editor-preview media-editor-preview--${ previewType }` }\n\t\t>\n\t\t\t{ previewType === 'image' && loadingState === 'loading' && (\n\t\t\t\t<div className=\"media-editor-preview__spinner\">\n\t\t\t\t\t<WCSpinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<MediaPreviewContent\n\t\t\t\tpreviewType={ previewType }\n\t\t\t\tmediaUrl={ mediaUrl }\n\t\t\t\taltText={ altText }\n\t\t\t\tdisplayTitle={ displayTitle }\n\t\t\t\tmimeType={ mimeType }\n\t\t\t\tonLoad={ () => setLoadingState( 'loaded' ) }\n\t\t\t\tonError={ () => setLoadingState( 'error' ) }\n\t\t\t\tloadingState={ loadingState }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"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"}