@wordpress/media-editor 0.21.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 (432) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/components/media-editor/index.cjs +586 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +42 -57
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -7
  6. package/build/components/media-editor/use-save-media-editor.cjs +131 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +117 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +81 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +61 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +181 -257
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -7
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +120 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/index.cjs +112 -155
  19. package/build/components/media-editor-modal/index.cjs.map +1 -7
  20. package/build/components/media-editor-provider/index.cjs +32 -55
  21. package/build/components/media-editor-provider/index.cjs.map +1 -7
  22. package/build/components/media-form/index.cjs +82 -77
  23. package/build/components/media-form/index.cjs.map +1 -7
  24. package/build/components/media-preview/index.cjs +113 -114
  25. package/build/components/media-preview/index.cjs.map +1 -7
  26. package/build/components/rotation-ruler/index.cjs +181 -188
  27. package/build/components/rotation-ruler/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  29. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  30. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  32. package/build/index.cjs +45 -39
  33. package/build/lock-unlock.cjs +9 -35
  34. package/build/lock-unlock.cjs.map +1 -7
  35. package/build/private-apis.cjs +16 -37
  36. package/build/private-apis.cjs.map +1 -7
  37. package/build/state/aspect-ratio-presets.cjs +59 -0
  38. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  39. package/build/state/composite-reducer.cjs +100 -113
  40. package/build/state/composite-reducer.cjs.map +1 -7
  41. package/build/state/index.cjs +22 -45
  42. package/build/state/media-editor-state-provider.cjs +35 -48
  43. package/build/state/media-editor-state-provider.cjs.map +1 -7
  44. package/build/state/types.cjs +11 -31
  45. package/build/state/types.cjs.map +1 -7
  46. package/build/state/use-media-editor-state.cjs +227 -296
  47. package/build/state/use-media-editor-state.cjs.map +1 -7
  48. package/build/store/actions.cjs +17 -44
  49. package/build/store/actions.cjs.map +1 -7
  50. package/build/store/constants.cjs +8 -29
  51. package/build/store/constants.cjs.map +1 -7
  52. package/build/store/index.cjs +33 -40
  53. package/build/store/index.cjs.map +1 -7
  54. package/build/store/reducer.cjs +28 -50
  55. package/build/store/reducer.cjs.map +1 -7
  56. package/build/store/selectors.cjs +16 -41
  57. package/build/store/selectors.cjs.map +1 -7
  58. package/build/utils/get-media-type.cjs +18 -41
  59. package/build/utils/get-media-type.cjs.map +1 -7
  60. package/build/utils/index.cjs +9 -28
  61. package/build-module/components/media-editor/index.mjs +545 -675
  62. package/build-module/components/media-editor/index.mjs.map +1 -7
  63. package/build-module/components/media-editor/use-crop-options.mjs +37 -32
  64. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  65. package/build-module/components/media-editor/use-save-media-editor.mjs +109 -157
  66. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  67. package/build-module/components/media-editor-canvas/index.mjs +95 -98
  68. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  69. package/build-module/components/media-editor-crop-panel/index.mjs +59 -46
  70. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  71. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -46
  72. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  73. package/build-module/components/media-editor-image-controls/index.mjs +171 -238
  74. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  75. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +113 -137
  76. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  77. package/build-module/components/media-editor-modal/index.mjs +88 -124
  78. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  79. package/build-module/components/media-editor-provider/index.mjs +26 -29
  80. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  81. package/build-module/components/media-form/index.mjs +74 -56
  82. package/build-module/components/media-form/index.mjs.map +1 -7
  83. package/build-module/components/media-preview/index.mjs +105 -90
  84. package/build-module/components/media-preview/index.mjs.map +1 -7
  85. package/build-module/components/rotation-ruler/index.mjs +161 -164
  86. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  87. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  88. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  89. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  90. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  91. package/build-module/index.mjs +3 -10
  92. package/build-module/lock-unlock.mjs +5 -10
  93. package/build-module/lock-unlock.mjs.map +1 -7
  94. package/build-module/private-apis.mjs +8 -9
  95. package/build-module/private-apis.mjs.map +1 -7
  96. package/build-module/state/aspect-ratio-presets.mjs +53 -0
  97. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  98. package/build-module/state/composite-reducer.mjs +80 -91
  99. package/build-module/state/composite-reducer.mjs.map +1 -7
  100. package/build-module/state/index.mjs +3 -26
  101. package/build-module/state/media-editor-state-provider.mjs +29 -24
  102. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  103. package/build-module/state/types.mjs +7 -7
  104. package/build-module/state/types.mjs.map +1 -7
  105. package/build-module/state/use-media-editor-state.mjs +223 -288
  106. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  107. package/build-module/store/actions.mjs +12 -19
  108. package/build-module/store/actions.mjs.map +1 -7
  109. package/build-module/store/constants.mjs +4 -5
  110. package/build-module/store/constants.mjs.map +1 -7
  111. package/build-module/store/index.mjs +8 -9
  112. package/build-module/store/index.mjs.map +1 -7
  113. package/build-module/store/reducer.mjs +23 -26
  114. package/build-module/store/reducer.mjs.map +1 -7
  115. package/build-module/store/selectors.mjs +8 -13
  116. package/build-module/store/selectors.mjs.map +1 -7
  117. package/build-module/utils/get-media-type.mjs +14 -17
  118. package/build-module/utils/get-media-type.mjs.map +1 -7
  119. package/build-module/utils/index.mjs +1 -6
  120. package/build-style/style-rtl.css +145 -61
  121. package/build-style/style.css +144 -61
  122. package/build-types/components/media-editor/index.d.ts +20 -2
  123. package/build-types/components/media-editor/index.d.ts.map +1 -1
  124. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  125. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  126. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  127. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  128. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  129. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  130. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  131. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  132. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  133. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  134. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  135. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  136. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  137. package/build-types/components/media-form/index.d.ts.map +1 -1
  138. package/build-types/components/media-preview/index.d.ts.map +1 -1
  139. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  140. package/build-types/state/aspect-ratio-presets.d.ts +24 -0
  141. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  142. package/build-types/state/composite-reducer.d.ts +17 -19
  143. package/build-types/state/composite-reducer.d.ts.map +1 -1
  144. package/build-types/state/index.d.ts +2 -4
  145. package/build-types/state/index.d.ts.map +1 -1
  146. package/build-types/state/types.d.ts +20 -63
  147. package/build-types/state/types.d.ts.map +1 -1
  148. package/build-types/state/use-media-editor-state.d.ts +33 -52
  149. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  150. package/package.json +22 -23
  151. package/src/components/media-editor/index.tsx +355 -167
  152. package/src/components/media-editor/style.scss +19 -0
  153. package/src/components/media-editor/use-crop-options.ts +9 -10
  154. package/src/components/media-editor/use-save-media-editor.ts +48 -10
  155. package/src/components/media-editor-canvas/index.tsx +30 -51
  156. package/src/components/media-editor-canvas/style.scss +6 -6
  157. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  158. package/src/components/media-editor-crop-panel/style.scss +21 -0
  159. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  160. package/src/components/media-editor-image-controls/index.tsx +15 -11
  161. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  162. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  163. package/src/components/media-editor-modal/index.tsx +1 -1
  164. package/src/components/media-editor-modal/style.scss +1 -1
  165. package/src/components/media-form/index.tsx +7 -1
  166. package/src/components/media-preview/index.tsx +65 -23
  167. package/src/components/media-preview/style.scss +16 -2
  168. package/src/components/rotation-ruler/style.scss +9 -5
  169. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  170. package/src/state/README.md +32 -0
  171. package/src/state/aspect-ratio-presets.ts +37 -0
  172. package/src/state/composite-reducer.ts +42 -80
  173. package/src/state/index.ts +2 -17
  174. package/src/state/types.ts +18 -72
  175. package/src/state/use-media-editor-state.ts +155 -238
  176. package/src/style.scss +2 -1
  177. package/build/components/media-editor-modal/build-modifiers.cjs +0 -91
  178. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -7
  179. package/build/image-editor/core/camera.cjs +0 -225
  180. package/build/image-editor/core/camera.cjs.map +0 -7
  181. package/build/image-editor/core/constants.cjs +0 -108
  182. package/build/image-editor/core/constants.cjs.map +0 -7
  183. package/build/image-editor/core/containment.cjs +0 -276
  184. package/build/image-editor/core/containment.cjs.map +0 -7
  185. package/build/image-editor/core/crop-rect.cjs +0 -48
  186. package/build/image-editor/core/crop-rect.cjs.map +0 -7
  187. package/build/image-editor/core/export/canvas-renderer.cjs +0 -151
  188. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -7
  189. package/build/image-editor/core/index.cjs +0 -62
  190. package/build/image-editor/core/index.cjs.map +0 -7
  191. package/build/image-editor/core/interaction-controller.cjs +0 -654
  192. package/build/image-editor/core/interaction-controller.cjs.map +0 -7
  193. package/build/image-editor/core/math/rotation.cjs +0 -41
  194. package/build/image-editor/core/math/rotation.cjs.map +0 -7
  195. package/build/image-editor/core/math/sanitize.cjs +0 -92
  196. package/build/image-editor/core/math/sanitize.cjs.map +0 -7
  197. package/build/image-editor/core/setter-helpers.cjs +0 -64
  198. package/build/image-editor/core/setter-helpers.cjs.map +0 -7
  199. package/build/image-editor/core/source-region.cjs +0 -206
  200. package/build/image-editor/core/source-region.cjs.map +0 -7
  201. package/build/image-editor/core/state.cjs +0 -283
  202. package/build/image-editor/core/state.cjs.map +0 -7
  203. package/build/image-editor/core/stencil-math.cjs +0 -216
  204. package/build/image-editor/core/stencil-math.cjs.map +0 -7
  205. package/build/image-editor/core/transform-style.cjs +0 -52
  206. package/build/image-editor/core/transform-style.cjs.map +0 -7
  207. package/build/image-editor/core/transforms/pipeline.cjs +0 -43
  208. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -7
  209. package/build/image-editor/core/types.cjs +0 -19
  210. package/build/image-editor/core/types.cjs.map +0 -7
  211. package/build/image-editor/core/viewport-state.cjs +0 -50
  212. package/build/image-editor/core/viewport-state.cjs.map +0 -7
  213. package/build/image-editor/index.cjs +0 -67
  214. package/build/image-editor/index.cjs.map +0 -7
  215. package/build/image-editor/react/components/cropper-provider.cjs +0 -50
  216. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -7
  217. package/build/image-editor/react/components/cropper.cjs +0 -722
  218. package/build/image-editor/react/components/cropper.cjs.map +0 -7
  219. package/build/image-editor/react/components/index.cjs +0 -36
  220. package/build/image-editor/react/components/index.cjs.map +0 -7
  221. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -172
  222. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -7
  223. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -62
  224. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -7
  225. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -91
  226. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -7
  227. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -426
  228. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -7
  229. package/build/image-editor/react/components/viewport-provider.cjs +0 -51
  230. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -7
  231. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -71
  232. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -7
  233. package/build/image-editor/react/hooks/index.cjs +0 -34
  234. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  235. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -160
  236. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -7
  237. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  238. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  239. package/build/image-editor/react/hooks/use-interaction.cjs +0 -213
  240. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -7
  241. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -38
  242. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -7
  243. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -51
  244. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -7
  245. package/build/image-editor/react/visually-hidden-style.cjs +0 -41
  246. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -7
  247. package/build/index.cjs.map +0 -7
  248. package/build/state/index.cjs.map +0 -7
  249. package/build/utils/index.cjs.map +0 -7
  250. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -66
  251. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -7
  252. package/build-module/image-editor/core/camera.mjs +0 -198
  253. package/build-module/image-editor/core/camera.mjs.map +0 -7
  254. package/build-module/image-editor/core/constants.mjs +0 -69
  255. package/build-module/image-editor/core/constants.mjs.map +0 -7
  256. package/build-module/image-editor/core/containment.mjs +0 -253
  257. package/build-module/image-editor/core/containment.mjs.map +0 -7
  258. package/build-module/image-editor/core/crop-rect.mjs +0 -23
  259. package/build-module/image-editor/core/crop-rect.mjs.map +0 -7
  260. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -120
  261. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -7
  262. package/build-module/image-editor/core/index.mjs +0 -36
  263. package/build-module/image-editor/core/index.mjs.map +0 -7
  264. package/build-module/image-editor/core/interaction-controller.mjs +0 -635
  265. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -7
  266. package/build-module/image-editor/core/math/rotation.mjs +0 -15
  267. package/build-module/image-editor/core/math/rotation.mjs.map +0 -7
  268. package/build-module/image-editor/core/math/sanitize.mjs +0 -63
  269. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -7
  270. package/build-module/image-editor/core/setter-helpers.mjs +0 -39
  271. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -7
  272. package/build-module/image-editor/core/source-region.mjs +0 -178
  273. package/build-module/image-editor/core/source-region.mjs.map +0 -7
  274. package/build-module/image-editor/core/state.mjs +0 -260
  275. package/build-module/image-editor/core/state.mjs.map +0 -7
  276. package/build-module/image-editor/core/stencil-math.mjs +0 -187
  277. package/build-module/image-editor/core/stencil-math.mjs.map +0 -7
  278. package/build-module/image-editor/core/transform-style.mjs +0 -27
  279. package/build-module/image-editor/core/transform-style.mjs.map +0 -7
  280. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -17
  281. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -7
  282. package/build-module/image-editor/core/types.mjs +0 -1
  283. package/build-module/image-editor/core/types.mjs.map +0 -7
  284. package/build-module/image-editor/core/viewport-state.mjs +0 -24
  285. package/build-module/image-editor/core/viewport-state.mjs.map +0 -7
  286. package/build-module/image-editor/index.mjs +0 -39
  287. package/build-module/image-editor/index.mjs.map +0 -7
  288. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -26
  289. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -7
  290. package/build-module/image-editor/react/components/cropper.mjs +0 -704
  291. package/build-module/image-editor/react/components/cropper.mjs.map +0 -7
  292. package/build-module/image-editor/react/components/index.mjs +0 -9
  293. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  294. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -147
  295. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -7
  296. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -37
  297. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -7
  298. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -66
  299. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -7
  300. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -414
  301. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -7
  302. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -27
  303. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -7
  304. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -46
  305. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -7
  306. package/build-module/image-editor/react/hooks/index.mjs +0 -8
  307. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  308. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -135
  309. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -7
  310. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  311. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  312. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -190
  313. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -7
  314. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -13
  315. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -7
  316. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -29
  317. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -7
  318. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -16
  319. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -7
  320. package/build-module/index.mjs.map +0 -7
  321. package/build-module/state/index.mjs.map +0 -7
  322. package/build-module/utils/index.mjs.map +0 -7
  323. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -80
  324. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  325. package/build-types/image-editor/core/camera.d.ts +0 -128
  326. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  327. package/build-types/image-editor/core/constants.d.ts +0 -99
  328. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  329. package/build-types/image-editor/core/containment.d.ts +0 -72
  330. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  331. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  332. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  333. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  334. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  335. package/build-types/image-editor/core/index.d.ts +0 -10
  336. package/build-types/image-editor/core/index.d.ts.map +0 -1
  337. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  338. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  339. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  340. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  341. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  342. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  343. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  344. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  345. package/build-types/image-editor/core/source-region.d.ts +0 -94
  346. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  347. package/build-types/image-editor/core/state.d.ts +0 -51
  348. package/build-types/image-editor/core/state.d.ts.map +0 -1
  349. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  350. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  351. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  352. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  353. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  354. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  355. package/build-types/image-editor/core/types.d.ts +0 -269
  356. package/build-types/image-editor/core/types.d.ts.map +0 -1
  357. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  358. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  359. package/build-types/image-editor/index.d.ts +0 -16
  360. package/build-types/image-editor/index.d.ts.map +0 -1
  361. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  362. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  363. package/build-types/image-editor/react/components/cropper.d.ts +0 -63
  364. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  365. package/build-types/image-editor/react/components/index.d.ts +0 -4
  366. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  367. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  368. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  369. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  370. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  371. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  372. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  373. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  374. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  375. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  376. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  377. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  378. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  379. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  380. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  381. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  382. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  383. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -55
  384. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
  385. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  386. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  387. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  388. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  389. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  390. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  391. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  392. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  393. package/src/components/media-editor-modal/build-modifiers.ts +0 -161
  394. package/src/image-editor/README.md +0 -61
  395. package/src/image-editor/core/camera.ts +0 -429
  396. package/src/image-editor/core/constants.ts +0 -150
  397. package/src/image-editor/core/containment.ts +0 -469
  398. package/src/image-editor/core/crop-rect.ts +0 -42
  399. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  400. package/src/image-editor/core/index.ts +0 -47
  401. package/src/image-editor/core/interaction-controller.ts +0 -976
  402. package/src/image-editor/core/math/rotation.ts +0 -26
  403. package/src/image-editor/core/math/sanitize.ts +0 -155
  404. package/src/image-editor/core/setter-helpers.ts +0 -63
  405. package/src/image-editor/core/source-region.ts +0 -367
  406. package/src/image-editor/core/state.ts +0 -484
  407. package/src/image-editor/core/stencil-math.ts +0 -379
  408. package/src/image-editor/core/transform-style.ts +0 -56
  409. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  410. package/src/image-editor/core/types.ts +0 -230
  411. package/src/image-editor/core/viewport-state.ts +0 -30
  412. package/src/image-editor/docs/architecture.md +0 -63
  413. package/src/image-editor/docs/recipes.md +0 -184
  414. package/src/image-editor/index.ts +0 -52
  415. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  416. package/src/image-editor/react/components/cropper.scss +0 -259
  417. package/src/image-editor/react/components/cropper.tsx +0 -1116
  418. package/src/image-editor/react/components/index.ts +0 -3
  419. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  420. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  421. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  422. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  423. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  424. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  425. package/src/image-editor/react/hooks/index.ts +0 -4
  426. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  427. package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -197
  428. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  429. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  430. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  431. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  432. package/src/image-editor/style.scss +0 -1
@@ -1,36 +1,34 @@
1
- import { type CropperState } from '../image-editor';
1
+ import { type ImageEditorState } from '@wordpress/image-editor';
2
2
  import { type MediaEditorAction, type MediaEditorState } from './types';
3
3
  /**
4
- * Pure composite reducer for the media editor.
4
+ * Pure reducer for the media editor.
5
5
  *
6
- * Delegates `CROPPER`-tagged actions to the framework-agnostic
7
- * `cropperReducer` and owns first-class transitions for the sidebar
8
- * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite
9
- * in one transaction (used by undo/redo).
6
+ * The image editor works out its own next state (through the controller from
7
+ * `@wordpress/image-editor`) and this reducer stores it. The reducer
8
+ * also owns the sidebar crop options and the named edits.
10
9
  *
11
- * Note: this reducer carries NO history of its own. Snapshots and
12
- * stacks live in the `useMediaEditorState` hook that wraps it.
10
+ * This reducer keeps no history; `useMediaEditorState` does.
13
11
  *
14
- * @param state Current composite state.
12
+ * @param state Current state.
15
13
  * @param action Action to apply.
16
- * @return Next composite state.
14
+ * @return Next state.
17
15
  */
18
16
  export declare function mediaEditorReducer(state: MediaEditorState, action: MediaEditorAction): MediaEditorState;
19
17
  /**
20
- * Value-equality check for two composite states. Used by the history
21
- * machinery to dedup snapshots when an action turned out to be a no-op.
18
+ * Value-equality check for two media editor states. The history uses it
19
+ * to skip snapshots when an action turned out to be a no-op.
22
20
  *
23
- * @param a First composite state.
24
- * @param b Second composite state.
21
+ * @param a First state.
22
+ * @param b Second state.
25
23
  * @return Whether `a` and `b` are value-equal across all slices.
26
24
  */
27
25
  export declare function areMediaEditorStatesEqual(a: MediaEditorState, b: MediaEditorState): boolean;
28
26
  /**
29
- * Build the composite state a session starts from: the given cropper
30
- * slice, default crop options, and no edits.
27
+ * Build the state a session starts from: the given image editor state,
28
+ * default crop options, and no edits.
31
29
  *
32
- * @param cropper The cropper slice.
33
- * @return Composite initial state.
30
+ * @param imageEditor The image editor state.
31
+ * @return Initial state.
34
32
  */
35
- export declare function buildInitialMediaEditorState(cropper: CropperState): MediaEditorState;
33
+ export declare function buildInitialMediaEditorState(imageEditor: ImageEditorState): MediaEditorState;
36
34
  //# sourceMappingURL=composite-reducer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"composite-reducer.d.ts","sourceRoot":"","sources":["../../src/state/composite-reducer.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,YAAY,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,GACvB,gBAAgB,CA0ElB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,EAAE,gBAAgB,EACnB,CAAC,EAAE,gBAAgB,GACjB,OAAO,CAST;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,YAAY,GACnB,gBAAgB,CAMlB"}
1
+ {"version":3,"file":"composite-reducer.d.ts","sourceRoot":"","sources":["../../src/state/composite-reducer.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,GACvB,gBAAgB,CAwClB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,EAAE,gBAAgB,EACnB,CAAC,EAAE,gBAAgB,GACjB,OAAO,CAST;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC3C,WAAW,EAAE,gBAAgB,GAC3B,gBAAgB,CAMlB"}
@@ -1,7 +1,5 @@
1
- export { useMediaEditorState, resolveAspectRatio, } from './use-media-editor-state';
1
+ export { useMediaEditorState } from './use-media-editor-state';
2
2
  export type { MediaEditorSession } from './use-media-editor-state';
3
3
  export { MediaEditorStateProvider, useMediaEditor, } from './media-editor-state-provider';
4
- export { mediaEditorReducer, areMediaEditorStatesEqual, buildInitialMediaEditorState, } from './composite-reducer';
5
- export { DEFAULT_CROP_OPTIONS } from './types';
6
- export type { CropOptionsSlice, EditsSlice, EditValue, MediaEditorState, MediaEditorAction, } from './types';
4
+ export type { EditsSlice, EditValue, MediaEditorState } from './types';
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACN,wBAAwB,EACxB,cAAc,GACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,kBAAkB,EAClB,yBAAyB,EACzB,4BAA4B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,YAAY,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACN,wBAAwB,EACxB,cAAc,GACd,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,19 +1,18 @@
1
- import type { CropperAction, CropperState, NormalizedRect, Size } from '../image-editor';
1
+ import type { ImageEditorState } from '@wordpress/image-editor';
2
2
  /**
3
- * Sidebar control state for the cropper. Lives in the composite store
4
- * so it participates in the same undo history as cropper geometry.
3
+ * Sidebar control state for the image editor, kept in the same undo history
4
+ * as the crop.
5
5
  */
6
6
  export interface CropOptionsSlice {
7
7
  /**
8
8
  * Selected aspect-ratio preset as a string (round-trippable through
9
9
  * `<SelectControl>`). `'0'` = Free, `'-1'` = Original, any positive
10
- * decimal = fixed ratio.
10
+ * decimal = fixed ratio. The image editor holds the resolved ratio itself.
11
11
  */
12
12
  aspectRatioValue: string;
13
13
  }
14
14
  /**
15
- * Default values for the crop-options slice. Mirrors the initial state
16
- * used by the sidebar before the user has touched anything.
15
+ * The crop options a session starts from.
17
16
  */
18
17
  export declare const DEFAULT_CROP_OPTIONS: CropOptionsSlice;
19
18
  /**
@@ -34,64 +33,28 @@ export type EditValue = string | number | boolean | null | EditValue[] | {
34
33
  */
35
34
  export type EditsSlice = Record<string, EditValue>;
36
35
  /**
37
- * The full composite state for the media editor — cropper geometry,
38
- * the sidebar control slice, and named edits.
36
+ * The full state of the media editor: the image editor's state, the sidebar
37
+ * crop options and named edits.
39
38
  *
40
39
  * Every undo/redo snapshot is a full `MediaEditorState`. Slices stay
41
40
  * referentially equal across actions that don't touch them.
42
41
  */
43
42
  export interface MediaEditorState {
44
- cropper: CropperState;
43
+ imageEditor: ImageEditorState;
45
44
  cropOptions: CropOptionsSlice;
46
45
  edits: EditsSlice;
47
46
  }
48
- /**
49
- * Composite reducer action union.
50
- *
51
- * Cropper geometry actions are wrapped in a `CROPPER` envelope and
52
- * delegated to the pure `cropperReducer`. Sidebar and history
53
- * concerns are first-class actions on this reducer.
54
- */
47
+ /** Actions the media editor reducer handles. */
55
48
  export type MediaEditorAction =
56
- /**
57
- * Delegate to the underlying cropper reducer. Used for every
58
- * geometry transition (pan / zoom / rotation / flip / cropRect /
59
- * settle / etc.).
60
- */
49
+ /** Replace the image editor's state with the next one it reports. */
61
50
  {
62
- type: 'CROPPER';
63
- action: CropperAction;
51
+ type: 'SET_IMAGE_EDITOR';
52
+ payload: ImageEditorState;
64
53
  }
65
- /**
66
- * Set the aspect-ratio preset. Atomically updates the preset key
67
- * and the cropRect (computed from the resolved ratio and the
68
- * current visualSize). One transaction = one undo entry.
69
- */
54
+ /** Set the aspect-ratio preset the dropdown shows. */
70
55
  | {
71
56
  type: 'SET_ASPECT_RATIO_VALUE';
72
- payload: {
73
- /** Preset key as it appears in the dropdown. */
74
- presetKey: string;
75
- /**
76
- * Resolved width/height ratio. `undefined` = Free
77
- * (no lock; cropRect stays where it is).
78
- */
79
- resolved: number | undefined;
80
- /**
81
- * Rendered image size used to compute the inscribed
82
- * rect. Caller supplies it because the reducer is
83
- * framework-agnostic and has no DOM access.
84
- */
85
- visualSize: Size;
86
- };
87
- }
88
- /**
89
- * Put every slice back to its starting state, keeping the image:
90
- * default geometry, default crop options, no edits. One action,
91
- * so one undo entry.
92
- */
93
- | {
94
- type: 'RESET';
57
+ payload: string;
95
58
  }
96
59
  /** Set a named edit, or remove it when `value` is `undefined`. */
97
60
  | {
@@ -102,21 +65,15 @@ export type MediaEditorAction =
102
65
  };
103
66
  }
104
67
  /**
105
- * Replace the entire composite state with `payload`. Used by
106
- * undo/redo to restore a full snapshot atomically.
68
+ * Put every slice back to its starting state, keeping the image. One
69
+ * action, so one undo entry.
107
70
  */
108
71
  | {
109
- type: 'RESTORE_SNAPSHOT';
110
- payload: MediaEditorState;
72
+ type: 'RESET';
111
73
  }
112
- /**
113
- * Adjust the cropper's cropRect in response to a viewport change
114
- * (e.g., window resize). Behaviorally identical to a `CROPPER
115
- * SET_CROP_RECT` dispatch, but tagged so the hook layer can skip
116
- * history recording — viewport reshapes aren't editor actions.
117
- */
74
+ /** Replace the whole state with a snapshot (undo/redo). */
118
75
  | {
119
- type: 'VIEWPORT_ADJUST_CROP_RECT';
120
- payload: NormalizedRect;
76
+ type: 'RESTORE_SNAPSHOT';
77
+ payload: MediaEditorState;
121
78
  };
122
79
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/state/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,IAAI,EACJ,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,gBAElC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAE,GAAG,EAAE,MAAM,GAAI,SAAS,CAAA;CAAE,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAE,MAAM,EAAE,SAAS,CAAE,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,YAAY,CAAC;IACtB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,KAAK,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB;AAC5B;;;;GAIG;AACD;IACA,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;CACrB;AACH;;;;GAIG;GACD;IACA,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE;QACR,gDAAgD;QAChD,SAAS,EAAE,MAAM,CAAC;QAClB;;;WAGG;QACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B;;;;WAIG;QACH,UAAU,EAAE,IAAI,CAAC;KACjB,CAAC;CACD;AACH;;;;GAIG;GACD;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE;AACnB,kEAAkE;GAChE;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;KAAE,CAAC;CACvD;AACH;;;GAGG;GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE;AACzD;;;;;GAKG;GACD;IACA,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,cAAc,CAAC;CACvB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/state/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,gBAElC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAE,GAAG,EAAE,MAAM,GAAI,SAAS,CAAA;CAAE,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAE,MAAM,EAAE,SAAS,CAAE,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,KAAK,EAAE,UAAU,CAAC;CAClB;AAED,gDAAgD;AAChD,MAAM,MAAM,iBAAiB;AAC5B,qEAAqE;AACnE;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE;AACzD,sDAAsD;GACpD;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACrD,kEAAkE;GAChE;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;KAAE,CAAC;CACvD;AACH;;;GAGG;GACD;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE;AACnB,2DAA2D;GACzD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC"}
@@ -1,47 +1,30 @@
1
- import { type CropperController, type CropperState } from '../image-editor';
1
+ import { type ImageEditorController, type ImageEditorState } from '@wordpress/image-editor';
2
2
  import type { CropOptionsSlice, EditsSlice, EditValue } from './types';
3
- /**
4
- * Resolve an aspect-ratio preset value (the string the dropdown
5
- * round-trips) into a numeric width/height ratio for the cropper.
6
- *
7
- * - `'0'` → `undefined` (Free; no lock)
8
- * - `'-1'` (Original) → image's natural width / height, or `undefined`
9
- * if no image is loaded.
10
- * - Any positive decimal → the parsed number.
11
- *
12
- * Centralizing here means the dropdown, the action dispatcher, and
13
- * the test harness all resolve the same way.
14
- *
15
- * @param presetKey Preset value from the dropdown.
16
- * @param cropperImage The cropper's loaded image, or `null`.
17
- * @return The resolved ratio, or `undefined` for Free / unresolvable.
18
- */
19
- export declare function resolveAspectRatio(presetKey: string, cropperImage: CropperState['image'] | null): number | undefined;
20
3
  /**
21
4
  * The media editor session exposed by `useMediaEditorState`.
22
5
  *
23
6
  * The session owns what is being edited and how: the source image,
24
7
  * every editing slice, the shared undo/redo history, gesture
25
8
  * boundaries, and whether the edits change the saved image. The
26
- * cropper is one participant in the session — `cropper` is a
27
- * geometry-only controller that a `<Cropper>` takes via its
28
- * `controller` prop — rather than the session itself.
9
+ * image editor is one participant in the session — `imageEditor` is the
10
+ * controller an `<ImageEditorCanvas>` takes via its `controller` prop — rather
11
+ * than the session itself.
29
12
  */
30
13
  export interface MediaEditorSession {
31
14
  /**
32
- * Geometry controller for the cropper slice. Its setters record
33
- * history in the session; its `isDirty` covers geometry only.
34
- * Its `setImage` is `setSourceImage`, so the `<Cropper>` reporting
35
- * a newly loaded image starts a fresh session.
15
+ * Controller for the image editor. Its setters record history in the
16
+ * session; its `isDirty` covers the crop only. Its `setImage` is
17
+ * `setSourceImage`, so the `<ImageEditorCanvas>` reporting a newly loaded
18
+ * image starts a fresh session.
36
19
  */
37
- cropper: CropperController;
20
+ imageEditor: ImageEditorController;
38
21
  /** The cropOptions slice. */
39
22
  cropOptions: CropOptionsSlice;
40
- /** Set the aspect-ratio preset. Atomic with the cropRect reshape. */
23
+ /** Set the aspect-ratio preset and reshape the crop in one undo entry. */
41
24
  setAspectRatioValue: (presetKey: string) => void;
42
25
  /**
43
26
  * Put every slice back to its starting state in one undo entry:
44
- * default geometry and crop options, no edits. Keeps the image.
27
+ * default crop and crop options, no edits. Keeps the image.
45
28
  */
46
29
  reset: () => void;
47
30
  /** The named edits other than crop, keyed by edit name. */
@@ -54,11 +37,10 @@ export interface MediaEditorSession {
54
37
  setEdit: (name: string, value: EditValue | undefined) => void;
55
38
  /**
56
39
  * Replace the image being edited. A different image starts a
57
- * fresh session: default geometry and crop options, a clean
58
- * baseline, and no history. Reporting the same image again is a
59
- * no-op.
40
+ * fresh session: default crop and crop options, a clean baseline,
41
+ * and no history. Reporting the same image again is a no-op.
60
42
  */
61
- setSourceImage: (image: CropperState['image']) => void;
43
+ setSourceImage: (image: ImageEditorState['image']) => void;
62
44
  /**
63
45
  * Whether anything in the session differs from its baseline,
64
46
  * including editor-only state such as the aspect-ratio preset.
@@ -73,14 +55,14 @@ export interface MediaEditorSession {
73
55
  hasUndo: boolean;
74
56
  /** Whether there's a redoable change in history. */
75
57
  hasRedo: boolean;
76
- /** Undo the last committed action across all slices. */
58
+ /** Undo the last committed change across all slices. */
77
59
  undo: () => void;
78
- /** Redo the last undone action across all slices. */
60
+ /** Redo the last undone change across all slices. */
79
61
  redo: () => void;
80
62
  /**
81
- * Open a gesture boundary. During a gesture all state-changing
82
- * actions coalesce into one undo entry — the snapshot taken at
83
- * `beginGesture`. Pair with `endGesture` on pointer-up / key-up.
63
+ * Open a gesture boundary. During a gesture all changes coalesce
64
+ * into one undo entry — the snapshot taken at `beginGesture`. Pair
65
+ * with `endGesture` on pointer-up / key-up.
84
66
  */
85
67
  beginGesture: () => void;
86
68
  /** Close a gesture boundary and commit the pre-gesture snapshot. */
@@ -89,24 +71,23 @@ export interface MediaEditorSession {
89
71
  /**
90
72
  * The media editor session.
91
73
  *
92
- * Owns the only undo/redo history for the editor. Cropper geometry
93
- * actions, sidebar cropOptions actions and named edits flow through
94
- * the same reducer and the same history stack.
74
+ * Owns the only undo/redo history for the editor. The image editor's state,
75
+ * the sidebar crop options and named edits are slices of one state, so
76
+ * one history stack covers them all. The image editor works out its own
77
+ * changes and reports each next state through `onChange`.
95
78
  *
96
79
  * History semantics:
97
- * - Each action's pre-state is pushed to the undo stack before the
98
- * action commits, unless a gesture is open or the action is a
99
- * no-op (post-state value-equal to pre-state).
100
- * - During a gesture (`beginGesture` → `endGesture`) all mutations
101
- * coalesce: only the pre-gesture snapshot is pushed, at gesture
102
- * end. Any pending gesture is flushed on undo/redo.
103
- * - Viewport-driven cropRect reshapes (window resize) use a
104
- * dedicated non-recording dispatch path so they never produce
105
- * undo entries.
80
+ * - Each change pushes its pre-state to the undo stack, unless a
81
+ * gesture is open or the change is a no-op (post-state value-equal
82
+ * to pre-state).
83
+ * - During a gesture (`beginGesture` → `endGesture`) changes coalesce:
84
+ * only the pre-gesture snapshot is pushed, at gesture end. Undo and
85
+ * redo close an open gesture first.
86
+ * - Changes the image editor marks as not edits (an image loading, a refit
87
+ * after a window resize) are never recorded.
106
88
  *
107
- * `isDirty` tracks the full editor session, including undoable UI
108
- * state. Use `hasOutputEdits` when deciding whether the image output
109
- * needs saving.
89
+ * `isDirty` tracks the full session, including undoable UI state. Use
90
+ * `hasOutputEdits` when deciding whether the image output needs saving.
110
91
  *
111
92
  * The session starts empty. Call `setSourceImage` to load an image.
112
93
  *
@@ -1 +1 @@
1
- {"version":3,"file":"use-media-editor-state.d.ts","sourceRoot":"","sources":["../../src/state/use-media-editor-state.ts"],"names":[],"mappings":"AAOA,OAAO,EAQN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAGjB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EAGT,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,CAAE,OAAO,CAAE,GAAG,IAAI,GAC1C,MAAM,GAAG,SAAS,CAmBpB;AAaD;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,OAAO,EAAE,iBAAiB,CAAC;IAC3B,6BAA6B;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,qEAAqE;IACrE,mBAAmB,EAAE,CAAE,SAAS,EAAE,MAAM,KAAM,IAAI,CAAC;IACnD;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,2DAA2D;IAC3D,KAAK,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,KAAM,IAAI,CAAC;IAChE;;;;;OAKG;IACH,cAAc,EAAE,CAAE,KAAK,EAAE,YAAY,CAAE,OAAO,CAAE,KAAM,IAAI,CAAC;IAC3D;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,qDAAqD;IACrD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,oEAAoE;IACpE,UAAU,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,IAAI,kBAAkB,CA0UxD"}
1
+ {"version":3,"file":"use-media-editor-state.d.ts","sourceRoot":"","sources":["../../src/state/use-media-editor-state.ts"],"names":[],"mappings":"AAOA,OAAO,EAGN,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EAGT,MAAM,SAAS,CAAC;AA8CjB;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,WAAW,EAAE,qBAAqB,CAAC;IACnC,6BAA6B;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,0EAA0E;IAC1E,mBAAmB,EAAE,CAAE,SAAS,EAAE,MAAM,KAAM,IAAI,CAAC;IACnD;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,2DAA2D;IAC3D,KAAK,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,KAAM,IAAI,CAAC;IAChE;;;;OAIG;IACH,cAAc,EAAE,CAAE,KAAK,EAAE,gBAAgB,CAAE,OAAO,CAAE,KAAM,IAAI,CAAC;IAC/D;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,qDAAqD;IACrD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,oEAAoE;IACpE,UAAU,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,IAAI,kBAAkB,CAsQxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/media-editor",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Media editor components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -52,34 +52,33 @@
52
52
  "build-module/store/index.mjs"
53
53
  ],
54
54
  "dependencies": {
55
- "@wordpress/a11y": "^5.0.0",
56
- "@wordpress/admin-ui": "^3.0.0",
57
- "@wordpress/api-fetch": "^8.0.0",
58
- "@wordpress/base-styles": "^14.0.0",
59
- "@wordpress/components": "^43.0.0",
60
- "@wordpress/compose": "^9.0.0",
61
- "@wordpress/core-data": "^9.0.0",
62
- "@wordpress/data": "^11.0.0",
63
- "@wordpress/dataviews": "^21.0.0",
64
- "@wordpress/element": "^10.0.0",
65
- "@wordpress/i18n": "^7.0.0",
66
- "@wordpress/icons": "^19.0.0",
67
- "@wordpress/keyboard-shortcuts": "^6.0.0",
68
- "@wordpress/keycodes": "^5.0.0",
69
- "@wordpress/notices": "^6.0.0",
70
- "@wordpress/private-apis": "^3.0.0",
71
- "@wordpress/ui": "^0.25.0",
55
+ "@wordpress/admin-ui": "^3.2.0",
56
+ "@wordpress/api-fetch": "^8.2.0",
57
+ "@wordpress/base-styles": "^15.1.0",
58
+ "@wordpress/components": "^45.0.0",
59
+ "@wordpress/compose": "^9.2.0",
60
+ "@wordpress/core-data": "^9.2.0",
61
+ "@wordpress/data": "^11.2.0",
62
+ "@wordpress/dataviews": "^22.1.0",
63
+ "@wordpress/element": "^10.2.0",
64
+ "@wordpress/i18n": "^7.2.0",
65
+ "@wordpress/icons": "^21.0.0",
66
+ "@wordpress/image-editor": "^0.1.0",
67
+ "@wordpress/keyboard-shortcuts": "^6.2.0",
68
+ "@wordpress/keycodes": "^5.2.0",
69
+ "@wordpress/notices": "^6.2.0",
70
+ "@wordpress/private-apis": "^3.2.0",
71
+ "@wordpress/ui": "^0.27.0",
72
72
  "clsx": "^2.1.1",
73
- "fast-deep-equal": "^3.1.3",
74
- "gl-matrix": "^3.4.3"
73
+ "fast-deep-equal": "^3.1.3"
75
74
  },
76
75
  "devDependencies": {
77
- "@storybook/react-vite": "^10.6.1",
76
+ "@storybook/react-vite": "^10.6.6",
78
77
  "@testing-library/dom": "^10.4.2",
79
78
  "@testing-library/jest-dom": "^7.0.1",
80
79
  "@testing-library/react": "^16.3.3",
81
80
  "@testing-library/user-event": "^14.6.8",
82
- "vitest": "^5.0.3",
81
+ "vitest": "^5.1.0",
83
82
  "vitest-browser-react": "^2.3.0"
84
83
  },
85
84
  "peerDependencies": {
@@ -99,5 +98,5 @@
99
98
  "publishConfig": {
100
99
  "access": "public"
101
100
  },
102
- "gitHead": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
101
+ "gitHead": "1000cdf1dffd5b5e69f75cc4360aa76db8252264"
103
102
  }