@wordpress/media-editor 0.9.0 → 0.10.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 (292) hide show
  1. package/build/components/media-editor/index.cjs +34 -135
  2. package/build/components/media-editor/index.cjs.map +3 -3
  3. package/build/components/media-editor/use-crop-options.cjs +87 -0
  4. package/build/components/media-editor/use-crop-options.cjs.map +7 -0
  5. package/build/components/media-editor/use-save-media-editor.cjs +185 -0
  6. package/build/components/media-editor/use-save-media-editor.cjs.map +7 -0
  7. package/build/components/media-editor-canvas/index.cjs +32 -11
  8. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  9. package/build/components/media-editor-crop-panel/index.cjs +66 -83
  10. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  11. package/build/components/media-editor-modal/index.cjs +40 -11
  12. package/build/components/media-editor-modal/index.cjs.map +3 -3
  13. package/build/components/media-editor-toolbar/index.cjs +7 -3
  14. package/build/components/media-editor-toolbar/index.cjs.map +2 -2
  15. package/build/components/media-form/index.cjs +19 -1
  16. package/build/components/media-form/index.cjs.map +3 -3
  17. package/build/components/media-form/sidebar-datetime-view.cjs +53 -0
  18. package/build/components/media-form/sidebar-datetime-view.cjs.map +7 -0
  19. package/build/components/rotation-ruler/index.cjs +8 -2
  20. package/build/components/rotation-ruler/index.cjs.map +2 -2
  21. package/build/hooks/use-crop-gesture-handlers.cjs +41 -4
  22. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  23. package/build/image-editor/core/camera.cjs +29 -11
  24. package/build/image-editor/core/camera.cjs.map +2 -2
  25. package/build/image-editor/core/constants.cjs +6 -0
  26. package/build/image-editor/core/constants.cjs.map +2 -2
  27. package/build/image-editor/core/containment.cjs +71 -34
  28. package/build/image-editor/core/containment.cjs.map +2 -2
  29. package/build/image-editor/core/crop-rect.cjs +48 -0
  30. package/build/image-editor/core/crop-rect.cjs.map +7 -0
  31. package/build/image-editor/core/index.cjs +12 -0
  32. package/build/image-editor/core/index.cjs.map +2 -2
  33. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  34. package/build/image-editor/core/math/sanitize.cjs +92 -0
  35. package/build/image-editor/core/math/sanitize.cjs.map +7 -0
  36. package/build/image-editor/core/setter-helpers.cjs +64 -0
  37. package/build/image-editor/core/setter-helpers.cjs.map +7 -0
  38. package/build/image-editor/core/source-region.cjs +16 -14
  39. package/build/image-editor/core/source-region.cjs.map +2 -2
  40. package/build/image-editor/core/state.cjs +20 -10
  41. package/build/image-editor/core/state.cjs.map +2 -2
  42. package/build/image-editor/core/stencil-math.cjs +31 -20
  43. package/build/image-editor/core/stencil-math.cjs.map +2 -2
  44. package/build/image-editor/core/transform-style.cjs +12 -6
  45. package/build/image-editor/core/transform-style.cjs.map +2 -2
  46. package/build/image-editor/core/types.cjs.map +1 -1
  47. package/build/image-editor/index.cjs +12 -2
  48. package/build/image-editor/index.cjs.map +2 -2
  49. package/build/image-editor/react/components/cropper-provider.cjs +2 -2
  50. package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
  51. package/build/image-editor/react/components/cropper.cjs +121 -48
  52. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  53. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +172 -0
  54. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +7 -0
  55. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +20 -10
  56. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  57. package/build/image-editor/react/hooks/build-cropper-setters.cjs +71 -0
  58. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +7 -0
  59. package/build/image-editor/react/hooks/index.cjs +6 -3
  60. package/build/image-editor/react/hooks/index.cjs.map +2 -2
  61. package/build/image-editor/react/hooks/use-aria-announcer.cjs +3 -1
  62. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  63. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +113 -0
  64. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +7 -0
  65. package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
  66. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  67. package/build/state/composite-reducer.cjs +115 -0
  68. package/build/state/composite-reducer.cjs.map +7 -0
  69. package/build/state/index.cjs +48 -0
  70. package/build/state/index.cjs.map +7 -0
  71. package/build/state/media-editor-state-provider.cjs +58 -0
  72. package/build/state/media-editor-state-provider.cjs.map +7 -0
  73. package/build/state/types.cjs +34 -0
  74. package/build/state/types.cjs.map +7 -0
  75. package/build/state/use-media-editor-state.cjs +298 -0
  76. package/build/state/use-media-editor-state.cjs.map +7 -0
  77. package/build-module/components/media-editor/index.mjs +40 -140
  78. package/build-module/components/media-editor/index.mjs.map +2 -2
  79. package/build-module/components/media-editor/use-crop-options.mjs +61 -0
  80. package/build-module/components/media-editor/use-crop-options.mjs.map +7 -0
  81. package/build-module/components/media-editor/use-save-media-editor.mjs +151 -0
  82. package/build-module/components/media-editor/use-save-media-editor.mjs.map +7 -0
  83. package/build-module/components/media-editor-canvas/index.mjs +33 -12
  84. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  85. package/build-module/components/media-editor-crop-panel/index.mjs +68 -83
  86. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  87. package/build-module/components/media-editor-modal/index.mjs +40 -11
  88. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  89. package/build-module/components/media-editor-toolbar/index.mjs +7 -3
  90. package/build-module/components/media-editor-toolbar/index.mjs.map +2 -2
  91. package/build-module/components/media-form/index.mjs +9 -1
  92. package/build-module/components/media-form/index.mjs.map +2 -2
  93. package/build-module/components/media-form/sidebar-datetime-view.mjs +32 -0
  94. package/build-module/components/media-form/sidebar-datetime-view.mjs.map +7 -0
  95. package/build-module/components/rotation-ruler/index.mjs +8 -2
  96. package/build-module/components/rotation-ruler/index.mjs.map +2 -2
  97. package/build-module/hooks/use-crop-gesture-handlers.mjs +41 -4
  98. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  99. package/build-module/image-editor/core/camera.mjs +34 -11
  100. package/build-module/image-editor/core/camera.mjs.map +2 -2
  101. package/build-module/image-editor/core/constants.mjs +4 -0
  102. package/build-module/image-editor/core/constants.mjs.map +2 -2
  103. package/build-module/image-editor/core/containment.mjs +75 -34
  104. package/build-module/image-editor/core/containment.mjs.map +2 -2
  105. package/build-module/image-editor/core/crop-rect.mjs +23 -0
  106. package/build-module/image-editor/core/crop-rect.mjs.map +7 -0
  107. package/build-module/image-editor/core/index.mjs +12 -0
  108. package/build-module/image-editor/core/index.mjs.map +2 -2
  109. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  110. package/build-module/image-editor/core/math/sanitize.mjs +63 -0
  111. package/build-module/image-editor/core/math/sanitize.mjs.map +7 -0
  112. package/build-module/image-editor/core/setter-helpers.mjs +39 -0
  113. package/build-module/image-editor/core/setter-helpers.mjs.map +7 -0
  114. package/build-module/image-editor/core/source-region.mjs +16 -14
  115. package/build-module/image-editor/core/source-region.mjs.map +2 -2
  116. package/build-module/image-editor/core/state.mjs +25 -11
  117. package/build-module/image-editor/core/state.mjs.map +2 -2
  118. package/build-module/image-editor/core/stencil-math.mjs +30 -19
  119. package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
  120. package/build-module/image-editor/core/transform-style.mjs +12 -6
  121. package/build-module/image-editor/core/transform-style.mjs.map +2 -2
  122. package/build-module/image-editor/index.mjs +11 -2
  123. package/build-module/image-editor/index.mjs.map +2 -2
  124. package/build-module/image-editor/react/components/cropper-provider.mjs +3 -3
  125. package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
  126. package/build-module/image-editor/react/components/cropper.mjs +122 -49
  127. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  128. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +147 -0
  129. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +7 -0
  130. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +20 -10
  131. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  132. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +46 -0
  133. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +7 -0
  134. package/build-module/image-editor/react/hooks/index.mjs +4 -2
  135. package/build-module/image-editor/react/hooks/index.mjs.map +2 -2
  136. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +3 -1
  137. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  138. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +100 -0
  139. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +7 -0
  140. package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
  141. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  142. package/build-module/state/composite-reducer.mjs +94 -0
  143. package/build-module/state/composite-reducer.mjs.map +7 -0
  144. package/build-module/state/index.mjs +26 -0
  145. package/build-module/state/index.mjs.map +7 -0
  146. package/build-module/state/media-editor-state-provider.mjs +34 -0
  147. package/build-module/state/media-editor-state-provider.mjs.map +7 -0
  148. package/build-module/state/types.mjs +9 -0
  149. package/build-module/state/types.mjs.map +7 -0
  150. package/build-module/state/use-media-editor-state.mjs +289 -0
  151. package/build-module/state/use-media-editor-state.mjs.map +7 -0
  152. package/build-style/style-rtl.css +46 -9
  153. package/build-style/style.css +46 -9
  154. package/build-types/components/media-editor/index.d.ts +4 -7
  155. package/build-types/components/media-editor/index.d.ts.map +1 -1
  156. package/build-types/components/media-editor/use-crop-options.d.ts +37 -0
  157. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -0
  158. package/build-types/components/media-editor/use-save-media-editor.d.ts +29 -0
  159. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -0
  160. package/build-types/components/media-editor-canvas/index.d.ts +5 -10
  161. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  162. package/build-types/components/media-editor-crop-panel/index.d.ts +4 -16
  163. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  164. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  165. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -1
  166. package/build-types/components/media-form/index.d.ts.map +1 -1
  167. package/build-types/components/media-form/sidebar-datetime-view.d.ts +10 -0
  168. package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +1 -0
  169. package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
  170. package/build-types/hooks/use-crop-gesture-handlers.d.ts +13 -14
  171. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  172. package/build-types/image-editor/core/camera.d.ts.map +1 -1
  173. package/build-types/image-editor/core/constants.d.ts +18 -0
  174. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  175. package/build-types/image-editor/core/containment.d.ts +10 -0
  176. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  177. package/build-types/image-editor/core/crop-rect.d.ts +19 -0
  178. package/build-types/image-editor/core/crop-rect.d.ts.map +1 -0
  179. package/build-types/image-editor/core/index.d.ts +3 -1
  180. package/build-types/image-editor/core/index.d.ts.map +1 -1
  181. package/build-types/image-editor/core/interaction-controller.d.ts +5 -1
  182. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  183. package/build-types/image-editor/core/math/sanitize.d.ts +70 -0
  184. package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -0
  185. package/build-types/image-editor/core/setter-helpers.d.ts +24 -0
  186. package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -0
  187. package/build-types/image-editor/core/source-region.d.ts.map +1 -1
  188. package/build-types/image-editor/core/state.d.ts +12 -0
  189. package/build-types/image-editor/core/state.d.ts.map +1 -1
  190. package/build-types/image-editor/core/stencil-math.d.ts +23 -18
  191. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
  192. package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
  193. package/build-types/image-editor/core/types.d.ts +23 -4
  194. package/build-types/image-editor/core/types.d.ts.map +1 -1
  195. package/build-types/image-editor/index.d.ts +4 -4
  196. package/build-types/image-editor/index.d.ts.map +1 -1
  197. package/build-types/image-editor/react/components/cropper-provider.d.ts +11 -7
  198. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  199. package/build-types/image-editor/react/components/cropper.d.ts +6 -4
  200. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  201. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +36 -0
  202. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -0
  203. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +2 -1
  204. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  205. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +47 -0
  206. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -0
  207. package/build-types/image-editor/react/hooks/index.d.ts +4 -2
  208. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  209. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  210. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +58 -0
  211. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -0
  212. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  213. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
  214. package/build-types/state/composite-reducer.d.ts +39 -0
  215. package/build-types/state/composite-reducer.d.ts.map +1 -0
  216. package/build-types/state/index.d.ts +7 -0
  217. package/build-types/state/index.d.ts.map +1 -0
  218. package/build-types/state/media-editor-state-provider.d.ts +34 -0
  219. package/build-types/state/media-editor-state-provider.d.ts.map +1 -0
  220. package/build-types/state/types.d.ts +104 -0
  221. package/build-types/state/types.d.ts.map +1 -0
  222. package/build-types/state/use-media-editor-state.d.ts +104 -0
  223. package/build-types/state/use-media-editor-state.d.ts.map +1 -0
  224. package/package.json +19 -17
  225. package/src/components/media-editor/index.tsx +52 -188
  226. package/src/components/media-editor/test/use-crop-options.tsx +164 -0
  227. package/src/components/media-editor/use-crop-options.ts +115 -0
  228. package/src/components/media-editor/use-save-media-editor.ts +214 -0
  229. package/src/components/media-editor-canvas/index.tsx +56 -24
  230. package/src/components/media-editor-crop-panel/index.tsx +25 -61
  231. package/src/components/media-editor-crop-panel/test/index.tsx +17 -43
  232. package/src/components/media-editor-modal/index.tsx +50 -12
  233. package/src/components/media-editor-modal/test/build-modifiers.test.ts +14 -0
  234. package/src/components/media-editor-modal/test/index.tsx +143 -0
  235. package/src/components/media-editor-toolbar/index.tsx +9 -5
  236. package/src/components/media-form/index.tsx +15 -1
  237. package/src/components/media-form/sidebar-datetime-view.tsx +47 -0
  238. package/src/components/media-form/test/sidebar-datetime-view.test.tsx +96 -0
  239. package/src/components/rotation-ruler/README.md +11 -25
  240. package/src/components/rotation-ruler/index.tsx +17 -2
  241. package/src/components/rotation-ruler/style.scss +49 -13
  242. package/src/hooks/use-crop-gesture-handlers.ts +66 -17
  243. package/src/image-editor/README.md +28 -129
  244. package/src/image-editor/core/camera.ts +51 -26
  245. package/src/image-editor/core/constants.ts +19 -0
  246. package/src/image-editor/core/containment.ts +102 -49
  247. package/src/image-editor/core/crop-rect.ts +45 -0
  248. package/src/image-editor/core/index.ts +16 -4
  249. package/src/image-editor/core/interaction-controller.ts +5 -1
  250. package/src/image-editor/core/math/sanitize.ts +158 -0
  251. package/src/image-editor/core/math/test/sanitize.ts +244 -0
  252. package/src/image-editor/core/setter-helpers.ts +66 -0
  253. package/src/image-editor/core/source-region.ts +21 -14
  254. package/src/image-editor/core/state.ts +67 -15
  255. package/src/image-editor/core/stencil-math.ts +55 -35
  256. package/src/image-editor/core/test/camera.ts +367 -1
  257. package/src/image-editor/core/test/state.ts +101 -8
  258. package/src/image-editor/core/test/stencil-math.ts +193 -0
  259. package/src/image-editor/core/transform-style.ts +21 -6
  260. package/src/image-editor/core/types.ts +24 -4
  261. package/src/image-editor/docs/architecture.md +48 -89
  262. package/src/image-editor/docs/recipes.md +123 -659
  263. package/src/image-editor/index.ts +12 -3
  264. package/src/image-editor/react/components/cropper-provider.tsx +16 -12
  265. package/src/image-editor/react/components/cropper.scss +23 -4
  266. package/src/image-editor/react/components/cropper.tsx +197 -90
  267. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +269 -0
  268. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +22 -9
  269. package/src/image-editor/react/components/test/cropper.tsx +55 -13
  270. package/src/image-editor/react/hooks/build-cropper-setters.ts +105 -0
  271. package/src/image-editor/react/hooks/index.ts +4 -2
  272. package/src/image-editor/react/hooks/test/{use-cropper-state.ts → use-cropper-reducer.ts} +142 -286
  273. package/src/image-editor/react/hooks/use-aria-announcer.ts +3 -1
  274. package/src/image-editor/react/hooks/use-cropper-reducer.ts +204 -0
  275. package/src/image-editor/react/hooks/use-interaction.ts +3 -2
  276. package/src/image-editor/stories/rectangle-crop.story.tsx +7 -17
  277. package/src/state/composite-reducer.ts +152 -0
  278. package/src/state/index.ts +20 -0
  279. package/src/state/media-editor-state-provider.tsx +70 -0
  280. package/src/state/test/use-media-editor-state.ts +402 -0
  281. package/src/state/types.ts +107 -0
  282. package/src/state/use-media-editor-state.ts +488 -0
  283. package/tsconfig.json +2 -0
  284. package/tsconfig.tsbuildinfo +1 -1
  285. package/build/image-editor/react/hooks/use-cropper-state.cjs +0 -277
  286. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +0 -7
  287. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +0 -262
  288. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +0 -7
  289. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -97
  290. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
  291. package/src/image-editor/docs/roadmap.md +0 -66
  292. package/src/image-editor/react/hooks/use-cropper-state.ts +0 -457
@@ -8,27 +8,36 @@
8
8
  */
9
9
 
10
10
  // React surface.
11
- export { useCropperState } from './react/hooks';
11
+ export { useCropperReducer, buildCropperSetters } from './react/hooks';
12
12
  export { Cropper, CropperProvider, useCropper } from './react/components';
13
- export type { UseCropperStateReturn } from './react/hooks';
13
+ export type { CropperController, CropperSetters } from './react/hooks';
14
14
  export type { CropperProps } from './react/components';
15
15
 
16
16
  // State and extension types.
17
17
  export type {
18
18
  CropperState,
19
+ CropperAction,
19
20
  TransformOperation,
20
21
  NormalizedPoint,
21
22
  NormalizedRect,
22
23
  Size,
23
24
  Flip,
24
25
  StencilProps,
26
+ HandlePosition,
25
27
  } from './core';
26
28
 
27
- // Deterministic cropper helpers.
29
+ // Deterministic cropper helpers. The reducer + containment + state
30
+ // equality helpers are exported so consumers can build composite
31
+ // stores that delegate cropper actions (see `useMediaEditorState` for
32
+ // the media editor's composite store).
28
33
  export {
29
34
  DEFAULT_STATE,
30
35
  DEFAULT_ASPECT_RATIOS,
31
36
  ORIGINAL_ASPECT_RATIO,
37
+ cropperReducer,
38
+ enforceContainment,
39
+ areCropperStatesEqual,
40
+ computeInscribedRect,
32
41
  getSourceRegion,
33
42
  getSourceRegionPercent,
34
43
  applyOperationToState,
@@ -7,16 +7,16 @@ import { createContext, useContext } from '@wordpress/element';
7
7
  * Internal dependencies
8
8
  */
9
9
  import {
10
- useCropperState,
11
- type UseCropperStateReturn,
12
- } from '../hooks/use-cropper-state';
10
+ useCropperReducer,
11
+ type CropperController,
12
+ } from '../hooks/use-cropper-reducer';
13
13
  import type { CropperState } from '../../core/types';
14
14
 
15
15
  /**
16
16
  * The context value type for the CropperProvider.
17
- * Contains the full return value of useCropperState.
17
+ * Contains the cropper controller from useCropperReducer.
18
18
  */
19
- type CropperContextValue = UseCropperStateReturn | null;
19
+ type CropperContextValue = CropperController | null;
20
20
 
21
21
  const CropperContext = createContext< CropperContextValue >( null );
22
22
 
@@ -31,12 +31,16 @@ interface CropperProviderProps {
31
31
  }
32
32
 
33
33
  /**
34
- * Convenience context provider that wraps useCropperState.
34
+ * Convenience context provider that wraps `useCropperReducer`.
35
35
  *
36
- * Provides the full cropper state and action creators to all
37
- * descendant components via React context.
36
+ * Provides the pure cropper controller (state + setters, NO undo
37
+ * history) to all descendant components via React context.
38
38
  *
39
- * @param props Provider props.
39
+ * History is a higher-layer concern owned by composite stores
40
+ * (see `useMediaEditorState` in media-editor/state for the media
41
+ * editor's composite controller with undo/redo).
42
+ *
43
+ * @param props
40
44
  * @param props.initialState
41
45
  * @param props.children
42
46
  * @return The provider element wrapping children.
@@ -45,7 +49,7 @@ export function CropperProvider( {
45
49
  initialState,
46
50
  children,
47
51
  }: CropperProviderProps ) {
48
- const cropperReturn = useCropperState( initialState );
52
+ const cropperReturn = useCropperReducer( initialState );
49
53
 
50
54
  return (
51
55
  <CropperContext.Provider value={ cropperReturn }>
@@ -60,9 +64,9 @@ export function CropperProvider( {
60
64
  * Must be used within a CropperProvider. Throws if used outside
61
65
  * of the provider tree.
62
66
  *
63
- * @return The cropper state and action creators.
67
+ * @return The cropper controller.
64
68
  */
65
- export function useCropper(): UseCropperStateReturn {
69
+ export function useCropper(): CropperController {
66
70
  const context = useContext( CropperContext );
67
71
 
68
72
  if ( ! context ) {
@@ -106,6 +106,20 @@ $handle-touch-target-size: 44px;
106
106
  }
107
107
  }
108
108
 
109
+ &__dimensions-tooltip {
110
+ position: absolute;
111
+ padding: 2px 6px;
112
+ background: #fff;
113
+ color: #1e1e1e;
114
+ font-size: 11px;
115
+ line-height: 1.4;
116
+ font-variant-numeric: tabular-nums;
117
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.08);
118
+ pointer-events: none;
119
+ white-space: nowrap;
120
+ z-index: 2;
121
+ }
122
+
109
123
  &__stencil-rect {
110
124
  position: absolute;
111
125
  border: 1px solid rgba(255, 255, 255, 0.7);
@@ -117,8 +131,10 @@ $handle-touch-target-size: 44px;
117
131
  // Blue border on the crop rectangle when the canvas has keyboard focus.
118
132
  // Uses a JS-controlled class rather than :focus-visible — browsers can
119
133
  // restore :focus-visible across programmatic focus calls, making pure
120
- // CSS unreliable for pointer-to-keyboard transitions.
121
- &__canvas--focus-visible &__stencil-rect {
134
+ // CSS unreliable for pointer-to-keyboard transitions. The :focus check
135
+ // on the canvas ensures the outline appears only when the canvas
136
+ // itself is focused, not when focus is on a child handle.
137
+ &__canvas--focus-visible:focus &__stencil-rect {
122
138
  border-color: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
123
139
  box-shadow: 0 0 0 1px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
124
140
  }
@@ -148,8 +164,11 @@ $handle-touch-target-size: 44px;
148
164
  }
149
165
 
150
166
  // Double ring (white inner + theme-color outer) for legibility
151
- // over the dark dimming overlay.
152
- &:focus-visible {
167
+ // over the dark dimming overlay. Gated on the JS-controlled
168
+ // keyboard-active class so that mouse interactions after a
169
+ // keyboard session — e.g., clicking a handle to start a drag —
170
+ // don't leave the active ring stuck on the handle.
171
+ .wp-media-editor-image-editor__canvas--focus-visible &:focus {
153
172
  background: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
154
173
  border-color: transparent;
155
174
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
@@ -24,64 +24,38 @@ import { __ } from '@wordpress/i18n';
24
24
  */
25
25
  import type {
26
26
  CropperState,
27
+ HandlePosition,
27
28
  StencilProps,
28
29
  Size,
29
30
  NormalizedRect,
30
31
  } from '../../core/types';
31
- import type { UseCropperStateReturn } from '../hooks/use-cropper-state';
32
- import { getImageFit } from '../../core/camera';
33
- import { getImageCropBounds } from '../../core/containment';
32
+ import type { CropperController } from '../hooks/use-cropper-reducer';
33
+ import { getImageFit, getRotatedBBox } from '../../core/camera';
34
+ import { getImageCropBounds, getMinZoom } from '../../core/containment';
35
+ import { MIN_CROP_PIXELS } from '../../core/constants';
36
+ import { computeInscribedRect } from '../../core/crop-rect';
34
37
  import { useInteraction } from '../hooks/use-interaction';
35
38
  import { useTransformStyle } from '../hooks/use-transform-style';
36
39
  import { useAriaAnnouncer } from '../hooks/use-aria-announcer';
37
40
  import { RectangleStencil } from './stencils/rectangle-stencil';
38
41
  import { DimmingOverlay } from './overlays/dimming-overlay';
39
42
  import { GridOverlay } from './overlays/grid-overlay';
43
+ import { DimensionsOverlay } from './overlays/dimensions-overlay';
44
+ import { getSourceRegion } from '../../core/source-region';
40
45
  import { ViewportProvider, useViewport } from './viewport-provider';
41
46
  import { VISUALLY_HIDDEN_STYLE } from '../visually-hidden-style';
42
47
 
43
48
  /** Threshold for comparing normalized crop rect values. */
44
49
  const CROP_RECT_EPSILON = 1e-6;
45
50
 
46
- // Largest rect of the given pixel aspect ratio that fits inside the visual
47
- // bounds, centered in [0,1] × [0,1] normalized space. Returns a full-frame
48
- // rect (1×1) if `aspectRatio` is unset or non-positive.
49
- function computeInscribedRect(
50
- aspectRatio: number | undefined,
51
- visualSize: Size
52
- ): NormalizedRect {
53
- let w = 1;
54
- let h = 1;
55
- if ( aspectRatio && aspectRatio > 0 && visualSize.width > 0 ) {
56
- // normalizedRatio = w/h in normalized space that produces the
57
- // desired pixel aspect ratio.
58
- // pixelW = w * visualW, pixelH = h * visualH
59
- // pixelW / pixelH = aspectRatio
60
- // => w / h = aspectRatio * visualH / visualW
61
- const normalizedRatio =
62
- ( aspectRatio * visualSize.height ) / visualSize.width;
63
- if ( normalizedRatio <= 1 ) {
64
- w = normalizedRatio;
65
- } else {
66
- h = 1 / normalizedRatio;
67
- }
68
- }
69
- return {
70
- x: ( 1 - w ) / 2,
71
- y: ( 1 - h ) / 2,
72
- width: w,
73
- height: h,
74
- };
75
- }
76
-
77
51
  /**
78
52
  * Props for the Cropper component.
79
53
  */
80
54
  export interface CropperProps {
81
55
  /** Image source URL. */
82
56
  src: string;
83
- /** The full state/setter object from `useCropperState`. */
84
- controller: UseCropperStateReturn;
57
+ /** The cropper controller from `useCropperReducer` or a composite store. */
58
+ controller: CropperController;
85
59
  /** Stencil component for the crop area. Defaults to RectangleStencil. */
86
60
  stencil?: React.ComponentType< StencilProps >;
87
61
  /** Show the rule-of-thirds grid overlay, or only during interactions. */
@@ -90,7 +64,9 @@ export interface CropperProps {
90
64
  isPlacementActive?: boolean;
91
65
  /** Show the dimming overlay outside the crop area. */
92
66
  showDimming?: boolean;
93
- /** Minimum zoom level. */
67
+ /** Show the live output dimensions tooltip during a resize. */
68
+ showDimensions?: boolean;
69
+ /** Minimum zoom level override. Defaults to the coverage-aware minimum. */
94
70
  minZoom?: number;
95
71
  /** Maximum zoom level. */
96
72
  maxZoom?: number;
@@ -137,12 +113,13 @@ export interface CropperProps {
137
113
  *
138
114
  * @param root0 Component props implementing CropperProps.
139
115
  * @param root0.src Image source URL.
140
- * @param root0.controller The full state/setter object from `useCropperState`.
116
+ * @param root0.controller The cropper controller from `useCropperReducer` or a composite store.
141
117
  * @param root0.stencil Custom stencil component.
142
118
  * @param root0.showGrid Grid overlay mode: false | true | 'interactive'.
143
119
  * @param root0.isPlacementActive Keep grid visible during external placement activity.
144
120
  * @param root0.showDimming Show dimming overlay outside crop.
145
- * @param root0.minZoom Minimum zoom level.
121
+ * @param root0.showDimensions Show live dimensions tooltip during resize.
122
+ * @param root0.minZoom Minimum zoom level override.
146
123
  * @param root0.maxZoom Maximum zoom level.
147
124
  * @param root0.aspectRatio Fixed aspect ratio (width/height).
148
125
  * @param root0.freeformCrop Enable resize handles.
@@ -162,6 +139,7 @@ function CropperInner(
162
139
  showGrid = false,
163
140
  isPlacementActive = false,
164
141
  showDimming = true,
142
+ showDimensions = true,
165
143
  minZoom,
166
144
  maxZoom,
167
145
  aspectRatio,
@@ -175,7 +153,14 @@ function CropperInner(
175
153
  }: CropperProps,
176
154
  ref: React.ForwardedRef< HTMLDivElement >
177
155
  ) {
178
- const { state, setImage, setCropRect, settleCrop } = controller;
156
+ const {
157
+ state,
158
+ setImage,
159
+ setCropRect,
160
+ settleCrop,
161
+ setVisualSize,
162
+ adjustCropRectForViewport,
163
+ } = controller;
179
164
  const {
180
165
  viewport: viewportState,
181
166
  setViewportPan,
@@ -202,18 +187,20 @@ function CropperInner(
202
187
 
203
188
  const handleCropAreaFocus = useCallback(
204
189
  ( event: React.FocusEvent< HTMLDivElement > ) => {
205
- if ( event.target === event.currentTarget ) {
190
+ const target = event.target as HTMLElement;
191
+ if ( target === event.currentTarget ) {
206
192
  setIsCropAreaFocused( true );
207
- // Show the outline only when focus arrived via keyboard
208
- // navigation. relatedTarget is null for pointer-initiated and
209
- // cross-window focus, so it reliably excludes those cases
210
- // without needing a separate ref or flag.
211
- if (
212
- event.relatedTarget !== null &&
213
- event.currentTarget.matches( ':focus-visible' )
214
- ) {
215
- setIsFocusVisible( true );
216
- }
193
+ }
194
+ // Show the outline only when focus arrived via keyboard
195
+ // navigation. relatedTarget is null for pointer-initiated and
196
+ // cross-window focus, so it reliably excludes those cases
197
+ // without needing a separate ref or flag. Applies to focus
198
+ // arriving on the canvas itself or on a descendant handle.
199
+ if (
200
+ event.relatedTarget !== null &&
201
+ target.matches( ':focus-visible' )
202
+ ) {
203
+ setIsFocusVisible( true );
217
204
  }
218
205
  },
219
206
  []
@@ -223,6 +210,15 @@ function CropperInner(
223
210
  ( event: React.FocusEvent< HTMLDivElement > ) => {
224
211
  if ( event.target === event.currentTarget ) {
225
212
  setIsCropAreaFocused( false );
213
+ }
214
+ // Reset keyboard-active styling only when focus leaves the
215
+ // cropper entirely. Moves between the canvas and a handle (or
216
+ // between handles) keep the keyboard-active state intact.
217
+ if (
218
+ ! event.currentTarget.contains(
219
+ event.relatedTarget as Node | null
220
+ )
221
+ ) {
226
222
  setIsFocusVisible( false );
227
223
  }
228
224
  },
@@ -272,9 +268,47 @@ function CropperInner(
272
268
  [ canvasSize, naturalWidth, naturalHeight, state.rotation ]
273
269
  );
274
270
 
275
- // In fixed-crop mode, auto-size the crop rect only when a fixed aspect
276
- // ratio is selected. With "Free" selected, turning freeform handles off
277
- // should preserve the user's current unconstrained crop.
271
+ // Per-axis minimum crop size in normalized space, expressing a
272
+ // pixel floor on the captured source region. cropRect is normalized
273
+ // in the viewport's snap-rotation bbox; the captured source-pixel
274
+ // width is `cropRect.width * bbox.width / zoom`, so the normalized
275
+ // floor scales with `zoom` to keep the source-pixel floor constant.
276
+ // Without this, SETTLE_CROP zooms in proportional to the shrink and
277
+ // successive drags can crop arbitrarily small.
278
+ const minCropSize: Size | undefined = useMemo( () => {
279
+ if ( naturalWidth <= 0 || naturalHeight <= 0 ) {
280
+ return undefined;
281
+ }
282
+ const snapRotation = Math.round( state.rotation / 90 ) * 90;
283
+ const bbox = getRotatedBBox(
284
+ naturalWidth,
285
+ naturalHeight,
286
+ snapRotation
287
+ );
288
+ return {
289
+ width: Math.min( 1, ( MIN_CROP_PIXELS * state.zoom ) / bbox.width ),
290
+ height: Math.min(
291
+ 1,
292
+ ( MIN_CROP_PIXELS * state.zoom ) / bbox.height
293
+ ),
294
+ };
295
+ }, [ naturalWidth, naturalHeight, state.rotation, state.zoom ] );
296
+
297
+ // Report the rendered image size to the controller. Composite
298
+ // controllers need it to compute aspect-ratio reshapes from the
299
+ // reducer (the dropdown dispatches without DOM access); pure
300
+ // controllers ignore it.
301
+ useEffect( () => {
302
+ setVisualSize( visualSize );
303
+ }, [ visualSize, setVisualSize ] );
304
+
305
+ // In fixed-crop mode, auto-size the crop rect only when a fixed
306
+ // aspect ratio is selected. With "Free" selected, turning freeform
307
+ // handles off should preserve the user's current unconstrained
308
+ // crop. Uses `adjustCropRectForViewport` so window-resize-driven
309
+ // reshapes don't create undo entries (composite controller); the
310
+ // dedup at lines below avoids redundant dispatches when the
311
+ // reducer has already updated the cropRect for an aspect change.
278
312
  useEffect( () => {
279
313
  if (
280
314
  freeformCrop ||
@@ -295,11 +329,20 @@ function CropperInner(
295
329
  ) {
296
330
  return;
297
331
  }
298
- setCropRect( rect );
299
- }, [ freeformCrop, aspectRatio, visualSize, setCropRect, state.cropRect ] );
300
-
301
- // In freeform mode, when aspectRatio changes, reshape the crop to the
302
- // largest inscribed rect of the new ratio.
332
+ adjustCropRectForViewport( rect );
333
+ }, [
334
+ freeformCrop,
335
+ aspectRatio,
336
+ visualSize,
337
+ adjustCropRectForViewport,
338
+ state.cropRect,
339
+ ] );
340
+
341
+ // In freeform mode, when aspectRatio changes, reshape the crop to
342
+ // the largest inscribed rect of the new ratio. Bails out when the
343
+ // cropRect already matches the inscribed rect — composite stores
344
+ // reshape atomically inside the reducer, so this effect is a
345
+ // no-op there.
303
346
  const prevAspectRatioRef = useRef( aspectRatio );
304
347
  useEffect( () => {
305
348
  if ( prevAspectRatioRef.current === aspectRatio ) {
@@ -316,8 +359,24 @@ function CropperInner(
316
359
  ) {
317
360
  return;
318
361
  }
319
- setCropRect( computeInscribedRect( aspectRatio, visualSize ) );
320
- }, [ aspectRatio, freeformCrop, visualSize, setCropRect ] );
362
+ const rect = computeInscribedRect( aspectRatio, visualSize );
363
+ const current = state.cropRect;
364
+ if (
365
+ Math.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&
366
+ Math.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&
367
+ Math.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&
368
+ Math.abs( current.height - rect.height ) < CROP_RECT_EPSILON
369
+ ) {
370
+ return;
371
+ }
372
+ adjustCropRectForViewport( rect );
373
+ }, [
374
+ aspectRatio,
375
+ freeformCrop,
376
+ visualSize,
377
+ adjustCropRectForViewport,
378
+ state.cropRect,
379
+ ] );
321
380
 
322
381
  // Compute the crop handle bounds from the actual image footprint.
323
382
  // Depends on the full state object because getImageCropBounds reads
@@ -330,9 +389,17 @@ function CropperInner(
330
389
  }
331
390
  return getImageCropBounds( state, elementSize, visualSize );
332
391
  }, [ state, elementSize, visualSize ] );
392
+ const effectiveMinZoom =
393
+ minZoom !== undefined ? minZoom : getMinZoom( state );
333
394
  const [ isResizing, setIsResizing ] = useState( false );
334
395
  const isResizingRef = useRef( false );
335
396
  const isSettlingRef = useRef( false );
397
+ // Direction of the handle the user is currently resizing — pointer or
398
+ // keyboard. `null` outside of an active resize. Drives the live
399
+ // dimensions tooltip overlay.
400
+ const [ activeHandle, setActiveHandle ] = useState< HandlePosition | null >(
401
+ null
402
+ );
336
403
 
337
404
  // Use the interaction hook for mouse, touch, and keyboard events.
338
405
  const {
@@ -342,7 +409,7 @@ function CropperInner(
342
409
  isZooming,
343
410
  isPlacementActive: isInteractionPlacementActive,
344
411
  } = useInteraction( state, controller, canvasSize, visualSize, {
345
- minZoom,
412
+ minZoom: effectiveMinZoom,
346
413
  maxZoom,
347
414
  onGestureStart,
348
415
  onGestureEnd,
@@ -351,27 +418,31 @@ function CropperInner(
351
418
  // Compose focus-visibility tracking into the canvas event handlers.
352
419
  // Kept as a spread rather than explicit props to avoid triggering
353
420
  // jsx-a11y/no-noninteractive-element-interactions on role="group".
421
+ //
422
+ // The pointer/key tracking lives in the capture phase so it runs
423
+ // before any child handler — handles call stopPropagation in their
424
+ // own onPointerDown / onKeyDown, which would otherwise prevent the
425
+ // keyboard-active state from updating when the user interacts with
426
+ // a handle directly.
354
427
  const canvasHandlers = {
355
428
  ...handlers,
356
- onPointerDown: ( event: React.PointerEvent< HTMLDivElement > ) => {
357
- handlers.onPointerDown?.( event );
358
- // Called after handlers so it lands last in the React batch —
359
- // el.focus() inside the handler fires onFocus, which may
360
- // otherwise set isFocusVisible back to true.
429
+ onPointerDownCapture: () => {
361
430
  setIsFocusVisible( false );
362
431
  },
363
- onKeyDown: ( event: React.KeyboardEvent< HTMLDivElement > ) => {
364
- // Guard against keydowns bubbling up from child handles
365
- // (e.g. Tab between handles, unhandled keys). Modifier-only
366
- // keypresses are excluded — they precede another key rather
367
- // than indicating deliberate keyboard interaction on their own.
432
+ onKeyDownCapture: ( event: React.KeyboardEvent< HTMLDivElement > ) => {
433
+ // Modifier-only keypresses precede another key rather than
434
+ // indicating deliberate keyboard interaction on their own.
368
435
  if (
369
- event.target === event.currentTarget &&
370
436
  ! [ 'Shift', 'Control', 'Alt', 'Meta' ].includes( event.key )
371
437
  ) {
372
438
  setIsFocusVisible( true );
373
439
  }
374
- handlers.onKeyDown?.( event );
440
+ },
441
+ onPointerDown: ( event: React.PointerEvent< HTMLDivElement > ) => {
442
+ handlers.onPointerDown?.( event );
443
+ // Re-assert false after handlers run — el.focus() inside the
444
+ // handler fires onFocus, which may otherwise set it back to true.
445
+ setIsFocusVisible( false );
375
446
  },
376
447
  };
377
448
 
@@ -470,7 +541,9 @@ function CropperInner(
470
541
 
471
542
  // Settling animation: brief linear transition after resize end.
472
543
  const [ settling, setSettling ] = useState( false );
473
- const settleTimerRef = useRef< ReturnType< typeof setTimeout > >();
544
+ const settleTimerRef = useRef<
545
+ ReturnType< typeof setTimeout > | undefined
546
+ >( undefined );
474
547
 
475
548
  // Clear the pending settle timer on unmount so it can't fire a
476
549
  // state update on an unmounted component.
@@ -485,6 +558,20 @@ function CropperInner(
485
558
  isInteractiveGrid &&
486
559
  ( isInteractionPlacementActive || isResizing || isPlacementActive );
487
560
 
561
+ // Output crop size in source pixels — drives the live tooltip
562
+ // overlay. Only computed during pointer drags, so the per-frame
563
+ // state churn during pan/zoom doesn't pay for it.
564
+ const outputSize = useMemo( () => {
565
+ if ( ! showDimensions || ! activeHandle || ! state.image ) {
566
+ return null;
567
+ }
568
+ const region = getSourceRegion( state, {
569
+ width: state.image.naturalWidth,
570
+ height: state.image.naturalHeight,
571
+ } );
572
+ return { width: region.width, height: region.height };
573
+ }, [ showDimensions, activeHandle, state ] );
574
+
488
575
  /**
489
576
  * Handle Escape on a resize handle — return focus to the canvas so
490
577
  * arrow keys pan the image rather than resize.
@@ -496,18 +583,22 @@ function CropperInner(
496
583
  canvasRef.current?.focus( { preventScroll: true } );
497
584
  }, [] );
498
585
 
499
- const handleResizeStart = useCallback( () => {
500
- isResizingRef.current = true;
501
- setIsResizing( true );
502
- // Clear any in-flight settle so transitions don't apply during the
503
- // new drag (rapid successive resizes would otherwise inherit the
504
- // previous settle animation).
505
- clearTimeout( settleTimerRef.current );
506
- isSettlingRef.current = false;
507
- setSettling( false );
508
- resetViewport();
509
- onGestureStart?.();
510
- }, [ onGestureStart, resetViewport ] );
586
+ const handleResizeStart = useCallback(
587
+ ( handle?: HandlePosition ) => {
588
+ isResizingRef.current = true;
589
+ setIsResizing( true );
590
+ setActiveHandle( handle ?? null );
591
+ // Clear any in-flight settle so transitions don't apply during the
592
+ // new drag (rapid successive resizes would otherwise inherit the
593
+ // previous settle animation).
594
+ clearTimeout( settleTimerRef.current );
595
+ isSettlingRef.current = false;
596
+ setSettling( false );
597
+ resetViewport();
598
+ onGestureStart?.();
599
+ },
600
+ [ onGestureStart, resetViewport ]
601
+ );
511
602
 
512
603
  /**
513
604
  * Handle resize end — settle the crop rect (re-center, fill height)
@@ -516,6 +607,7 @@ function CropperInner(
516
607
  const handleResizeEnd = useCallback( () => {
517
608
  isResizingRef.current = false;
518
609
  setIsResizing( false );
610
+ setActiveHandle( null );
519
611
  isSettlingRef.current = true;
520
612
  setSettling( true );
521
613
  // Reset viewport pan first so it transitions back to zero in sync
@@ -622,10 +714,12 @@ function CropperInner(
622
714
  'wp-media-editor-image-editor__canvas--show-grid',
623
715
  settling &&
624
716
  'wp-media-editor-image-editor__canvas--settling',
625
- // Show the keyboard focus outline only when the canvas
626
- // itself (not a child handle) has keyboard focus.
717
+ // Marks the cropper as in keyboard-interaction mode.
718
+ // CSS uses :focus on the canvas to show the stencil
719
+ // outline and :focus on a handle to show its ring,
720
+ // so the class applies whenever any cropper element
721
+ // has keyboard focus.
627
722
  isFocusVisible &&
628
- isCropAreaFocused &&
629
723
  'wp-media-editor-image-editor__canvas--focus-visible'
630
724
  ) }
631
725
  tabIndex={ 0 }
@@ -691,6 +785,7 @@ function CropperInner(
691
785
  freeformCrop={ freeformCrop }
692
786
  stencilTransition={ settleStencilTransition }
693
787
  cropBounds={ cropBounds }
788
+ minCropSize={ minCropSize }
694
789
  />
695
790
 
696
791
  { /* Rule-of-thirds grid */ }
@@ -701,6 +796,18 @@ function CropperInner(
701
796
  imageSize={ visualSize }
702
797
  />
703
798
  ) }
799
+
800
+ { /* Live dimensions tooltip pinned to the dragged handle. */ }
801
+ { activeHandle && outputSize && (
802
+ <DimensionsOverlay
803
+ cropRect={ state.cropRect }
804
+ containerSize={ canvasSize }
805
+ imageSize={ visualSize }
806
+ activeHandle={ activeHandle }
807
+ outputWidth={ outputSize.width }
808
+ outputHeight={ outputSize.height }
809
+ />
810
+ ) }
704
811
  </div>
705
812
 
706
813
  { /* ARIA live region for screen reader announcements */ }