@wordpress/media-editor 0.22.0 → 0.23.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 (353) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +74 -21
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-crop-options.cjs +4 -5
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -1
  6. package/build/components/media-editor/use-save-media-editor.cjs +23 -3
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +6 -11
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +17 -1
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +4 -5
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  14. package/build/components/media-editor-image-controls/index.cjs +4 -6
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -1
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +1 -0
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs.map +1 -1
  19. package/build/components/media-form/index.cjs +7 -1
  20. package/build/components/media-form/index.cjs.map +1 -1
  21. package/build/components/media-preview/index.cjs +0 -1
  22. package/build/components/media-preview/index.cjs.map +1 -1
  23. package/build/state/aspect-ratio-presets.cjs +10 -4
  24. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  25. package/build/state/composite-reducer.cjs +32 -67
  26. package/build/state/composite-reducer.cjs.map +1 -1
  27. package/build/state/index.cjs +0 -39
  28. package/build/state/types.cjs +1 -2
  29. package/build/state/types.cjs.map +1 -1
  30. package/build/state/use-media-editor-state.cjs +70 -106
  31. package/build/state/use-media-editor-state.cjs.map +1 -1
  32. package/build-module/components/media-editor/index.mjs +78 -25
  33. package/build-module/components/media-editor/index.mjs.map +1 -1
  34. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  35. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  36. package/build-module/components/media-editor/use-save-media-editor.mjs +23 -3
  37. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  38. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  39. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  40. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  41. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  42. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  43. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  44. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  45. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  46. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +1 -0
  47. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  48. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  49. package/build-module/components/media-form/index.mjs +7 -1
  50. package/build-module/components/media-form/index.mjs.map +1 -1
  51. package/build-module/components/media-preview/index.mjs +0 -1
  52. package/build-module/components/media-preview/index.mjs.map +1 -1
  53. package/build-module/state/aspect-ratio-presets.mjs +10 -5
  54. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  55. package/build-module/state/composite-reducer.mjs +32 -67
  56. package/build-module/state/composite-reducer.mjs.map +1 -1
  57. package/build-module/state/index.mjs +2 -5
  58. package/build-module/state/types.mjs +1 -2
  59. package/build-module/state/types.mjs.map +1 -1
  60. package/build-module/state/use-media-editor-state.mjs +70 -105
  61. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  62. package/build-style/style-rtl.css +104 -57
  63. package/build-style/style.css +103 -57
  64. package/build-types/components/media-editor/index.d.ts +17 -3
  65. package/build-types/components/media-editor/index.d.ts.map +1 -1
  66. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  67. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  68. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  69. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  70. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  71. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  72. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  73. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  74. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  75. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  76. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  77. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  78. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  79. package/build-types/components/media-form/index.d.ts.map +1 -1
  80. package/build-types/components/media-preview/index.d.ts.map +1 -1
  81. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  82. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  83. package/build-types/state/composite-reducer.d.ts +17 -19
  84. package/build-types/state/composite-reducer.d.ts.map +1 -1
  85. package/build-types/state/index.d.ts +2 -5
  86. package/build-types/state/index.d.ts.map +1 -1
  87. package/build-types/state/types.d.ts +20 -64
  88. package/build-types/state/types.d.ts.map +1 -1
  89. package/build-types/state/use-media-editor-state.d.ts +33 -52
  90. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  91. package/package.json +22 -23
  92. package/src/components/media-editor/index.tsx +163 -28
  93. package/src/components/media-editor/use-crop-options.ts +7 -11
  94. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  95. package/src/components/media-editor-canvas/index.tsx +15 -26
  96. package/src/components/media-editor-canvas/style.scss +6 -6
  97. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  98. package/src/components/media-editor-crop-panel/style.scss +21 -0
  99. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  100. package/src/components/media-editor-image-controls/index.tsx +11 -9
  101. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  102. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  103. package/src/components/media-editor-modal/index.tsx +1 -1
  104. package/src/components/media-form/index.tsx +7 -1
  105. package/src/components/media-preview/index.tsx +0 -1
  106. package/src/components/rotation-ruler/style.scss +3 -3
  107. package/src/state/README.md +32 -0
  108. package/src/state/aspect-ratio-presets.ts +22 -3
  109. package/src/state/composite-reducer.ts +42 -80
  110. package/src/state/index.ts +2 -18
  111. package/src/state/types.ts +18 -68
  112. package/src/state/use-media-editor-state.ts +155 -240
  113. package/src/style.scss +2 -1
  114. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  115. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  116. package/build/image-editor/core/camera.cjs +0 -277
  117. package/build/image-editor/core/camera.cjs.map +0 -1
  118. package/build/image-editor/core/constants.cjs +0 -133
  119. package/build/image-editor/core/constants.cjs.map +0 -1
  120. package/build/image-editor/core/containment.cjs +0 -289
  121. package/build/image-editor/core/containment.cjs.map +0 -1
  122. package/build/image-editor/core/crop-rect.cjs +0 -37
  123. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  124. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  125. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  126. package/build/image-editor/core/index.cjs +0 -89
  127. package/build/image-editor/core/interaction-controller.cjs +0 -591
  128. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  129. package/build/image-editor/core/math/rotation.cjs +0 -32
  130. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  131. package/build/image-editor/core/math/sanitize.cjs +0 -136
  132. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  133. package/build/image-editor/core/setter-helpers.cjs +0 -61
  134. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  135. package/build/image-editor/core/source-region.cjs +0 -236
  136. package/build/image-editor/core/source-region.cjs.map +0 -1
  137. package/build/image-editor/core/state.cjs +0 -296
  138. package/build/image-editor/core/state.cjs.map +0 -1
  139. package/build/image-editor/core/stencil-math.cjs +0 -203
  140. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  141. package/build/image-editor/core/transform-style.cjs +0 -43
  142. package/build/image-editor/core/transform-style.cjs.map +0 -1
  143. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  144. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  145. package/build/image-editor/core/types.cjs +0 -5
  146. package/build/image-editor/core/viewport-state.cjs +0 -36
  147. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  148. package/build/image-editor/index.cjs +0 -68
  149. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  150. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  151. package/build/image-editor/react/components/cropper.cjs +0 -595
  152. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  153. package/build/image-editor/react/components/index.cjs +0 -25
  154. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  155. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  156. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  157. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  158. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  159. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  160. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  161. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  162. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  163. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  164. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  165. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  166. package/build/image-editor/react/hooks/index.cjs +0 -19
  167. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  168. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  169. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  170. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  171. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  172. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  173. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  174. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  175. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  176. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  177. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  178. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  179. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  180. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  181. package/build-module/image-editor/core/camera.mjs +0 -265
  182. package/build-module/image-editor/core/camera.mjs.map +0 -1
  183. package/build-module/image-editor/core/constants.mjs +0 -115
  184. package/build-module/image-editor/core/constants.mjs.map +0 -1
  185. package/build-module/image-editor/core/containment.mjs +0 -281
  186. package/build-module/image-editor/core/containment.mjs.map +0 -1
  187. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  188. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  189. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  190. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  191. package/build-module/image-editor/core/index.mjs +0 -7
  192. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  193. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  194. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  195. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  196. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  197. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  198. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  199. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  200. package/build-module/image-editor/core/source-region.mjs +0 -228
  201. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  202. package/build-module/image-editor/core/state.mjs +0 -288
  203. package/build-module/image-editor/core/state.mjs.map +0 -1
  204. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  205. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  206. package/build-module/image-editor/core/transform-style.mjs +0 -38
  207. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  208. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  209. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  210. package/build-module/image-editor/core/types.mjs +0 -0
  211. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  212. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  213. package/build-module/image-editor/index.mjs +0 -4
  214. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  215. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  216. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  217. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  218. package/build-module/image-editor/react/components/index.mjs +0 -3
  219. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  220. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  221. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  222. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  223. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  224. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  225. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  226. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  227. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  228. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  229. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  230. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  231. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  232. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  233. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  234. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  235. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  236. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  237. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  238. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  239. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  240. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  241. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  242. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  243. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  244. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  245. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  246. package/build-types/image-editor/core/camera.d.ts +0 -128
  247. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  248. package/build-types/image-editor/core/constants.d.ts +0 -98
  249. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  250. package/build-types/image-editor/core/containment.d.ts +0 -72
  251. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  252. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  253. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  254. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  255. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  256. package/build-types/image-editor/core/index.d.ts +0 -10
  257. package/build-types/image-editor/core/index.d.ts.map +0 -1
  258. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  259. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  260. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  261. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  262. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  263. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  264. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  265. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  266. package/build-types/image-editor/core/source-region.d.ts +0 -94
  267. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  268. package/build-types/image-editor/core/state.d.ts +0 -51
  269. package/build-types/image-editor/core/state.d.ts.map +0 -1
  270. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  271. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  272. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  273. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  274. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  275. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  276. package/build-types/image-editor/core/types.d.ts +0 -269
  277. package/build-types/image-editor/core/types.d.ts.map +0 -1
  278. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  279. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  280. package/build-types/image-editor/index.d.ts +0 -17
  281. package/build-types/image-editor/index.d.ts.map +0 -1
  282. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  283. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  284. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  285. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  286. package/build-types/image-editor/react/components/index.d.ts +0 -4
  287. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  288. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  289. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  290. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  291. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  292. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  293. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  294. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  295. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  296. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  297. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  298. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  299. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  300. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  301. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  302. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  303. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  304. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  305. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  306. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  307. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  308. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  309. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  310. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  311. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  312. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  313. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  314. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  315. package/src/image-editor/README.md +0 -61
  316. package/src/image-editor/core/camera.ts +0 -429
  317. package/src/image-editor/core/constants.ts +0 -137
  318. package/src/image-editor/core/containment.ts +0 -469
  319. package/src/image-editor/core/crop-rect.ts +0 -42
  320. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  321. package/src/image-editor/core/index.ts +0 -43
  322. package/src/image-editor/core/interaction-controller.ts +0 -976
  323. package/src/image-editor/core/math/rotation.ts +0 -26
  324. package/src/image-editor/core/math/sanitize.ts +0 -155
  325. package/src/image-editor/core/setter-helpers.ts +0 -63
  326. package/src/image-editor/core/source-region.ts +0 -367
  327. package/src/image-editor/core/state.ts +0 -484
  328. package/src/image-editor/core/stencil-math.ts +0 -379
  329. package/src/image-editor/core/transform-style.ts +0 -56
  330. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  331. package/src/image-editor/core/types.ts +0 -230
  332. package/src/image-editor/core/viewport-state.ts +0 -30
  333. package/src/image-editor/docs/architecture.md +0 -63
  334. package/src/image-editor/docs/recipes.md +0 -184
  335. package/src/image-editor/index.ts +0 -43
  336. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  337. package/src/image-editor/react/components/cropper.scss +0 -259
  338. package/src/image-editor/react/components/cropper.tsx +0 -1108
  339. package/src/image-editor/react/components/index.ts +0 -3
  340. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  341. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  342. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  343. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  344. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  345. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  346. package/src/image-editor/react/hooks/index.ts +0 -4
  347. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  348. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  349. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  350. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  351. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  352. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  353. package/src/image-editor/style.scss +0 -1
@@ -1,8 +1,9 @@
1
1
  import { SelectControl, Stack, VisuallyHidden } from '@wordpress/ui';
2
2
  import { __ } from '@wordpress/i18n';
3
+ import { Icon, getAspectRatioIcon } from '@wordpress/icons';
4
+ import type { AspectRatioPreset } from '../../state/aspect-ratio-presets';
3
5
  import { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';
4
6
  import MediaEditorImageControls from '../media-editor-image-controls';
5
- import type { AspectRatioPreset } from '../../image-editor/core/constants';
6
7
 
7
8
  export interface MediaEditorCropPanelProps {
8
9
  /**
@@ -66,7 +67,42 @@ export default function MediaEditorCropPanel( {
66
67
  } }
67
68
  disabled={ disabled }
68
69
  items={ items }
69
- />
70
+ trigger={
71
+ <SelectControl.Trigger>
72
+ { ( item ) => (
73
+ <span className="media-editor-crop-panel__aspect-ratio-option">
74
+ <Icon
75
+ icon={ getAspectRatioIcon(
76
+ Number( item.value )
77
+ ) }
78
+ />
79
+ <span className="media-editor-crop-panel__aspect-ratio-label">
80
+ { item.label }
81
+ </span>
82
+ </span>
83
+ ) }
84
+ </SelectControl.Trigger>
85
+ }
86
+ >
87
+ { items.map( ( item ) => (
88
+ <SelectControl.Item
89
+ key={ item.value }
90
+ value={ item }
91
+ label={ item.label }
92
+ >
93
+ <SelectControl.ItemLabel>
94
+ <span className="media-editor-crop-panel__aspect-ratio-option">
95
+ <Icon
96
+ icon={ getAspectRatioIcon(
97
+ Number( item.value )
98
+ ) }
99
+ />
100
+ { item.label }
101
+ </span>
102
+ </SelectControl.ItemLabel>
103
+ </SelectControl.Item>
104
+ ) ) }
105
+ </SelectControl>
70
106
  </Stack>
71
107
  );
72
108
  }
@@ -0,0 +1,21 @@
1
+ @use "@wordpress/base-styles/variables" as *;
2
+
3
+ .media-editor-crop-panel__aspect-ratio-option {
4
+ display: flex;
5
+ align-items: center;
6
+ gap: $grid-unit-10;
7
+ // Allow the label to shrink so that it can be truncated.
8
+ min-width: 0;
9
+
10
+ svg {
11
+ flex-shrink: 0;
12
+ }
13
+ }
14
+
15
+ // The trigger truncates its value with an ellipsis, which doesn't apply
16
+ // through the flex wrapper, so truncate the label itself.
17
+ .media-editor-crop-panel__aspect-ratio-label {
18
+ overflow: hidden;
19
+ text-overflow: ellipsis;
20
+ white-space: nowrap;
21
+ }
@@ -1,7 +1,6 @@
1
1
  import { __ } from '@wordpress/i18n';
2
2
  import { useMediaEditor } from '../../state';
3
3
  import { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';
4
- import { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants';
5
4
  import RotationRuler from '../rotation-ruler';
6
5
 
7
6
  export interface MediaEditorFineRotationProps {
@@ -28,7 +27,8 @@ export default function MediaEditorFineRotation( {
28
27
  onPlacementControlInteraction,
29
28
  disabled = false,
30
29
  }: MediaEditorFineRotationProps ) {
31
- const { state, setRotation } = useMediaEditor().cropper;
30
+ const { state, setRotation, maxRotationOffset } =
31
+ useMediaEditor().imageEditor;
32
32
  // `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce
33
33
  // into one undo entry via the gesture idle window. Pointer-up still
34
34
  // closes pointer drags immediately.
@@ -50,8 +50,8 @@ export default function MediaEditorFineRotation( {
50
50
  // causing subsequent events to spiral.
51
51
  const EPS = 0.01;
52
52
  const clamped = Math.max(
53
- -MAX_ROTATION_OFFSET + EPS,
54
- Math.min( MAX_ROTATION_OFFSET - EPS, value )
53
+ -maxRotationOffset + EPS,
54
+ Math.min( maxRotationOffset - EPS, value )
55
55
  );
56
56
  onPlacementControlInteraction?.();
57
57
  setRotation( baseAngle + clamped * visualDir );
@@ -65,8 +65,8 @@ export default function MediaEditorFineRotation( {
65
65
  >
66
66
  <RotationRuler
67
67
  label={ __( 'Fine rotation' ) }
68
- min={ -MAX_ROTATION_OFFSET }
69
- max={ MAX_ROTATION_OFFSET }
68
+ min={ -maxRotationOffset }
69
+ max={ maxRotationOffset }
70
70
  value={ fineOffset }
71
71
  onChange={ handleRotationSlider }
72
72
  disabled={ disabled }
@@ -6,6 +6,7 @@ import {
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import {
8
8
  aspectRatio as aspectRatioIcon,
9
+ getAspectRatioIcon,
9
10
  rotateLeft,
10
11
  rotateRight,
11
12
  flipHorizontal,
@@ -14,11 +15,7 @@ import {
14
15
  plus,
15
16
  } from '@wordpress/icons';
16
17
  import { useMediaEditor } from '../../state';
17
- import {
18
- MAX_ZOOM,
19
- type AspectRatioPreset,
20
- } from '../../image-editor/core/constants';
21
- import { getMinZoom } from '../../image-editor/core/containment';
18
+ import type { AspectRatioPreset } from '../../state/aspect-ratio-presets';
22
19
  import { useCropOptions } from '../media-editor/use-crop-options';
23
20
 
24
21
  /**
@@ -79,14 +76,14 @@ export default function MediaEditorImageControls( {
79
76
  zoomFactor = DEFAULT_ZOOM_FACTOR,
80
77
  disabled = false,
81
78
  }: MediaEditorImageControlsProps ) {
82
- const { state, setFlip, snapRotate90, setZoom } = useMediaEditor().cropper;
79
+ const { state, setFlip, snapRotate90, setZoom, minZoom, maxZoom } =
80
+ useMediaEditor().imageEditor;
83
81
  const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =
84
82
  useCropOptions( { aspectRatioPresets } );
85
83
  const hasAspectRatioControl = ! withLabels && showAspectRatioControl;
86
- const minZoom = getMinZoom( state );
87
84
  const zoomByFactor = ( factor: number ) => {
88
85
  setZoom(
89
- Math.min( MAX_ZOOM, Math.max( minZoom, state.zoom * factor ) )
86
+ Math.min( maxZoom, Math.max( minZoom, state.zoom * factor ) )
90
87
  );
91
88
  };
92
89
 
@@ -155,7 +152,7 @@ export default function MediaEditorImageControls( {
155
152
  icon={ plus }
156
153
  label={ __( 'Zoom in' ) }
157
154
  showTooltip
158
- disabled={ disabled || state.zoom >= MAX_ZOOM }
155
+ disabled={ disabled || state.zoom >= maxZoom }
159
156
  accessibleWhenDisabled
160
157
  onClick={ () => zoomByFactor( zoomFactor ) }
161
158
  />
@@ -202,6 +199,11 @@ export default function MediaEditorImageControls( {
202
199
  value={ preset.value.toString() }
203
200
  closeOnClick
204
201
  disabled={ disabled }
202
+ prefix={
203
+ <Menu.PrefixIcon
204
+ icon={ getAspectRatioIcon( preset.value ) }
205
+ />
206
+ }
205
207
  >
206
208
  <Menu.ItemLabel>{ preset.label }</Menu.ItemLabel>
207
209
  </Menu.RadioItem>
@@ -109,6 +109,7 @@ function KeyCombinationDisplay( {
109
109
  return (
110
110
  <kbd
111
111
  className="media-editor-keyboard-shortcuts-modal__shortcut-term"
112
+ dir="ltr"
112
113
  aria-label={ label }
113
114
  >
114
115
  { keys.map( ( key, index ) =>
@@ -47,7 +47,7 @@
47
47
  margin: 0 0.2rem 0 0.2rem;
48
48
 
49
49
  &:last-child {
50
- margin: 0 0 0 0.2rem;
50
+ margin-inline-end: 0;
51
51
  }
52
52
  }
53
53
  }
@@ -5,11 +5,11 @@ import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
5
5
  import { store as noticesStore } from '@wordpress/notices';
6
6
  import type { Field, Form } from '@wordpress/dataviews';
7
7
  import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
8
+ import type { AspectRatioPreset } from '../../state/aspect-ratio-presets';
8
9
  import MediaEditor from '../media-editor';
9
10
  import type { Media } from '../media-editor-provider';
10
11
  import { store as mediaEditorStore } from '../../store';
11
12
  import type { MediaEditorModalUpdate } from '../../store/actions';
12
- import type { AspectRatioPreset } from '../../image-editor/core/constants';
13
13
 
14
14
  interface MediaEditorModalProps {
15
15
  /**
@@ -30,7 +30,13 @@ const DEFAULT_FORM: Form = {
30
30
  },
31
31
  } ) ),
32
32
  'date',
33
- 'author',
33
+ {
34
+ id: 'author',
35
+ layout: {
36
+ type: 'panel' as const,
37
+ showPlaceholderIfEmpty: true,
38
+ },
39
+ },
34
40
  'filename',
35
41
  'mime_type',
36
42
  'filesize',
@@ -44,7 +44,6 @@ function MediaPreviewFileInfo( {
44
44
  <a
45
45
  href={ mediaUrl }
46
46
  target="_blank"
47
- rel="noopener"
48
47
  className="media-editor-preview__download-link"
49
48
  >
50
49
  { __( 'View file' ) }
@@ -18,8 +18,7 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
18
18
  height: 32px;
19
19
  padding: 0 $grid-unit-10;
20
20
  box-sizing: border-box;
21
- color: $gray-900;
22
- font-family: $font-family-body;
21
+ font-family: var(--wpds-typography-font-family-body);
23
22
  user-select: none;
24
23
  touch-action: none;
25
24
  cursor: ew-resize;
@@ -89,6 +88,8 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
89
88
 
90
89
  .rotation-ruler__ticks {
91
90
  position: absolute;
91
+ // Keep SVG ticks visible when the browser forces dark colors.
92
+ color: CanvasText;
92
93
  // The tick offset is applied as a JS-set inline `transform: translateX()`
93
94
  // (see rotation-ruler/index.tsx), which rtlcss can't mirror. If rtlcss
94
95
  // flipped this `left` to `right`, the anchor and the transform would
@@ -145,7 +146,6 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
145
146
  font-size: 12px;
146
147
  font-weight: var(--wpds-typography-font-weight-emphasis);
147
148
  line-height: 14px;
148
- color: $gray-900;
149
149
  pointer-events: none;
150
150
 
151
151
  &::before {
@@ -0,0 +1,32 @@
1
+ # Media Editor Session
2
+
3
+ The media editor's session owns its undo and redo history. The image editor's state from `@wordpress/image-editor` is one slice of the session's state, next to the sidebar crop options and named edits, kept through `useImageEditor( { state, onChange } )`, so one history covers them all.
4
+
5
+ `useMediaEditorState()` creates a media editor session; `<MediaEditorStateProvider>` calls it, and `useMediaEditor()` reads the one it made. Calling `useMediaEditorState()` again inside the provider makes a second session that shares nothing with the first, so components use `useMediaEditor()`. The session owns the source image, every editing slice, the shared undo/redo history, gesture boundaries, and whether the edits change the saved image (`hasOutputEdits`). The image editor is one participant: `session.imageEditor` is a geometry-only `ImageEditorController` that an `<ImageEditorCanvas>` takes via its `controller` prop, and its `isDirty` covers geometry alone. Replacing the source image (`setSourceImage`, which the image editor's `setImage` also calls) starts a fresh session with default geometry and crop options, a clean baseline, and no history. Save code asks the session, not the image editor, whether image output needs saving.
6
+
7
+ The session also holds named edits other than crop: `session.edits`, set with `session.setEdit( name, value )` and removed by passing `undefined`. They share the crop history, so undo, redo and gestures treat them like any crop change, and a different source image clears them. Values are plain data (`EditValue`: strings, numbers, booleans, `null`, and arrays and objects of those), because the session compares them by content to tell a real change from a no-op. Edits do not yet count towards `hasOutputEdits`; nothing saves them.
8
+
9
+ `session.reset()` puts every slice back to its starting state in one undo entry: default geometry and crop options, no edits, same image. The Reset button calls it; it does not compose per-slice resets itself.
10
+
11
+ ## Use the Session With the Canvas
12
+
13
+ Use the media editor session when image editor state must share history with controls such as aspect ratio. The session owns history and gesture boundaries; pass its `imageEditor` controller to `<ImageEditorCanvas>`.
14
+
15
+ ```tsx
16
+ import { ImageEditorCanvas } from '@wordpress/image-editor';
17
+ import { useMediaEditor } from '../state';
18
+
19
+ function MediaEditorCanvas( { src }: { src: string } ) {
20
+ const session = useMediaEditor();
21
+
22
+ return (
23
+ <ImageEditorCanvas
24
+ src={ src }
25
+ controller={ session.imageEditor }
26
+ freeformCrop
27
+ onGestureStart={ session.beginGesture }
28
+ onGestureEnd={ session.endGesture }
29
+ />
30
+ );
31
+ }
32
+ ```
@@ -1,9 +1,28 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { ORIGINAL_ASPECT_RATIO, type AspectRatioPreset } from '../image-editor';
3
2
 
4
3
  /**
5
- * The presets the editor offers by default. The labels live here rather
6
- * than in the cropper core, which has no user-facing strings.
4
+ * An aspect ratio preset with a human-readable label.
5
+ */
6
+ export interface AspectRatioPreset {
7
+ /** Display label (e.g., "Square (1:1)"). */
8
+ label: string;
9
+ /**
10
+ * The aspect ratio value (width / height). 0 = free,
11
+ * `ORIGINAL_ASPECT_RATIO` = the image's own ratio.
12
+ */
13
+ value: number;
14
+ }
15
+
16
+ /**
17
+ * Sentinel value for "Original" aspect ratio — resolved at runtime
18
+ * to the image's natural width / height.
19
+ */
20
+ export const ORIGINAL_ASPECT_RATIO = -1;
21
+
22
+ /**
23
+ * The presets the editor offers by default. They live here rather than
24
+ * in the image editor package, because which ratios to offer, and what
25
+ * to call them, is a product choice. The package takes a plain number.
7
26
  */
8
27
  export const DEFAULT_ASPECT_RATIOS: AspectRatioPreset[] = [
9
28
  { label: __( 'Free' ), value: 0 },
@@ -1,81 +1,47 @@
1
1
  import fastDeepEqual from 'fast-deep-equal/es6/index.js';
2
- import type { CropperState } from '../image-editor';
3
2
  import {
4
- cropperReducer,
5
- areCropperStatesEqual,
6
- computeInscribedRect,
7
- } from '../image-editor/core';
3
+ areImageEditorStatesEqual,
4
+ createImageEditorState,
5
+ type ImageEditorState,
6
+ } from '@wordpress/image-editor';
8
7
  import {
9
8
  DEFAULT_CROP_OPTIONS,
10
- type CropOptionsSlice,
11
9
  type MediaEditorAction,
12
10
  type MediaEditorState,
13
11
  } from './types';
14
12
 
15
13
  /**
16
- * Pure composite reducer for the media editor.
14
+ * Pure reducer for the media editor.
17
15
  *
18
- * Delegates `CROPPER`-tagged actions to the framework-agnostic
19
- * `cropperReducer` and owns first-class transitions for the sidebar
20
- * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite
21
- * in one transaction (used by undo/redo).
16
+ * The image editor works out its own next state (through the controller from
17
+ * `@wordpress/image-editor`) and this reducer stores it. The reducer
18
+ * also owns the sidebar crop options and the named edits.
22
19
  *
23
- * Note: this reducer carries NO history of its own. Snapshots and
24
- * stacks live in the `useMediaEditorState` hook that wraps it.
20
+ * This reducer keeps no history; `useMediaEditorState` does.
25
21
  *
26
- * @param state Current composite state.
22
+ * @param state Current state.
27
23
  * @param action Action to apply.
28
- * @return Next composite state.
24
+ * @return Next state.
29
25
  */
30
26
  export function mediaEditorReducer(
31
27
  state: MediaEditorState,
32
28
  action: MediaEditorAction
33
29
  ): MediaEditorState {
34
30
  switch ( action.type ) {
35
- case 'CROPPER': {
36
- const nextCropper = cropperReducer( state.cropper, action.action );
37
- if ( nextCropper === state.cropper ) {
38
- return state;
39
- }
40
- return { ...state, cropper: nextCropper };
41
- }
42
- case 'SET_ASPECT_RATIO_VALUE': {
43
- const { presetKey, resolved, visualSize } = action.payload;
44
- // Atomically: update the preset key AND reshape the
45
- // cropRect (when the ratio is non-Free and we have a
46
- // visualSize). One transaction = one undo entry.
47
- const shouldReshape =
48
- resolved !== undefined &&
49
- resolved > 0 &&
50
- visualSize.width > 0 &&
51
- visualSize.height > 0;
52
- const nextCropOptions: CropOptionsSlice = {
53
- ...state.cropOptions,
54
- aspectRatioValue: presetKey,
55
- };
56
- if ( ! shouldReshape ) {
57
- if ( state.cropOptions.aspectRatioValue === presetKey ) {
58
- return state;
59
- }
60
- return { ...state, cropOptions: nextCropOptions };
61
- }
62
- const newCropRect = computeInscribedRect( resolved, visualSize );
63
- const nextCropper = cropperReducer( state.cropper, {
64
- type: 'SET_CROP_RECT',
65
- payload: newCropRect,
66
- } );
67
- return {
68
- ...state,
69
- cropper: nextCropper,
70
- cropOptions: nextCropOptions,
71
- };
72
- }
73
- case 'RESET': {
74
- const next = buildInitialMediaEditorState(
75
- cropperReducer( state.cropper, { type: 'RESET' } )
76
- );
77
- return areMediaEditorStatesEqual( state, next ) ? state : next;
78
- }
31
+ case 'SET_IMAGE_EDITOR':
32
+ return action.payload === state.imageEditor
33
+ ? state
34
+ : { ...state, imageEditor: action.payload };
35
+ case 'SET_ASPECT_RATIO_VALUE':
36
+ return state.cropOptions.aspectRatioValue === action.payload
37
+ ? state
38
+ : {
39
+ ...state,
40
+ cropOptions: {
41
+ ...state.cropOptions,
42
+ aspectRatioValue: action.payload,
43
+ },
44
+ };
79
45
  case 'SET_EDIT': {
80
46
  const { name, value } = action.payload;
81
47
  if ( value === undefined ) {
@@ -91,27 +57,23 @@ export function mediaEditorReducer(
91
57
  }
92
58
  return { ...state, edits: { ...state.edits, [ name ]: value } };
93
59
  }
60
+ case 'RESET': {
61
+ const next = buildInitialMediaEditorState(
62
+ createImageEditorState( { image: state.imageEditor.image } )
63
+ );
64
+ return areMediaEditorStatesEqual( state, next ) ? state : next;
65
+ }
94
66
  case 'RESTORE_SNAPSHOT':
95
67
  return action.payload;
96
- case 'VIEWPORT_ADJUST_CROP_RECT': {
97
- const nextCropper = cropperReducer( state.cropper, {
98
- type: 'SET_CROP_RECT',
99
- payload: action.payload,
100
- } );
101
- if ( nextCropper === state.cropper ) {
102
- return state;
103
- }
104
- return { ...state, cropper: nextCropper };
105
- }
106
68
  }
107
69
  }
108
70
 
109
71
  /**
110
- * Value-equality check for two composite states. Used by the history
111
- * machinery to dedup snapshots when an action turned out to be a no-op.
72
+ * Value-equality check for two media editor states. The history uses it
73
+ * to skip snapshots when an action turned out to be a no-op.
112
74
  *
113
- * @param a First composite state.
114
- * @param b Second composite state.
75
+ * @param a First state.
76
+ * @param b Second state.
115
77
  * @return Whether `a` and `b` are value-equal across all slices.
116
78
  */
117
79
  export function areMediaEditorStatesEqual(
@@ -122,24 +84,24 @@ export function areMediaEditorStatesEqual(
122
84
  return true;
123
85
  }
124
86
  return (
125
- areCropperStatesEqual( a.cropper, b.cropper ) &&
87
+ areImageEditorStatesEqual( a.imageEditor, b.imageEditor ) &&
126
88
  a.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue &&
127
89
  fastDeepEqual( a.edits, b.edits )
128
90
  );
129
91
  }
130
92
 
131
93
  /**
132
- * Build the composite state a session starts from: the given cropper
133
- * slice, default crop options, and no edits.
94
+ * Build the state a session starts from: the given image editor state,
95
+ * default crop options, and no edits.
134
96
  *
135
- * @param cropper The cropper slice.
136
- * @return Composite initial state.
97
+ * @param imageEditor The image editor state.
98
+ * @return Initial state.
137
99
  */
138
100
  export function buildInitialMediaEditorState(
139
- cropper: CropperState
101
+ imageEditor: ImageEditorState
140
102
  ): MediaEditorState {
141
103
  return {
142
- cropper,
104
+ imageEditor,
143
105
  cropOptions: { ...DEFAULT_CROP_OPTIONS },
144
106
  edits: {},
145
107
  };
@@ -1,23 +1,7 @@
1
- export {
2
- useMediaEditorState,
3
- resolveAspectRatio,
4
- } from './use-media-editor-state';
1
+ export { useMediaEditorState } from './use-media-editor-state';
5
2
  export type { MediaEditorSession } from './use-media-editor-state';
6
3
  export {
7
4
  MediaEditorStateProvider,
8
5
  useMediaEditor,
9
6
  } from './media-editor-state-provider';
10
- export {
11
- mediaEditorReducer,
12
- areMediaEditorStatesEqual,
13
- buildInitialMediaEditorState,
14
- } from './composite-reducer';
15
- export { DEFAULT_CROP_OPTIONS } from './types';
16
- export { DEFAULT_ASPECT_RATIOS } from './aspect-ratio-presets';
17
- export type {
18
- CropOptionsSlice,
19
- EditsSlice,
20
- EditValue,
21
- MediaEditorState,
22
- MediaEditorAction,
23
- } from './types';
7
+ export type { EditsSlice, EditValue, MediaEditorState } from './types';
@@ -1,22 +1,20 @@
1
- import type { CropperState, NormalizedRect, Size } from '../image-editor';
2
- import type { CropperAction } from '../image-editor/core';
1
+ import type { ImageEditorState } from '@wordpress/image-editor';
3
2
 
4
3
  /**
5
- * Sidebar control state for the cropper. Lives in the composite store
6
- * so it participates in the same undo history as cropper geometry.
4
+ * Sidebar control state for the image editor, kept in the same undo history
5
+ * as the crop.
7
6
  */
8
7
  export interface CropOptionsSlice {
9
8
  /**
10
9
  * Selected aspect-ratio preset as a string (round-trippable through
11
10
  * `<SelectControl>`). `'0'` = Free, `'-1'` = Original, any positive
12
- * decimal = fixed ratio.
11
+ * decimal = fixed ratio. The image editor holds the resolved ratio itself.
13
12
  */
14
13
  aspectRatioValue: string;
15
14
  }
16
15
 
17
16
  /**
18
- * Default values for the crop-options slice. Mirrors the initial state
19
- * used by the sidebar before the user has touched anything.
17
+ * The crop options a session starts from.
20
18
  */
21
19
  export const DEFAULT_CROP_OPTIONS: CropOptionsSlice = {
22
20
  aspectRatioValue: '0',
@@ -46,81 +44,33 @@ export type EditValue =
46
44
  export type EditsSlice = Record< string, EditValue >;
47
45
 
48
46
  /**
49
- * The full composite state for the media editor — cropper geometry,
50
- * the sidebar control slice, and named edits.
47
+ * The full state of the media editor: the image editor's state, the sidebar
48
+ * crop options and named edits.
51
49
  *
52
50
  * Every undo/redo snapshot is a full `MediaEditorState`. Slices stay
53
51
  * referentially equal across actions that don't touch them.
54
52
  */
55
53
  export interface MediaEditorState {
56
- cropper: CropperState;
54
+ imageEditor: ImageEditorState;
57
55
  cropOptions: CropOptionsSlice;
58
56
  edits: EditsSlice;
59
57
  }
60
58
 
61
- /**
62
- * Composite reducer action union.
63
- *
64
- * Cropper geometry actions are wrapped in a `CROPPER` envelope and
65
- * delegated to the pure `cropperReducer`. Sidebar and history
66
- * concerns are first-class actions on this reducer.
67
- */
59
+ /** Actions the media editor reducer handles. */
68
60
  export type MediaEditorAction =
69
- /**
70
- * Delegate to the underlying cropper reducer. Used for every
71
- * geometry transition (pan / zoom / rotation / flip / cropRect /
72
- * settle / etc.).
73
- */
74
- | {
75
- type: 'CROPPER';
76
- action: CropperAction;
77
- }
78
- /**
79
- * Set the aspect-ratio preset. Atomically updates the preset key
80
- * and the cropRect (computed from the resolved ratio and the
81
- * current visualSize). One transaction = one undo entry.
82
- */
83
- | {
84
- type: 'SET_ASPECT_RATIO_VALUE';
85
- payload: {
86
- /** Preset key as it appears in the dropdown. */
87
- presetKey: string;
88
- /**
89
- * Resolved width/height ratio. `undefined` = Free
90
- * (no lock; cropRect stays where it is).
91
- */
92
- resolved: number | undefined;
93
- /**
94
- * Rendered image size used to compute the inscribed
95
- * rect. Caller supplies it because the reducer is
96
- * framework-agnostic and has no DOM access.
97
- */
98
- visualSize: Size;
99
- };
100
- }
101
- /**
102
- * Put every slice back to its starting state, keeping the image:
103
- * default geometry, default crop options, no edits. One action,
104
- * so one undo entry.
105
- */
106
- | { type: 'RESET' }
61
+ /** Replace the image editor's state with the next one it reports. */
62
+ | { type: 'SET_IMAGE_EDITOR'; payload: ImageEditorState }
63
+ /** Set the aspect-ratio preset the dropdown shows. */
64
+ | { type: 'SET_ASPECT_RATIO_VALUE'; payload: string }
107
65
  /** Set a named edit, or remove it when `value` is `undefined`. */
108
66
  | {
109
67
  type: 'SET_EDIT';
110
68
  payload: { name: string; value: EditValue | undefined };
111
69
  }
112
70
  /**
113
- * Replace the entire composite state with `payload`. Used by
114
- * undo/redo to restore a full snapshot atomically.
71
+ * Put every slice back to its starting state, keeping the image. One
72
+ * action, so one undo entry.
115
73
  */
116
- | { type: 'RESTORE_SNAPSHOT'; payload: MediaEditorState }
117
- /**
118
- * Adjust the cropper's cropRect in response to a viewport change
119
- * (e.g., window resize). Behaviorally identical to a `CROPPER
120
- * SET_CROP_RECT` dispatch, but tagged so the hook layer can skip
121
- * history recording — viewport reshapes aren't editor actions.
122
- */
123
- | {
124
- type: 'VIEWPORT_ADJUST_CROP_RECT';
125
- payload: NormalizedRect;
126
- };
74
+ | { type: 'RESET' }
75
+ /** Replace the whole state with a snapshot (undo/redo). */
76
+ | { type: 'RESTORE_SNAPSHOT'; payload: MediaEditorState };