@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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.24.0 (2026-12-02)
6
+
7
+ ### Enhancements
8
+
9
+ - `MediaEditor` builds its sidebar tabs from mounted `MediaEditorPanel` components and mounts plugins registered with `registerPlugin` in the `media-editor` scope inside the editor's session provider. Core's Crop and Details are two such panels. A panel's content renders in the panel's own React tree, a panel that throws keeps the failure inside its tab, and common mistakes warn in development ([#84664](https://github.com/WordPress/gutenberg/pull/84664)).
10
+
11
+ ### Bug Fixes
12
+
13
+ - `MediaEditor`: Ignore keyboard shortcuts and Escape-to-close handling during IME composition ([#87354](https://github.com/WordPress/gutenberg/pull/87354)).
14
+ - Expose readable text for shortcut keycaps, including arrow groups and the Plus and Minus zoom keys ([#85490](https://github.com/WordPress/gutenberg/pull/85490)).
15
+
16
+ ### Internal
17
+
18
+ - Add `@wordpress/plugins`, `@wordpress/react-inert-value` and `@wordpress/warning` as dependencies ([#84664](https://github.com/WordPress/gutenberg/pull/84664)).
19
+
20
+ ## 0.23.0 (2026-11-18)
21
+
22
+ ### Enhancements
23
+
24
+ - `MediaEditor.MoreMenu` takes `actions` and `item` props, and lists the actions eligible for the item, such as "Permanently delete". It now also shows for media other than images when it has actions ([#86349](https://github.com/WordPress/gutenberg/pull/86349)).
25
+ - Show the shape of each aspect ratio in the aspect ratio dropdown of the crop panel and in the aspect ratio menu used on narrow screens ([#86348](https://github.com/WordPress/gutenberg/pull/86348)).
26
+ - `MediaPreview` shows media without a preview, such as a zip file, with its filename, file type and size, and Download and Copy URL buttons. Its empty and error states also use `EmptyState` from `@wordpress/ui` ([#86490](https://github.com/WordPress/gutenberg/pull/86490)).
27
+
28
+ ### Bug Fixes
29
+
30
+ - Keyboard shortcuts modal: Show key combinations left to right on right-to-left pages ([#86606](https://github.com/WordPress/gutenberg/pull/86606)).
31
+ - Keep the fine-rotation ruler's ticks and labels visible when the browser forces dark colors ([#86402](https://github.com/WordPress/gutenberg/pull/86402)).
32
+
33
+ ### Internal
34
+
35
+ - Update the Storybook development dependencies to 10.6.6 ([#86507](https://github.com/WordPress/gutenberg/pull/86507)).
36
+ - Use the image cropper from the new `@wordpress/image-editor` package ([#86223](https://github.com/WordPress/gutenberg/pull/86223)).
37
+
5
38
  ## 0.22.0 (2026-11-04)
6
39
 
7
40
  ### Enhancements
@@ -9,6 +42,7 @@
9
42
  - Use the design system focus ring for the rotation ruler ([#85535](https://github.com/WordPress/gutenberg/pull/85535)).
10
43
  - Animate the details/crop sidebar when it opens or closes beside the canvas ([#85889](https://github.com/WordPress/gutenberg/pull/85889)).
11
44
  - `MediaPreview` shows an inline preview of PDF files when the browser has a built-in PDF viewer, and falls back to the file info otherwise ([#86002](https://github.com/WordPress/gutenberg/pull/86002)).
45
+ - Add an `onEditOriginal` prop to `MediaEditor`. When set, the history menu reads "Edit original" and hands the original's id to the caller instead of loading it into the cropper, so a frame can open it on its own ([#86281](https://github.com/WordPress/gutenberg/pull/86281)).
12
46
 
13
47
  ### Bug Fixes
14
48
 
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -25,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
27
  enumerable: true
26
28
  }) : target, mod));
27
29
  let clsx = require("clsx");
28
- clsx = __toESM(clsx);
29
30
  let _wordpress_components = require("@wordpress/components");
30
31
  let _wordpress_ui = require("@wordpress/ui");
32
+ let _wordpress_plugins = require("@wordpress/plugins");
31
33
  let _wordpress_compose = require("@wordpress/compose");
32
34
  let _wordpress_data = require("@wordpress/data");
33
35
  let _wordpress_core_data = require("@wordpress/core-data");
@@ -37,39 +39,45 @@ let _wordpress_i18n = require("@wordpress/i18n");
37
39
  let _wordpress_icons = require("@wordpress/icons");
38
40
  let _wordpress_keycodes = require("@wordpress/keycodes");
39
41
  let _wordpress_notices = require("@wordpress/notices");
42
+ let _wordpress_react_inert_value = require("@wordpress/react-inert-value");
40
43
  let ___media_editor_provider_index_tsx = require("../media-editor-provider/index.cjs");
41
44
  let ___media_preview_index_tsx = require("../media-preview/index.cjs");
42
- ___media_preview_index_tsx = __toESM(___media_preview_index_tsx);
43
45
  let ___media_editor_canvas_index_tsx = require("../media-editor-canvas/index.cjs");
44
- ___media_editor_canvas_index_tsx = __toESM(___media_editor_canvas_index_tsx);
45
46
  let ___media_editor_fine_rotation_index_tsx = require("../media-editor-fine-rotation/index.cjs");
46
- ___media_editor_fine_rotation_index_tsx = __toESM(___media_editor_fine_rotation_index_tsx);
47
47
  let ___media_editor_crop_panel_index_tsx = require("../media-editor-crop-panel/index.cjs");
48
- ___media_editor_crop_panel_index_tsx = __toESM(___media_editor_crop_panel_index_tsx);
49
48
  let ___media_editor_image_controls_index_tsx = require("../media-editor-image-controls/index.cjs");
50
- ___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
51
49
  let ___media_form_index_tsx = require("../media-form/index.cjs");
52
- ___media_form_index_tsx = __toESM(___media_form_index_tsx);
50
+ let ___media_editor_panel_index_tsx = require("../media-editor-panel/index.cjs");
53
51
  let ______utils_index_ts = require("../../utils/index.cjs");
54
52
  let ______state_index_ts = require("../../state/index.cjs");
55
53
  let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
56
54
  let ___media_editor_keyboard_shortcuts_modal_index_tsx = require("../media-editor-keyboard-shortcuts-modal/index.cjs");
57
- ___media_editor_keyboard_shortcuts_modal_index_tsx = __toESM(___media_editor_keyboard_shortcuts_modal_index_tsx);
58
55
  let __use_save_media_editor_ts = require("./use-save-media-editor.cjs");
59
56
  let __use_crop_options_ts = require("./use-crop-options.cjs");
60
57
  let react_jsx_runtime = require("react/jsx-runtime");
58
+ clsx = __toESM(clsx);
59
+ ___media_preview_index_tsx = __toESM(___media_preview_index_tsx);
60
+ ___media_editor_canvas_index_tsx = __toESM(___media_editor_canvas_index_tsx);
61
+ ___media_editor_fine_rotation_index_tsx = __toESM(___media_editor_fine_rotation_index_tsx);
62
+ ___media_editor_crop_panel_index_tsx = __toESM(___media_editor_crop_panel_index_tsx);
63
+ ___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
64
+ ___media_form_index_tsx = __toESM(___media_form_index_tsx);
65
+ ___media_editor_panel_index_tsx = __toESM(___media_editor_panel_index_tsx);
66
+ ___media_editor_keyboard_shortcuts_modal_index_tsx = __toESM(___media_editor_keyboard_shortcuts_modal_index_tsx);
61
67
  // packages/media-editor/src/components/media-editor/index.tsx
62
68
  const ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
63
69
  const PLACEMENT_CONTROL_IDLE_MS = 300;
64
70
  /**
65
- * Identifier for the details panel, and the panel the sidebar opens on before
66
- * the user picks another. The sidebar tracks which panel is open rather than
67
- * whether one is, so a further panel is a new id here and a new entry in the
68
- * tab list — not a change to the state's shape.
71
+ * The Details panel's id. Every media type has this panel, so the sidebar
72
+ * shows it when the requested panel doesn't exist.
73
+ *
74
+ * The sidebar stores the open panel's id, so adding a panel only needs a new
75
+ * id and a new tab.
69
76
  */
70
- const DETAILS_PANEL = "details";
77
+ const DETAILS_PANEL = "core/details";
71
78
  /** Identifier for the crop panel. Images only; other media has nothing to crop. */
72
- const CROP_PANEL = "crop";
79
+ const CROP_PANEL = "core/crop";
80
+ const CROP_MEDIA_TYPES = ["image"];
73
81
  const SIDEBAR_ANIMATION_DURATION = .3;
74
82
  const sidebarVariants = {
75
83
  open: { width: "auto" },
@@ -103,6 +111,7 @@ function MediaEditorSidebar({ tabs, activeTab, onSelectTab, disabled = false })
103
111
  value: tab.id,
104
112
  tabIndex: -1,
105
113
  className: "media-editor__panel",
114
+ inert: (0, _wordpress_react_inert_value.inertValue)(disabled),
106
115
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Stack, {
107
116
  direction: "column",
108
117
  gap: "lg",
@@ -125,6 +134,16 @@ function useMediaEditorFrameContext() {
125
134
  if (!context) throw new Error("useMediaEditorFrameContext must be used within MediaEditor");
126
135
  return context;
127
136
  }
137
+ function CropPanelContent({ disabled }) {
138
+ const { aspectRatioPresets } = useMediaEditorFrameContext();
139
+ const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, __use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
140
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_crop_panel_index_tsx.default, {
141
+ aspectRatioValue,
142
+ onAspectRatioChange: setAspectRatioValue,
143
+ aspectRatioOptions,
144
+ disabled
145
+ });
146
+ }
128
147
  function PanelToggle() {
129
148
  const { isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
130
149
  const isPanelOpen = !!activePanel;
@@ -137,24 +156,71 @@ function PanelToggle() {
137
156
  onClick: onTogglePanel
138
157
  });
139
158
  }
140
- function MoreMenu() {
141
- const { isImage } = useMediaEditorFrameContext();
159
+ function getActionLabel(action, items) {
160
+ return typeof action.label === "string" ? action.label : action.label(items);
161
+ }
162
+ function MediaActionModal({ action, items, closeModal }) {
163
+ const header = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
164
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Modal, {
165
+ title: header || getActionLabel(action, items),
166
+ __experimentalHideHeader: !!action.hideModalHeader,
167
+ onRequestClose: closeModal,
168
+ focusOnMount: action.modalFocusOnMount ?? true,
169
+ size: action.modalSize || "medium",
170
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(action.RenderModal, {
171
+ items,
172
+ closeModal
173
+ })
174
+ });
175
+ }
176
+ function MoreMenu({ actions = [], item }) {
177
+ const { isImage, isSaving } = useMediaEditorFrameContext();
178
+ const registry = (0, _wordpress_data.useRegistry)();
142
179
  const [isShortcutsModalOpen, setIsShortcutsModalOpen] = (0, _wordpress_element.useState)(false);
143
- if (!isImage) return null;
144
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.DropdownMenu, {
145
- icon: _wordpress_icons.moreVertical,
146
- label: (0, _wordpress_i18n.__)("More options"),
147
- toggleProps: { size: "compact" },
148
- children: ({ onClose: closeMenu }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
149
- icon: _wordpress_icons.keyboard,
150
- iconPosition: "left",
151
- onClick: () => {
152
- setIsShortcutsModalOpen(true);
153
- closeMenu();
154
- },
155
- children: (0, _wordpress_i18n.__)("Keyboard shortcuts")
156
- }) })
157
- }), isShortcutsModalOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_keyboard_shortcuts_modal_index_tsx.default, { onClose: () => setIsShortcutsModalOpen(false) })] });
180
+ const [activeModalAction, setActiveModalAction] = (0, _wordpress_element.useState)(null);
181
+ const items = item ? [item] : [];
182
+ const eligibleActions = (0, _wordpress_element.useMemo)(() => item ? actions.filter((action) => !action.isEligible || action.isEligible(item)) : [], [actions, item]);
183
+ if (!isImage && !eligibleActions.length) return null;
184
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
185
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.DropdownMenu, {
186
+ icon: _wordpress_icons.moreVertical,
187
+ label: (0, _wordpress_i18n.__)("More options"),
188
+ toggleProps: { size: "compact" },
189
+ children: ({ onClose: closeMenu }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
190
+ icon: _wordpress_icons.keyboard,
191
+ iconPosition: "left",
192
+ onClick: () => {
193
+ setIsShortcutsModalOpen(true);
194
+ closeMenu();
195
+ },
196
+ children: (0, _wordpress_i18n.__)("Keyboard shortcuts")
197
+ }) }), !!eligibleActions.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: eligibleActions.map((action) => {
198
+ const label = getActionLabel(action, items);
199
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
200
+ disabled: isSaving || action.disabled,
201
+ onClick: () => {
202
+ closeMenu();
203
+ if ("RenderModal" in action) {
204
+ setActiveModalAction(action);
205
+ return;
206
+ }
207
+ action.callback(items, { registry });
208
+ },
209
+ children: "RenderModal" in action ? (0, _wordpress_i18n.sprintf)(
210
+ /** translators: %s: Action label. Use the ellipsis and spacing appropriate for your language. */
211
+ (0, _wordpress_i18n._x)("%s…", "menu item requiring further input"),
212
+ label
213
+ ) : label
214
+ }, action.id);
215
+ }) })] })
216
+ }),
217
+ isShortcutsModalOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_keyboard_shortcuts_modal_index_tsx.default, { onClose: () => setIsShortcutsModalOpen(false) }),
218
+ activeModalAction && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaActionModal, {
219
+ action: activeModalAction,
220
+ items,
221
+ closeModal: () => setActiveModalAction(null)
222
+ })
223
+ ] });
158
224
  }
159
225
  function HeaderActions({ showCloseButton = false }) {
160
226
  const { isSaving, onCancel } = useMediaEditorFrameContext();
@@ -178,7 +244,7 @@ function HeaderActions({ showCloseButton = false }) {
178
244
  });
179
245
  }
180
246
  function HistoryActions() {
181
- const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, onRestoreOriginal } = useMediaEditorFrameContext();
247
+ const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, opensOriginal, onRestoreOriginal } = useMediaEditorFrameContext();
182
248
  const { reset, isDirty, hasUndo, hasRedo, undo: undoCrop, redo: redoCrop } = (0, ______state_index_ts.useMediaEditor)();
183
249
  if (!isImage || !isWide && !!activePanel) return null;
184
250
  const handleUndo = () => {
@@ -241,7 +307,7 @@ function HistoryActions() {
241
307
  onRestoreOriginal();
242
308
  closeMenu();
243
309
  },
244
- children: (0, _wordpress_i18n.__)("Restore original")
310
+ children: opensOriginal ? (0, _wordpress_i18n.__)("Edit original") : (0, _wordpress_i18n.__)("Restore original")
245
311
  }) })] })
246
312
  })
247
313
  ]
@@ -275,7 +341,7 @@ function SaveActions({ size = "default" }) {
275
341
  })]
276
342
  });
277
343
  }
278
- function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false }) {
344
+ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, onEditOriginal, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false, defaultPanel = DETAILS_PANEL }) {
279
345
  const session = (0, ______state_index_ts.useMediaEditor)();
280
346
  const isWide = (0, _wordpress_compose.useViewportMatch)("small");
281
347
  const sidebarTransition = {
@@ -293,7 +359,17 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
293
359
  const layout = isWide ? "wide" : "narrow";
294
360
  const sourceMedia = (0, _wordpress_data.useSelect)((select) => select(_wordpress_core_data.store).getEntityRecord("postType", "attachment", id), [id]);
295
361
  const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = (0, _wordpress_data.useDispatch)(_wordpress_core_data.store);
296
- const { removeAllNotices } = (0, _wordpress_data.useDispatch)(_wordpress_notices.store);
362
+ const { createErrorNotice, removeAllNotices } = (0, _wordpress_data.useDispatch)(_wordpress_notices.store);
363
+ const handlePluginError = (0, _wordpress_element.useCallback)((name) => {
364
+ createErrorNotice((0, _wordpress_i18n.sprintf)(
365
+ /** translators: %s: plugin name */
366
+ (0, _wordpress_i18n.__)("The \"%s\" plugin has encountered an error and cannot be rendered."),
367
+ name
368
+ ), {
369
+ type: "snackbar",
370
+ context: __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT
371
+ });
372
+ }, [createErrorNotice]);
297
373
  const [isDiscardDialogOpen, setIsDiscardDialogOpen] = (0, _wordpress_element.useState)(false);
298
374
  const [isPlacementActive, setIsPlacementActive] = (0, _wordpress_element.useState)(false);
299
375
  const [isCanvasGestureActive, setIsCanvasGestureActive] = (0, _wordpress_element.useState)(false);
@@ -353,12 +429,21 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
353
429
  }, [activeId, invalidateResolution]);
354
430
  const handleRestoreOriginal = (0, _wordpress_element.useCallback)(() => {
355
431
  clearEntityRecordEdits("postType", "attachment", id);
432
+ if (onEditOriginal && originalId) {
433
+ onEditOriginal(originalId);
434
+ return;
435
+ }
356
436
  setIsSourceReplaced(true);
357
- }, [clearEntityRecordEdits, id]);
437
+ }, [
438
+ clearEntityRecordEdits,
439
+ id,
440
+ onEditOriginal,
441
+ originalId
442
+ ]);
358
443
  const hasChanges = session.hasOutputEdits || hasEdits || isSourceReplaced;
359
444
  const mediaType = (0, ______utils_index_ts.getMediaTypeFromMimeType)(media?.mime_type).type;
360
445
  const isImage = !!media && mediaType === "image";
361
- const currentTab = chosenTab ?? (isWide && isImage ? CROP_PANEL : DETAILS_PANEL);
446
+ const currentTab = chosenTab ?? (isWide ? defaultPanel : DETAILS_PANEL);
362
447
  let activePanel = chosenPanel;
363
448
  if (activePanel === void 0) activePanel = isWide ? currentTab : null;
364
449
  const selectPanel = (0, _wordpress_element.useCallback)((panel) => {
@@ -368,7 +453,6 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
368
453
  const togglePanel = (0, _wordpress_element.useCallback)(() => {
369
454
  setChosenPanel(activePanel ? null : currentTab);
370
455
  }, [activePanel, currentTab]);
371
- const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, __use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
372
456
  const { isSaving, save: saveMediaEditor } = (0, __use_save_media_editor_ts.useSaveMediaEditor)({
373
457
  session,
374
458
  id,
@@ -395,7 +479,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
395
479
  }
396
480
  discardAndClose();
397
481
  };
398
- const handleKeyDown = (event) => {
482
+ const handleKeyDown = (0, _wordpress_keycodes.withIgnoreIMEEvents)((event) => {
399
483
  const isUndoShortcut = _wordpress_keycodes.isKeyboardEvent.primary(event, "z");
400
484
  const isRedoShortcut = _wordpress_keycodes.isKeyboardEvent.primaryShift(event, "z") || !(0, _wordpress_keycodes.isAppleOS)() && _wordpress_keycodes.isKeyboardEvent.primary(event, "y");
401
485
  if ((isUndoShortcut || isRedoShortcut) && isImage) {
@@ -418,7 +502,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
418
502
  setIsDiscardDialogOpen(true);
419
503
  }
420
504
  }
421
- };
505
+ });
422
506
  const snackbar = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_notices.SnackbarNotices, {
423
507
  className: noticesClassName,
424
508
  context: __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT
@@ -428,91 +512,78 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
428
512
  aspectRatioPresets,
429
513
  disabled: isSaving
430
514
  }) : null;
431
- const tabs = [...isImage ? [{
432
- id: CROP_PANEL,
433
- title: (0, _wordpress_i18n.__)("Crop"),
434
- render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_crop_panel_index_tsx.default, {
435
- aspectRatioValue,
436
- onAspectRatioChange: setAspectRatioValue,
437
- aspectRatioOptions,
438
- disabled: isSaving
515
+ const { panels, contextValue: panelsContextValue } = (0, ___media_editor_panel_index_tsx.useMediaEditorPanels)();
516
+ const availableTabs = panels.filter((panel) => !panel.mediaTypes || panel.mediaTypes.includes(mediaType)).map((panel) => ({
517
+ id: panel.name,
518
+ title: panel.title,
519
+ render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Slot, {
520
+ bubblesVirtually: true,
521
+ name: (0, ___media_editor_panel_index_tsx.getPanelSlotName)(panel.name),
522
+ fillProps: { disabled: isSaving }
439
523
  })
440
- }] : [], {
441
- id: DETAILS_PANEL,
442
- title: (0, _wordpress_i18n.__)("Details"),
443
- render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_form_index_tsx.default, {})
444
- }];
524
+ }));
525
+ const defaultTab = availableTabs.find((tab) => tab.id === defaultPanel);
526
+ const tabs = defaultTab ? [defaultTab, ...availableTabs.filter((tab) => tab !== defaultTab)] : availableTabs;
445
527
  const ruler = isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_fine_rotation_index_tsx.default, {
446
528
  onPlacementControlInteraction: signalPlacementControlInteraction,
447
529
  disabled: isSaving
448
530
  }) : null;
449
- const children = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(___media_editor_provider_index_tsx.MediaEditorProvider, {
450
- value: media ?? void 0,
451
- onChange: handleChange,
452
- settings: {
453
- fields: isSaving ? fields.map((field) => ({
454
- ...field,
455
- isDisabled: true
456
- })) : fields,
457
- form
458
- },
459
- children: [
460
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
461
- className: "media-editor",
462
- children: !media ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
463
- className: "media-editor__loading",
464
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
465
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
466
- className: (0, clsx.default)("media-editor__body", { "has-panel-open": !!activePanel }),
467
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_admin_ui.NavigableRegion, {
468
- className: "media-editor__content",
469
- ariaLabel: isImage ? (0, _wordpress_i18n.__)("Image editor") : (0, _wordpress_i18n.__)("Media preview"),
470
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
471
- className: "media-editor__canvas-area",
472
- children: isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_canvas_index_tsx.default, {
473
- isPlacementActive,
474
- onGestureStart: handleCanvasGestureStart,
475
- onGestureEnd: handleCanvasGestureEnd,
476
- disabled: isSaving
477
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_preview_index_tsx.default, {})
478
- }), isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
479
- className: "media-editor__canvas-toolbar",
480
- children: [ruler, imageControls]
481
- })]
482
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableAnimatePresence, {
483
- initial: false,
484
- custom: sidebarTransition,
485
- children: !!activePanel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableMotion.div, {
486
- className: "media-editor__sidebar-container",
487
- variants: sidebarVariants,
488
- initial: "closed",
489
- animate: "open",
490
- exit: "closed",
491
- transition: sidebarTransition,
492
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorSidebar, {
493
- tabs,
494
- activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
495
- onSelectTab: selectPanel,
496
- disabled: isSaving
497
- })
498
- })
531
+ const children = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
532
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
533
+ className: "media-editor",
534
+ children: !media ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
535
+ className: "media-editor__loading",
536
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
537
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
538
+ className: (0, clsx.default)("media-editor__body", { "has-panel-open": !!activePanel }),
539
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_admin_ui.NavigableRegion, {
540
+ className: "media-editor__content",
541
+ ariaLabel: isImage ? (0, _wordpress_i18n.__)("Image editor") : (0, _wordpress_i18n.__)("Media preview"),
542
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
543
+ className: "media-editor__canvas-area",
544
+ children: isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_canvas_index_tsx.default, {
545
+ isPlacementActive,
546
+ onGestureStart: handleCanvasGestureStart,
547
+ onGestureEnd: handleCanvasGestureEnd,
548
+ disabled: isSaving
549
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_preview_index_tsx.default, {})
550
+ }), isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
551
+ className: "media-editor__canvas-toolbar",
552
+ children: [ruler, imageControls]
499
553
  })]
500
- })
501
- }),
502
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalConfirmDialog, {
503
- isOpen: isDiscardDialogOpen,
504
- confirmButtonText: (0, _wordpress_i18n.__)("Discard"),
505
- cancelButtonText: (0, _wordpress_i18n.__)("Keep editing"),
506
- onCancel: () => setIsDiscardDialogOpen(false),
507
- onConfirm: () => {
508
- setIsDiscardDialogOpen(false);
509
- discardAndClose();
510
- },
511
- children: (0, _wordpress_i18n.__)("Are you sure you want to discard your unsaved changes?")
512
- }),
513
- noticesPortalElement ? (0, _wordpress_element.createPortal)(snackbar, noticesPortalElement) : snackbar
514
- ]
515
- });
554
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableAnimatePresence, {
555
+ initial: false,
556
+ custom: sidebarTransition,
557
+ children: !!activePanel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableMotion.div, {
558
+ className: "media-editor__sidebar-container",
559
+ variants: sidebarVariants,
560
+ initial: "closed",
561
+ animate: "open",
562
+ exit: "closed",
563
+ transition: sidebarTransition,
564
+ children: tabs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorSidebar, {
565
+ tabs,
566
+ activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
567
+ onSelectTab: selectPanel,
568
+ disabled: isSaving
569
+ })
570
+ })
571
+ })]
572
+ })
573
+ }),
574
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalConfirmDialog, {
575
+ isOpen: isDiscardDialogOpen,
576
+ confirmButtonText: (0, _wordpress_i18n.__)("Discard"),
577
+ cancelButtonText: (0, _wordpress_i18n.__)("Keep editing"),
578
+ onCancel: () => setIsDiscardDialogOpen(false),
579
+ onConfirm: () => {
580
+ setIsDiscardDialogOpen(false);
581
+ discardAndClose();
582
+ },
583
+ children: (0, _wordpress_i18n.__)("Are you sure you want to discard your unsaved changes?")
584
+ }),
585
+ noticesPortalElement ? (0, _wordpress_element.createPortal)(snackbar, noticesPortalElement) : snackbar
586
+ ] });
516
587
  const contextValue = {
517
588
  isImage,
518
589
  isSaving,
@@ -527,12 +598,44 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
527
598
  onSave: saveMediaEditor,
528
599
  canRestoreOriginal,
529
600
  isSourceReplaced,
601
+ opensOriginal: !!onEditOriginal,
530
602
  onRestoreOriginal: handleRestoreOriginal
531
603
  };
532
604
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorFrameContext.Provider, {
533
605
  value: contextValue,
534
606
  children: renderFrame({
535
- children,
607
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_provider_index_tsx.MediaEditorProvider, {
608
+ value: media ?? void 0,
609
+ onChange: handleChange,
610
+ settings: {
611
+ fields: isSaving ? fields.map((field) => ({
612
+ ...field,
613
+ isDisabled: true
614
+ })) : fields,
615
+ form
616
+ },
617
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.SlotFillProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(___media_editor_panel_index_tsx.MediaEditorPanelsProvider, {
618
+ value: panelsContextValue,
619
+ children: [
620
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_panel_index_tsx.default, {
621
+ name: CROP_PANEL,
622
+ title: (0, _wordpress_i18n.__)("Crop"),
623
+ mediaTypes: CROP_MEDIA_TYPES,
624
+ children: ({ disabled }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CropPanelContent, { disabled })
625
+ }),
626
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_panel_index_tsx.default, {
627
+ name: DETAILS_PANEL,
628
+ title: (0, _wordpress_i18n.__)("Details"),
629
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_form_index_tsx.default, {})
630
+ }),
631
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_plugins.PluginArea, {
632
+ scope: ___media_editor_panel_index_tsx.MEDIA_EDITOR_PLUGIN_SCOPE,
633
+ onError: handlePluginError
634
+ }),
635
+ children
636
+ ]
637
+ }) })
638
+ }),
536
639
  isImage,
537
640
  layout,
538
641
  onRequestClose: handleRequestClose,