@wordpress/media-editor 0.15.0 → 0.17.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 (295) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +115 -119
  3. package/build/components/media-editor/index.cjs.map +3 -3
  4. package/build/components/media-editor/use-crop-options.cjs.map +2 -2
  5. package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
  6. package/build/components/media-editor-canvas/index.cjs +0 -2
  7. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  8. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  9. package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
  10. package/build/components/media-editor-image-controls/index.cjs.map +2 -2
  11. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +2 -2
  12. package/build/components/media-editor-modal/build-modifiers.cjs.map +2 -2
  13. package/build/components/media-editor-modal/index.cjs +31 -15
  14. package/build/components/media-editor-modal/index.cjs.map +3 -3
  15. package/build/components/media-editor-provider/index.cjs.map +2 -2
  16. package/build/components/media-form/index.cjs.map +2 -2
  17. package/build/components/media-preview/index.cjs.map +2 -2
  18. package/build/components/rotation-ruler/index.cjs.map +2 -2
  19. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +2 -2
  20. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  21. package/build/image-editor/core/camera.cjs.map +2 -2
  22. package/build/image-editor/core/constants.cjs.map +2 -2
  23. package/build/image-editor/core/containment.cjs.map +2 -2
  24. package/build/image-editor/core/crop-rect.cjs.map +2 -2
  25. package/build/image-editor/core/export/canvas-renderer.cjs.map +2 -2
  26. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  27. package/build/image-editor/core/math/sanitize.cjs.map +2 -2
  28. package/build/image-editor/core/setter-helpers.cjs.map +2 -2
  29. package/build/image-editor/core/source-region.cjs.map +2 -2
  30. package/build/image-editor/core/state.cjs.map +2 -2
  31. package/build/image-editor/core/stencil-math.cjs.map +2 -2
  32. package/build/image-editor/core/transform-style.cjs.map +2 -2
  33. package/build/image-editor/core/transforms/pipeline.cjs.map +2 -2
  34. package/build/image-editor/core/viewport-state.cjs.map +2 -2
  35. package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
  36. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  37. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +2 -2
  38. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +2 -2
  39. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +2 -2
  40. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  41. package/build/image-editor/react/components/viewport-provider.cjs.map +2 -2
  42. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +2 -2
  43. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  44. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +2 -2
  45. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  46. package/build/image-editor/react/hooks/use-transform-style.cjs.map +2 -2
  47. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +2 -2
  48. package/build/lock-unlock.cjs.map +2 -2
  49. package/build/private-apis.cjs.map +2 -2
  50. package/build/state/composite-reducer.cjs.map +2 -2
  51. package/build/state/media-editor-state-provider.cjs.map +2 -2
  52. package/build/state/types.cjs.map +2 -2
  53. package/build/state/use-media-editor-state.cjs.map +2 -2
  54. package/build/store/index.cjs.map +2 -2
  55. package/build/store/reducer.cjs.map +2 -2
  56. package/build/store/selectors.cjs.map +2 -2
  57. package/build-module/components/media-editor/index.mjs +117 -120
  58. package/build-module/components/media-editor/index.mjs.map +2 -2
  59. package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
  60. package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
  61. package/build-module/components/media-editor-canvas/index.mjs +0 -2
  62. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  63. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  64. package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
  65. package/build-module/components/media-editor-image-controls/index.mjs.map +2 -2
  66. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +2 -2
  67. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +2 -2
  68. package/build-module/components/media-editor-modal/index.mjs +31 -15
  69. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  70. package/build-module/components/media-editor-provider/index.mjs.map +2 -2
  71. package/build-module/components/media-form/index.mjs.map +2 -2
  72. package/build-module/components/media-preview/index.mjs.map +2 -2
  73. package/build-module/components/rotation-ruler/index.mjs.map +2 -2
  74. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +2 -2
  75. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  76. package/build-module/image-editor/core/camera.mjs.map +2 -2
  77. package/build-module/image-editor/core/constants.mjs.map +2 -2
  78. package/build-module/image-editor/core/containment.mjs.map +2 -2
  79. package/build-module/image-editor/core/crop-rect.mjs.map +2 -2
  80. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +2 -2
  81. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  82. package/build-module/image-editor/core/math/sanitize.mjs.map +2 -2
  83. package/build-module/image-editor/core/setter-helpers.mjs.map +2 -2
  84. package/build-module/image-editor/core/source-region.mjs.map +2 -2
  85. package/build-module/image-editor/core/state.mjs.map +2 -2
  86. package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
  87. package/build-module/image-editor/core/transform-style.mjs.map +2 -2
  88. package/build-module/image-editor/core/transforms/pipeline.mjs.map +2 -2
  89. package/build-module/image-editor/core/viewport-state.mjs.map +2 -2
  90. package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
  91. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  92. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +2 -2
  93. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +2 -2
  94. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +2 -2
  95. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  96. package/build-module/image-editor/react/components/viewport-provider.mjs.map +2 -2
  97. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +2 -2
  98. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  99. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +2 -2
  100. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  101. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +2 -2
  102. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +2 -2
  103. package/build-module/lock-unlock.mjs.map +2 -2
  104. package/build-module/private-apis.mjs.map +2 -2
  105. package/build-module/state/composite-reducer.mjs.map +2 -2
  106. package/build-module/state/media-editor-state-provider.mjs.map +2 -2
  107. package/build-module/state/types.mjs.map +2 -2
  108. package/build-module/state/use-media-editor-state.mjs.map +2 -2
  109. package/build-module/store/index.mjs.map +2 -2
  110. package/build-module/store/reducer.mjs.map +2 -2
  111. package/build-module/store/selectors.mjs.map +2 -2
  112. package/build-style/style-rtl.css +6 -6
  113. package/build-style/style.css +6 -6
  114. package/build-types/components/media-editor/index.d.ts +46 -11
  115. package/build-types/components/media-editor/index.d.ts.map +1 -1
  116. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  117. package/build-types/components/media-editor/use-save-media-editor.d.ts +0 -3
  118. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  119. package/build-types/components/media-editor-canvas/index.d.ts +1 -4
  120. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  121. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  122. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  123. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  124. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  125. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -3
  126. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
  127. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  128. package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
  129. package/build-types/components/media-form/index.d.ts.map +1 -1
  130. package/build-types/components/media-preview/index.d.ts.map +1 -1
  131. package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
  132. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  133. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  134. package/build-types/image-editor/core/camera.d.ts +0 -3
  135. package/build-types/image-editor/core/camera.d.ts.map +1 -1
  136. package/build-types/image-editor/core/constants.d.ts +0 -3
  137. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  138. package/build-types/image-editor/core/containment.d.ts +0 -3
  139. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  140. package/build-types/image-editor/core/crop-rect.d.ts +0 -3
  141. package/build-types/image-editor/core/crop-rect.d.ts.map +1 -1
  142. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -3
  143. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -1
  144. package/build-types/image-editor/core/interaction-controller.d.ts +0 -3
  145. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  146. package/build-types/image-editor/core/math/sanitize.d.ts +0 -3
  147. package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -1
  148. package/build-types/image-editor/core/setter-helpers.d.ts +0 -3
  149. package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -1
  150. package/build-types/image-editor/core/source-region.d.ts +0 -3
  151. package/build-types/image-editor/core/source-region.d.ts.map +1 -1
  152. package/build-types/image-editor/core/state.d.ts +0 -3
  153. package/build-types/image-editor/core/state.d.ts.map +1 -1
  154. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
  155. package/build-types/image-editor/core/transform-style.d.ts +0 -3
  156. package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
  157. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -3
  158. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -1
  159. package/build-types/image-editor/core/viewport-state.d.ts +0 -3
  160. package/build-types/image-editor/core/viewport-state.d.ts.map +1 -1
  161. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -3
  162. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  163. package/build-types/image-editor/react/components/cropper.d.ts +0 -6
  164. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  165. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -3
  166. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -1
  167. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -3
  168. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -1
  169. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -3
  170. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -1
  171. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -3
  172. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  173. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -3
  174. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -1
  175. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -3
  176. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -1
  177. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -3
  178. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  179. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -3
  180. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -1
  181. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -3
  182. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  183. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -3
  184. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -1
  185. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -3
  186. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -1
  187. package/build-types/lock-unlock.d.ts.map +1 -1
  188. package/build-types/private-apis.d.ts.map +1 -1
  189. package/build-types/state/composite-reducer.d.ts +0 -3
  190. package/build-types/state/composite-reducer.d.ts.map +1 -1
  191. package/build-types/state/media-editor-state-provider.d.ts +0 -3
  192. package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
  193. package/build-types/state/types.d.ts +0 -3
  194. package/build-types/state/types.d.ts.map +1 -1
  195. package/build-types/state/use-media-editor-state.d.ts +0 -3
  196. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  197. package/build-types/store/index.d.ts.map +1 -1
  198. package/build-types/store/reducer.d.ts +0 -3
  199. package/build-types/store/reducer.d.ts.map +1 -1
  200. package/build-types/store/selectors.d.ts +0 -3
  201. package/build-types/store/selectors.d.ts.map +1 -1
  202. package/global.d.ts +5 -0
  203. package/package.json +24 -22
  204. package/src/components/media-editor/index.tsx +233 -194
  205. package/src/components/media-editor/style.scss +6 -3
  206. package/src/components/media-editor/test/use-crop-options.tsx +0 -7
  207. package/src/components/media-editor/use-crop-options.ts +0 -7
  208. package/src/components/media-editor/use-save-media-editor.ts +0 -7
  209. package/src/components/media-editor-canvas/index.tsx +5 -20
  210. package/src/components/media-editor-crop-panel/index.tsx +0 -7
  211. package/src/components/media-editor-crop-panel/test/index.tsx +0 -7
  212. package/src/components/media-editor-fine-rotation/index.tsx +0 -7
  213. package/src/components/media-editor-image-controls/index.tsx +0 -7
  214. package/src/components/media-editor-image-controls/test/index.tsx +0 -7
  215. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +0 -3
  216. package/src/components/media-editor-modal/build-modifiers.ts +0 -3
  217. package/src/components/media-editor-modal/index.tsx +43 -19
  218. package/src/components/media-editor-modal/style.scss +8 -4
  219. package/src/components/media-editor-modal/test/build-modifiers.test.ts +0 -8
  220. package/src/components/media-editor-modal/test/index.tsx +0 -11
  221. package/src/components/media-editor-provider/index.tsx +0 -3
  222. package/src/components/media-form/index.tsx +0 -7
  223. package/src/components/media-preview/index.tsx +0 -7
  224. package/src/components/rotation-ruler/index.tsx +0 -11
  225. package/src/components/rotation-ruler/stories/index.story.tsx +0 -11
  226. package/src/components/rotation-ruler/test/index.tsx +0 -7
  227. package/src/components/rotation-ruler/use-ruler-drag.ts +0 -3
  228. package/src/hooks/use-crop-gesture-handlers.ts +0 -7
  229. package/src/image-editor/core/camera.ts +0 -7
  230. package/src/image-editor/core/constants.ts +0 -7
  231. package/src/image-editor/core/containment.ts +0 -7
  232. package/src/image-editor/core/crop-rect.ts +0 -3
  233. package/src/image-editor/core/export/canvas-renderer.ts +0 -3
  234. package/src/image-editor/core/export/test/canvas-renderer.ts +0 -3
  235. package/src/image-editor/core/interaction-controller.ts +0 -3
  236. package/src/image-editor/core/math/sanitize.ts +0 -3
  237. package/src/image-editor/core/math/test/sanitize.ts +0 -3
  238. package/src/image-editor/core/setter-helpers.ts +0 -3
  239. package/src/image-editor/core/source-region.ts +0 -7
  240. package/src/image-editor/core/state.ts +0 -3
  241. package/src/image-editor/core/stencil-math.ts +0 -3
  242. package/src/image-editor/core/test/interaction-controller.ts +0 -3
  243. package/src/image-editor/core/test/preview-export-parity.ts +0 -1
  244. package/src/image-editor/core/test/stencil-math.ts +0 -3
  245. package/src/image-editor/core/transform-style.ts +0 -3
  246. package/src/image-editor/core/transforms/pipeline.ts +0 -3
  247. package/src/image-editor/core/transforms/test/pipeline.ts +0 -3
  248. package/src/image-editor/core/viewport-state.ts +0 -3
  249. package/src/image-editor/react/components/cropper-provider.tsx +0 -7
  250. package/src/image-editor/react/components/cropper.tsx +0 -12
  251. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -7
  252. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -3
  253. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -3
  254. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -7
  255. package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +0 -7
  256. package/src/image-editor/react/components/test/cropper.tsx +0 -7
  257. package/src/image-editor/react/components/viewport-provider.tsx +0 -7
  258. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -3
  259. package/src/image-editor/react/hooks/test/use-aria-announcer.ts +0 -11
  260. package/src/image-editor/react/hooks/test/use-cropper-reducer.ts +0 -7
  261. package/src/image-editor/react/hooks/test/use-interaction.ts +0 -7
  262. package/src/image-editor/react/hooks/test/use-transform-style.ts +0 -7
  263. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -7
  264. package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -7
  265. package/src/image-editor/react/hooks/use-interaction.ts +0 -7
  266. package/src/image-editor/react/hooks/use-transform-style.ts +0 -7
  267. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -7
  268. package/src/image-editor/stories/rectangle-crop.story.tsx +15 -11
  269. package/src/lock-unlock.ts +0 -3
  270. package/src/private-apis.ts +0 -3
  271. package/src/state/composite-reducer.ts +0 -3
  272. package/src/state/media-editor-state-provider.tsx +0 -7
  273. package/src/state/test/use-media-editor-state.ts +0 -7
  274. package/src/state/types.ts +0 -3
  275. package/src/state/use-media-editor-state.ts +0 -7
  276. package/src/store/index.ts +0 -7
  277. package/src/store/reducer.ts +0 -3
  278. package/src/store/selectors.ts +0 -3
  279. package/src/store/test/reducer.ts +0 -3
  280. package/tsconfig.build.json +26 -0
  281. package/tsconfig.build.tsbuildinfo +1 -0
  282. package/tsconfig.json +22 -15
  283. package/build-types/components/media-editor-toolbar/index.d.ts +0 -24
  284. package/build-types/components/media-editor-toolbar/index.d.ts.map +0 -1
  285. package/build-types/components/media-editor-transform-controls/index.d.ts +0 -21
  286. package/build-types/components/media-editor-transform-controls/index.d.ts.map +0 -1
  287. package/build-types/components/media-form/sidebar-datetime-view.d.ts +0 -10
  288. package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +0 -1
  289. package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -14
  290. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
  291. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -108
  292. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
  293. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -16
  294. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
  295. package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.17.0 (2026-08-26)
6
+
7
+ ### Enhancements
8
+
9
+ - Add a `scope` prop to `MediaEditor` so each frame can keep its own persisted details-sidebar visibility ([#81559](https://github.com/WordPress/gutenberg/pull/81559)).
10
+ - Expose the header, history (reset/undo/redo), save (cancel/save) and image control clusters as `MediaEditor` sub-components, so each frame imports and arranges them to suit its own chrome. `renderFrame` now passes data only: `footerActions` is gone, `footerLayout` is now `layout`, and `isImage` is new. `showCloseButton` moves from `MediaEditor` to `MediaEditor.HeaderActions` ([#81563](https://github.com/WordPress/gutenberg/pull/81563)).
11
+
12
+ ### Bug Fixes
13
+
14
+ - Keep the Details sidebar from clipping focus outlines, with balanced horizontal padding ([#81703](https://github.com/WordPress/gutenberg/pull/81703)).
15
+ - Keep initial focus on the modal dialog frame instead of moving it to the crop area once the image loads ([#81541](https://github.com/WordPress/gutenberg/pull/81541)).
16
+
17
+ ### Internal
18
+
19
+ - Split tsconfig into a build project and a default dev project so dev files are type checked without publishing their declarations. ([#81514](https://github.com/WordPress/gutenberg/pull/81514))
20
+
21
+ ## 0.16.0 (2026-08-12)
22
+
5
23
  ## 0.15.0 (2026-07-29)
6
24
 
7
25
  ## 0.14.0 (2026-07-14)
@@ -61,11 +61,16 @@ var import_use_crop_options = require("./use-crop-options.cjs");
61
61
  var import_jsx_runtime = require("react/jsx-runtime");
62
62
  var ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
63
63
  var PLACEMENT_CONTROL_IDLE_MS = 300;
64
- function MediaEditorSidebar({ tabs }) {
64
+ function MediaEditorSidebar({
65
+ tabs,
66
+ activeTabId,
67
+ onTabChange,
68
+ scope
69
+ }) {
65
70
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
66
71
  import_interface.ComplementaryArea,
67
72
  {
68
- scope: "media-editor",
73
+ scope,
69
74
  identifier: "media-editor/details",
70
75
  title: (0, import_i18n.__)("Details"),
71
76
  icon: import_icons.drawerRight,
@@ -74,25 +79,38 @@ function MediaEditorSidebar({ tabs }) {
74
79
  panelClassName: "media-editor__sidebar-panel",
75
80
  headerClassName: "media-editor__sidebar-header",
76
81
  closeLabel: (0, import_i18n.__)("Close media panel"),
82
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
+ import_ui.Tabs.Root,
84
+ {
85
+ value: activeTabId,
86
+ onValueChange: (value) => onTabChange(value)
87
+ }
88
+ ),
77
89
  header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.List, { variant: "minimal", children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.Tab, { value: tab.id, children: tab.title }, tab.id)) }),
78
90
  children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.Panel, { value: tab.id, tabIndex: -1, children: tab.panel }, tab.id))
79
91
  }
80
92
  );
81
93
  }
82
- function HeaderActions({
83
- isSaving,
84
- isImage,
85
- showCloseButton = false,
86
- onCancel
87
- }) {
94
+ var MediaEditorFrameContext = (0, import_element.createContext)(null);
95
+ function useMediaEditorFrameContext() {
96
+ const context = (0, import_element.useContext)(MediaEditorFrameContext);
97
+ if (!context) {
98
+ throw new Error(
99
+ "useMediaEditorFrameContext must be used within MediaEditor"
100
+ );
101
+ }
102
+ return context;
103
+ }
104
+ function HeaderActions({ showCloseButton = false }) {
105
+ const { isImage, isSaving, onCancel, scope } = useMediaEditorFrameContext();
88
106
  const [isShortcutsModalOpen, setIsShortcutsModalOpen] = (0, import_element.useState)(false);
89
107
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
90
- import_components.Flex,
108
+ import_ui.Stack,
91
109
  {
92
110
  className: "media-editor__header-actions",
93
111
  justify: "flex-end",
94
- expanded: false,
95
- gap: 2,
112
+ align: "center",
113
+ gap: "sm",
96
114
  children: [
97
115
  isImage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
116
  import_components.Button,
@@ -103,7 +121,7 @@ function HeaderActions({
103
121
  onClick: () => setIsShortcutsModalOpen(true)
104
122
  }
105
123
  ),
106
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.PinnedItems.Slot, { scope: "media-editor" }),
124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.PinnedItems.Slot, { scope }),
107
125
  showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
126
  import_components.Button,
109
127
  {
@@ -125,10 +143,8 @@ function HeaderActions({
125
143
  }
126
144
  );
127
145
  }
128
- function HistoryActions({
129
- isUndoRedoDisabled = false,
130
- onReset
131
- }) {
146
+ function HistoryActions() {
147
+ const { isImage, isUndoRedoDisabled, onReset } = useMediaEditorFrameContext();
132
148
  const {
133
149
  reset,
134
150
  isDirty,
@@ -139,6 +155,9 @@ function HistoryActions({
139
155
  beginGesture,
140
156
  endGesture
141
157
  } = (0, import_state.useMediaEditor)();
158
+ if (!isImage) {
159
+ return null;
160
+ }
142
161
  const handleUndo = () => {
143
162
  if (isUndoRedoDisabled) {
144
163
  return;
@@ -158,11 +177,11 @@ function HistoryActions({
158
177
  endGesture();
159
178
  };
160
179
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
161
- import_components.Flex,
180
+ import_ui.Stack,
162
181
  {
163
182
  className: "media-editor__history-actions",
164
- expanded: false,
165
- gap: 2,
183
+ align: "center",
184
+ gap: "sm",
166
185
  children: [
167
186
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
168
187
  import_components.Button,
@@ -205,26 +224,22 @@ function HistoryActions({
205
224
  }
206
225
  );
207
226
  }
208
- function FooterActions({
209
- isSaving,
210
- hasMedia,
211
- hasChanges,
212
- onCancel,
213
- onSave
214
- }) {
227
+ function SaveActions({ size = "default" }) {
228
+ const { isSaving, hasMedia, hasChanges, onCancel, onSave } = useMediaEditorFrameContext();
215
229
  const saveDisabled = isSaving || !hasMedia || !hasChanges;
216
230
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
217
- import_components.Flex,
231
+ import_ui.Stack,
218
232
  {
219
- className: "media-editor__footer-actions",
233
+ className: "media-editor__save-actions",
220
234
  justify: "flex-end",
221
- expanded: false,
222
- gap: 2,
235
+ align: "center",
236
+ gap: "sm",
223
237
  children: [
224
238
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
225
239
  import_components.Button,
226
240
  {
227
241
  __next40pxDefaultSize: true,
242
+ size,
228
243
  variant: "tertiary",
229
244
  onClick: onCancel,
230
245
  disabled: isSaving,
@@ -236,6 +251,7 @@ function FooterActions({
236
251
  import_components.Button,
237
252
  {
238
253
  __next40pxDefaultSize: true,
254
+ size,
239
255
  variant: "primary",
240
256
  onClick: onSave,
241
257
  isBusy: isSaving,
@@ -248,6 +264,19 @@ function FooterActions({
248
264
  }
249
265
  );
250
266
  }
267
+ function ImageControls() {
268
+ const { isImage, aspectRatioPresets } = useMediaEditorFrameContext();
269
+ if (!isImage) {
270
+ return null;
271
+ }
272
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
+ import_media_editor_image_controls.default,
274
+ {
275
+ showAspectRatioControl: true,
276
+ aspectRatioPresets
277
+ }
278
+ );
279
+ }
251
280
  function MediaEditorContent({
252
281
  fields = [],
253
282
  id,
@@ -257,12 +286,12 @@ function MediaEditorContent({
257
286
  renderFrame,
258
287
  noticesClassName = "media-editor__snackbar",
259
288
  noticesPortalElement,
260
- showCloseButton = false,
261
- shouldCloseOnEsc = false
289
+ shouldCloseOnEsc = false,
290
+ scope = "media-editor"
262
291
  }) {
263
292
  const cropper = (0, import_state.useMediaEditor)();
264
293
  const isPanelLayout = (0, import_compose.useViewportMatch)("small");
265
- const footerLayout = isPanelLayout ? "wide" : "narrow";
294
+ const layout = isPanelLayout ? "wide" : "narrow";
266
295
  const { media, hasEdits } = (0, import_data.useSelect)(
267
296
  (select) => {
268
297
  const {
@@ -466,40 +495,39 @@ function MediaEditorContent({
466
495
  onChange: handleChange,
467
496
  settings: { fields },
468
497
  children: [
469
- !media ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__loading", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
470
- import_ui.Tabs.Root,
471
- {
472
- className: "media-editor",
473
- value: activeTabId,
474
- onValueChange: (value) => setSelectedTabId(value),
475
- children: [
476
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaEditorSidebar, { tabs }),
477
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
478
- import_interface.InterfaceSkeleton,
479
- {
480
- className: "media-editor__skeleton",
481
- labels: {
482
- body: isImage ? (0, import_i18n.__)("Image editor") : (0, import_i18n.__)("Media preview"),
483
- sidebar: (0, import_i18n.__)("Media details")
484
- },
485
- content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor__content", children: [
486
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-area", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
487
- import_media_editor_canvas.default,
488
- {
489
- focusOnMount: true,
490
- isPlacementActive,
491
- onGestureStart: handleCanvasGestureStart,
492
- onGestureEnd: handleCanvasGestureEnd
493
- }
494
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_preview.default, {}) }),
495
- isImage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-toolbar", children: ruler })
496
- ] }),
497
- sidebar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.ComplementaryArea.Slot, { scope: "media-editor" })
498
- }
499
- )
500
- ]
501
- }
502
- ),
498
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor", children: !media ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__loading", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
500
+ MediaEditorSidebar,
501
+ {
502
+ tabs,
503
+ activeTabId,
504
+ onTabChange: setSelectedTabId,
505
+ scope
506
+ }
507
+ ),
508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
509
+ import_interface.InterfaceSkeleton,
510
+ {
511
+ className: "media-editor__skeleton",
512
+ labels: {
513
+ body: isImage ? (0, import_i18n.__)("Image editor") : (0, import_i18n.__)("Media preview"),
514
+ sidebar: (0, import_i18n.__)("Media details")
515
+ },
516
+ content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor__content", children: [
517
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-area", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
518
+ import_media_editor_canvas.default,
519
+ {
520
+ isPlacementActive,
521
+ onGestureStart: handleCanvasGestureStart,
522
+ onGestureEnd: handleCanvasGestureEnd
523
+ }
524
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_preview.default, {}) }),
525
+ isImage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-toolbar", children: ruler })
526
+ ] }),
527
+ sidebar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.ComplementaryArea.Slot, { scope })
528
+ }
529
+ )
530
+ ] }) }),
503
531
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
504
532
  import_components.__experimentalConfirmDialog,
505
533
  {
@@ -520,69 +548,37 @@ function MediaEditorContent({
520
548
  ]
521
549
  }
522
550
  );
523
- const history = isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
524
- HistoryActions,
525
- {
526
- isUndoRedoDisabled: isCropInteractionActive,
527
- onReset: resetCropOptions
528
- }
529
- ) : null;
530
- const imageControls = isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
531
- import_media_editor_image_controls.default,
532
- {
533
- showAspectRatioControl: true,
534
- aspectRatioPresets
535
- }
536
- ) : null;
537
- const actions = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
538
- FooterActions,
539
- {
540
- isSaving,
541
- hasMedia: !!media,
542
- hasChanges,
543
- onCancel: handleRequestClose,
544
- onSave: saveMediaEditor
545
- }
546
- );
547
- let footerActions;
548
- if (footerLayout === "wide") {
549
- footerActions = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
550
- history,
551
- actions
552
- ] });
553
- } else {
554
- footerActions = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
555
- imageControls,
556
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-modal__footer-row", children: [
557
- history,
558
- actions
559
- ] })
560
- ] });
561
- }
562
- return renderFrame({
551
+ const contextValue = {
552
+ isImage,
553
+ isSaving,
554
+ hasMedia: !!media,
555
+ hasChanges,
556
+ isUndoRedoDisabled: isCropInteractionActive,
557
+ scope,
558
+ aspectRatioPresets,
559
+ onCancel: handleRequestClose,
560
+ onSave: saveMediaEditor,
561
+ onReset: resetCropOptions
562
+ };
563
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaEditorFrameContext.Provider, { value: contextValue, children: renderFrame({
563
564
  children,
564
- headerActions: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
565
- HeaderActions,
566
- {
567
- isSaving,
568
- isImage,
569
- showCloseButton,
570
- onCancel: handleRequestClose
571
- }
572
- ),
573
- footerActions,
574
- footerLayout,
565
+ isImage,
566
+ layout,
575
567
  onRequestClose: handleRequestClose,
576
568
  onKeyDown: handleKeyDown,
577
569
  shouldCloseOnClickOutside: !hasChanges && !isSaving,
578
570
  isSaving,
579
571
  hasChanges,
580
572
  hasMedia: !!media
581
- });
573
+ }) });
582
574
  }
583
575
  function MediaEditor(props) {
584
576
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_state.MediaEditorStateProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaEditorContent, { ...props }) }, props.id);
585
577
  }
578
+ MediaEditor.HeaderActions = HeaderActions;
579
+ MediaEditor.HistoryActions = HistoryActions;
580
+ MediaEditor.SaveActions = SaveActions;
581
+ MediaEditor.ImageControls = ImageControls;
586
582
  var media_editor_default = MediaEditor;
587
583
  // Annotate the CommonJS export names for ESM import in node:
588
584
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFlex,\n\tSpinner,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { Stack, Tabs } from '@wordpress/ui';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tcreatePortal,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close, drawerRight, keyboard, redo, undo } from '@wordpress/icons';\nimport {\n\tdisplayShortcut,\n\tisAppleOS,\n\tisKeyboardEvent,\n} from '@wordpress/keycodes';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport {\n\tComplementaryArea,\n\tInterfaceSkeleton,\n\tPinnedItems,\n\t// No type declarations available for @wordpress/interface.\n\t// @ts-expect-error\n} from '@wordpress/interface';\nimport type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { MediaEditorProvider } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\nimport MediaPreview from '../media-preview';\nimport MediaEditorCanvas from '../media-editor-canvas';\nimport MediaEditorFineRotation from '../media-editor-fine-rotation';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport MediaEditorCropPanel from '../media-editor-crop-panel';\nimport MediaForm from '../media-form';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { MediaEditorStateProvider, useMediaEditor } from '../../state';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorKeyboardShortcutsModal from '../media-editor-keyboard-shortcuts-modal';\nimport {\n\tMEDIA_EDITOR_NOTICES_CONTEXT,\n\tuseSaveMediaEditor,\n\ttype MediaEditorSaveResult,\n} from './use-save-media-editor';\nimport { useCropOptions } from './use-crop-options';\n\nexport type { MediaEditorSaveResult } from './use-save-media-editor';\n\n// Embed query for the attachment's author and parent post. Shared between\n// the `getEntityRecord` read and the matching `invalidateResolution` so the\n// two stay in lockstep.\nconst ATTACHMENT_EMBED_QUERY = { _embed: 'author,wp:attached-to' } as const;\n\nconst PLACEMENT_CONTROL_IDLE_MS = 300;\n\ninterface EditorTab {\n\tid: string;\n\ttitle: string;\n\tpanel: JSX.Element;\n}\n\nexport interface MediaEditorFrameProps {\n\tchildren: ReactNode;\n\theaderActions: ReactNode;\n\tfooterActions: ReactNode;\n\t/**\n\t * Footer layout selector. Frames apply this to the footer container\n\t * as a modifier class. Tracks the sidebar-collapse breakpoint (`medium`).\n\t *\n\t * - `wide` — sidebar is a column; footer is a single row of History |\n\t * Cancel/Save (transform controls live in the Crop panel).\n\t * - `narrow` — sidebar collapsed; transform controls sit above a\n\t * History | Cancel/Save row.\n\t */\n\tfooterLayout: 'wide' | 'narrow';\n\tonRequestClose: () => void;\n\tonKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;\n\tshouldCloseOnClickOutside: boolean;\n\tisSaving: boolean;\n\thasChanges: boolean;\n\thasMedia: boolean;\n}\n\nexport interface MediaEditorProps {\n\tfields?: Field< Media >[];\n\tid: number;\n\taspectRatioPresets?: AspectRatioPreset[];\n\tonClose?: () => void;\n\tonSaved?: ( result: MediaEditorSaveResult ) => void;\n\trenderFrame: ( props: MediaEditorFrameProps ) => JSX.Element;\n\tnoticesClassName?: string;\n\tnoticesPortalElement?: Element | null;\n\tshowCloseButton?: boolean;\n\tshouldCloseOnEsc?: boolean;\n}\n\nfunction MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {\n\t// The tab list and panels must share one `<Tabs.Root>`, but they render in\n\t// separate `ComplementaryArea` regions (header vs body). A non-virtual Slot\n\t// reconciles both inline at the Slot, so the `Root` is lifted to wrap this\n\t// Fill and that Slot together — see `MediaEditorContent`.\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tscope=\"media-editor\"\n\t\t\tidentifier=\"media-editor/details\"\n\t\t\ttitle={ __( 'Details' ) }\n\t\t\ticon={ drawerRight }\n\t\t\tisActiveByDefault\n\t\t\tclassName=\"media-editor__sidebar\"\n\t\t\tpanelClassName=\"media-editor__sidebar-panel\"\n\t\t\theaderClassName=\"media-editor__sidebar-header\"\n\t\t\tcloseLabel={ __( 'Close media panel' ) }\n\t\t\theader={\n\t\t\t\t<Tabs.List variant=\"minimal\">\n\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab key={ tab.id } value={ tab.id }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.List>\n\t\t\t}\n\t\t>\n\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t<Tabs.Panel key={ tab.id } value={ tab.id } tabIndex={ -1 }>\n\t\t\t\t\t{ tab.panel }\n\t\t\t\t</Tabs.Panel>\n\t\t\t) ) }\n\t\t</ComplementaryArea>\n\t);\n}\n\ninterface HeaderActionsProps {\n\tisSaving: boolean;\n\tisImage: boolean;\n\tshowCloseButton?: boolean;\n\tonCancel: () => void;\n}\n\nfunction HeaderActions( {\n\tisSaving,\n\tisImage,\n\tshowCloseButton = false,\n\tonCancel,\n}: HeaderActionsProps ) {\n\tconst [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );\n\treturn (\n\t\t<Flex\n\t\t\tclassName=\"media-editor__header-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\texpanded={ false }\n\t\t\tgap={ 2 }\n\t\t>\n\t\t\t{ isImage && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ keyboard }\n\t\t\t\t\tlabel={ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\tonClick={ () => setIsShortcutsModalOpen( true ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<PinnedItems.Slot scope=\"media-editor\" />\n\t\t\t{ showCloseButton && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isShortcutsModalOpen && (\n\t\t\t\t<MediaEditorKeyboardShortcutsModal\n\t\t\t\t\tonClose={ () => setIsShortcutsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\ninterface HistoryActionsProps {\n\tisUndoRedoDisabled?: boolean;\n\tonReset: () => void;\n}\n\nfunction HistoryActions( {\n\tisUndoRedoDisabled = false,\n\tonReset,\n}: HistoryActionsProps ) {\n\tconst {\n\t\treset,\n\t\tisDirty,\n\t\thasUndo,\n\t\thasRedo,\n\t\tundo: undoCrop,\n\t\tredo: redoCrop,\n\t\tbeginGesture,\n\t\tendGesture,\n\t} = useMediaEditor();\n\tconst handleUndo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tundoCrop();\n\t};\n\tconst handleRedo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tredoCrop();\n\t};\n\tconst handleReset = () => {\n\t\tbeginGesture();\n\t\treset();\n\t\tonReset();\n\t\tendGesture();\n\t};\n\treturn (\n\t\t<Flex\n\t\t\tclassName=\"media-editor__history-actions\"\n\t\t\texpanded={ false }\n\t\t\tgap={ 2 }\n\t\t>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleReset }\n\t\t\t>\n\t\t\t\t{ __( 'Reset' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ undo }\n\t\t\t\tlabel={ __( 'Undo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasUndo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleUndo }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ redo }\n\t\t\t\tlabel={ __( 'Redo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={\n\t\t\t\t\tisAppleOS()\n\t\t\t\t\t\t? displayShortcut.primaryShift( 'z' )\n\t\t\t\t\t\t: displayShortcut.primary( 'y' )\n\t\t\t\t}\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasRedo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleRedo }\n\t\t\t/>\n\t\t</Flex>\n\t);\n}\n\ninterface FooterActionsProps {\n\tisSaving: boolean;\n\thasMedia: boolean;\n\thasChanges: boolean;\n\tonCancel: () => void;\n\tonSave: () => void;\n}\n\nfunction FooterActions( {\n\tisSaving,\n\thasMedia,\n\thasChanges,\n\tonCancel,\n\tonSave,\n}: FooterActionsProps ) {\n\tconst saveDisabled = isSaving || ! hasMedia || ! hasChanges;\n\treturn (\n\t\t<Flex\n\t\t\tclassName=\"media-editor__footer-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\texpanded={ false }\n\t\t\tgap={ 2 }\n\t\t>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tonClick={ onCancel }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ onSave }\n\t\t\t\tisBusy={ isSaving }\n\t\t\t\tdisabled={ saveDisabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Save' ) }\n\t\t\t</Button>\n\t\t</Flex>\n\t);\n}\n\nfunction MediaEditorContent( {\n\tfields = [],\n\tid,\n\taspectRatioPresets,\n\tonClose,\n\tonSaved,\n\trenderFrame,\n\tnoticesClassName = 'media-editor__snackbar',\n\tnoticesPortalElement,\n\tshowCloseButton = false,\n\tshouldCloseOnEsc = false,\n}: MediaEditorProps ) {\n\tconst cropper = useMediaEditor();\n\t// The sidebar is a side column from the `small` breakpoint up and collapses\n\t// to an overlay below it — mirroring InterfaceSkeleton's behaviour, shifted\n\t// from `medium` to `small` (see the matching CSS overrides in style.scss).\n\t// Track that single breakpoint: in \"panel mode\" (≥ small) the\n\t// rotate/flip/zoom controls live in the Crop panel and the footer is just\n\t// History + Cancel/Save; below it the controls drop into the footer. (The\n\t// fine-rotation ruler always sits under the canvas.)\n\tconst isPanelLayout = useViewportMatch( 'small' );\n\tconst footerLayout: 'wide' | 'narrow' = isPanelLayout ? 'wide' : 'narrow';\n\n\tconst { media, hasEdits } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\thasEditsForEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\t// Trigger an _embed fetch so `_embedded.author` and\n\t\t\t// `_embedded['wp:attached-to']` land on the record for the Details\n\t\t\t// fields to read. `getEditedEntityRecord` doesn't formally accept a\n\t\t\t// query, so we can't embed via that selector directly.\n\t\t\tgetEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tid,\n\t\t\t\tATTACHMENT_EMBED_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tmedia: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) as Media,\n\t\t\t\thasEdits: hasEditsForEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id ]\n\t);\n\n\tconst hasChanges = cropper.isCropperDirty || hasEdits;\n\n\tconst { clearEntityRecordEdits, editEntityRecord, invalidateResolution } =\n\t\tuseDispatch( coreStore );\n\tconst { removeAllNotices } = useDispatch( noticesStore );\n\n\tconst [ isDiscardDialogOpen, setIsDiscardDialogOpen ] = useState( false );\n\tconst [ isPlacementActive, setIsPlacementActive ] = useState( false );\n\tconst [ isCanvasGestureActive, setIsCanvasGestureActive ] =\n\t\tuseState( false );\n\tconst placementControlTimerRef =\n\t\tuseRef< ReturnType< typeof setTimeout > >();\n\n\tconst signalPlacementControlInteraction = useCallback( () => {\n\t\tsetIsPlacementActive( true );\n\t\tclearTimeout( placementControlTimerRef.current );\n\t\tplacementControlTimerRef.current = setTimeout( () => {\n\t\t\tsetIsPlacementActive( false );\n\t\t}, PLACEMENT_CONTROL_IDLE_MS );\n\t}, [] );\n\tconst handleCanvasGestureStart = useCallback( () => {\n\t\tsetIsCanvasGestureActive( true );\n\t}, [] );\n\tconst handleCanvasGestureEnd = useCallback( () => {\n\t\tsetIsCanvasGestureActive( false );\n\t}, [] );\n\tconst isCropInteractionActive = isPlacementActive || isCanvasGestureActive;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( placementControlTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsPlacementActive( false );\n\t\tsetIsCanvasGestureActive( false );\n\t}, [ id ] );\n\n\t// Bust the cached `_embed` resolution each time the editor mounts (or the\n\t// id changes) so embedded data such as the attached post's title or the\n\t// author's name reflects any edits made elsewhere since the last open.\n\tuseEffect( () => {\n\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t'postType',\n\t\t\t'attachment',\n\t\t\tid,\n\t\t\tATTACHMENT_EMBED_QUERY,\n\t\t] );\n\t}, [ id, invalidateResolution ] );\n\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type ).type;\n\tconst isImage = !! media && mediaType === 'image';\n\tconst {\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tresetCropOptions,\n\t} = useCropOptions( {\n\t\taspectRatioPresets,\n\t} );\n\tconst { isSaving, save: saveMediaEditor } = useSaveMediaEditor( {\n\t\tcropper,\n\t\tid,\n\t\tisImage,\n\t\tmedia,\n\t\tonSaved,\n\t} );\n\n\tconst tabs = useMemo< EditorTab[] >( () => {\n\t\tconst detailsTab: EditorTab = {\n\t\t\tid: 'details',\n\t\t\ttitle: __( 'Details' ),\n\t\t\tpanel: (\n\t\t\t\t<Stack\n\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"lg\"\n\t\t\t\t>\n\t\t\t\t\t<MediaForm />\n\t\t\t\t</Stack>\n\t\t\t),\n\t\t};\n\t\tif ( ! isImage ) {\n\t\t\treturn [ detailsTab ];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'crop',\n\t\t\t\ttitle: __( 'Crop' ),\n\t\t\t\tpanel: (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\tgap=\"lg\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<MediaEditorCropPanel\n\t\t\t\t\t\t\taspectRatioValue={ aspectRatioValue }\n\t\t\t\t\t\t\tonAspectRatioChange={ setAspectRatioValue }\n\t\t\t\t\t\t\taspectRatioOptions={ aspectRatioOptions }\n\t\t\t\t\t\t\tshowTransformControls={ isPanelLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Stack>\n\t\t\t\t),\n\t\t\t},\n\t\t\tdetailsTab,\n\t\t];\n\t}, [\n\t\tisImage,\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tisPanelLayout,\n\t] );\n\n\t// Control the active tab from state here so the selection survives the\n\t// sidebar closing (which unmounts the `ComplementaryArea` Fill and its\n\t// tabs). Fall back to the first tab until one is picked, so images open on\n\t// Crop.\n\tconst [ selectedTabId, setSelectedTabId ] = useState< string >();\n\tconst activeTabId = selectedTabId ?? tabs[ 0 ]?.id;\n\n\tconst handleChange = ( updates: Partial< Media > ) => {\n\t\teditEntityRecord( 'postType', 'attachment', id, updates );\n\t};\n\n\tconst discardAndClose = () => {\n\t\tremoveAllNotices( 'snackbar', MEDIA_EDITOR_NOTICES_CONTEXT );\n\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\tonClose?.();\n\t};\n\n\tconst handleRequestClose = () => {\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( hasChanges ) {\n\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\treturn;\n\t\t}\n\t\tdiscardAndClose();\n\t};\n\n\tconst handleKeyDown = ( event: ReactKeyboardEvent< HTMLElement > ) => {\n\t\tconst isUndoShortcut = isKeyboardEvent.primary( event, 'z' );\n\t\tconst isRedoShortcut =\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' ) ||\n\t\t\t( ! isAppleOS() && isKeyboardEvent.primary( event, 'y' ) );\n\t\tif ( ( isUndoShortcut || isRedoShortcut ) && isImage ) {\n\t\t\tconst target = event.target as HTMLElement;\n\t\t\tconst isMetadataField =\n\t\t\t\t( target.tagName === 'INPUT' ||\n\t\t\t\t\ttarget.tagName === 'TEXTAREA' ||\n\t\t\t\t\ttarget.isContentEditable ) &&\n\t\t\t\t! target.closest( `[${ CROP_CONTROL_ATTR }]` );\n\t\t\tif ( ! isMetadataField ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( isCropInteractionActive ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( isRedoShortcut ) {\n\t\t\t\t\tcropper.redo();\n\t\t\t\t} else {\n\t\t\t\t\tcropper.undo();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( shouldCloseOnEsc ) {\n\t\t\tif ( event.code !== 'Escape' && event.key !== 'Escape' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( isSaving ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( hasChanges ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst snackbar = (\n\t\t<SnackbarNotices\n\t\t\tclassName={ noticesClassName }\n\t\t\tcontext={ MEDIA_EDITOR_NOTICES_CONTEXT }\n\t\t/>\n\t);\n\n\tconst ruler = isImage ? (\n\t\t<MediaEditorFineRotation\n\t\t\tonPlacementControlInteraction={ signalPlacementControlInteraction }\n\t\t/>\n\t) : null;\n\n\tconst children = (\n\t\t<MediaEditorProvider\n\t\t\tvalue={ media ?? undefined }\n\t\t\tonChange={ handleChange }\n\t\t\tsettings={ { fields } }\n\t\t>\n\t\t\t{ ! media ? (\n\t\t\t\t<div className=\"media-editor\">\n\t\t\t\t\t<div className=\"media-editor__loading\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<Tabs.Root\n\t\t\t\t\tclassName=\"media-editor\"\n\t\t\t\t\tvalue={ activeTabId }\n\t\t\t\t\tonValueChange={ ( value ) =>\n\t\t\t\t\t\tsetSelectedTabId( value as string )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<MediaEditorSidebar tabs={ tabs } />\n\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\tclassName=\"media-editor__skeleton\"\n\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\tbody: isImage\n\t\t\t\t\t\t\t\t? __( 'Image editor' )\n\t\t\t\t\t\t\t\t: __( 'Media preview' ),\n\t\t\t\t\t\t\tsidebar: __( 'Media details' ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t<div className=\"media-editor__content\">\n\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas-area\">\n\t\t\t\t\t\t\t\t\t{ isImage ? (\n\t\t\t\t\t\t\t\t\t\t<MediaEditorCanvas\n\t\t\t\t\t\t\t\t\t\t\tfocusOnMount\n\t\t\t\t\t\t\t\t\t\t\tisPlacementActive={\n\t\t\t\t\t\t\t\t\t\t\t\tisPlacementActive\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonGestureStart={\n\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureStart\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonGestureEnd={\n\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureEnd\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<MediaPreview />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{ isImage && (\n\t\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas-toolbar\">\n\t\t\t\t\t\t\t\t\t\t{ ruler }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"media-editor\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.Root>\n\t\t\t) }\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isDiscardDialogOpen }\n\t\t\t\tconfirmButtonText={ __( 'Discard' ) }\n\t\t\t\tcancelButtonText={ __( 'Keep editing' ) }\n\t\t\t\tonCancel={ () => setIsDiscardDialogOpen( false ) }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\tsetIsDiscardDialogOpen( false );\n\t\t\t\t\tdiscardAndClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Are you sure you want to discard your unsaved changes?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t\t{ noticesPortalElement\n\t\t\t\t? createPortal( snackbar, noticesPortalElement )\n\t\t\t\t: snackbar }\n\t\t</MediaEditorProvider>\n\t);\n\n\tconst history = isImage ? (\n\t\t<HistoryActions\n\t\t\tisUndoRedoDisabled={ isCropInteractionActive }\n\t\t\tonReset={ resetCropOptions }\n\t\t/>\n\t) : null;\n\tconst imageControls = isImage ? (\n\t\t<MediaEditorImageControls\n\t\t\tshowAspectRatioControl\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t/>\n\t) : null;\n\tconst actions = (\n\t\t<FooterActions\n\t\t\tisSaving={ isSaving }\n\t\t\thasMedia={ !! media }\n\t\t\thasChanges={ hasChanges }\n\t\t\tonCancel={ handleRequestClose }\n\t\t\tonSave={ saveMediaEditor }\n\t\t/>\n\t);\n\n\t// The fine-rotation ruler always lives under the canvas (in\n\t// `media-editor__content`), never the footer, so it stays constrained to\n\t// the canvas column at every viewport. One JSX tree per layout; DOM order\n\t// matches visual order.\n\tlet footerActions: ReactNode;\n\tif ( footerLayout === 'wide' ) {\n\t\t// Sidebar is a column: image controls live in the Crop panel, so\n\t\t// the footer is just History + Cancel/Save.\n\t\tfooterActions = (\n\t\t\t<>\n\t\t\t\t{ history }\n\t\t\t\t{ actions }\n\t\t\t</>\n\t\t);\n\t} else {\n\t\t// Sidebar collapsed: the image controls drop into the footer.\n\t\tfooterActions = (\n\t\t\t<>\n\t\t\t\t{ imageControls }\n\t\t\t\t<div className=\"media-editor-modal__footer-row\">\n\t\t\t\t\t{ history }\n\t\t\t\t\t{ actions }\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn renderFrame( {\n\t\tchildren,\n\t\theaderActions: (\n\t\t\t<HeaderActions\n\t\t\t\tisSaving={ isSaving }\n\t\t\t\tisImage={ isImage }\n\t\t\t\tshowCloseButton={ showCloseButton }\n\t\t\t\tonCancel={ handleRequestClose }\n\t\t\t/>\n\t\t),\n\t\tfooterActions,\n\t\tfooterLayout,\n\t\tonRequestClose: handleRequestClose,\n\t\tonKeyDown: handleKeyDown,\n\t\tshouldCloseOnClickOutside: ! hasChanges && ! isSaving,\n\t\tisSaving,\n\t\thasChanges,\n\t\thasMedia: !! media,\n\t} );\n}\n\nexport function MediaEditor( props: MediaEditorProps ) {\n\treturn (\n\t\t<MediaEditorStateProvider key={ props.id }>\n\t\t\t<MediaEditorContent { ...props } />\n\t\t</MediaEditorStateProvider>\n\t);\n}\n\nexport default MediaEditor;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAKO;AACP,gBAA4B;AAC5B,qBAAiC;AACjC,kBAAuC;AACvC,uBAAmC;AACnC,qBAOO;AACP,kBAAmB;AACnB,mBAAyD;AACzD,sBAIO;AACP,qBAAuD;AAEvD,uBAMO;AAMP,mCAAoC;AAEpC,2BAAyB;AACzB,iCAA8B;AAC9B,wCAAoC;AACpC,yCAAqC;AACrC,qCAAiC;AACjC,wBAAsB;AACtB,mBAAyC;AACzC,mBAAyD;AAEzD,uCAAkC;AAClC,mDAA8C;AAC9C,mCAIO;AACP,8BAA+B;AAuEzB;AAhEN,IAAM,yBAAyB,EAAE,QAAQ,wBAAwB;AAEjE,IAAM,4BAA4B;AA2ClC,SAAS,mBAAoB,EAAE,KAAK,GAA2B;AAK9D,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAM;AAAA,MACN,YAAW;AAAA,MACX,WAAQ,gBAAI,SAAU;AAAA,MACtB,MAAO;AAAA,MACP,mBAAiB;AAAA,MACjB,WAAU;AAAA,MACV,gBAAe;AAAA,MACf,iBAAgB;AAAA,MAChB,gBAAa,gBAAI,mBAAoB;AAAA,MACrC,QACC,4CAAC,eAAK,MAAL,EAAU,SAAQ,WAChB,eAAK,IAAK,CAAE,QACb,4CAAC,eAAK,KAAL,EAAwB,OAAQ,IAAI,IAClC,cAAI,SADS,IAAI,EAEpB,CACC,GACH;AAAA,MAGC,eAAK,IAAK,CAAE,QACb,4CAAC,eAAK,OAAL,EAA0B,OAAQ,I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,MACA;AAAA,OACH;AAAA,EAEF,OAAO;AAEN,oBACC,4EACG;AAAA;AAAA,MACF,6CAAC,SAAI,WAAU,kCACZ;AAAA;AAAA,QACA;AAAA,SACH;AAAA,OACD;AAAA,EAEF;AAEA,SAAO,YAAa;AAAA,IACnB;AAAA,IACA,eACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAW;AAAA;AAAA,IACZ;AAAA,IAED;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,2BAA2B,CAAE,cAAc,CAAE;AAAA,IAC7C;AAAA,IACA;AAAA,IACA,UAAU,CAAC,CAAE;AAAA,EACd,CAAE;AACH;AAEO,SAAS,YAAa,OAA0B;AACtD,SACC,4CAAC,yCACA,sDAAC,sBAAqB,GAAG,OAAQ,KADF,MAAM,EAEtC;AAEF;AAEA,IAAO,uBAAQ;",
6
- "names": ["MediaEditorKeyboardShortcutsModal", "coreStore", "noticesStore", "MediaForm", "MediaEditorCropPanel", "MediaEditorFineRotation", "MediaEditorCanvas", "MediaPreview", "ConfirmDialog", "MediaEditorImageControls"]
4
+ "sourcesContent": ["import {\n\tButton,\n\tSpinner,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { Stack, Tabs } from '@wordpress/ui';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tcreateContext,\n\tcreatePortal,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close, drawerRight, keyboard, redo, undo } from '@wordpress/icons';\nimport {\n\tdisplayShortcut,\n\tisAppleOS,\n\tisKeyboardEvent,\n} from '@wordpress/keycodes';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport {\n\tComplementaryArea,\n\tInterfaceSkeleton,\n\tPinnedItems,\n\t// @ts-expect-error `@wordpress/interface` is not typed yet.\n} from '@wordpress/interface';\nimport type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\nimport { MediaEditorProvider } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\nimport MediaPreview from '../media-preview';\nimport MediaEditorCanvas from '../media-editor-canvas';\nimport MediaEditorFineRotation from '../media-editor-fine-rotation';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport MediaEditorCropPanel from '../media-editor-crop-panel';\nimport MediaForm from '../media-form';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { MediaEditorStateProvider, useMediaEditor } from '../../state';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorKeyboardShortcutsModal from '../media-editor-keyboard-shortcuts-modal';\nimport {\n\tMEDIA_EDITOR_NOTICES_CONTEXT,\n\tuseSaveMediaEditor,\n\ttype MediaEditorSaveResult,\n} from './use-save-media-editor';\nimport { useCropOptions } from './use-crop-options';\n\nexport type { MediaEditorSaveResult } from './use-save-media-editor';\n\n// Embed query for the attachment's author and parent post. Shared between\n// the `getEntityRecord` read and the matching `invalidateResolution` so the\n// two stay in lockstep.\nconst ATTACHMENT_EMBED_QUERY = { _embed: 'author,wp:attached-to' } as const;\n\nconst PLACEMENT_CONTROL_IDLE_MS = 300;\n\ninterface EditorTab {\n\tid: string;\n\ttitle: string;\n\tpanel: JSX.Element;\n}\n\nexport interface MediaEditorFrameProps {\n\tchildren: ReactNode;\n\t/**\n\t * Whether the media being edited is an image. The history and transform\n\t * clusters render nothing for other media types, so a frame uses this to\n\t * decide whether the container it would put them in is worth rendering at\n\t * all.\n\t */\n\tisImage: boolean;\n\tlayout: 'wide' | 'narrow';\n\tonRequestClose: () => void;\n\tonKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;\n\tshouldCloseOnClickOutside: boolean;\n\tisSaving: boolean;\n\thasChanges: boolean;\n\thasMedia: boolean;\n}\n\nexport interface MediaEditorProps {\n\tfields?: Field< Media >[];\n\tid: number;\n\taspectRatioPresets?: AspectRatioPreset[];\n\tonClose?: () => void;\n\tonSaved?: ( result: MediaEditorSaveResult ) => void;\n\trenderFrame: ( props: MediaEditorFrameProps ) => JSX.Element;\n\tnoticesClassName?: string;\n\tnoticesPortalElement?: Element | null;\n\tshouldCloseOnEsc?: boolean;\n\t/**\n\t * The `@wordpress/interface` scope for the details sidebar and its pinned\n\t * items. Frames should pass a distinct scope so that sidebar visibility —\n\t * which is persisted per scope to user meta — is remembered separately for\n\t * each surface. The modal is a transient surface where a collapsed sidebar\n\t * is a reasonable choice; the full-screen route is one where the sidebar is\n\t * the primary metadata surface and should open by default. Sharing a scope\n\t * would let a choice made in one decide the other's starting state.\n\t *\n\t * @default 'media-editor'\n\t */\n\tscope?: string;\n}\n\ninterface MediaEditorSidebarProps {\n\ttabs: EditorTab[];\n\tactiveTabId?: string;\n\tonTabChange: ( tabId: string ) => void;\n\tscope: string;\n}\n\nfunction MediaEditorSidebar( {\n\ttabs,\n\tactiveTabId,\n\tonTabChange,\n\tscope,\n}: MediaEditorSidebarProps ) {\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tscope={ scope }\n\t\t\tidentifier=\"media-editor/details\"\n\t\t\ttitle={ __( 'Details' ) }\n\t\t\ticon={ drawerRight }\n\t\t\tisActiveByDefault\n\t\t\tclassName=\"media-editor__sidebar\"\n\t\t\tpanelClassName=\"media-editor__sidebar-panel\"\n\t\t\theaderClassName=\"media-editor__sidebar-header\"\n\t\t\tcloseLabel={ __( 'Close media panel' ) }\n\t\t\t// Makes `Tabs.Root` the container, so the tab list passed as\n\t\t\t// `header` and the panels below share a subtree across the fill.\n\t\t\trender={\n\t\t\t\t<Tabs.Root\n\t\t\t\t\tvalue={ activeTabId }\n\t\t\t\t\tonValueChange={ ( value ) =>\n\t\t\t\t\t\tonTabChange( value as string )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t}\n\t\t\theader={\n\t\t\t\t<Tabs.List variant=\"minimal\">\n\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab key={ tab.id } value={ tab.id }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.List>\n\t\t\t}\n\t\t>\n\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t<Tabs.Panel key={ tab.id } value={ tab.id } tabIndex={ -1 }>\n\t\t\t\t\t{ tab.panel }\n\t\t\t\t</Tabs.Panel>\n\t\t\t) ) }\n\t\t</ComplementaryArea>\n\t);\n}\n\n/**\n * Everything the frame's action clusters need from the editor. Supplied by\n * context rather than by props so the clusters can be module-level components:\n * a component created during a render has a new identity on every pass, which\n * remounts its subtree and drops focus mid-interaction.\n */\ninterface MediaEditorFrameContextValue {\n\tisImage: boolean;\n\tisSaving: boolean;\n\thasMedia: boolean;\n\thasChanges: boolean;\n\tisUndoRedoDisabled: boolean;\n\tscope: string;\n\taspectRatioPresets?: AspectRatioPreset[];\n\tonCancel: () => void;\n\tonSave: () => void;\n\tonReset: () => void;\n}\n\nconst MediaEditorFrameContext =\n\tcreateContext< MediaEditorFrameContextValue | null >( null );\n\n/**\n * Hook to access the media editor's frame context.\n *\n * Must be used within a MediaEditor component.\n *\n * @return MediaEditorFrameContextValue the action clusters render from.\n */\nfunction useMediaEditorFrameContext(): MediaEditorFrameContextValue {\n\tconst context = useContext( MediaEditorFrameContext );\n\tif ( ! context ) {\n\t\tthrow new Error(\n\t\t\t'useMediaEditorFrameContext must be used within MediaEditor'\n\t\t);\n\t}\n\treturn context;\n}\n\nexport interface HeaderActionsProps {\n\t/**\n\t * Whether to include a Close button. Frames with a dismissal affordance of\n\t * their own — a route's breadcrumbs, say — leave it out.\n\t *\n\t * @default false\n\t */\n\tshowCloseButton?: boolean;\n}\n\nfunction HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {\n\tconst { isImage, isSaving, onCancel, scope } = useMediaEditorFrameContext();\n\tconst [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__header-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t{ isImage && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ keyboard }\n\t\t\t\t\tlabel={ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\tonClick={ () => setIsShortcutsModalOpen( true ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<PinnedItems.Slot scope={ scope } />\n\t\t\t{ showCloseButton && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isShortcutsModalOpen && (\n\t\t\t\t<MediaEditorKeyboardShortcutsModal\n\t\t\t\t\tonClose={ () => setIsShortcutsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction HistoryActions() {\n\tconst { isImage, isUndoRedoDisabled, onReset } =\n\t\tuseMediaEditorFrameContext();\n\tconst {\n\t\treset,\n\t\tisDirty,\n\t\thasUndo,\n\t\thasRedo,\n\t\tundo: undoCrop,\n\t\tredo: redoCrop,\n\t\tbeginGesture,\n\t\tendGesture,\n\t} = useMediaEditor();\n\t// Non-image media has no edit history. Checked after the hooks above so\n\t// the hook order stays stable across renders.\n\tif ( ! isImage ) {\n\t\treturn null;\n\t}\n\tconst handleUndo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tundoCrop();\n\t};\n\tconst handleRedo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tredoCrop();\n\t};\n\tconst handleReset = () => {\n\t\tbeginGesture();\n\t\treset();\n\t\tonReset();\n\t\tendGesture();\n\t};\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__history-actions\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleReset }\n\t\t\t>\n\t\t\t\t{ __( 'Reset' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ undo }\n\t\t\t\tlabel={ __( 'Undo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasUndo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleUndo }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ redo }\n\t\t\t\tlabel={ __( 'Redo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={\n\t\t\t\t\tisAppleOS()\n\t\t\t\t\t\t? displayShortcut.primaryShift( 'z' )\n\t\t\t\t\t\t: displayShortcut.primary( 'y' )\n\t\t\t\t}\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasRedo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleRedo }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n\nexport interface SaveActionsProps {\n\t/**\n\t * Button height. Footers take the 40px default; frames placing these in a\n\t * page header pass `compact` to match the header's other controls.\n\t *\n\t * @default 'default'\n\t */\n\tsize?: 'default' | 'compact';\n}\n\nfunction SaveActions( { size = 'default' }: SaveActionsProps ) {\n\tconst { isSaving, hasMedia, hasChanges, onCancel, onSave } =\n\t\tuseMediaEditorFrameContext();\n\tconst saveDisabled = isSaving || ! hasMedia || ! hasChanges;\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__save-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tonClick={ onCancel }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ onSave }\n\t\t\t\tisBusy={ isSaving }\n\t\t\t\tdisabled={ saveDisabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Save' ) }\n\t\t\t</Button>\n\t\t</Stack>\n\t);\n}\n\nfunction ImageControls() {\n\tconst { isImage, aspectRatioPresets } = useMediaEditorFrameContext();\n\t// Non-image media has nothing to transform. Placement is the frame's call:\n\t// render this only in the `narrow` layout, since above that breakpoint the\n\t// Crop panel holds these controls already.\n\tif ( ! isImage ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<MediaEditorImageControls\n\t\t\tshowAspectRatioControl\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t/>\n\t);\n}\n\nfunction MediaEditorContent( {\n\tfields = [],\n\tid,\n\taspectRatioPresets,\n\tonClose,\n\tonSaved,\n\trenderFrame,\n\tnoticesClassName = 'media-editor__snackbar',\n\tnoticesPortalElement,\n\tshouldCloseOnEsc = false,\n\tscope = 'media-editor',\n}: MediaEditorProps ) {\n\tconst cropper = useMediaEditor();\n\t// The sidebar is a side column from the `small` breakpoint up and collapses\n\t// to an overlay below it — mirroring InterfaceSkeleton's behaviour, shifted\n\t// from `medium` to `small` (see the matching CSS overrides in style.scss).\n\t// Track that single breakpoint: in \"panel mode\" (≥ small) the\n\t// rotate/flip/zoom controls live in the Crop panel; below it they have no\n\t// panel to live in and the frame places them instead. (The fine-rotation\n\t// ruler always sits under the canvas.)\n\tconst isPanelLayout = useViewportMatch( 'small' );\n\tconst layout: 'wide' | 'narrow' = isPanelLayout ? 'wide' : 'narrow';\n\n\tconst { media, hasEdits } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\thasEditsForEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\t// Trigger an _embed fetch so `_embedded.author` and\n\t\t\t// `_embedded['wp:attached-to']` land on the record for the Details\n\t\t\t// fields to read. `getEditedEntityRecord` doesn't formally accept a\n\t\t\t// query, so we can't embed via that selector directly.\n\t\t\tgetEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tid,\n\t\t\t\tATTACHMENT_EMBED_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tmedia: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) as Media,\n\t\t\t\thasEdits: hasEditsForEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id ]\n\t);\n\n\tconst hasChanges = cropper.isCropperDirty || hasEdits;\n\n\tconst { clearEntityRecordEdits, editEntityRecord, invalidateResolution } =\n\t\tuseDispatch( coreStore );\n\tconst { removeAllNotices } = useDispatch( noticesStore );\n\n\tconst [ isDiscardDialogOpen, setIsDiscardDialogOpen ] = useState( false );\n\tconst [ isPlacementActive, setIsPlacementActive ] = useState( false );\n\tconst [ isCanvasGestureActive, setIsCanvasGestureActive ] =\n\t\tuseState( false );\n\tconst placementControlTimerRef =\n\t\tuseRef< ReturnType< typeof setTimeout > >();\n\n\tconst signalPlacementControlInteraction = useCallback( () => {\n\t\tsetIsPlacementActive( true );\n\t\tclearTimeout( placementControlTimerRef.current );\n\t\tplacementControlTimerRef.current = setTimeout( () => {\n\t\t\tsetIsPlacementActive( false );\n\t\t}, PLACEMENT_CONTROL_IDLE_MS );\n\t}, [] );\n\tconst handleCanvasGestureStart = useCallback( () => {\n\t\tsetIsCanvasGestureActive( true );\n\t}, [] );\n\tconst handleCanvasGestureEnd = useCallback( () => {\n\t\tsetIsCanvasGestureActive( false );\n\t}, [] );\n\tconst isCropInteractionActive = isPlacementActive || isCanvasGestureActive;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( placementControlTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsPlacementActive( false );\n\t\tsetIsCanvasGestureActive( false );\n\t}, [ id ] );\n\n\t// Bust the cached `_embed` resolution each time the editor mounts (or the\n\t// id changes) so embedded data such as the attached post's title or the\n\t// author's name reflects any edits made elsewhere since the last open.\n\tuseEffect( () => {\n\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t'postType',\n\t\t\t'attachment',\n\t\t\tid,\n\t\t\tATTACHMENT_EMBED_QUERY,\n\t\t] );\n\t}, [ id, invalidateResolution ] );\n\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type ).type;\n\tconst isImage = !! media && mediaType === 'image';\n\tconst {\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tresetCropOptions,\n\t} = useCropOptions( {\n\t\taspectRatioPresets,\n\t} );\n\tconst { isSaving, save: saveMediaEditor } = useSaveMediaEditor( {\n\t\tcropper,\n\t\tid,\n\t\tisImage,\n\t\tmedia,\n\t\tonSaved,\n\t} );\n\n\tconst tabs = useMemo< EditorTab[] >( () => {\n\t\tconst detailsTab: EditorTab = {\n\t\t\tid: 'details',\n\t\t\ttitle: __( 'Details' ),\n\t\t\tpanel: (\n\t\t\t\t<Stack\n\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"lg\"\n\t\t\t\t>\n\t\t\t\t\t<MediaForm />\n\t\t\t\t</Stack>\n\t\t\t),\n\t\t};\n\t\tif ( ! isImage ) {\n\t\t\treturn [ detailsTab ];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'crop',\n\t\t\t\ttitle: __( 'Crop' ),\n\t\t\t\tpanel: (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\tgap=\"lg\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<MediaEditorCropPanel\n\t\t\t\t\t\t\taspectRatioValue={ aspectRatioValue }\n\t\t\t\t\t\t\tonAspectRatioChange={ setAspectRatioValue }\n\t\t\t\t\t\t\taspectRatioOptions={ aspectRatioOptions }\n\t\t\t\t\t\t\tshowTransformControls={ isPanelLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Stack>\n\t\t\t\t),\n\t\t\t},\n\t\t\tdetailsTab,\n\t\t];\n\t}, [\n\t\tisImage,\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tisPanelLayout,\n\t] );\n\n\t// Control the active tab from state here so the selection survives the\n\t// sidebar closing (which unmounts the `ComplementaryArea` Fill and its\n\t// tabs). Fall back to the first tab until one is picked, so images open on\n\t// Crop.\n\tconst [ selectedTabId, setSelectedTabId ] = useState< string >();\n\tconst activeTabId = selectedTabId ?? tabs[ 0 ]?.id;\n\n\tconst handleChange = ( updates: Partial< Media > ) => {\n\t\teditEntityRecord( 'postType', 'attachment', id, updates );\n\t};\n\n\tconst discardAndClose = () => {\n\t\tremoveAllNotices( 'snackbar', MEDIA_EDITOR_NOTICES_CONTEXT );\n\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\tonClose?.();\n\t};\n\n\tconst handleRequestClose = () => {\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( hasChanges ) {\n\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\treturn;\n\t\t}\n\t\tdiscardAndClose();\n\t};\n\n\tconst handleKeyDown = ( event: ReactKeyboardEvent< HTMLElement > ) => {\n\t\tconst isUndoShortcut = isKeyboardEvent.primary( event, 'z' );\n\t\tconst isRedoShortcut =\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' ) ||\n\t\t\t( ! isAppleOS() && isKeyboardEvent.primary( event, 'y' ) );\n\t\tif ( ( isUndoShortcut || isRedoShortcut ) && isImage ) {\n\t\t\tconst target = event.target as HTMLElement;\n\t\t\tconst isMetadataField =\n\t\t\t\t( target.tagName === 'INPUT' ||\n\t\t\t\t\ttarget.tagName === 'TEXTAREA' ||\n\t\t\t\t\ttarget.isContentEditable ) &&\n\t\t\t\t! target.closest( `[${ CROP_CONTROL_ATTR }]` );\n\t\t\tif ( ! isMetadataField ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( isCropInteractionActive ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( isRedoShortcut ) {\n\t\t\t\t\tcropper.redo();\n\t\t\t\t} else {\n\t\t\t\t\tcropper.undo();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( shouldCloseOnEsc ) {\n\t\t\tif ( event.code !== 'Escape' && event.key !== 'Escape' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( isSaving ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( hasChanges ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst snackbar = (\n\t\t<SnackbarNotices\n\t\t\tclassName={ noticesClassName }\n\t\t\tcontext={ MEDIA_EDITOR_NOTICES_CONTEXT }\n\t\t/>\n\t);\n\n\tconst ruler = isImage ? (\n\t\t<MediaEditorFineRotation\n\t\t\tonPlacementControlInteraction={ signalPlacementControlInteraction }\n\t\t/>\n\t) : null;\n\n\tconst children = (\n\t\t<MediaEditorProvider\n\t\t\tvalue={ media ?? undefined }\n\t\t\tonChange={ handleChange }\n\t\t\tsettings={ { fields } }\n\t\t>\n\t\t\t<div className=\"media-editor\">\n\t\t\t\t{ ! media ? (\n\t\t\t\t\t<div className=\"media-editor__loading\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MediaEditorSidebar\n\t\t\t\t\t\t\ttabs={ tabs }\n\t\t\t\t\t\t\tactiveTabId={ activeTabId }\n\t\t\t\t\t\t\tonTabChange={ setSelectedTabId }\n\t\t\t\t\t\t\tscope={ scope }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\tclassName=\"media-editor__skeleton\"\n\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\tbody: isImage\n\t\t\t\t\t\t\t\t\t? __( 'Image editor' )\n\t\t\t\t\t\t\t\t\t: __( 'Media preview' ),\n\t\t\t\t\t\t\t\tsidebar: __( 'Media details' ),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t<div className=\"media-editor__content\">\n\t\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas-area\">\n\t\t\t\t\t\t\t\t\t\t{ isImage ? (\n\t\t\t\t\t\t\t\t\t\t\t<MediaEditorCanvas\n\t\t\t\t\t\t\t\t\t\t\t\tisPlacementActive={\n\t\t\t\t\t\t\t\t\t\t\t\t\tisPlacementActive\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tonGestureStart={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureStart\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tonGestureEnd={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureEnd\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t<MediaPreview />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t{ isImage && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas-toolbar\">\n\t\t\t\t\t\t\t\t\t\t\t{ ruler }\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope={ scope } />\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isDiscardDialogOpen }\n\t\t\t\tconfirmButtonText={ __( 'Discard' ) }\n\t\t\t\tcancelButtonText={ __( 'Keep editing' ) }\n\t\t\t\tonCancel={ () => setIsDiscardDialogOpen( false ) }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\tsetIsDiscardDialogOpen( false );\n\t\t\t\t\tdiscardAndClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Are you sure you want to discard your unsaved changes?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t\t{ noticesPortalElement\n\t\t\t\t? createPortal( snackbar, noticesPortalElement )\n\t\t\t\t: snackbar }\n\t\t</MediaEditorProvider>\n\t);\n\n\t// Rebuilt each render, like the elements it replaces: consumers re-render\n\t// as they always did, but the cluster component types stay stable.\n\tconst contextValue: MediaEditorFrameContextValue = {\n\t\tisImage,\n\t\tisSaving,\n\t\thasMedia: !! media,\n\t\thasChanges,\n\t\tisUndoRedoDisabled: isCropInteractionActive,\n\t\tscope,\n\t\taspectRatioPresets,\n\t\tonCancel: handleRequestClose,\n\t\tonSave: saveMediaEditor,\n\t\tonReset: resetCropOptions,\n\t};\n\n\treturn (\n\t\t<MediaEditorFrameContext.Provider value={ contextValue }>\n\t\t\t{ renderFrame( {\n\t\t\t\tchildren,\n\t\t\t\tisImage,\n\t\t\t\tlayout,\n\t\t\t\tonRequestClose: handleRequestClose,\n\t\t\t\tonKeyDown: handleKeyDown,\n\t\t\t\tshouldCloseOnClickOutside: ! hasChanges && ! isSaving,\n\t\t\t\tisSaving,\n\t\t\t\thasChanges,\n\t\t\t\thasMedia: !! media,\n\t\t\t} ) }\n\t\t</MediaEditorFrameContext.Provider>\n\t);\n}\n\nexport function MediaEditor( props: MediaEditorProps ) {\n\treturn (\n\t\t<MediaEditorStateProvider key={ props.id }>\n\t\t\t<MediaEditorContent { ...props } />\n\t\t</MediaEditorStateProvider>\n\t);\n}\n\n// Attached to `MediaEditor` so frames import and arrange them, the way\n// `DataViewsPicker` exposes its own sub-components. They read what they need\n// from context, so a frame only chooses where they go and how they look.\nMediaEditor.HeaderActions = HeaderActions;\nMediaEditor.HistoryActions = HistoryActions;\nMediaEditor.SaveActions = SaveActions;\nMediaEditor.ImageControls = ImageControls;\n\nexport default MediaEditor;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAIO;AACP,gBAA4B;AAC5B,qBAAiC;AACjC,kBAAuC;AACvC,uBAAmC;AACnC,qBASO;AACP,kBAAmB;AACnB,mBAAyD;AACzD,sBAIO;AACP,qBAAuD;AAEvD,uBA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AAAA,IACX,2BAA2B,CAAE,cAAc,CAAE;AAAA,IAC7C;AAAA,IACA;AAAA,IACA,UAAU,CAAC,CAAE;AAAA,EACd,CAAE,GACH;AAEF;AAEO,SAAS,YAAa,OAA0B;AACtD,SACC,4CAAC,yCACA,sDAAC,sBAAqB,GAAG,OAAQ,KADF,MAAM,EAEtC;AAEF;AAKA,YAAY,gBAAgB;AAC5B,YAAY,iBAAiB;AAC7B,YAAY,cAAc;AAC1B,YAAY,gBAAgB;AAE5B,IAAO,uBAAQ;",
6
+ "names": ["MediaEditorKeyboardShortcutsModal", "MediaEditorImageControls", "coreStore", "noticesStore", "MediaForm", "MediaEditorCropPanel", "MediaEditorFineRotation", "MediaEditorCanvas", "MediaPreview", "ConfirmDialog"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor/use-crop-options.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_ASPECT_RATIOS } from '../../image-editor/core/constants';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\nimport { useMediaEditor, resolveAspectRatio } from '../../state';\n\ninterface UseCropOptionsArgs {\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\ninterface UseCropOptionsReturn {\n\taspectRatioValue: string;\n\tsetAspectRatioValue: ( value: string ) => void;\n\taspectRatioOptions: AspectRatioPreset[];\n\tresolvedAspectRatio: number | undefined;\n\tresetCropOptions: () => void;\n}\n\n/**\n * Build the preset list shown in the dropdown — always include the\n * non-numeric presets (Free, Original) and append either the\n * caller-supplied set or the defaults.\n *\n * @param aspectRatioPresets Optional caller-supplied presets.\n * @return The full preset list to render.\n */\nexport function getAspectRatioOptions(\n\taspectRatioPresets?: AspectRatioPreset[]\n): AspectRatioPreset[] {\n\treturn [\n\t\t...DEFAULT_ASPECT_RATIOS.filter( ( preset ) => preset.value <= 0 ),\n\t\t...( aspectRatioPresets ??\n\t\t\tDEFAULT_ASPECT_RATIOS.filter( ( preset ) => preset.value > 0 ) ),\n\t];\n}\n\n/**\n * Thin selector over the composite media-editor store for the Crop\n * sidebar tab. Reads the cropOptions slice (preset key) and exposes\n * the corresponding setters plus a render-time `resolvedAspectRatio`\n * derivation.\n *\n * No local React state, no refs, no synchronization effects — the\n * composite store is the single source of truth.\n *\n * @param args\n * @param args.aspectRatioPresets Optional caller-supplied aspect-ratio presets.\n */\nexport function useCropOptions( {\n\taspectRatioPresets,\n}: UseCropOptionsArgs = {} ): UseCropOptionsReturn {\n\tconst controller = useMediaEditor();\n\tconst { aspectRatioValue } = controller.cropOptions;\n\tconst cropperImage = controller.state.image;\n\n\tconst aspectRatioOptions = useMemo(\n\t\t() => getAspectRatioOptions( aspectRatioPresets ),\n\t\t[ aspectRatioPresets ]\n\t);\n\n\tconst resolvedAspectRatio = useMemo(\n\t\t() => resolveAspectRatio( aspectRatioValue, cropperImage ),\n\t\t[ aspectRatioValue, cropperImage ]\n\t);\n\n\treturn {\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue: controller.setAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tresolvedAspectRatio,\n\t\tresetCropOptions: controller.resetCropOptions,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AAKxB,uBAAsC;AAEtC,mBAAmD;AAsB5C,SAAS,sBACf,oBACsB;AACtB,SAAO;AAAA,IACN,GAAG,uCAAsB,OAAQ,CAAE,WAAY,OAAO,SAAS,CAAE;AAAA,IACjE,GAAK,sBACJ,uCAAsB,OAAQ,CAAE,WAAY,OAAO,QAAQ,CAAE;AAAA,EAC/D;AACD;AAcO,SAAS,eAAgB;AAAA,EAC/B;AACD,IAAwB,CAAC,GAA0B;AAClD,QAAM,iBAAa,6BAAe;AAClC,QAAM,EAAE,iBAAiB,IAAI,WAAW;AACxC,QAAM,eAAe,WAAW,MAAM;AAEtC,QAAM,yBAAqB;AAAA,IAC1B,MAAM,sBAAuB,kBAAmB;AAAA,IAChD,CAAE,kBAAmB;AAAA,EACtB;AAEA,QAAM,0BAAsB;AAAA,IAC3B,UAAM,iCAAoB,kBAAkB,YAAa;AAAA,IACzD,CAAE,kBAAkB,YAAa;AAAA,EAClC;AAEA,SAAO;AAAA,IACN;AAAA,IACA,qBAAqB,WAAW;AAAA,IAChC;AAAA,IACA;AAAA,IACA,kBAAkB,WAAW;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport { DEFAULT_ASPECT_RATIOS } from '../../image-editor/core/constants';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\nimport { useMediaEditor, resolveAspectRatio } from '../../state';\n\ninterface UseCropOptionsArgs {\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\ninterface UseCropOptionsReturn {\n\taspectRatioValue: string;\n\tsetAspectRatioValue: ( value: string ) => void;\n\taspectRatioOptions: AspectRatioPreset[];\n\tresolvedAspectRatio: number | undefined;\n\tresetCropOptions: () => void;\n}\n\n/**\n * Build the preset list shown in the dropdown — always include the\n * non-numeric presets (Free, Original) and append either the\n * caller-supplied set or the defaults.\n *\n * @param aspectRatioPresets Optional caller-supplied presets.\n * @return The full preset list to render.\n */\nexport function getAspectRatioOptions(\n\taspectRatioPresets?: AspectRatioPreset[]\n): AspectRatioPreset[] {\n\treturn [\n\t\t...DEFAULT_ASPECT_RATIOS.filter( ( preset ) => preset.value <= 0 ),\n\t\t...( aspectRatioPresets ??\n\t\t\tDEFAULT_ASPECT_RATIOS.filter( ( preset ) => preset.value > 0 ) ),\n\t];\n}\n\n/**\n * Thin selector over the composite media-editor store for the Crop\n * sidebar tab. Reads the cropOptions slice (preset key) and exposes\n * the corresponding setters plus a render-time `resolvedAspectRatio`\n * derivation.\n *\n * No local React state, no refs, no synchronization effects — the\n * composite store is the single source of truth.\n *\n * @param args\n * @param args.aspectRatioPresets Optional caller-supplied aspect-ratio presets.\n */\nexport function useCropOptions( {\n\taspectRatioPresets,\n}: UseCropOptionsArgs = {} ): UseCropOptionsReturn {\n\tconst controller = useMediaEditor();\n\tconst { aspectRatioValue } = controller.cropOptions;\n\tconst cropperImage = controller.state.image;\n\n\tconst aspectRatioOptions = useMemo(\n\t\t() => getAspectRatioOptions( aspectRatioPresets ),\n\t\t[ aspectRatioPresets ]\n\t);\n\n\tconst resolvedAspectRatio = useMemo(\n\t\t() => resolveAspectRatio( aspectRatioValue, cropperImage ),\n\t\t[ aspectRatioValue, cropperImage ]\n\t);\n\n\treturn {\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue: controller.setAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tresolvedAspectRatio,\n\t\tresetCropOptions: controller.resetCropOptions,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AACxB,uBAAsC;AAEtC,mBAAmD;AAsB5C,SAAS,sBACf,oBACsB;AACtB,SAAO;AAAA,IACN,GAAG,uCAAsB,OAAQ,CAAE,WAAY,OAAO,SAAS,CAAE;AAAA,IACjE,GAAK,sBACJ,uCAAsB,OAAQ,CAAE,WAAY,OAAO,QAAQ,CAAE;AAAA,EAC/D;AACD;AAcO,SAAS,eAAgB;AAAA,EAC/B;AACD,IAAwB,CAAC,GAA0B;AAClD,QAAM,iBAAa,6BAAe;AAClC,QAAM,EAAE,iBAAiB,IAAI,WAAW;AACxC,QAAM,eAAe,WAAW,MAAM;AAEtC,QAAM,yBAAqB;AAAA,IAC1B,MAAM,sBAAuB,kBAAmB;AAAA,IAChD,CAAE,kBAAmB;AAAA,EACtB;AAEA,QAAM,0BAAsB;AAAA,IAC3B,UAAM,iCAAoB,kBAAkB,YAAa;AAAA,IACzD,CAAE,kBAAkB,YAAa;AAAA,EAClC;AAEA,SAAO;AAAA,IACN;AAAA,IACA,qBAAqB,WAAW;AAAA,IAChC;AAAA,IACA;AAAA,IACA,kBAAkB,WAAW;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor/use-save-media-editor.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useCallback, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport type { Media } from '../media-editor-provider';\nimport type { MediaEditorController } from '../../state';\nimport {\n\tbuildModifiers,\n\ttype Modifier,\n} from '../media-editor-modal/build-modifiers';\n\n// Details-tab edits are bundled into transformed `/edit` requests. Core's\n// endpoint only accepts this whitelist.\nconst METADATA_EDIT_KEYS = [\n\t'title',\n\t'caption',\n\t'description',\n\t'alt_text',\n\t'post',\n] as const;\n\n// Scope media editor snackbars so they don't leak into the host editor/page.\nexport const MEDIA_EDITOR_NOTICES_CONTEXT = 'media-editor';\n\ntype PendingMetadataEdits = Record< string, unknown > | undefined;\n\nexport interface MediaEditorSaveResult {\n\tid: number;\n\turl?: string;\n\tmedia: Media;\n\tprevious?: {\n\t\tid: number;\n\t\turl?: string;\n\t};\n}\n\ninterface UseSaveMediaEditorArgs {\n\tcropper: MediaEditorController;\n\tid: number;\n\tisImage: boolean;\n\tmedia?: Media | null;\n\tonSaved?: ( result: MediaEditorSaveResult ) => void;\n}\n\ninterface UseSaveMediaEditorReturn {\n\tisSaving: boolean;\n\tsave: () => Promise< void >;\n}\n\nfunction getCropModifiers( cropper: MediaEditorController ): Modifier[] {\n\tif ( ! cropper.isCropperDirty || ! cropper.state.image ) {\n\t\treturn [];\n\t}\n\treturn buildModifiers( cropper.state, {\n\t\twidth: cropper.state.image.naturalWidth,\n\t\theight: cropper.state.image.naturalHeight,\n\t} );\n}\n\nfunction getMetadataEdits(\n\tpendingEdits: PendingMetadataEdits,\n\tmedia?: Media | null\n): Record< string, unknown > {\n\tconst metadataEdits: Record< string, unknown > = {};\n\tfor ( const key of METADATA_EDIT_KEYS ) {\n\t\tif ( pendingEdits && key in pendingEdits ) {\n\t\t\tmetadataEdits[ key ] = pendingEdits[ key ];\n\t\t}\n\t}\n\t// The `/edit` endpoint creates a new attachment for the crop and doesn't\n\t// inherit `post_parent` from the source (unlike title/caption/etc.), so\n\t// carry the existing value across when the user hasn't explicitly edited\n\t// it. Use a defined-check so an explicit `0` (unattached) is preserved.\n\tif ( ! ( 'post' in metadataEdits ) && media?.post !== undefined ) {\n\t\tmetadataEdits.post = media.post;\n\t}\n\treturn metadataEdits;\n}\n\nexport function useSaveMediaEditor( {\n\tcropper,\n\tid,\n\tisImage,\n\tmedia,\n\tonSaved,\n}: UseSaveMediaEditorArgs ): UseSaveMediaEditorReturn {\n\tconst registry = useRegistry();\n\tconst {\n\t\tclearEntityRecordEdits,\n\t\treceiveEntityRecords,\n\t\tsaveEditedEntityRecord,\n\t} = useDispatch( coreStore );\n\tconst { createErrorNotice, removeAllNotices } = useDispatch( noticesStore );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\n\tconst save = useCallback( async () => {\n\t\tremoveAllNotices( 'snackbar', MEDIA_EDITOR_NOTICES_CONTEXT );\n\t\tsetIsSaving( true );\n\t\ttry {\n\t\t\tlet saved: Media | null | undefined;\n\t\t\tconst modifiers = getCropModifiers( cropper );\n\t\t\tconst previous =\n\t\t\t\tmodifiers.length > 0 && media\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\turl: media.source_url,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined;\n\n\t\t\tif ( modifiers.length > 0 ) {\n\t\t\t\tconst pendingEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.getEntityRecordNonTransientEdits(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\tid\n\t\t\t\t\t) as PendingMetadataEdits;\n\t\t\t\tconst metadataEdits = getMetadataEdits( pendingEdits, media );\n\n\t\t\t\tsaved = ( await apiFetch( {\n\t\t\t\t\tpath: `/wp/v2/media/${ id }/edit`,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tsrc: media?.source_url,\n\t\t\t\t\t\tmodifiers,\n\t\t\t\t\t\t...metadataEdits,\n\t\t\t\t\t},\n\t\t\t\t} ) ) as Media;\n\n\t\t\t\tif ( saved ) {\n\t\t\t\t\treceiveEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\tsaved,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsaved = ( await saveEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) ) as Media | undefined;\n\t\t\t}\n\n\t\t\tconst next = ( saved ?? media ) as Media | null;\n\n\t\t\tif ( next && next.id !== id ) {\n\t\t\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\t\t}\n\n\t\t\tif ( next && next.id ) {\n\t\t\t\tif ( next.id === id ) {\n\t\t\t\t\tcropper.reset();\n\t\t\t\t}\n\t\t\t\tonSaved?.( {\n\t\t\t\t\tid: next.id,\n\t\t\t\t\turl: next.source_url,\n\t\t\t\t\tmedia: next,\n\t\t\t\t\tprevious,\n\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst message =\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.message\n\t\t\t\t\t: ( error as { message?: string } )?.message ??\n\t\t\t\t\t __( 'An unknown error occurred.' );\n\t\t\tcreateErrorNotice(\n\t\t\t\tisImage\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Error message. */\n\t\t\t\t\t\t\t__( 'Could not save image. %s' ),\n\t\t\t\t\t\t\tmessage\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Error message. */\n\t\t\t\t\t\t\t__( 'Could not save media. %s' ),\n\t\t\t\t\t\t\tmessage\n\t\t\t\t\t ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tcontext: MEDIA_EDITOR_NOTICES_CONTEXT,\n\t\t\t\t}\n\t\t\t);\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t}\n\t}, [\n\t\tclearEntityRecordEdits,\n\t\tcreateErrorNotice,\n\t\tcropper,\n\t\tid,\n\t\tisImage,\n\t\tmedia,\n\t\tonSaved,\n\t\treceiveEntityRecords,\n\t\tregistry,\n\t\tremoveAllNotices,\n\t\tsaveEditedEntityRecord,\n\t] );\n\n\treturn { isSaving, save };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAqB;AACrB,kBAAyC;AACzC,uBAAmC;AACnC,qBAAsC;AACtC,kBAA4B;AAC5B,qBAAsC;AAOtC,6BAGO;AAIP,IAAM,qBAAqB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAGO,IAAM,+BAA+B;AA2B5C,SAAS,iBAAkB,SAA6C;AACvE,MAAK,CAAE,QAAQ,kBAAkB,CAAE,QAAQ,MAAM,OAAQ;AACxD,WAAO,CAAC;AAAA,EACT;AACA,aAAO,uCAAgB,QAAQ,OAAO;AAAA,IACrC,OAAO,QAAQ,MAAM,MAAM;AAAA,IAC3B,QAAQ,QAAQ,MAAM,MAAM;AAAA,EAC7B,CAAE;AACH;AAEA,SAAS,iBACR,cACA,OAC4B;AAC5B,QAAM,gBAA2C,CAAC;AAClD,aAAY,OAAO,oBAAq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AA,UACf;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAEA,YAAM,OAAS,SAAS;AAExB,UAAK,QAAQ,KAAK,OAAO,IAAK;AAC7B,+BAAwB,YAAY,cAAc,EAAG;AAAA,MACtD;AAEA,UAAK,QAAQ,KAAK,IAAK;AACtB,YAAK,KAAK,OAAO,IAAK;AACrB,kBAAQ,MAAM;AAAA,QACf;AACA,kBAAW;AAAA,UACV,IAAI,KAAK;AAAA,UACT,KAAK,KAAK;AAAA,UACV,OAAO;AAAA,UACP;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD,SAAU,OAAQ;AACjB,YAAM,UACL,iBAAiB,QACd,MAAM,UACJ,OAAiC,eACnC,gBAAI,4BAA6B;AACrC;AAAA,QACC,cACG;AAAA;AAAA,cAEA,gBAAI,0BAA2B;AAAA,UAC/B;AAAA,QACA,QACA;AAAA;AAAA,cAEA,gBAAI,0BAA2B;AAAA,UAC/B;AAAA,QACA;AAAA,QACH;AAAA,UACC,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,MACD;AAAA,IACD,UAAE;AACD,kBAAa,KAAM;AAAA,IACpB;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO,EAAE,UAAU,KAAK;AACzB;",
4
+ "sourcesContent": ["import apiFetch from '@wordpress/api-fetch';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useCallback, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Media } from '../media-editor-provider';\nimport type { MediaEditorController } from '../../state';\nimport {\n\tbuildModifiers,\n\ttype Modifier,\n} from '../media-editor-modal/build-modifiers';\n\n// Details-tab edits are bundled into transformed `/edit` requests. Core's\n// endpoint only accepts this whitelist.\nconst METADATA_EDIT_KEYS = [\n\t'title',\n\t'caption',\n\t'description',\n\t'alt_text',\n\t'post',\n] as const;\n\n// Scope media editor snackbars so they don't leak into the host editor/page.\nexport const MEDIA_EDITOR_NOTICES_CONTEXT = 'media-editor';\n\ntype PendingMetadataEdits = Record< string, unknown > | undefined;\n\nexport interface MediaEditorSaveResult {\n\tid: number;\n\turl?: string;\n\tmedia: Media;\n\tprevious?: {\n\t\tid: number;\n\t\turl?: string;\n\t};\n}\n\ninterface UseSaveMediaEditorArgs {\n\tcropper: MediaEditorController;\n\tid: number;\n\tisImage: boolean;\n\tmedia?: Media | null;\n\tonSaved?: ( result: MediaEditorSaveResult ) => void;\n}\n\ninterface UseSaveMediaEditorReturn {\n\tisSaving: boolean;\n\tsave: () => Promise< void >;\n}\n\nfunction getCropModifiers( cropper: MediaEditorController ): Modifier[] {\n\tif ( ! cropper.isCropperDirty || ! cropper.state.image ) {\n\t\treturn [];\n\t}\n\treturn buildModifiers( cropper.state, {\n\t\twidth: cropper.state.image.naturalWidth,\n\t\theight: cropper.state.image.naturalHeight,\n\t} );\n}\n\nfunction getMetadataEdits(\n\tpendingEdits: PendingMetadataEdits,\n\tmedia?: Media | null\n): Record< string, unknown > {\n\tconst metadataEdits: Record< string, unknown > = {};\n\tfor ( const key of METADATA_EDIT_KEYS ) {\n\t\tif ( pendingEdits && key in pendingEdits ) {\n\t\t\tmetadataEdits[ key ] = pendingEdits[ key ];\n\t\t}\n\t}\n\t// The `/edit` endpoint creates a new attachment for the crop and doesn't\n\t// inherit `post_parent` from the source (unlike title/caption/etc.), so\n\t// carry the existing value across when the user hasn't explicitly edited\n\t// it. Use a defined-check so an explicit `0` (unattached) is preserved.\n\tif ( ! ( 'post' in metadataEdits ) && media?.post !== undefined ) {\n\t\tmetadataEdits.post = media.post;\n\t}\n\treturn metadataEdits;\n}\n\nexport function useSaveMediaEditor( {\n\tcropper,\n\tid,\n\tisImage,\n\tmedia,\n\tonSaved,\n}: UseSaveMediaEditorArgs ): UseSaveMediaEditorReturn {\n\tconst registry = useRegistry();\n\tconst {\n\t\tclearEntityRecordEdits,\n\t\treceiveEntityRecords,\n\t\tsaveEditedEntityRecord,\n\t} = useDispatch( coreStore );\n\tconst { createErrorNotice, removeAllNotices } = useDispatch( noticesStore );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\n\tconst save = useCallback( async () => {\n\t\tremoveAllNotices( 'snackbar', MEDIA_EDITOR_NOTICES_CONTEXT );\n\t\tsetIsSaving( true );\n\t\ttry {\n\t\t\tlet saved: Media | null | undefined;\n\t\t\tconst modifiers = getCropModifiers( cropper );\n\t\t\tconst previous =\n\t\t\t\tmodifiers.length > 0 && media\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\turl: media.source_url,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined;\n\n\t\t\tif ( modifiers.length > 0 ) {\n\t\t\t\tconst pendingEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.getEntityRecordNonTransientEdits(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\tid\n\t\t\t\t\t) as PendingMetadataEdits;\n\t\t\t\tconst metadataEdits = getMetadataEdits( pendingEdits, media );\n\n\t\t\t\tsaved = ( await apiFetch( {\n\t\t\t\t\tpath: `/wp/v2/media/${ id }/edit`,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tsrc: media?.source_url,\n\t\t\t\t\t\tmodifiers,\n\t\t\t\t\t\t...metadataEdits,\n\t\t\t\t\t},\n\t\t\t\t} ) ) as Media;\n\n\t\t\t\tif ( saved ) {\n\t\t\t\t\treceiveEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\tsaved,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsaved = ( await saveEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) ) as Media | undefined;\n\t\t\t}\n\n\t\t\tconst next = ( saved ?? media ) as Media | null;\n\n\t\t\tif ( next && next.id !== id ) {\n\t\t\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\t\t}\n\n\t\t\tif ( next && next.id ) {\n\t\t\t\tif ( next.id === id ) {\n\t\t\t\t\tcropper.reset();\n\t\t\t\t}\n\t\t\t\tonSaved?.( {\n\t\t\t\t\tid: next.id,\n\t\t\t\t\turl: next.source_url,\n\t\t\t\t\tmedia: next,\n\t\t\t\t\tprevious,\n\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst message =\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.message\n\t\t\t\t\t: ( error as { message?: string } )?.message ??\n\t\t\t\t\t __( 'An unknown error occurred.' );\n\t\t\tcreateErrorNotice(\n\t\t\t\tisImage\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Error message. */\n\t\t\t\t\t\t\t__( 'Could not save image. %s' ),\n\t\t\t\t\t\t\tmessage\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Error message. */\n\t\t\t\t\t\t\t__( 'Could not save media. %s' ),\n\t\t\t\t\t\t\tmessage\n\t\t\t\t\t ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tcontext: MEDIA_EDITOR_NOTICES_CONTEXT,\n\t\t\t\t}\n\t\t\t);\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t}\n\t}, [\n\t\tclearEntityRecordEdits,\n\t\tcreateErrorNotice,\n\t\tcropper,\n\t\tid,\n\t\tisImage,\n\t\tmedia,\n\t\tonSaved,\n\t\treceiveEntityRecords,\n\t\tregistry,\n\t\tremoveAllNotices,\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