@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
@@ -26,63 +26,35 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  }) : target, mod));
27
27
  let fast_deep_equal_es6_index_js = require("fast-deep-equal/es6/index.js");
28
28
  fast_deep_equal_es6_index_js = __toESM(fast_deep_equal_es6_index_js);
29
- let ___image_editor_core_index_ts = require("../image-editor/core/index.cjs");
29
+ let _wordpress_image_editor = require("@wordpress/image-editor");
30
30
  let __types_ts = require("./types.cjs");
31
31
  // packages/media-editor/src/state/composite-reducer.ts
32
32
  /**
33
- * Pure composite reducer for the media editor.
33
+ * Pure reducer for the media editor.
34
34
  *
35
- * Delegates `CROPPER`-tagged actions to the framework-agnostic
36
- * `cropperReducer` and owns first-class transitions for the sidebar
37
- * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite
38
- * in one transaction (used by undo/redo).
35
+ * The image editor works out its own next state (through the controller from
36
+ * `@wordpress/image-editor`) and this reducer stores it. The reducer
37
+ * also owns the sidebar crop options and the named edits.
39
38
  *
40
- * Note: this reducer carries NO history of its own. Snapshots and
41
- * stacks live in the `useMediaEditorState` hook that wraps it.
39
+ * This reducer keeps no history; `useMediaEditorState` does.
42
40
  *
43
- * @param state Current composite state.
41
+ * @param state Current state.
44
42
  * @param action Action to apply.
45
- * @return Next composite state.
43
+ * @return Next state.
46
44
  */
47
45
  function mediaEditorReducer(state, action) {
48
46
  switch (action.type) {
49
- case "CROPPER": {
50
- const nextCropper = (0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, action.action);
51
- if (nextCropper === state.cropper) return state;
52
- return {
53
- ...state,
54
- cropper: nextCropper
55
- };
56
- }
57
- case "SET_ASPECT_RATIO_VALUE": {
58
- const { presetKey, resolved, visualSize } = action.payload;
59
- const shouldReshape = resolved !== void 0 && resolved > 0 && visualSize.width > 0 && visualSize.height > 0;
60
- const nextCropOptions = {
47
+ case "SET_IMAGE_EDITOR": return action.payload === state.imageEditor ? state : {
48
+ ...state,
49
+ imageEditor: action.payload
50
+ };
51
+ case "SET_ASPECT_RATIO_VALUE": return state.cropOptions.aspectRatioValue === action.payload ? state : {
52
+ ...state,
53
+ cropOptions: {
61
54
  ...state.cropOptions,
62
- aspectRatioValue: presetKey
63
- };
64
- if (!shouldReshape) {
65
- if (state.cropOptions.aspectRatioValue === presetKey) return state;
66
- return {
67
- ...state,
68
- cropOptions: nextCropOptions
69
- };
55
+ aspectRatioValue: action.payload
70
56
  }
71
- const newCropRect = (0, ___image_editor_core_index_ts.computeInscribedRect)(resolved, visualSize);
72
- const nextCropper = (0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, {
73
- type: "SET_CROP_RECT",
74
- payload: newCropRect
75
- });
76
- return {
77
- ...state,
78
- cropper: nextCropper,
79
- cropOptions: nextCropOptions
80
- };
81
- }
82
- case "RESET": {
83
- const next = buildInitialMediaEditorState((0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, { type: "RESET" }));
84
- return areMediaEditorStatesEqual(state, next) ? state : next;
85
- }
57
+ };
86
58
  case "SET_EDIT": {
87
59
  const { name, value } = action.payload;
88
60
  if (value === void 0) {
@@ -103,42 +75,35 @@ function mediaEditorReducer(state, action) {
103
75
  }
104
76
  };
105
77
  }
106
- case "RESTORE_SNAPSHOT": return action.payload;
107
- case "VIEWPORT_ADJUST_CROP_RECT": {
108
- const nextCropper = (0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, {
109
- type: "SET_CROP_RECT",
110
- payload: action.payload
111
- });
112
- if (nextCropper === state.cropper) return state;
113
- return {
114
- ...state,
115
- cropper: nextCropper
116
- };
78
+ case "RESET": {
79
+ const next = buildInitialMediaEditorState((0, _wordpress_image_editor.createImageEditorState)({ image: state.imageEditor.image }));
80
+ return areMediaEditorStatesEqual(state, next) ? state : next;
117
81
  }
82
+ case "RESTORE_SNAPSHOT": return action.payload;
118
83
  }
119
84
  }
120
85
  /**
121
- * Value-equality check for two composite states. Used by the history
122
- * machinery to dedup snapshots when an action turned out to be a no-op.
86
+ * Value-equality check for two media editor states. The history uses it
87
+ * to skip snapshots when an action turned out to be a no-op.
123
88
  *
124
- * @param a First composite state.
125
- * @param b Second composite state.
89
+ * @param a First state.
90
+ * @param b Second state.
126
91
  * @return Whether `a` and `b` are value-equal across all slices.
127
92
  */
128
93
  function areMediaEditorStatesEqual(a, b) {
129
94
  if (a === b) return true;
130
- return (0, ___image_editor_core_index_ts.areCropperStatesEqual)(a.cropper, b.cropper) && a.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue && (0, fast_deep_equal_es6_index_js.default)(a.edits, b.edits);
95
+ return (0, _wordpress_image_editor.areImageEditorStatesEqual)(a.imageEditor, b.imageEditor) && a.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue && (0, fast_deep_equal_es6_index_js.default)(a.edits, b.edits);
131
96
  }
132
97
  /**
133
- * Build the composite state a session starts from: the given cropper
134
- * slice, default crop options, and no edits.
98
+ * Build the state a session starts from: the given image editor state,
99
+ * default crop options, and no edits.
135
100
  *
136
- * @param cropper The cropper slice.
137
- * @return Composite initial state.
101
+ * @param imageEditor The image editor state.
102
+ * @return Initial state.
138
103
  */
139
- function buildInitialMediaEditorState(cropper) {
104
+ function buildInitialMediaEditorState(imageEditor) {
140
105
  return {
141
- cropper,
106
+ imageEditor,
142
107
  cropOptions: { ...__types_ts.DEFAULT_CROP_OPTIONS },
143
108
  edits: {}
144
109
  };
@@ -1 +1 @@
1
- {"version":3,"file":"composite-reducer.cjs","names":["cropperReducer","computeInscribedRect","fastDeepEqual","areCropperStatesEqual","DEFAULT_CROP_OPTIONS"],"sources":["../../src/state/composite-reducer.ts"],"sourcesContent":["import fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport type { CropperState } from '../image-editor';\nimport {\n\tcropperReducer,\n\tareCropperStatesEqual,\n\tcomputeInscribedRect,\n} from '../image-editor/core';\nimport {\n\tDEFAULT_CROP_OPTIONS,\n\ttype CropOptionsSlice,\n\ttype MediaEditorAction,\n\ttype MediaEditorState,\n} from './types';\n\n/**\n * Pure composite reducer for the media editor.\n *\n * Delegates `CROPPER`-tagged actions to the framework-agnostic\n * `cropperReducer` and owns first-class transitions for the sidebar\n * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite\n * in one transaction (used by undo/redo).\n *\n * Note: this reducer carries NO history of its own. Snapshots and\n * stacks live in the `useMediaEditorState` hook that wraps it.\n *\n * @param state Current composite state.\n * @param action Action to apply.\n * @return Next composite state.\n */\nexport function mediaEditorReducer(\n\tstate: MediaEditorState,\n\taction: MediaEditorAction\n): MediaEditorState {\n\tswitch ( action.type ) {\n\t\tcase 'CROPPER': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, action.action );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t\tcase 'SET_ASPECT_RATIO_VALUE': {\n\t\t\tconst { presetKey, resolved, visualSize } = action.payload;\n\t\t\t// Atomically: update the preset key AND reshape the\n\t\t\t// cropRect (when the ratio is non-Free and we have a\n\t\t\t// visualSize). One transaction = one undo entry.\n\t\t\tconst shouldReshape =\n\t\t\t\tresolved !== undefined &&\n\t\t\t\tresolved > 0 &&\n\t\t\t\tvisualSize.width > 0 &&\n\t\t\t\tvisualSize.height > 0;\n\t\t\tconst nextCropOptions: CropOptionsSlice = {\n\t\t\t\t...state.cropOptions,\n\t\t\t\taspectRatioValue: presetKey,\n\t\t\t};\n\t\t\tif ( ! shouldReshape ) {\n\t\t\t\tif ( state.cropOptions.aspectRatioValue === presetKey ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\treturn { ...state, cropOptions: nextCropOptions };\n\t\t\t}\n\t\t\tconst newCropRect = computeInscribedRect( resolved, visualSize );\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: newCropRect,\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tcropper: nextCropper,\n\t\t\t\tcropOptions: nextCropOptions,\n\t\t\t};\n\t\t}\n\t\tcase 'RESET': {\n\t\t\tconst next = buildInitialMediaEditorState(\n\t\t\t\tcropperReducer( state.cropper, { type: 'RESET' } )\n\t\t\t);\n\t\t\treturn areMediaEditorStatesEqual( state, next ) ? state : next;\n\t\t}\n\t\tcase 'SET_EDIT': {\n\t\t\tconst { name, value } = action.payload;\n\t\t\tif ( value === undefined ) {\n\t\t\t\tif ( ! Object.hasOwn( state.edits, name ) ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\tconst edits = { ...state.edits };\n\t\t\t\tdelete edits[ name ];\n\t\t\t\treturn { ...state, edits };\n\t\t\t}\n\t\t\tif ( fastDeepEqual( state.edits[ name ], value ) ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, edits: { ...state.edits, [ name ]: value } };\n\t\t}\n\t\tcase 'RESTORE_SNAPSHOT':\n\t\t\treturn action.payload;\n\t\tcase 'VIEWPORT_ADJUST_CROP_RECT': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: action.payload,\n\t\t\t} );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t}\n}\n\n/**\n * Value-equality check for two composite states. Used by the history\n * machinery to dedup snapshots when an action turned out to be a no-op.\n *\n * @param a First composite state.\n * @param b Second composite state.\n * @return Whether `a` and `b` are value-equal across all slices.\n */\nexport function areMediaEditorStatesEqual(\n\ta: MediaEditorState,\n\tb: MediaEditorState\n): boolean {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tareCropperStatesEqual( a.cropper, b.cropper ) &&\n\t\ta.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue &&\n\t\tfastDeepEqual( a.edits, b.edits )\n\t);\n}\n\n/**\n * Build the composite state a session starts from: the given cropper\n * slice, default crop options, and no edits.\n *\n * @param cropper The cropper slice.\n * @return Composite initial state.\n */\nexport function buildInitialMediaEditorState(\n\tcropper: CropperState\n): MediaEditorState {\n\treturn {\n\t\tcropper,\n\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS },\n\t\tedits: {},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,mBACf,OACA,QACmB;CACnB,QAAS,OAAO,MAAhB;EACC,KAAK,WAAW;GACf,MAAM,eAAA,GAAcA,8BAAAA,eAAAA,CAAgB,MAAM,SAAS,OAAO,MAAO;GACjE,IAAK,gBAAgB,MAAM,SAC1B,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,SAAS;GAAY;EACzC;EACA,KAAK,0BAA0B;GAC9B,MAAM,EAAE,WAAW,UAAU,eAAe,OAAO;GAInD,MAAM,gBACL,aAAa,KAAA,KACb,WAAW,KACX,WAAW,QAAQ,KACnB,WAAW,SAAS;GACrB,MAAM,kBAAoC;IACzC,GAAG,MAAM;IACT,kBAAkB;GACnB;GACA,IAAK,CAAE,eAAgB;IACtB,IAAK,MAAM,YAAY,qBAAqB,WAC3C,OAAO;IAER,OAAO;KAAE,GAAG;KAAO,aAAa;IAAgB;GACjD;GACA,MAAM,eAAA,GAAcC,8BAAAA,qBAAAA,CAAsB,UAAU,UAAW;GAC/D,MAAM,eAAA,GAAcD,8BAAAA,eAAAA,CAAgB,MAAM,SAAS;IAClD,MAAM;IACN,SAAS;GACV,CAAE;GACF,OAAO;IACN,GAAG;IACH,SAAS;IACT,aAAa;GACd;EACD;EACA,KAAK,SAAS;GACb,MAAM,OAAO,8BAAA,GACZA,8BAAAA,eAAAA,CAAgB,MAAM,SAAS,EAAE,MAAM,QAAQ,CAAE,CAClD;GACA,OAAO,0BAA2B,OAAO,IAAK,IAAI,QAAQ;EAC3D;EACA,KAAK,YAAY;GAChB,MAAM,EAAE,MAAM,UAAU,OAAO;GAC/B,IAAK,UAAU,KAAA,GAAY;IAC1B,IAAK,CAAE,OAAO,OAAQ,MAAM,OAAO,IAAK,GACvC,OAAO;IAER,MAAM,QAAQ,EAAE,GAAG,MAAM,MAAM;IAC/B,OAAO,MAAO;IACd,OAAO;KAAE,GAAG;KAAO;IAAM;GAC1B;GACA,KAAA,GAAKE,6BAAAA,QAAAA,CAAe,MAAM,MAAO,OAAQ,KAAM,GAC9C,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,OAAO;KAAE,GAAG,MAAM;MAAS,OAAQ;IAAM;GAAE;EAC/D;EACA,KAAK,oBACJ,OAAO,OAAO;EACf,KAAK,6BAA6B;GACjC,MAAM,eAAA,GAAcF,8BAAAA,eAAAA,CAAgB,MAAM,SAAS;IAClD,MAAM;IACN,SAAS,OAAO;GACjB,CAAE;GACF,IAAK,gBAAgB,MAAM,SAC1B,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,SAAS;GAAY;EACzC;CACD;AACD;;;;;;;;;AAUA,SAAgB,0BACf,GACA,GACU;CACV,IAAK,MAAM,GACV,OAAO;CAER,QAAA,GACCG,8BAAAA,sBAAAA,CAAuB,EAAE,SAAS,EAAE,OAAQ,KAC5C,EAAE,YAAY,qBAAqB,EAAE,YAAY,qBAAA,GACjDD,6BAAAA,QAAAA,CAAe,EAAE,OAAO,EAAE,KAAM;AAElC;;;;;;;;AASA,SAAgB,6BACf,SACmB;CACnB,OAAO;EACN;EACA,aAAa,EAAE,GAAGE,WAAAA,qBAAqB;EACvC,OAAO,CAAC;CACT;AACD"}
1
+ {"version":3,"file":"composite-reducer.cjs","names":["fastDeepEqual","createImageEditorState","areImageEditorStatesEqual","DEFAULT_CROP_OPTIONS"],"sources":["../../src/state/composite-reducer.ts"],"sourcesContent":["import fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport {\n\tareImageEditorStatesEqual,\n\tcreateImageEditorState,\n\ttype ImageEditorState,\n} from '@wordpress/image-editor';\nimport {\n\tDEFAULT_CROP_OPTIONS,\n\ttype MediaEditorAction,\n\ttype MediaEditorState,\n} from './types';\n\n/**\n * Pure reducer for the media editor.\n *\n * The image editor works out its own next state (through the controller from\n * `@wordpress/image-editor`) and this reducer stores it. The reducer\n * also owns the sidebar crop options and the named edits.\n *\n * This reducer keeps no history; `useMediaEditorState` does.\n *\n * @param state Current state.\n * @param action Action to apply.\n * @return Next state.\n */\nexport function mediaEditorReducer(\n\tstate: MediaEditorState,\n\taction: MediaEditorAction\n): MediaEditorState {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IMAGE_EDITOR':\n\t\t\treturn action.payload === state.imageEditor\n\t\t\t\t? state\n\t\t\t\t: { ...state, imageEditor: action.payload };\n\t\tcase 'SET_ASPECT_RATIO_VALUE':\n\t\t\treturn state.cropOptions.aspectRatioValue === action.payload\n\t\t\t\t? state\n\t\t\t\t: {\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\tcropOptions: {\n\t\t\t\t\t\t\t...state.cropOptions,\n\t\t\t\t\t\t\taspectRatioValue: action.payload,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\tcase 'SET_EDIT': {\n\t\t\tconst { name, value } = action.payload;\n\t\t\tif ( value === undefined ) {\n\t\t\t\tif ( ! Object.hasOwn( state.edits, name ) ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\tconst edits = { ...state.edits };\n\t\t\t\tdelete edits[ name ];\n\t\t\t\treturn { ...state, edits };\n\t\t\t}\n\t\t\tif ( fastDeepEqual( state.edits[ name ], value ) ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, edits: { ...state.edits, [ name ]: value } };\n\t\t}\n\t\tcase 'RESET': {\n\t\t\tconst next = buildInitialMediaEditorState(\n\t\t\t\tcreateImageEditorState( { image: state.imageEditor.image } )\n\t\t\t);\n\t\t\treturn areMediaEditorStatesEqual( state, next ) ? state : next;\n\t\t}\n\t\tcase 'RESTORE_SNAPSHOT':\n\t\t\treturn action.payload;\n\t}\n}\n\n/**\n * Value-equality check for two media editor states. The history uses it\n * to skip snapshots when an action turned out to be a no-op.\n *\n * @param a First state.\n * @param b Second state.\n * @return Whether `a` and `b` are value-equal across all slices.\n */\nexport function areMediaEditorStatesEqual(\n\ta: MediaEditorState,\n\tb: MediaEditorState\n): boolean {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tareImageEditorStatesEqual( a.imageEditor, b.imageEditor ) &&\n\t\ta.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue &&\n\t\tfastDeepEqual( a.edits, b.edits )\n\t);\n}\n\n/**\n * Build the state a session starts from: the given image editor state,\n * default crop options, and no edits.\n *\n * @param imageEditor The image editor state.\n * @return Initial state.\n */\nexport function buildInitialMediaEditorState(\n\timageEditor: ImageEditorState\n): MediaEditorState {\n\treturn {\n\t\timageEditor,\n\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS },\n\t\tedits: {},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,mBACf,OACA,QACmB;CACnB,QAAS,OAAO,MAAhB;EACC,KAAK,oBACJ,OAAO,OAAO,YAAY,MAAM,cAC7B,QACA;GAAE,GAAG;GAAO,aAAa,OAAO;EAAQ;EAC5C,KAAK,0BACJ,OAAO,MAAM,YAAY,qBAAqB,OAAO,UAClD,QACA;GACA,GAAG;GACH,aAAa;IACZ,GAAG,MAAM;IACT,kBAAkB,OAAO;GAC1B;EACD;EACH,KAAK,YAAY;GAChB,MAAM,EAAE,MAAM,UAAU,OAAO;GAC/B,IAAK,UAAU,KAAA,GAAY;IAC1B,IAAK,CAAE,OAAO,OAAQ,MAAM,OAAO,IAAK,GACvC,OAAO;IAER,MAAM,QAAQ,EAAE,GAAG,MAAM,MAAM;IAC/B,OAAO,MAAO;IACd,OAAO;KAAE,GAAG;KAAO;IAAM;GAC1B;GACA,KAAA,GAAKA,6BAAAA,QAAAA,CAAe,MAAM,MAAO,OAAQ,KAAM,GAC9C,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,OAAO;KAAE,GAAG,MAAM;MAAS,OAAQ;IAAM;GAAE;EAC/D;EACA,KAAK,SAAS;GACb,MAAM,OAAO,8BAAA,GACZC,wBAAAA,uBAAAA,CAAwB,EAAE,OAAO,MAAM,YAAY,MAAM,CAAE,CAC5D;GACA,OAAO,0BAA2B,OAAO,IAAK,IAAI,QAAQ;EAC3D;EACA,KAAK,oBACJ,OAAO,OAAO;CAChB;AACD;;;;;;;;;AAUA,SAAgB,0BACf,GACA,GACU;CACV,IAAK,MAAM,GACV,OAAO;CAER,QAAA,GACCC,wBAAAA,0BAAAA,CAA2B,EAAE,aAAa,EAAE,WAAY,KACxD,EAAE,YAAY,qBAAqB,EAAE,YAAY,qBAAA,GACjDF,6BAAAA,QAAAA,CAAe,EAAE,OAAO,EAAE,KAAM;AAElC;;;;;;;;AASA,SAAgB,6BACf,aACmB;CACnB,OAAO;EACN;EACA,aAAa,EAAE,GAAGG,WAAAA,qBAAqB;EACvC,OAAO,CAAC;CACT;AACD"}
@@ -5,51 +5,12 @@ Object.defineProperties(exports, {
5
5
  });
6
6
  let __use_media_editor_state_ts = require("./use-media-editor-state.cjs");
7
7
  let __media_editor_state_provider_tsx = require("./media-editor-state-provider.cjs");
8
- let __composite_reducer_ts = require("./composite-reducer.cjs");
9
- let __types_ts = require("./types.cjs");
10
- let __aspect_ratio_presets_ts = require("./aspect-ratio-presets.cjs");
11
- Object.defineProperty(exports, "DEFAULT_ASPECT_RATIOS", {
12
- enumerable: true,
13
- get: function() {
14
- return __aspect_ratio_presets_ts.DEFAULT_ASPECT_RATIOS;
15
- }
16
- });
17
- Object.defineProperty(exports, "DEFAULT_CROP_OPTIONS", {
18
- enumerable: true,
19
- get: function() {
20
- return __types_ts.DEFAULT_CROP_OPTIONS;
21
- }
22
- });
23
8
  Object.defineProperty(exports, "MediaEditorStateProvider", {
24
9
  enumerable: true,
25
10
  get: function() {
26
11
  return __media_editor_state_provider_tsx.MediaEditorStateProvider;
27
12
  }
28
13
  });
29
- Object.defineProperty(exports, "areMediaEditorStatesEqual", {
30
- enumerable: true,
31
- get: function() {
32
- return __composite_reducer_ts.areMediaEditorStatesEqual;
33
- }
34
- });
35
- Object.defineProperty(exports, "buildInitialMediaEditorState", {
36
- enumerable: true,
37
- get: function() {
38
- return __composite_reducer_ts.buildInitialMediaEditorState;
39
- }
40
- });
41
- Object.defineProperty(exports, "mediaEditorReducer", {
42
- enumerable: true,
43
- get: function() {
44
- return __composite_reducer_ts.mediaEditorReducer;
45
- }
46
- });
47
- Object.defineProperty(exports, "resolveAspectRatio", {
48
- enumerable: true,
49
- get: function() {
50
- return __use_media_editor_state_ts.resolveAspectRatio;
51
- }
52
- });
53
14
  Object.defineProperty(exports, "useMediaEditor", {
54
15
  enumerable: true,
55
16
  get: function() {
@@ -5,8 +5,7 @@ Object.defineProperties(exports, {
5
5
  });
6
6
  // packages/media-editor/src/state/types.ts
7
7
  /**
8
- * Default values for the crop-options slice. Mirrors the initial state
9
- * used by the sidebar before the user has touched anything.
8
+ * The crop options a session starts from.
10
9
  */
11
10
  const DEFAULT_CROP_OPTIONS = { aspectRatioValue: "0" };
12
11
  exports.DEFAULT_CROP_OPTIONS = DEFAULT_CROP_OPTIONS;
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../src/state/types.ts"],"sourcesContent":["import type { CropperState, NormalizedRect, Size } from '../image-editor';\nimport type { CropperAction } from '../image-editor/core';\n\n/**\n * Sidebar control state for the cropper. Lives in the composite store\n * so it participates in the same undo history as cropper geometry.\n */\nexport interface CropOptionsSlice {\n\t/**\n\t * Selected aspect-ratio preset as a string (round-trippable through\n\t * `<SelectControl>`). `'0'` = Free, `'-1'` = Original, any positive\n\t * decimal = fixed ratio.\n\t */\n\taspectRatioValue: string;\n}\n\n/**\n * Default values for the crop-options slice. Mirrors the initial state\n * used by the sidebar before the user has touched anything.\n */\nexport const DEFAULT_CROP_OPTIONS: CropOptionsSlice = {\n\taspectRatioValue: '0',\n};\n\n/**\n * A value an edit can hold: plain data only, because the session\n * compares values by content to tell a real change from a no-op.\n * Anything else, such as a `Blob`, would compare equal to any other\n * and the change would be dropped — keep bytes behind a URL instead.\n *\n * Objects must satisfy the index signature, so type a value with a\n * `type` alias rather than an `interface`.\n */\nexport type EditValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| EditValue[]\n\t| { [ key: string ]: EditValue };\n\n/**\n * Named edits other than crop, keyed by edit name (for example\n * `my-plugin/vignette`). An edit that is not present means \"no edit\".\n */\nexport type EditsSlice = Record< string, EditValue >;\n\n/**\n * The full composite state for the media editor — cropper geometry,\n * the sidebar control slice, and named edits.\n *\n * Every undo/redo snapshot is a full `MediaEditorState`. Slices stay\n * referentially equal across actions that don't touch them.\n */\nexport interface MediaEditorState {\n\tcropper: CropperState;\n\tcropOptions: CropOptionsSlice;\n\tedits: EditsSlice;\n}\n\n/**\n * Composite reducer action union.\n *\n * Cropper geometry actions are wrapped in a `CROPPER` envelope and\n * delegated to the pure `cropperReducer`. Sidebar and history\n * concerns are first-class actions on this reducer.\n */\nexport type MediaEditorAction =\n\t/**\n\t * Delegate to the underlying cropper reducer. Used for every\n\t * geometry transition (pan / zoom / rotation / flip / cropRect /\n\t * settle / etc.).\n\t */\n\t| {\n\t\t\ttype: 'CROPPER';\n\t\t\taction: CropperAction;\n\t }\n\t/**\n\t * Set the aspect-ratio preset. Atomically updates the preset key\n\t * and the cropRect (computed from the resolved ratio and the\n\t * current visualSize). One transaction = one undo entry.\n\t */\n\t| {\n\t\t\ttype: 'SET_ASPECT_RATIO_VALUE';\n\t\t\tpayload: {\n\t\t\t\t/** Preset key as it appears in the dropdown. */\n\t\t\t\tpresetKey: string;\n\t\t\t\t/**\n\t\t\t\t * Resolved width/height ratio. `undefined` = Free\n\t\t\t\t * (no lock; cropRect stays where it is).\n\t\t\t\t */\n\t\t\t\tresolved: number | undefined;\n\t\t\t\t/**\n\t\t\t\t * Rendered image size used to compute the inscribed\n\t\t\t\t * rect. Caller supplies it because the reducer is\n\t\t\t\t * framework-agnostic and has no DOM access.\n\t\t\t\t */\n\t\t\t\tvisualSize: Size;\n\t\t\t};\n\t }\n\t/**\n\t * Put every slice back to its starting state, keeping the image:\n\t * default geometry, default crop options, no edits. One action,\n\t * so one undo entry.\n\t */\n\t| { type: 'RESET' }\n\t/** Set a named edit, or remove it when `value` is `undefined`. */\n\t| {\n\t\t\ttype: 'SET_EDIT';\n\t\t\tpayload: { name: string; value: EditValue | undefined };\n\t }\n\t/**\n\t * Replace the entire composite state with `payload`. Used by\n\t * undo/redo to restore a full snapshot atomically.\n\t */\n\t| { type: 'RESTORE_SNAPSHOT'; payload: MediaEditorState }\n\t/**\n\t * Adjust the cropper's cropRect in response to a viewport change\n\t * (e.g., window resize). Behaviorally identical to a `CROPPER\n\t * SET_CROP_RECT` dispatch, but tagged so the hook layer can skip\n\t * history recording — viewport reshapes aren't editor actions.\n\t */\n\t| {\n\t\t\ttype: 'VIEWPORT_ADJUST_CROP_RECT';\n\t\t\tpayload: NormalizedRect;\n\t };\n"],"mappings":";;;;;;;;;;AAoBA,MAAa,uBAAyC,EACrD,kBAAkB,IACnB"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/state/types.ts"],"sourcesContent":["import type { ImageEditorState } from '@wordpress/image-editor';\n\n/**\n * Sidebar control state for the image editor, kept in the same undo history\n * as the crop.\n */\nexport interface CropOptionsSlice {\n\t/**\n\t * Selected aspect-ratio preset as a string (round-trippable through\n\t * `<SelectControl>`). `'0'` = Free, `'-1'` = Original, any positive\n\t * decimal = fixed ratio. The image editor holds the resolved ratio itself.\n\t */\n\taspectRatioValue: string;\n}\n\n/**\n * The crop options a session starts from.\n */\nexport const DEFAULT_CROP_OPTIONS: CropOptionsSlice = {\n\taspectRatioValue: '0',\n};\n\n/**\n * A value an edit can hold: plain data only, because the session\n * compares values by content to tell a real change from a no-op.\n * Anything else, such as a `Blob`, would compare equal to any other\n * and the change would be dropped — keep bytes behind a URL instead.\n *\n * Objects must satisfy the index signature, so type a value with a\n * `type` alias rather than an `interface`.\n */\nexport type EditValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| EditValue[]\n\t| { [ key: string ]: EditValue };\n\n/**\n * Named edits other than crop, keyed by edit name (for example\n * `my-plugin/vignette`). An edit that is not present means \"no edit\".\n */\nexport type EditsSlice = Record< string, EditValue >;\n\n/**\n * The full state of the media editor: the image editor's state, the sidebar\n * crop options and named edits.\n *\n * Every undo/redo snapshot is a full `MediaEditorState`. Slices stay\n * referentially equal across actions that don't touch them.\n */\nexport interface MediaEditorState {\n\timageEditor: ImageEditorState;\n\tcropOptions: CropOptionsSlice;\n\tedits: EditsSlice;\n}\n\n/** Actions the media editor reducer handles. */\nexport type MediaEditorAction =\n\t/** Replace the image editor's state with the next one it reports. */\n\t| { type: 'SET_IMAGE_EDITOR'; payload: ImageEditorState }\n\t/** Set the aspect-ratio preset the dropdown shows. */\n\t| { type: 'SET_ASPECT_RATIO_VALUE'; payload: string }\n\t/** Set a named edit, or remove it when `value` is `undefined`. */\n\t| {\n\t\t\ttype: 'SET_EDIT';\n\t\t\tpayload: { name: string; value: EditValue | undefined };\n\t }\n\t/**\n\t * Put every slice back to its starting state, keeping the image. One\n\t * action, so one undo entry.\n\t */\n\t| { type: 'RESET' }\n\t/** Replace the whole state with a snapshot (undo/redo). */\n\t| { type: 'RESTORE_SNAPSHOT'; payload: MediaEditorState };\n"],"mappings":";;;;;;;;;AAkBA,MAAa,uBAAyC,EACrD,kBAAkB,IACnB"}
@@ -4,73 +4,64 @@ Object.defineProperties(exports, {
4
4
  [Symbol.toStringTag]: { value: "Module" }
5
5
  });
6
6
  let _wordpress_element = require("@wordpress/element");
7
- let ___image_editor_index_ts = require("../image-editor/index.cjs");
8
- let ___image_editor_core_index_ts = require("../image-editor/core/index.cjs");
9
- let ___image_editor_react_hooks_index_ts = require("../image-editor/react/hooks/index.cjs");
7
+ let _wordpress_image_editor = require("@wordpress/image-editor");
8
+ let __aspect_ratio_presets_ts = require("./aspect-ratio-presets.cjs");
10
9
  let __composite_reducer_ts = require("./composite-reducer.cjs");
11
10
  // packages/media-editor/src/state/use-media-editor-state.ts
12
11
  /**
13
12
  * Resolve an aspect-ratio preset value (the string the dropdown
14
- * round-trips) into a numeric width/height ratio for the cropper.
13
+ * round-trips) into a numeric width/height ratio for the image editor.
15
14
  *
16
15
  * - `'0'` → `undefined` (Free; no lock)
17
16
  * - `'-1'` (Original) → image's natural width / height, or `undefined`
18
17
  * if no image is loaded.
19
18
  * - Any positive decimal → the parsed number.
20
19
  *
21
- * Centralizing here means the dropdown, the action dispatcher, and
22
- * the test harness all resolve the same way.
23
- *
24
- * @param presetKey Preset value from the dropdown.
25
- * @param cropperImage The cropper's loaded image, or `null`.
20
+ * @param presetKey Preset value from the dropdown.
21
+ * @param image The image editor's loaded image, or `null`.
26
22
  * @return The resolved ratio, or `undefined` for Free / unresolvable.
27
23
  */
28
- function resolveAspectRatio(presetKey, cropperImage) {
24
+ function resolveAspectRatio(presetKey, image) {
29
25
  const num = parseFloat(presetKey);
30
26
  if (num === 0 || Number.isNaN(num)) return;
31
- if (num === ___image_editor_index_ts.ORIGINAL_ASPECT_RATIO) {
32
- if (cropperImage && cropperImage.naturalWidth > 0 && cropperImage.naturalHeight > 0) return cropperImage.naturalWidth / cropperImage.naturalHeight;
27
+ if (num === __aspect_ratio_presets_ts.ORIGINAL_ASPECT_RATIO) {
28
+ if (image && image.naturalWidth > 0 && image.naturalHeight > 0) return image.naturalWidth / image.naturalHeight;
33
29
  return;
34
30
  }
35
31
  if (num > 0) return num;
36
32
  }
37
- function areCropperImagesEqual(a, b) {
33
+ function areImagesEqual(a, b) {
38
34
  return a?.src === b?.src && a?.naturalWidth === b?.naturalWidth && a?.naturalHeight === b?.naturalHeight;
39
35
  }
40
36
  /**
41
37
  * The media editor session.
42
38
  *
43
- * Owns the only undo/redo history for the editor. Cropper geometry
44
- * actions, sidebar cropOptions actions and named edits flow through
45
- * the same reducer and the same history stack.
39
+ * Owns the only undo/redo history for the editor. The image editor's state,
40
+ * the sidebar crop options and named edits are slices of one state, so
41
+ * one history stack covers them all. The image editor works out its own
42
+ * changes and reports each next state through `onChange`.
46
43
  *
47
44
  * History semantics:
48
- * - Each action's pre-state is pushed to the undo stack before the
49
- * action commits, unless a gesture is open or the action is a
50
- * no-op (post-state value-equal to pre-state).
51
- * - During a gesture (`beginGesture` → `endGesture`) all mutations
52
- * coalesce: only the pre-gesture snapshot is pushed, at gesture
53
- * end. Any pending gesture is flushed on undo/redo.
54
- * - Viewport-driven cropRect reshapes (window resize) use a
55
- * dedicated non-recording dispatch path so they never produce
56
- * undo entries.
45
+ * - Each change pushes its pre-state to the undo stack, unless a
46
+ * gesture is open or the change is a no-op (post-state value-equal
47
+ * to pre-state).
48
+ * - During a gesture (`beginGesture` → `endGesture`) changes coalesce:
49
+ * only the pre-gesture snapshot is pushed, at gesture end. Undo and
50
+ * redo close an open gesture first.
51
+ * - Changes the image editor marks as not edits (an image loading, a refit
52
+ * after a window resize) are never recorded.
57
53
  *
58
- * `isDirty` tracks the full editor session, including undoable UI
59
- * state. Use `hasOutputEdits` when deciding whether the image output
60
- * needs saving.
54
+ * `isDirty` tracks the full session, including undoable UI state. Use
55
+ * `hasOutputEdits` when deciding whether the image output needs saving.
61
56
  *
62
57
  * The session starts empty. Call `setSourceImage` to load an image.
63
58
  *
64
59
  * @return The media editor session.
65
60
  */
66
61
  function useMediaEditorState() {
67
- const [state, dispatch] = (0, _wordpress_element.useReducer)(__composite_reducer_ts.mediaEditorReducer, null, () => (0, __composite_reducer_ts.buildInitialMediaEditorState)({ ...___image_editor_core_index_ts.DEFAULT_STATE }));
62
+ const [state, dispatch] = (0, _wordpress_element.useReducer)(__composite_reducer_ts.mediaEditorReducer, null, () => (0, __composite_reducer_ts.buildInitialMediaEditorState)((0, _wordpress_image_editor.createImageEditorState)()));
68
63
  const [initialBaseline, setInitialBaseline] = (0, _wordpress_element.useState)(() => state);
69
64
  const stateRef = (0, _wordpress_element.useRef)(state);
70
- const visualSizeRef = (0, _wordpress_element.useRef)({
71
- width: 0,
72
- height: 0
73
- });
74
65
  const historyRef = (0, _wordpress_element.useRef)([]);
75
66
  const redoStackRef = (0, _wordpress_element.useRef)([]);
76
67
  const [hasUndo, setHasUndo] = (0, _wordpress_element.useState)(false);
@@ -88,12 +79,10 @@ function useMediaEditorState() {
88
79
  const dispatchWithHistory = (0, _wordpress_element.useCallback)((action, recordHistory = true) => {
89
80
  const preState = stateRef.current;
90
81
  const postState = (0, __composite_reducer_ts.mediaEditorReducer)(preState, action);
91
- if (recordHistory) {
92
- if (!(0, __composite_reducer_ts.areMediaEditorStatesEqual)(preState, postState)) {
93
- if (isGestureOpenRef.current) {
94
- if (gestureSnapshotRef.current === null) gestureSnapshotRef.current = preState;
95
- } else pushSnapshot(preState);
96
- }
82
+ if (recordHistory && !(0, __composite_reducer_ts.areMediaEditorStatesEqual)(preState, postState)) {
83
+ if (isGestureOpenRef.current) {
84
+ if (gestureSnapshotRef.current === null) gestureSnapshotRef.current = preState;
85
+ } else pushSnapshot(preState);
97
86
  }
98
87
  stateRef.current = postState;
99
88
  dispatch(action);
@@ -109,19 +98,18 @@ function useMediaEditorState() {
109
98
  gestureSnapshotRef.current = null;
110
99
  isGestureOpenRef.current = false;
111
100
  }, [pushSnapshot]);
112
- const dispatchCropperAction = (0, _wordpress_element.useCallback)((action) => {
113
- dispatchWithHistory({
114
- type: "CROPPER",
115
- action
116
- });
117
- }, [dispatchWithHistory]);
118
- const cropperSetters = (0, _wordpress_element.useMemo)(() => (0, ___image_editor_react_hooks_index_ts.buildCropperSetters)(dispatchCropperAction, () => stateRef.current.cropper), [dispatchCropperAction]);
101
+ const asOneUndoEntry = (0, _wordpress_element.useCallback)((run) => {
102
+ if (isGestureOpenRef.current) {
103
+ run();
104
+ return;
105
+ }
106
+ beginGesture();
107
+ run();
108
+ endGesture();
109
+ }, [beginGesture, endGesture]);
119
110
  const setSourceImage = (0, _wordpress_element.useCallback)((image) => {
120
- if (areCropperImagesEqual(stateRef.current.cropper.image, image)) return;
121
- const next = (0, __composite_reducer_ts.buildInitialMediaEditorState)((0, ___image_editor_core_index_ts.enforceContainment)({
122
- ...___image_editor_core_index_ts.DEFAULT_STATE,
123
- image
124
- }));
111
+ if (areImagesEqual(stateRef.current.imageEditor.image, image)) return;
112
+ const next = (0, __composite_reducer_ts.buildInitialMediaEditorState)((0, _wordpress_image_editor.createImageEditorState)({ image }));
125
113
  stateRef.current = next;
126
114
  dispatch({
127
115
  type: "RESTORE_SNAPSHOT",
@@ -135,26 +123,33 @@ function useMediaEditorState() {
135
123
  setHasUndo(false);
136
124
  setHasRedo(false);
137
125
  }, []);
138
- const resetCropper = (0, _wordpress_element.useCallback)((resetState) => {
126
+ const handleImageEditorChange = (0, _wordpress_element.useCallback)((nextState, { isEdit }) => {
127
+ if (!areImagesEqual(stateRef.current.imageEditor.image, nextState.image)) {
128
+ setSourceImage(nextState.image);
129
+ return;
130
+ }
139
131
  dispatchWithHistory({
140
- type: "CROPPER",
141
- action: {
142
- type: "RESET",
143
- payload: resetState
144
- }
145
- });
146
- }, [dispatchWithHistory]);
132
+ type: "SET_IMAGE_EDITOR",
133
+ payload: nextState
134
+ }, isEdit);
135
+ }, [dispatchWithHistory, setSourceImage]);
136
+ const imageEditorController = (0, _wordpress_image_editor.useImageEditor)({
137
+ state: state.imageEditor,
138
+ onChange: handleImageEditorChange
139
+ });
147
140
  const setAspectRatioValue = (0, _wordpress_element.useCallback)((presetKey) => {
148
- const resolved = resolveAspectRatio(presetKey, stateRef.current.cropper.image);
149
- dispatchWithHistory({
150
- type: "SET_ASPECT_RATIO_VALUE",
151
- payload: {
152
- presetKey,
153
- resolved,
154
- visualSize: visualSizeRef.current
155
- }
141
+ asOneUndoEntry(() => {
142
+ dispatchWithHistory({
143
+ type: "SET_ASPECT_RATIO_VALUE",
144
+ payload: presetKey
145
+ });
146
+ imageEditorController.setAspectRatio(resolveAspectRatio(presetKey, stateRef.current.imageEditor.image));
156
147
  });
157
- }, [dispatchWithHistory]);
148
+ }, [
149
+ asOneUndoEntry,
150
+ dispatchWithHistory,
151
+ imageEditorController
152
+ ]);
158
153
  const reset = (0, _wordpress_element.useCallback)(() => {
159
154
  dispatchWithHistory({ type: "RESET" });
160
155
  }, [dispatchWithHistory]);
@@ -195,42 +190,13 @@ function useMediaEditorState() {
195
190
  payload: next
196
191
  });
197
192
  }, [endGesture]);
198
- const setVisualSize = (0, _wordpress_element.useCallback)((size) => {
199
- visualSizeRef.current = size;
200
- }, []);
201
- const adjustCropRectForViewport = (0, _wordpress_element.useCallback)((rect) => {
202
- dispatchWithHistory({
203
- type: "VIEWPORT_ADJUST_CROP_RECT",
204
- payload: rect
205
- }, false);
206
- }, [dispatchWithHistory]);
193
+ const imageEditor = (0, _wordpress_element.useMemo)(() => ({
194
+ ...imageEditorController,
195
+ setImage: setSourceImage
196
+ }), [imageEditorController, setSourceImage]);
207
197
  const isDirty = !(0, __composite_reducer_ts.areMediaEditorStatesEqual)(state, initialBaseline);
208
- const isCropperDirty = !(0, ___image_editor_core_index_ts.areCropperStatesEqual)(state.cropper, initialBaseline.cropper);
209
- const getCroppedImage = (0, _wordpress_element.useCallback)((mimeType, quality) => {
210
- if (!state.cropper.image) return Promise.reject(/* @__PURE__ */ new Error("No image loaded — call setSourceImage first."));
211
- return (0, ___image_editor_index_ts.exportCroppedImage)(state.cropper.image.src, state.cropper, mimeType, quality);
212
- }, [state.cropper]);
213
- const cropper = (0, _wordpress_element.useMemo)(() => ({
214
- ...cropperSetters,
215
- state: state.cropper,
216
- setImage: setSourceImage,
217
- reset: resetCropper,
218
- isDirty: isCropperDirty,
219
- getCroppedImage,
220
- setVisualSize,
221
- adjustCropRectForViewport
222
- }), [
223
- cropperSetters,
224
- state.cropper,
225
- setSourceImage,
226
- resetCropper,
227
- isCropperDirty,
228
- getCroppedImage,
229
- setVisualSize,
230
- adjustCropRectForViewport
231
- ]);
232
198
  return (0, _wordpress_element.useMemo)(() => ({
233
- cropper,
199
+ imageEditor,
234
200
  cropOptions: state.cropOptions,
235
201
  setAspectRatioValue,
236
202
  edits: state.edits,
@@ -238,7 +204,7 @@ function useMediaEditorState() {
238
204
  setSourceImage,
239
205
  reset,
240
206
  isDirty,
241
- hasOutputEdits: isCropperDirty,
207
+ hasOutputEdits: imageEditor.isDirty,
242
208
  hasUndo,
243
209
  hasRedo,
244
210
  undo,
@@ -246,7 +212,7 @@ function useMediaEditorState() {
246
212
  beginGesture,
247
213
  endGesture
248
214
  }), [
249
- cropper,
215
+ imageEditor,
250
216
  state.cropOptions,
251
217
  setAspectRatioValue,
252
218
  state.edits,
@@ -254,7 +220,6 @@ function useMediaEditorState() {
254
220
  setSourceImage,
255
221
  reset,
256
222
  isDirty,
257
- isCropperDirty,
258
223
  hasUndo,
259
224
  hasRedo,
260
225
  undo,
@@ -263,7 +228,6 @@ function useMediaEditorState() {
263
228
  endGesture
264
229
  ]);
265
230
  }
266
- exports.resolveAspectRatio = resolveAspectRatio;
267
231
  exports.useMediaEditorState = useMediaEditorState;
268
232
 
269
233
  //# sourceMappingURL=use-media-editor-state.cjs.map