@wordpress/media-editor 0.22.0 → 0.24.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 (391) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/build/components/media-editor/index.cjs +229 -126
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-crop-options.cjs +4 -5
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -1
  6. package/build/components/media-editor/use-save-media-editor.cjs +41 -11
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +15 -18
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +26 -8
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +13 -12
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  14. package/build/components/media-editor-image-controls/index.cjs +4 -6
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -1
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +33 -33
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs +10 -7
  19. package/build/components/media-editor-modal/index.cjs.map +1 -1
  20. package/build/components/media-editor-panel/error-boundary.cjs +68 -0
  21. package/build/components/media-editor-panel/error-boundary.cjs.map +1 -0
  22. package/build/components/media-editor-panel/index.cjs +158 -0
  23. package/build/components/media-editor-panel/index.cjs.map +1 -0
  24. package/build/components/media-form/index.cjs +7 -1
  25. package/build/components/media-form/index.cjs.map +1 -1
  26. package/build/components/media-preview/index.cjs +143 -37
  27. package/build/components/media-preview/index.cjs.map +1 -1
  28. package/build/components/rotation-ruler/index.cjs +9 -7
  29. package/build/components/rotation-ruler/index.cjs.map +1 -1
  30. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -1
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -1
  32. package/build/index.cjs +10 -8
  33. package/build/private-apis.cjs.map +1 -1
  34. package/build/state/aspect-ratio-presets.cjs +12 -6
  35. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  36. package/build/state/composite-reducer.cjs +41 -74
  37. package/build/state/composite-reducer.cjs.map +1 -1
  38. package/build/state/index.cjs +0 -39
  39. package/build/state/types.cjs +1 -2
  40. package/build/state/types.cjs.map +1 -1
  41. package/build/state/use-media-editor-state.cjs +70 -106
  42. package/build/state/use-media-editor-state.cjs.map +1 -1
  43. package/build/store/index.cjs +11 -9
  44. package/build/store/index.cjs.map +1 -1
  45. package/build/utils/get-media-type.cjs +8 -0
  46. package/build/utils/get-media-type.cjs.map +1 -1
  47. package/build/utils/index.cjs +6 -0
  48. package/build-module/components/media-editor/index.mjs +217 -117
  49. package/build-module/components/media-editor/index.mjs.map +1 -1
  50. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  51. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  52. package/build-module/components/media-editor/use-save-media-editor.mjs +32 -4
  53. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  54. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  55. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  56. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  57. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  58. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  59. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  60. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  61. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  62. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +33 -33
  63. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  64. package/build-module/components/media-editor-modal/index.mjs +1 -0
  65. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  66. package/build-module/components/media-editor-panel/error-boundary.mjs +63 -0
  67. package/build-module/components/media-editor-panel/error-boundary.mjs.map +1 -0
  68. package/build-module/components/media-editor-panel/index.mjs +123 -0
  69. package/build-module/components/media-editor-panel/index.mjs.map +1 -0
  70. package/build-module/components/media-form/index.mjs +7 -1
  71. package/build-module/components/media-form/index.mjs.map +1 -1
  72. package/build-module/components/media-preview/index.mjs +123 -41
  73. package/build-module/components/media-preview/index.mjs.map +1 -1
  74. package/build-module/state/aspect-ratio-presets.mjs +12 -7
  75. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  76. package/build-module/state/composite-reducer.mjs +32 -67
  77. package/build-module/state/composite-reducer.mjs.map +1 -1
  78. package/build-module/state/index.mjs +2 -5
  79. package/build-module/state/types.mjs +1 -2
  80. package/build-module/state/types.mjs.map +1 -1
  81. package/build-module/state/use-media-editor-state.mjs +70 -105
  82. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  83. package/build-module/utils/get-media-type.mjs +8 -1
  84. package/build-module/utils/get-media-type.mjs.map +1 -1
  85. package/build-module/utils/index.mjs +1 -1
  86. package/build-style/style-rtl.css +122 -87
  87. package/build-style/style.css +121 -87
  88. package/build-types/components/media-editor/index.d.ts +25 -3
  89. package/build-types/components/media-editor/index.d.ts.map +1 -1
  90. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  91. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  92. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  93. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  94. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  95. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  96. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  97. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  98. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  99. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  100. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  101. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  102. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  103. package/build-types/components/media-editor-panel/error-boundary.d.ts +23 -0
  104. package/build-types/components/media-editor-panel/error-boundary.d.ts.map +1 -0
  105. package/build-types/components/media-editor-panel/index.d.ts +46 -0
  106. package/build-types/components/media-editor-panel/index.d.ts.map +1 -0
  107. package/build-types/components/media-form/index.d.ts.map +1 -1
  108. package/build-types/components/media-preview/index.d.ts.map +1 -1
  109. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  110. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  111. package/build-types/state/composite-reducer.d.ts +17 -19
  112. package/build-types/state/composite-reducer.d.ts.map +1 -1
  113. package/build-types/state/index.d.ts +2 -5
  114. package/build-types/state/index.d.ts.map +1 -1
  115. package/build-types/state/types.d.ts +20 -64
  116. package/build-types/state/types.d.ts.map +1 -1
  117. package/build-types/state/use-media-editor-state.d.ts +40 -54
  118. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  119. package/build-types/utils/get-media-type.d.ts +3 -1
  120. package/build-types/utils/get-media-type.d.ts.map +1 -1
  121. package/build-types/utils/index.d.ts +1 -1
  122. package/build-types/utils/index.d.ts.map +1 -1
  123. package/package.json +27 -24
  124. package/src/components/media-editor/index.tsx +372 -142
  125. package/src/components/media-editor/style.scss +21 -1
  126. package/src/components/media-editor/use-crop-options.ts +7 -11
  127. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  128. package/src/components/media-editor-canvas/index.tsx +15 -26
  129. package/src/components/media-editor-canvas/style.scss +6 -6
  130. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  131. package/src/components/media-editor-crop-panel/style.scss +21 -0
  132. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  133. package/src/components/media-editor-image-controls/index.tsx +11 -9
  134. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +56 -63
  135. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  136. package/src/components/media-editor-modal/index.tsx +4 -1
  137. package/src/components/media-editor-panel/error-boundary.tsx +88 -0
  138. package/src/components/media-editor-panel/index.tsx +211 -0
  139. package/src/components/media-form/index.tsx +7 -1
  140. package/src/components/media-preview/index.tsx +195 -37
  141. package/src/components/media-preview/style.scss +11 -32
  142. package/src/components/rotation-ruler/style.scss +3 -3
  143. package/src/state/README.md +34 -0
  144. package/src/state/aspect-ratio-presets.ts +22 -3
  145. package/src/state/composite-reducer.ts +42 -80
  146. package/src/state/index.ts +2 -18
  147. package/src/state/types.ts +18 -68
  148. package/src/state/use-media-editor-state.ts +162 -242
  149. package/src/style.scss +2 -1
  150. package/src/utils/get-media-type.ts +9 -1
  151. package/src/utils/index.ts +1 -1
  152. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  153. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  154. package/build/image-editor/core/camera.cjs +0 -277
  155. package/build/image-editor/core/camera.cjs.map +0 -1
  156. package/build/image-editor/core/constants.cjs +0 -133
  157. package/build/image-editor/core/constants.cjs.map +0 -1
  158. package/build/image-editor/core/containment.cjs +0 -289
  159. package/build/image-editor/core/containment.cjs.map +0 -1
  160. package/build/image-editor/core/crop-rect.cjs +0 -37
  161. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  162. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  163. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  164. package/build/image-editor/core/index.cjs +0 -89
  165. package/build/image-editor/core/interaction-controller.cjs +0 -591
  166. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  167. package/build/image-editor/core/math/rotation.cjs +0 -32
  168. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  169. package/build/image-editor/core/math/sanitize.cjs +0 -136
  170. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  171. package/build/image-editor/core/setter-helpers.cjs +0 -61
  172. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  173. package/build/image-editor/core/source-region.cjs +0 -236
  174. package/build/image-editor/core/source-region.cjs.map +0 -1
  175. package/build/image-editor/core/state.cjs +0 -296
  176. package/build/image-editor/core/state.cjs.map +0 -1
  177. package/build/image-editor/core/stencil-math.cjs +0 -203
  178. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  179. package/build/image-editor/core/transform-style.cjs +0 -43
  180. package/build/image-editor/core/transform-style.cjs.map +0 -1
  181. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  182. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  183. package/build/image-editor/core/types.cjs +0 -5
  184. package/build/image-editor/core/viewport-state.cjs +0 -36
  185. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  186. package/build/image-editor/index.cjs +0 -68
  187. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  188. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  189. package/build/image-editor/react/components/cropper.cjs +0 -595
  190. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  191. package/build/image-editor/react/components/index.cjs +0 -25
  192. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  193. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  194. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  195. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  196. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  197. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  198. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  199. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  200. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  201. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  202. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  203. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  204. package/build/image-editor/react/hooks/index.cjs +0 -19
  205. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  206. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  207. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  208. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  209. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  210. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  211. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  212. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  213. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  214. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  215. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  216. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  217. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  218. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  219. package/build-module/image-editor/core/camera.mjs +0 -265
  220. package/build-module/image-editor/core/camera.mjs.map +0 -1
  221. package/build-module/image-editor/core/constants.mjs +0 -115
  222. package/build-module/image-editor/core/constants.mjs.map +0 -1
  223. package/build-module/image-editor/core/containment.mjs +0 -281
  224. package/build-module/image-editor/core/containment.mjs.map +0 -1
  225. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  226. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  227. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  228. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  229. package/build-module/image-editor/core/index.mjs +0 -7
  230. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  231. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  232. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  233. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  234. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  235. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  236. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  237. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  238. package/build-module/image-editor/core/source-region.mjs +0 -228
  239. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  240. package/build-module/image-editor/core/state.mjs +0 -288
  241. package/build-module/image-editor/core/state.mjs.map +0 -1
  242. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  243. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  244. package/build-module/image-editor/core/transform-style.mjs +0 -38
  245. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  246. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  247. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  248. package/build-module/image-editor/core/types.mjs +0 -0
  249. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  250. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  251. package/build-module/image-editor/index.mjs +0 -4
  252. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  253. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  254. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  255. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  256. package/build-module/image-editor/react/components/index.mjs +0 -3
  257. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  258. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  259. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  260. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  261. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  262. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  263. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  264. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  265. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  266. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  267. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  268. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  269. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  270. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  271. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  272. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  273. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  274. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  275. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  276. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  277. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  278. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  279. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  280. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  281. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  282. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  283. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  284. package/build-types/image-editor/core/camera.d.ts +0 -128
  285. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  286. package/build-types/image-editor/core/constants.d.ts +0 -98
  287. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  288. package/build-types/image-editor/core/containment.d.ts +0 -72
  289. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  290. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  291. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  292. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  293. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  294. package/build-types/image-editor/core/index.d.ts +0 -10
  295. package/build-types/image-editor/core/index.d.ts.map +0 -1
  296. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  297. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  298. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  299. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  300. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  301. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  302. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  303. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  304. package/build-types/image-editor/core/source-region.d.ts +0 -94
  305. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  306. package/build-types/image-editor/core/state.d.ts +0 -51
  307. package/build-types/image-editor/core/state.d.ts.map +0 -1
  308. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  309. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  310. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  311. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  312. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  313. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  314. package/build-types/image-editor/core/types.d.ts +0 -269
  315. package/build-types/image-editor/core/types.d.ts.map +0 -1
  316. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  317. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  318. package/build-types/image-editor/index.d.ts +0 -17
  319. package/build-types/image-editor/index.d.ts.map +0 -1
  320. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  321. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  322. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  323. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  324. package/build-types/image-editor/react/components/index.d.ts +0 -4
  325. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  326. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  327. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  328. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  329. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  330. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  331. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  332. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  333. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  334. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  335. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  336. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  337. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  338. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  339. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  340. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  341. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  342. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  343. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  344. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  345. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  346. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  347. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  348. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  349. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  350. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  351. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  352. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  353. package/src/image-editor/README.md +0 -61
  354. package/src/image-editor/core/camera.ts +0 -429
  355. package/src/image-editor/core/constants.ts +0 -137
  356. package/src/image-editor/core/containment.ts +0 -469
  357. package/src/image-editor/core/crop-rect.ts +0 -42
  358. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  359. package/src/image-editor/core/index.ts +0 -43
  360. package/src/image-editor/core/interaction-controller.ts +0 -976
  361. package/src/image-editor/core/math/rotation.ts +0 -26
  362. package/src/image-editor/core/math/sanitize.ts +0 -155
  363. package/src/image-editor/core/setter-helpers.ts +0 -63
  364. package/src/image-editor/core/source-region.ts +0 -367
  365. package/src/image-editor/core/state.ts +0 -484
  366. package/src/image-editor/core/stencil-math.ts +0 -379
  367. package/src/image-editor/core/transform-style.ts +0 -56
  368. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  369. package/src/image-editor/core/types.ts +0 -230
  370. package/src/image-editor/core/viewport-state.ts +0 -30
  371. package/src/image-editor/docs/architecture.md +0 -63
  372. package/src/image-editor/docs/recipes.md +0 -184
  373. package/src/image-editor/index.ts +0 -43
  374. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  375. package/src/image-editor/react/components/cropper.scss +0 -259
  376. package/src/image-editor/react/components/cropper.tsx +0 -1108
  377. package/src/image-editor/react/components/index.ts +0 -3
  378. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  379. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  380. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  381. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  382. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  383. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  384. package/src/image-editor/react/hooks/index.ts +0 -4
  385. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  386. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  387. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  388. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  389. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  390. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  391. package/src/image-editor/style.scss +0 -1
@@ -1,15 +1,17 @@
1
1
  import clsx from "clsx";
2
- import { Button, DropdownMenu, MenuGroup, MenuItem, Spinner, __experimentalConfirmDialog, __unstableAnimatePresence, __unstableMotion } from "@wordpress/components";
2
+ import { Button, DropdownMenu, MenuGroup, MenuItem, Modal, Slot, SlotFillProvider, Spinner, __experimentalConfirmDialog, __unstableAnimatePresence, __unstableMotion } from "@wordpress/components";
3
3
  import { Stack, Tabs, VisuallyHidden } from "@wordpress/ui";
4
+ import { PluginArea } from "@wordpress/plugins";
4
5
  import { useReducedMotion, useViewportMatch } from "@wordpress/compose";
5
- import { useDispatch, useSelect } from "@wordpress/data";
6
+ import { useDispatch, useRegistry, useSelect } from "@wordpress/data";
6
7
  import { store } from "@wordpress/core-data";
7
8
  import { NavigableRegion } from "@wordpress/admin-ui";
8
- import { createContext, createPortal, useCallback, useContext, useEffect, useRef, useState } from "@wordpress/element";
9
- import { __ } from "@wordpress/i18n";
9
+ import { createContext, createPortal, useCallback, useContext, useEffect, useMemo, useRef, useState } from "@wordpress/element";
10
+ import { __, _x, sprintf } from "@wordpress/i18n";
10
11
  import { backup, close, drawerRight, keyboard, moreVertical, redo, undo } from "@wordpress/icons";
11
- import { displayShortcut, isAppleOS, isKeyboardEvent } from "@wordpress/keycodes";
12
+ import { displayShortcut, isAppleOS, isKeyboardEvent, withIgnoreIMEEvents } from "@wordpress/keycodes";
12
13
  import { SnackbarNotices, store as store$1 } from "@wordpress/notices";
14
+ import { inertValue } from "@wordpress/react-inert-value";
13
15
  import { MediaEditorProvider } from "../media-editor-provider/index.mjs";
14
16
  import MediaPreview from "../media-preview/index.mjs";
15
17
  import MediaEditorCanvas from "../media-editor-canvas/index.mjs";
@@ -17,6 +19,7 @@ import MediaEditorFineRotation from "../media-editor-fine-rotation/index.mjs";
17
19
  import MediaEditorCropPanel from "../media-editor-crop-panel/index.mjs";
18
20
  import MediaEditorImageControls from "../media-editor-image-controls/index.mjs";
19
21
  import MediaForm from "../media-form/index.mjs";
22
+ import MediaEditorPanel, { MEDIA_EDITOR_PLUGIN_SCOPE, MediaEditorPanelsProvider, getPanelSlotName, useMediaEditorPanels } from "../media-editor-panel/index.mjs";
20
23
  import { getMediaTypeFromMimeType } from "../../utils/index.mjs";
21
24
  import { MediaEditorStateProvider, useMediaEditor } from "../../state/index.mjs";
22
25
  import { CROP_CONTROL_ATTR } from "../../hooks/use-crop-gesture-handlers.mjs";
@@ -28,14 +31,16 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
31
  const ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
29
32
  const PLACEMENT_CONTROL_IDLE_MS = 300;
30
33
  /**
31
- * Identifier for the details panel, and the panel the sidebar opens on before
32
- * the user picks another. The sidebar tracks which panel is open rather than
33
- * whether one is, so a further panel is a new id here and a new entry in the
34
- * tab list — not a change to the state's shape.
34
+ * The Details panel's id. Every media type has this panel, so the sidebar
35
+ * shows it when the requested panel doesn't exist.
36
+ *
37
+ * The sidebar stores the open panel's id, so adding a panel only needs a new
38
+ * id and a new tab.
35
39
  */
36
- const DETAILS_PANEL = "details";
40
+ const DETAILS_PANEL = "core/details";
37
41
  /** Identifier for the crop panel. Images only; other media has nothing to crop. */
38
- const CROP_PANEL = "crop";
42
+ const CROP_PANEL = "core/crop";
43
+ const CROP_MEDIA_TYPES = ["image"];
39
44
  const SIDEBAR_ANIMATION_DURATION = .3;
40
45
  const sidebarVariants = {
41
46
  open: { width: "auto" },
@@ -69,6 +74,7 @@ function MediaEditorSidebar({ tabs, activeTab, onSelectTab, disabled = false })
69
74
  value: tab.id,
70
75
  tabIndex: -1,
71
76
  className: "media-editor__panel",
77
+ inert: inertValue(disabled),
72
78
  children: /* @__PURE__ */ jsx(Stack, {
73
79
  direction: "column",
74
80
  gap: "lg",
@@ -91,6 +97,16 @@ function useMediaEditorFrameContext() {
91
97
  if (!context) throw new Error("useMediaEditorFrameContext must be used within MediaEditor");
92
98
  return context;
93
99
  }
100
+ function CropPanelContent({ disabled }) {
101
+ const { aspectRatioPresets } = useMediaEditorFrameContext();
102
+ const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = useCropOptions({ aspectRatioPresets });
103
+ return /* @__PURE__ */ jsx(MediaEditorCropPanel, {
104
+ aspectRatioValue,
105
+ onAspectRatioChange: setAspectRatioValue,
106
+ aspectRatioOptions,
107
+ disabled
108
+ });
109
+ }
94
110
  function PanelToggle() {
95
111
  const { isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
96
112
  const isPanelOpen = !!activePanel;
@@ -103,24 +119,71 @@ function PanelToggle() {
103
119
  onClick: onTogglePanel
104
120
  });
105
121
  }
106
- function MoreMenu() {
107
- const { isImage } = useMediaEditorFrameContext();
122
+ function getActionLabel(action, items) {
123
+ return typeof action.label === "string" ? action.label : action.label(items);
124
+ }
125
+ function MediaActionModal({ action, items, closeModal }) {
126
+ const header = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
127
+ return /* @__PURE__ */ jsx(Modal, {
128
+ title: header || getActionLabel(action, items),
129
+ __experimentalHideHeader: !!action.hideModalHeader,
130
+ onRequestClose: closeModal,
131
+ focusOnMount: action.modalFocusOnMount ?? true,
132
+ size: action.modalSize || "medium",
133
+ children: /* @__PURE__ */ jsx(action.RenderModal, {
134
+ items,
135
+ closeModal
136
+ })
137
+ });
138
+ }
139
+ function MoreMenu({ actions = [], item }) {
140
+ const { isImage, isSaving } = useMediaEditorFrameContext();
141
+ const registry = useRegistry();
108
142
  const [isShortcutsModalOpen, setIsShortcutsModalOpen] = useState(false);
109
- if (!isImage) return null;
110
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DropdownMenu, {
111
- icon: moreVertical,
112
- label: __("More options"),
113
- toggleProps: { size: "compact" },
114
- children: ({ onClose: closeMenu }) => /* @__PURE__ */ jsx(MenuGroup, { children: /* @__PURE__ */ jsx(MenuItem, {
115
- icon: keyboard,
116
- iconPosition: "left",
117
- onClick: () => {
118
- setIsShortcutsModalOpen(true);
119
- closeMenu();
120
- },
121
- children: __("Keyboard shortcuts")
122
- }) })
123
- }), isShortcutsModalOpen && /* @__PURE__ */ jsx(MediaEditorKeyboardShortcutsModal, { onClose: () => setIsShortcutsModalOpen(false) })] });
143
+ const [activeModalAction, setActiveModalAction] = useState(null);
144
+ const items = item ? [item] : [];
145
+ const eligibleActions = useMemo(() => item ? actions.filter((action) => !action.isEligible || action.isEligible(item)) : [], [actions, item]);
146
+ if (!isImage && !eligibleActions.length) return null;
147
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
148
+ /* @__PURE__ */ jsx(DropdownMenu, {
149
+ icon: moreVertical,
150
+ label: __("More options"),
151
+ toggleProps: { size: "compact" },
152
+ children: ({ onClose: closeMenu }) => /* @__PURE__ */ jsxs(Fragment, { children: [isImage && /* @__PURE__ */ jsx(MenuGroup, { children: /* @__PURE__ */ jsx(MenuItem, {
153
+ icon: keyboard,
154
+ iconPosition: "left",
155
+ onClick: () => {
156
+ setIsShortcutsModalOpen(true);
157
+ closeMenu();
158
+ },
159
+ children: __("Keyboard shortcuts")
160
+ }) }), !!eligibleActions.length && /* @__PURE__ */ jsx(MenuGroup, { children: eligibleActions.map((action) => {
161
+ const label = getActionLabel(action, items);
162
+ return /* @__PURE__ */ jsx(MenuItem, {
163
+ disabled: isSaving || action.disabled,
164
+ onClick: () => {
165
+ closeMenu();
166
+ if ("RenderModal" in action) {
167
+ setActiveModalAction(action);
168
+ return;
169
+ }
170
+ action.callback(items, { registry });
171
+ },
172
+ children: "RenderModal" in action ? sprintf(
173
+ /** translators: %s: Action label. Use the ellipsis and spacing appropriate for your language. */
174
+ _x("%s…", "menu item requiring further input"),
175
+ label
176
+ ) : label
177
+ }, action.id);
178
+ }) })] })
179
+ }),
180
+ isShortcutsModalOpen && /* @__PURE__ */ jsx(MediaEditorKeyboardShortcutsModal, { onClose: () => setIsShortcutsModalOpen(false) }),
181
+ activeModalAction && /* @__PURE__ */ jsx(MediaActionModal, {
182
+ action: activeModalAction,
183
+ items,
184
+ closeModal: () => setActiveModalAction(null)
185
+ })
186
+ ] });
124
187
  }
125
188
  function HeaderActions({ showCloseButton = false }) {
126
189
  const { isSaving, onCancel } = useMediaEditorFrameContext();
@@ -144,7 +207,7 @@ function HeaderActions({ showCloseButton = false }) {
144
207
  });
145
208
  }
146
209
  function HistoryActions() {
147
- const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, onRestoreOriginal } = useMediaEditorFrameContext();
210
+ const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, opensOriginal, onRestoreOriginal } = useMediaEditorFrameContext();
148
211
  const { reset, isDirty, hasUndo, hasRedo, undo: undoCrop, redo: redoCrop } = useMediaEditor();
149
212
  if (!isImage || !isWide && !!activePanel) return null;
150
213
  const handleUndo = () => {
@@ -207,7 +270,7 @@ function HistoryActions() {
207
270
  onRestoreOriginal();
208
271
  closeMenu();
209
272
  },
210
- children: __("Restore original")
273
+ children: opensOriginal ? __("Edit original") : __("Restore original")
211
274
  }) })] })
212
275
  })
213
276
  ]
@@ -241,7 +304,7 @@ function SaveActions({ size = "default" }) {
241
304
  })]
242
305
  });
243
306
  }
244
- function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false }) {
307
+ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, onEditOriginal, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false, defaultPanel = DETAILS_PANEL }) {
245
308
  const session = useMediaEditor();
246
309
  const isWide = useViewportMatch("small");
247
310
  const sidebarTransition = {
@@ -259,7 +322,17 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
259
322
  const layout = isWide ? "wide" : "narrow";
260
323
  const sourceMedia = useSelect((select) => select(store).getEntityRecord("postType", "attachment", id), [id]);
261
324
  const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = useDispatch(store);
262
- const { removeAllNotices } = useDispatch(store$1);
325
+ const { createErrorNotice, removeAllNotices } = useDispatch(store$1);
326
+ const handlePluginError = useCallback((name) => {
327
+ createErrorNotice(sprintf(
328
+ /** translators: %s: plugin name */
329
+ __("The \"%s\" plugin has encountered an error and cannot be rendered."),
330
+ name
331
+ ), {
332
+ type: "snackbar",
333
+ context: MEDIA_EDITOR_NOTICES_CONTEXT
334
+ });
335
+ }, [createErrorNotice]);
263
336
  const [isDiscardDialogOpen, setIsDiscardDialogOpen] = useState(false);
264
337
  const [isPlacementActive, setIsPlacementActive] = useState(false);
265
338
  const [isCanvasGestureActive, setIsCanvasGestureActive] = useState(false);
@@ -319,12 +392,21 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
319
392
  }, [activeId, invalidateResolution]);
320
393
  const handleRestoreOriginal = useCallback(() => {
321
394
  clearEntityRecordEdits("postType", "attachment", id);
395
+ if (onEditOriginal && originalId) {
396
+ onEditOriginal(originalId);
397
+ return;
398
+ }
322
399
  setIsSourceReplaced(true);
323
- }, [clearEntityRecordEdits, id]);
400
+ }, [
401
+ clearEntityRecordEdits,
402
+ id,
403
+ onEditOriginal,
404
+ originalId
405
+ ]);
324
406
  const hasChanges = session.hasOutputEdits || hasEdits || isSourceReplaced;
325
407
  const mediaType = getMediaTypeFromMimeType(media?.mime_type).type;
326
408
  const isImage = !!media && mediaType === "image";
327
- const currentTab = chosenTab ?? (isWide && isImage ? CROP_PANEL : DETAILS_PANEL);
409
+ const currentTab = chosenTab ?? (isWide ? defaultPanel : DETAILS_PANEL);
328
410
  let activePanel = chosenPanel;
329
411
  if (activePanel === void 0) activePanel = isWide ? currentTab : null;
330
412
  const selectPanel = useCallback((panel) => {
@@ -334,7 +416,6 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
334
416
  const togglePanel = useCallback(() => {
335
417
  setChosenPanel(activePanel ? null : currentTab);
336
418
  }, [activePanel, currentTab]);
337
- const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = useCropOptions({ aspectRatioPresets });
338
419
  const { isSaving, save: saveMediaEditor } = useSaveMediaEditor({
339
420
  session,
340
421
  id,
@@ -361,7 +442,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
361
442
  }
362
443
  discardAndClose();
363
444
  };
364
- const handleKeyDown = (event) => {
445
+ const handleKeyDown = withIgnoreIMEEvents((event) => {
365
446
  const isUndoShortcut = isKeyboardEvent.primary(event, "z");
366
447
  const isRedoShortcut = isKeyboardEvent.primaryShift(event, "z") || !isAppleOS() && isKeyboardEvent.primary(event, "y");
367
448
  if ((isUndoShortcut || isRedoShortcut) && isImage) {
@@ -384,7 +465,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
384
465
  setIsDiscardDialogOpen(true);
385
466
  }
386
467
  }
387
- };
468
+ });
388
469
  const snackbar = /* @__PURE__ */ jsx(SnackbarNotices, {
389
470
  className: noticesClassName,
390
471
  context: MEDIA_EDITOR_NOTICES_CONTEXT
@@ -394,91 +475,78 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
394
475
  aspectRatioPresets,
395
476
  disabled: isSaving
396
477
  }) : null;
397
- const tabs = [...isImage ? [{
398
- id: CROP_PANEL,
399
- title: __("Crop"),
400
- render: () => /* @__PURE__ */ jsx(MediaEditorCropPanel, {
401
- aspectRatioValue,
402
- onAspectRatioChange: setAspectRatioValue,
403
- aspectRatioOptions,
404
- disabled: isSaving
478
+ const { panels, contextValue: panelsContextValue } = useMediaEditorPanels();
479
+ const availableTabs = panels.filter((panel) => !panel.mediaTypes || panel.mediaTypes.includes(mediaType)).map((panel) => ({
480
+ id: panel.name,
481
+ title: panel.title,
482
+ render: () => /* @__PURE__ */ jsx(Slot, {
483
+ bubblesVirtually: true,
484
+ name: getPanelSlotName(panel.name),
485
+ fillProps: { disabled: isSaving }
405
486
  })
406
- }] : [], {
407
- id: DETAILS_PANEL,
408
- title: __("Details"),
409
- render: () => /* @__PURE__ */ jsx(MediaForm, {})
410
- }];
487
+ }));
488
+ const defaultTab = availableTabs.find((tab) => tab.id === defaultPanel);
489
+ const tabs = defaultTab ? [defaultTab, ...availableTabs.filter((tab) => tab !== defaultTab)] : availableTabs;
411
490
  const ruler = isImage ? /* @__PURE__ */ jsx(MediaEditorFineRotation, {
412
491
  onPlacementControlInteraction: signalPlacementControlInteraction,
413
492
  disabled: isSaving
414
493
  }) : null;
415
- const children = /* @__PURE__ */ jsxs(MediaEditorProvider, {
416
- value: media ?? void 0,
417
- onChange: handleChange,
418
- settings: {
419
- fields: isSaving ? fields.map((field) => ({
420
- ...field,
421
- isDisabled: true
422
- })) : fields,
423
- form
424
- },
425
- children: [
426
- /* @__PURE__ */ jsx("div", {
427
- className: "media-editor",
428
- children: !media ? /* @__PURE__ */ jsx("div", {
429
- className: "media-editor__loading",
430
- children: /* @__PURE__ */ jsx(Spinner, {})
431
- }) : /* @__PURE__ */ jsxs("div", {
432
- className: clsx("media-editor__body", { "has-panel-open": !!activePanel }),
433
- children: [/* @__PURE__ */ jsxs(NavigableRegion, {
434
- className: "media-editor__content",
435
- ariaLabel: isImage ? __("Image editor") : __("Media preview"),
436
- children: [/* @__PURE__ */ jsx("div", {
437
- className: "media-editor__canvas-area",
438
- children: isImage ? /* @__PURE__ */ jsx(MediaEditorCanvas, {
439
- isPlacementActive,
440
- onGestureStart: handleCanvasGestureStart,
441
- onGestureEnd: handleCanvasGestureEnd,
442
- disabled: isSaving
443
- }) : /* @__PURE__ */ jsx(MediaPreview, {})
444
- }), isImage && /* @__PURE__ */ jsxs("div", {
445
- className: "media-editor__canvas-toolbar",
446
- children: [ruler, imageControls]
447
- })]
448
- }), /* @__PURE__ */ jsx(__unstableAnimatePresence, {
449
- initial: false,
450
- custom: sidebarTransition,
451
- children: !!activePanel && /* @__PURE__ */ jsx(__unstableMotion.div, {
452
- className: "media-editor__sidebar-container",
453
- variants: sidebarVariants,
454
- initial: "closed",
455
- animate: "open",
456
- exit: "closed",
457
- transition: sidebarTransition,
458
- children: /* @__PURE__ */ jsx(MediaEditorSidebar, {
459
- tabs,
460
- activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
461
- onSelectTab: selectPanel,
462
- disabled: isSaving
463
- })
464
- })
494
+ const children = /* @__PURE__ */ jsxs(Fragment, { children: [
495
+ /* @__PURE__ */ jsx("div", {
496
+ className: "media-editor",
497
+ children: !media ? /* @__PURE__ */ jsx("div", {
498
+ className: "media-editor__loading",
499
+ children: /* @__PURE__ */ jsx(Spinner, {})
500
+ }) : /* @__PURE__ */ jsxs("div", {
501
+ className: clsx("media-editor__body", { "has-panel-open": !!activePanel }),
502
+ children: [/* @__PURE__ */ jsxs(NavigableRegion, {
503
+ className: "media-editor__content",
504
+ ariaLabel: isImage ? __("Image editor") : __("Media preview"),
505
+ children: [/* @__PURE__ */ jsx("div", {
506
+ className: "media-editor__canvas-area",
507
+ children: isImage ? /* @__PURE__ */ jsx(MediaEditorCanvas, {
508
+ isPlacementActive,
509
+ onGestureStart: handleCanvasGestureStart,
510
+ onGestureEnd: handleCanvasGestureEnd,
511
+ disabled: isSaving
512
+ }) : /* @__PURE__ */ jsx(MediaPreview, {})
513
+ }), isImage && /* @__PURE__ */ jsxs("div", {
514
+ className: "media-editor__canvas-toolbar",
515
+ children: [ruler, imageControls]
465
516
  })]
466
- })
467
- }),
468
- /* @__PURE__ */ jsx(__experimentalConfirmDialog, {
469
- isOpen: isDiscardDialogOpen,
470
- confirmButtonText: __("Discard"),
471
- cancelButtonText: __("Keep editing"),
472
- onCancel: () => setIsDiscardDialogOpen(false),
473
- onConfirm: () => {
474
- setIsDiscardDialogOpen(false);
475
- discardAndClose();
476
- },
477
- children: __("Are you sure you want to discard your unsaved changes?")
478
- }),
479
- noticesPortalElement ? createPortal(snackbar, noticesPortalElement) : snackbar
480
- ]
481
- });
517
+ }), /* @__PURE__ */ jsx(__unstableAnimatePresence, {
518
+ initial: false,
519
+ custom: sidebarTransition,
520
+ children: !!activePanel && /* @__PURE__ */ jsx(__unstableMotion.div, {
521
+ className: "media-editor__sidebar-container",
522
+ variants: sidebarVariants,
523
+ initial: "closed",
524
+ animate: "open",
525
+ exit: "closed",
526
+ transition: sidebarTransition,
527
+ children: tabs.length > 0 && /* @__PURE__ */ jsx(MediaEditorSidebar, {
528
+ tabs,
529
+ activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
530
+ onSelectTab: selectPanel,
531
+ disabled: isSaving
532
+ })
533
+ })
534
+ })]
535
+ })
536
+ }),
537
+ /* @__PURE__ */ jsx(__experimentalConfirmDialog, {
538
+ isOpen: isDiscardDialogOpen,
539
+ confirmButtonText: __("Discard"),
540
+ cancelButtonText: __("Keep editing"),
541
+ onCancel: () => setIsDiscardDialogOpen(false),
542
+ onConfirm: () => {
543
+ setIsDiscardDialogOpen(false);
544
+ discardAndClose();
545
+ },
546
+ children: __("Are you sure you want to discard your unsaved changes?")
547
+ }),
548
+ noticesPortalElement ? createPortal(snackbar, noticesPortalElement) : snackbar
549
+ ] });
482
550
  const contextValue = {
483
551
  isImage,
484
552
  isSaving,
@@ -493,12 +561,44 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
493
561
  onSave: saveMediaEditor,
494
562
  canRestoreOriginal,
495
563
  isSourceReplaced,
564
+ opensOriginal: !!onEditOriginal,
496
565
  onRestoreOriginal: handleRestoreOriginal
497
566
  };
498
567
  return /* @__PURE__ */ jsx(MediaEditorFrameContext.Provider, {
499
568
  value: contextValue,
500
569
  children: renderFrame({
501
- children,
570
+ children: /* @__PURE__ */ jsx(MediaEditorProvider, {
571
+ value: media ?? void 0,
572
+ onChange: handleChange,
573
+ settings: {
574
+ fields: isSaving ? fields.map((field) => ({
575
+ ...field,
576
+ isDisabled: true
577
+ })) : fields,
578
+ form
579
+ },
580
+ children: /* @__PURE__ */ jsx(SlotFillProvider, { children: /* @__PURE__ */ jsxs(MediaEditorPanelsProvider, {
581
+ value: panelsContextValue,
582
+ children: [
583
+ /* @__PURE__ */ jsx(MediaEditorPanel, {
584
+ name: CROP_PANEL,
585
+ title: __("Crop"),
586
+ mediaTypes: CROP_MEDIA_TYPES,
587
+ children: ({ disabled }) => /* @__PURE__ */ jsx(CropPanelContent, { disabled })
588
+ }),
589
+ /* @__PURE__ */ jsx(MediaEditorPanel, {
590
+ name: DETAILS_PANEL,
591
+ title: __("Details"),
592
+ children: /* @__PURE__ */ jsx(MediaForm, {})
593
+ }),
594
+ /* @__PURE__ */ jsx(PluginArea, {
595
+ scope: MEDIA_EDITOR_PLUGIN_SCOPE,
596
+ onError: handlePluginError
597
+ }),
598
+ children
599
+ ]
600
+ }) })
601
+ }),
502
602
  isImage,
503
603
  layout,
504
604
  onRequestClose: handleRequestClose,