@wordpress/media-editor 0.21.0 → 0.22.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 (339) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/components/media-editor/index.cjs +533 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +43 -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 +111 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +122 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +65 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +62 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +183 -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 +119 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/build-modifiers.cjs +107 -88
  19. package/build/components/media-editor-modal/build-modifiers.cjs.map +1 -7
  20. package/build/components/media-editor-modal/index.cjs +112 -155
  21. package/build/components/media-editor-modal/index.cjs.map +1 -7
  22. package/build/components/media-editor-provider/index.cjs +32 -55
  23. package/build/components/media-editor-provider/index.cjs.map +1 -7
  24. package/build/components/media-form/index.cjs +76 -77
  25. package/build/components/media-form/index.cjs.map +1 -7
  26. package/build/components/media-preview/index.cjs +114 -114
  27. package/build/components/media-preview/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/index.cjs +181 -188
  29. package/build/components/rotation-ruler/index.cjs.map +1 -7
  30. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  31. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  32. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  33. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  34. package/build/image-editor/core/camera.cjs +257 -205
  35. package/build/image-editor/core/camera.cjs.map +1 -7
  36. package/build/image-editor/core/constants.cjs +127 -102
  37. package/build/image-editor/core/constants.cjs.map +1 -7
  38. package/build/image-editor/core/containment.cjs +275 -262
  39. package/build/image-editor/core/containment.cjs.map +1 -7
  40. package/build/image-editor/core/crop-rect.cjs +33 -44
  41. package/build/image-editor/core/crop-rect.cjs.map +1 -7
  42. package/build/image-editor/core/export/canvas-renderer.cjs +165 -135
  43. package/build/image-editor/core/export/canvas-renderer.cjs.map +1 -7
  44. package/build/image-editor/core/index.cjs +88 -61
  45. package/build/image-editor/core/interaction-controller.cjs +583 -646
  46. package/build/image-editor/core/interaction-controller.cjs.map +1 -7
  47. package/build/image-editor/core/math/rotation.cjs +26 -35
  48. package/build/image-editor/core/math/rotation.cjs.map +1 -7
  49. package/build/image-editor/core/math/sanitize.cjs +124 -80
  50. package/build/image-editor/core/math/sanitize.cjs.map +1 -7
  51. package/build/image-editor/core/setter-helpers.cjs +57 -60
  52. package/build/image-editor/core/setter-helpers.cjs.map +1 -7
  53. package/build/image-editor/core/source-region.cjs +220 -190
  54. package/build/image-editor/core/source-region.cjs.map +1 -7
  55. package/build/image-editor/core/state.cjs +278 -265
  56. package/build/image-editor/core/state.cjs.map +1 -7
  57. package/build/image-editor/core/stencil-math.cjs +193 -206
  58. package/build/image-editor/core/stencil-math.cjs.map +1 -7
  59. package/build/image-editor/core/transform-style.cjs +39 -48
  60. package/build/image-editor/core/transform-style.cjs.map +1 -7
  61. package/build/image-editor/core/transforms/pipeline.cjs +36 -38
  62. package/build/image-editor/core/transforms/pipeline.cjs.map +1 -7
  63. package/build/image-editor/core/types.cjs +4 -18
  64. package/build/image-editor/core/viewport-state.cjs +31 -45
  65. package/build/image-editor/core/viewport-state.cjs.map +1 -7
  66. package/build/image-editor/index.cjs +65 -64
  67. package/build/image-editor/react/components/cropper-provider.cjs +44 -45
  68. package/build/image-editor/react/components/cropper-provider.cjs.map +1 -7
  69. package/build/image-editor/react/components/cropper.cjs +583 -710
  70. package/build/image-editor/react/components/cropper.cjs.map +1 -7
  71. package/build/image-editor/react/components/index.cjs +22 -33
  72. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +135 -160
  73. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +1 -7
  74. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +28 -59
  75. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +1 -7
  76. package/build/image-editor/react/components/overlays/grid-overlay.cjs +58 -88
  77. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +1 -7
  78. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +361 -420
  79. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +1 -7
  80. package/build/image-editor/react/components/viewport-provider.cjs +21 -46
  81. package/build/image-editor/react/components/viewport-provider.cjs.map +1 -7
  82. package/build/image-editor/react/hooks/build-cropper-setters.cjs +76 -67
  83. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +1 -7
  84. package/build/image-editor/react/hooks/index.cjs +16 -31
  85. package/build/image-editor/react/hooks/use-aria-announcer.cjs +90 -146
  86. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +1 -7
  87. package/build/image-editor/react/hooks/use-cropper-controller.cjs +80 -0
  88. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +1 -0
  89. package/build/image-editor/react/hooks/use-interaction.cjs +179 -205
  90. package/build/image-editor/react/hooks/use-interaction.cjs.map +1 -7
  91. package/build/image-editor/react/hooks/use-transform-style.cjs +20 -34
  92. package/build/image-editor/react/hooks/use-transform-style.cjs.map +1 -7
  93. package/build/image-editor/react/hooks/use-viewport-state.cjs +36 -47
  94. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +1 -7
  95. package/build/image-editor/react/visually-hidden-style.cjs +21 -38
  96. package/build/image-editor/react/visually-hidden-style.cjs.map +1 -7
  97. package/build/index.cjs +45 -39
  98. package/build/lock-unlock.cjs +9 -35
  99. package/build/lock-unlock.cjs.map +1 -7
  100. package/build/private-apis.cjs +16 -37
  101. package/build/private-apis.cjs.map +1 -7
  102. package/build/state/aspect-ratio-presets.cjs +53 -0
  103. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  104. package/build/state/composite-reducer.cjs +134 -112
  105. package/build/state/composite-reducer.cjs.map +1 -7
  106. package/build/state/index.cjs +63 -47
  107. package/build/state/media-editor-state-provider.cjs +35 -48
  108. package/build/state/media-editor-state-provider.cjs.map +1 -7
  109. package/build/state/types.cjs +12 -31
  110. package/build/state/types.cjs.map +1 -7
  111. package/build/state/use-media-editor-state.cjs +261 -294
  112. package/build/state/use-media-editor-state.cjs.map +1 -7
  113. package/build/store/actions.cjs +17 -44
  114. package/build/store/actions.cjs.map +1 -7
  115. package/build/store/constants.cjs +8 -29
  116. package/build/store/constants.cjs.map +1 -7
  117. package/build/store/index.cjs +33 -40
  118. package/build/store/index.cjs.map +1 -7
  119. package/build/store/reducer.cjs +28 -50
  120. package/build/store/reducer.cjs.map +1 -7
  121. package/build/store/selectors.cjs +16 -41
  122. package/build/store/selectors.cjs.map +1 -7
  123. package/build/utils/get-media-type.cjs +18 -41
  124. package/build/utils/get-media-type.cjs.map +1 -7
  125. package/build/utils/index.cjs +9 -28
  126. package/build-module/components/media-editor/index.mjs +490 -673
  127. package/build-module/components/media-editor/index.mjs.map +1 -7
  128. package/build-module/components/media-editor/use-crop-options.mjs +38 -32
  129. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  130. package/build-module/components/media-editor/use-save-media-editor.mjs +89 -157
  131. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  132. package/build-module/components/media-editor-canvas/index.mjs +98 -96
  133. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  134. package/build-module/components/media-editor-crop-panel/index.mjs +43 -46
  135. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  136. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -45
  137. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  138. package/build-module/components/media-editor-image-controls/index.mjs +172 -237
  139. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  140. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +112 -137
  141. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  142. package/build-module/components/media-editor-modal/build-modifiers.mjs +103 -64
  143. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +1 -7
  144. package/build-module/components/media-editor-modal/index.mjs +88 -124
  145. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  146. package/build-module/components/media-editor-provider/index.mjs +26 -29
  147. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  148. package/build-module/components/media-form/index.mjs +68 -56
  149. package/build-module/components/media-form/index.mjs.map +1 -7
  150. package/build-module/components/media-preview/index.mjs +106 -90
  151. package/build-module/components/media-preview/index.mjs.map +1 -7
  152. package/build-module/components/rotation-ruler/index.mjs +161 -164
  153. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  154. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  155. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  156. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  157. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  158. package/build-module/image-editor/core/camera.mjs +245 -178
  159. package/build-module/image-editor/core/camera.mjs.map +1 -7
  160. package/build-module/image-editor/core/constants.mjs +110 -64
  161. package/build-module/image-editor/core/constants.mjs.map +1 -7
  162. package/build-module/image-editor/core/containment.mjs +265 -237
  163. package/build-module/image-editor/core/containment.mjs.map +1 -7
  164. package/build-module/image-editor/core/crop-rect.mjs +29 -20
  165. package/build-module/image-editor/core/crop-rect.mjs.map +1 -7
  166. package/build-module/image-editor/core/export/canvas-renderer.mjs +155 -105
  167. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +1 -7
  168. package/build-module/image-editor/core/index.mjs +5 -34
  169. package/build-module/image-editor/core/interaction-controller.mjs +579 -628
  170. package/build-module/image-editor/core/interaction-controller.mjs.map +1 -7
  171. package/build-module/image-editor/core/math/rotation.mjs +21 -10
  172. package/build-module/image-editor/core/math/rotation.mjs.map +1 -7
  173. package/build-module/image-editor/core/math/sanitize.mjs +116 -52
  174. package/build-module/image-editor/core/math/sanitize.mjs.map +1 -7
  175. package/build-module/image-editor/core/setter-helpers.mjs +52 -35
  176. package/build-module/image-editor/core/setter-helpers.mjs.map +1 -7
  177. package/build-module/image-editor/core/source-region.mjs +210 -160
  178. package/build-module/image-editor/core/source-region.mjs.map +1 -7
  179. package/build-module/image-editor/core/state.mjs +271 -243
  180. package/build-module/image-editor/core/state.mjs.map +1 -7
  181. package/build-module/image-editor/core/stencil-math.mjs +185 -178
  182. package/build-module/image-editor/core/stencil-math.mjs.map +1 -7
  183. package/build-module/image-editor/core/transform-style.mjs +34 -23
  184. package/build-module/image-editor/core/transform-style.mjs.map +1 -7
  185. package/build-module/image-editor/core/transforms/pipeline.mjs +29 -11
  186. package/build-module/image-editor/core/transforms/pipeline.mjs.map +1 -7
  187. package/build-module/image-editor/core/types.mjs +0 -1
  188. package/build-module/image-editor/core/viewport-state.mjs +26 -20
  189. package/build-module/image-editor/core/viewport-state.mjs.map +1 -7
  190. package/build-module/image-editor/index.mjs +3 -38
  191. package/build-module/image-editor/react/components/cropper-provider.mjs +38 -21
  192. package/build-module/image-editor/react/components/cropper-provider.mjs.map +1 -7
  193. package/build-module/image-editor/react/components/cropper.mjs +550 -686
  194. package/build-module/image-editor/react/components/cropper.mjs.map +1 -7
  195. package/build-module/image-editor/react/components/index.mjs +1 -7
  196. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +130 -135
  197. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +1 -7
  198. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +24 -35
  199. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +1 -7
  200. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +54 -64
  201. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +1 -7
  202. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +355 -407
  203. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +1 -7
  204. package/build-module/image-editor/react/components/viewport-provider.mjs +15 -22
  205. package/build-module/image-editor/react/components/viewport-provider.mjs.map +1 -7
  206. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +72 -43
  207. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +1 -7
  208. package/build-module/image-editor/react/hooks/index.mjs +2 -7
  209. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +83 -119
  210. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +1 -7
  211. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +75 -0
  212. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +1 -0
  213. package/build-module/image-editor/react/hooks/use-interaction.mjs +175 -183
  214. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +1 -7
  215. package/build-module/image-editor/react/hooks/use-transform-style.mjs +15 -9
  216. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +1 -7
  217. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +32 -26
  218. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +1 -7
  219. package/build-module/image-editor/react/visually-hidden-style.mjs +17 -14
  220. package/build-module/image-editor/react/visually-hidden-style.mjs.map +1 -7
  221. package/build-module/index.mjs +3 -10
  222. package/build-module/lock-unlock.mjs +5 -10
  223. package/build-module/lock-unlock.mjs.map +1 -7
  224. package/build-module/private-apis.mjs +8 -9
  225. package/build-module/private-apis.mjs.map +1 -7
  226. package/build-module/state/aspect-ratio-presets.mjs +48 -0
  227. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  228. package/build-module/state/composite-reducer.mjs +114 -90
  229. package/build-module/state/composite-reducer.mjs.map +1 -7
  230. package/build-module/state/index.mjs +5 -25
  231. package/build-module/state/media-editor-state-provider.mjs +29 -24
  232. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  233. package/build-module/state/types.mjs +8 -7
  234. package/build-module/state/types.mjs.map +1 -7
  235. package/build-module/state/use-media-editor-state.mjs +256 -286
  236. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  237. package/build-module/store/actions.mjs +12 -19
  238. package/build-module/store/actions.mjs.map +1 -7
  239. package/build-module/store/constants.mjs +4 -5
  240. package/build-module/store/constants.mjs.map +1 -7
  241. package/build-module/store/index.mjs +8 -9
  242. package/build-module/store/index.mjs.map +1 -7
  243. package/build-module/store/reducer.mjs +23 -26
  244. package/build-module/store/reducer.mjs.map +1 -7
  245. package/build-module/store/selectors.mjs +8 -13
  246. package/build-module/store/selectors.mjs.map +1 -7
  247. package/build-module/utils/get-media-type.mjs +14 -17
  248. package/build-module/utils/get-media-type.mjs.map +1 -7
  249. package/build-module/utils/index.mjs +1 -6
  250. package/build-style/style-rtl.css +41 -4
  251. package/build-style/style.css +41 -4
  252. package/build-types/components/media-editor/index.d.ts +4 -0
  253. package/build-types/components/media-editor/index.d.ts.map +1 -1
  254. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  255. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  256. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  257. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  258. package/build-types/components/media-editor-modal/build-modifiers.d.ts +6 -5
  259. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
  260. package/build-types/components/media-preview/index.d.ts.map +1 -1
  261. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  262. package/build-types/image-editor/core/constants.d.ts +0 -1
  263. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  264. package/build-types/image-editor/core/index.d.ts +1 -1
  265. package/build-types/image-editor/core/index.d.ts.map +1 -1
  266. package/build-types/image-editor/core/setter-helpers.d.ts +1 -1
  267. package/build-types/image-editor/core/types.d.ts +1 -1
  268. package/build-types/image-editor/index.d.ts +7 -6
  269. package/build-types/image-editor/index.d.ts.map +1 -1
  270. package/build-types/image-editor/react/components/cropper-provider.d.ts +2 -2
  271. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  272. package/build-types/image-editor/react/components/cropper.d.ts +5 -14
  273. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  274. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +2 -2
  275. package/build-types/image-editor/react/hooks/index.d.ts +2 -2
  276. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  277. package/build-types/image-editor/react/hooks/{use-cropper-reducer.d.ts → use-cropper-controller.d.ts} +12 -12
  278. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +1 -0
  279. package/build-types/state/aspect-ratio-presets.d.ts +7 -0
  280. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  281. package/build-types/state/composite-reducer.d.ts +1 -1
  282. package/build-types/state/composite-reducer.d.ts.map +1 -1
  283. package/build-types/state/index.d.ts +1 -0
  284. package/build-types/state/index.d.ts.map +1 -1
  285. package/build-types/state/types.d.ts +2 -1
  286. package/build-types/state/types.d.ts.map +1 -1
  287. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  288. package/package.json +21 -21
  289. package/src/components/media-editor/index.tsx +215 -162
  290. package/src/components/media-editor/style.scss +19 -0
  291. package/src/components/media-editor/use-crop-options.ts +5 -2
  292. package/src/components/media-editor/use-save-media-editor.ts +2 -6
  293. package/src/components/media-editor-canvas/index.tsx +16 -26
  294. package/src/components/media-editor-image-controls/index.tsx +4 -2
  295. package/src/components/media-editor-modal/build-modifiers.ts +13 -7
  296. package/src/components/media-editor-modal/style.scss +1 -1
  297. package/src/components/media-preview/index.tsx +66 -23
  298. package/src/components/media-preview/style.scss +16 -2
  299. package/src/components/rotation-ruler/style.scss +6 -2
  300. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  301. package/src/image-editor/README.md +8 -8
  302. package/src/image-editor/core/constants.ts +0 -13
  303. package/src/image-editor/core/index.ts +1 -5
  304. package/src/image-editor/core/setter-helpers.ts +1 -1
  305. package/src/image-editor/core/types.ts +1 -1
  306. package/src/image-editor/docs/architecture.md +1 -1
  307. package/src/image-editor/docs/recipes.md +3 -3
  308. package/src/image-editor/index.ts +7 -16
  309. package/src/image-editor/react/components/cropper-provider.tsx +5 -5
  310. package/src/image-editor/react/components/cropper.tsx +19 -27
  311. package/src/image-editor/react/hooks/build-cropper-setters.ts +2 -2
  312. package/src/image-editor/react/hooks/index.ts +2 -2
  313. package/src/image-editor/react/hooks/{use-cropper-reducer.ts → use-cropper-controller.ts} +11 -11
  314. package/src/state/aspect-ratio-presets.ts +18 -0
  315. package/src/state/composite-reducer.ts +2 -2
  316. package/src/state/index.ts +1 -0
  317. package/src/state/types.ts +2 -6
  318. package/src/state/use-media-editor-state.ts +7 -5
  319. package/build/image-editor/core/index.cjs.map +0 -7
  320. package/build/image-editor/core/types.cjs.map +0 -7
  321. package/build/image-editor/index.cjs.map +0 -7
  322. package/build/image-editor/react/components/index.cjs.map +0 -7
  323. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  324. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  325. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  326. package/build/index.cjs.map +0 -7
  327. package/build/state/index.cjs.map +0 -7
  328. package/build/utils/index.cjs.map +0 -7
  329. package/build-module/image-editor/core/index.mjs.map +0 -7
  330. package/build-module/image-editor/core/types.mjs.map +0 -7
  331. package/build-module/image-editor/index.mjs.map +0 -7
  332. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  333. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  334. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  335. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  336. package/build-module/index.mjs.map +0 -7
  337. package/build-module/state/index.mjs.map +0 -7
  338. package/build-module/utils/index.mjs.map +0 -7
  339. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
@@ -1,162 +1,124 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/components/media-editor-keyboard-shortcuts-modal/index.tsx
21
- var media_editor_keyboard_shortcuts_modal_exports = {};
22
- __export(media_editor_keyboard_shortcuts_modal_exports, {
23
- default: () => MediaEditorKeyboardShortcutsModal
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(media_editor_keyboard_shortcuts_modal_exports);
26
- var import_components = require("@wordpress/components");
27
- var import_element = require("@wordpress/element");
28
- var import_i18n = require("@wordpress/i18n");
29
- var import_keycodes = require("@wordpress/keycodes");
30
- var import_jsx_runtime = require("react/jsx-runtime");
31
- var SHORTCUTS = [
32
- {
33
- description: (0, import_i18n.__)("Undo"),
34
- keyCombination: { modifier: "primary", character: "z" }
35
- },
36
- {
37
- description: (0, import_i18n.__)("Redo"),
38
- keyCombination: { modifier: "primaryShift", character: "z" }
39
- },
40
- {
41
- description: (0, import_i18n.__)("Pan"),
42
- keyCombination: {
43
- character: ["↑", "↓", "←", "→"],
44
- ariaLabel: (0, import_i18n.__)("Arrow keys")
45
- }
46
- },
47
- {
48
- description: (0, import_i18n.__)("Zoom in"),
49
- keyCombination: { character: "+" }
50
- },
51
- {
52
- description: (0, import_i18n.__)("Zoom out"),
53
- keyCombination: { character: "-" }
54
- },
55
- {
56
- description: (0, import_i18n.__)("Rotate 90° clockwise"),
57
- keyCombination: { character: "R" }
58
- },
59
- {
60
- description: (0, import_i18n.__)("Rotate 90° counter-clockwise"),
61
- keyCombination: { modifier: "shift", character: "R" }
62
- },
63
- {
64
- description: (0, import_i18n.__)("Flip horizontal"),
65
- keyCombination: { character: "H" }
66
- },
67
- {
68
- description: (0, import_i18n.__)("Flip vertical"),
69
- keyCombination: { character: "V" }
70
- },
71
- {
72
- description: (0, import_i18n.__)("Pan or resize crop (large step)"),
73
- keyCombination: {
74
- modifier: "shift",
75
- character: ["↑", "↓", "←", "→"],
76
- ariaLabel: (0, import_i18n.__)("Shift + Arrow keys")
77
- }
78
- }
6
+ let _wordpress_components = require("@wordpress/components");
7
+ let _wordpress_element = require("@wordpress/element");
8
+ let _wordpress_i18n = require("@wordpress/i18n");
9
+ let _wordpress_keycodes = require("@wordpress/keycodes");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+ // packages/media-editor/src/components/media-editor-keyboard-shortcuts-modal/index.tsx
12
+ const SHORTCUTS = [
13
+ {
14
+ description: (0, _wordpress_i18n.__)("Undo"),
15
+ keyCombination: {
16
+ modifier: "primary",
17
+ character: "z"
18
+ }
19
+ },
20
+ {
21
+ description: (0, _wordpress_i18n.__)("Redo"),
22
+ keyCombination: {
23
+ modifier: "primaryShift",
24
+ character: "z"
25
+ }
26
+ },
27
+ {
28
+ description: (0, _wordpress_i18n.__)("Pan"),
29
+ keyCombination: {
30
+ character: [
31
+ "↑",
32
+ "↓",
33
+ "←",
34
+ "→"
35
+ ],
36
+ ariaLabel: (0, _wordpress_i18n.__)("Arrow keys")
37
+ }
38
+ },
39
+ {
40
+ description: (0, _wordpress_i18n.__)("Zoom in"),
41
+ keyCombination: { character: "+" }
42
+ },
43
+ {
44
+ description: (0, _wordpress_i18n.__)("Zoom out"),
45
+ keyCombination: { character: "-" }
46
+ },
47
+ {
48
+ description: (0, _wordpress_i18n.__)("Rotate 90° clockwise"),
49
+ keyCombination: { character: "R" }
50
+ },
51
+ {
52
+ description: (0, _wordpress_i18n.__)("Rotate 90° counter-clockwise"),
53
+ keyCombination: {
54
+ modifier: "shift",
55
+ character: "R"
56
+ }
57
+ },
58
+ {
59
+ description: (0, _wordpress_i18n.__)("Flip horizontal"),
60
+ keyCombination: { character: "H" }
61
+ },
62
+ {
63
+ description: (0, _wordpress_i18n.__)("Flip vertical"),
64
+ keyCombination: { character: "V" }
65
+ },
66
+ {
67
+ description: (0, _wordpress_i18n.__)("Pan or resize crop (large step)"),
68
+ keyCombination: {
69
+ modifier: "shift",
70
+ character: [
71
+ "↑",
72
+ "↓",
73
+ "←",
74
+ "→"
75
+ ],
76
+ ariaLabel: (0, _wordpress_i18n.__)("Shift + Arrow keys")
77
+ }
78
+ }
79
79
  ];
80
- function KeyCombinationDisplay({
81
- keyCombination
82
- }) {
83
- const { modifier, character, ariaLabel } = keyCombination;
84
- let keys;
85
- if (Array.isArray(character)) {
86
- if (modifier) {
87
- const sample = import_keycodes.displayShortcutList[modifier](character[0]);
88
- keys = [...sample.slice(0, -1), ...character];
89
- } else {
90
- keys = character;
91
- }
92
- } else {
93
- keys = modifier ? import_keycodes.displayShortcutList[modifier](character) : [character];
94
- }
95
- const charString = Array.isArray(character) ? character.join("") : character;
96
- let label;
97
- if (ariaLabel) {
98
- label = ariaLabel;
99
- } else if (modifier) {
100
- label = import_keycodes.shortcutAriaLabel[modifier](charString);
101
- } else {
102
- label = charString;
103
- }
104
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
105
- "kbd",
106
- {
107
- className: "media-editor-keyboard-shortcuts-modal__shortcut-term",
108
- "aria-label": label,
109
- children: keys.map(
110
- (key, index) => key === "+" && modifier ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element.Fragment, { children: key }, index) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
111
- "kbd",
112
- {
113
- className: "media-editor-keyboard-shortcuts-modal__shortcut-key",
114
- children: key
115
- },
116
- index
117
- )
118
- )
119
- }
120
- );
80
+ function KeyCombinationDisplay({ keyCombination }) {
81
+ const { modifier, character, ariaLabel } = keyCombination;
82
+ let keys;
83
+ if (Array.isArray(character)) {
84
+ if (modifier) keys = [..._wordpress_keycodes.displayShortcutList[modifier](character[0]).slice(0, -1), ...character];
85
+ else keys = character;
86
+ } else keys = modifier ? _wordpress_keycodes.displayShortcutList[modifier](character) : [character];
87
+ const charString = Array.isArray(character) ? character.join("") : character;
88
+ let label;
89
+ if (ariaLabel) label = ariaLabel;
90
+ else if (modifier) label = _wordpress_keycodes.shortcutAriaLabel[modifier](charString);
91
+ else label = charString;
92
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
93
+ className: "media-editor-keyboard-shortcuts-modal__shortcut-term",
94
+ "aria-label": label,
95
+ children: keys.map((key, index) => key === "+" && modifier ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_element.Fragment, { children: key }, index) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
96
+ className: "media-editor-keyboard-shortcuts-modal__shortcut-key",
97
+ children: key
98
+ }, index))
99
+ });
121
100
  }
122
- function MediaEditorKeyboardShortcutsModal({
123
- onClose
124
- }) {
125
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
126
- import_components.Modal,
127
- {
128
- className: "media-editor-keyboard-shortcuts-modal",
129
- title: (0, import_i18n.__)("Keyboard shortcuts"),
130
- onRequestClose: onClose,
131
- children: [
132
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "media-editor-keyboard-shortcuts-modal__note", children: (0, import_i18n.__)(
133
- "These shortcuts work when the image editor has focus."
134
- ) }),
135
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
136
- "ul",
137
- {
138
- className: "media-editor-keyboard-shortcuts-modal__shortcut-list",
139
- role: "list",
140
- children: SHORTCUTS.map(({ description, keyCombination }, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
141
- "li",
142
- {
143
- className: "media-editor-keyboard-shortcuts-modal__shortcut",
144
- children: [
145
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "media-editor-keyboard-shortcuts-modal__shortcut-description", children: description }),
146
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
147
- KeyCombinationDisplay,
148
- {
149
- keyCombination
150
- }
151
- )
152
- ]
153
- },
154
- index
155
- ))
156
- }
157
- )
158
- ]
159
- }
160
- );
101
+ function MediaEditorKeyboardShortcutsModal({ onClose }) {
102
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_components.Modal, {
103
+ className: "media-editor-keyboard-shortcuts-modal",
104
+ title: (0, _wordpress_i18n.__)("Keyboard shortcuts"),
105
+ onRequestClose: onClose,
106
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
107
+ className: "media-editor-keyboard-shortcuts-modal__note",
108
+ children: (0, _wordpress_i18n.__)("These shortcuts work when the image editor has focus.")
109
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
110
+ className: "media-editor-keyboard-shortcuts-modal__shortcut-list",
111
+ role: "list",
112
+ children: SHORTCUTS.map(({ description, keyCombination }, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
113
+ className: "media-editor-keyboard-shortcuts-modal__shortcut",
114
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
115
+ className: "media-editor-keyboard-shortcuts-modal__shortcut-description",
116
+ children: description
117
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyCombinationDisplay, { keyCombination })]
118
+ }, index))
119
+ })]
120
+ });
161
121
  }
162
- //# sourceMappingURL=index.cjs.map
122
+ exports.default = MediaEditorKeyboardShortcutsModal;
123
+
124
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/media-editor-keyboard-shortcuts-modal/index.tsx"],
4
- "sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { Fragment } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tdisplayShortcutList,\n\tshortcutAriaLabel,\n\ttype WPKeycodeModifier,\n} from '@wordpress/keycodes';\n\ninterface KeyCombination {\n\t/** Modifier for cross-platform display (e.g. 'primary', 'primaryShift', 'shift'). */\n\tmodifier?: WPKeycodeModifier;\n\t/** The key character(s) to display. Pass an array to render each as its own key. */\n\tcharacter: string | string[];\n\t/** Optional aria-label override (used when character is a symbol). */\n\tariaLabel?: string;\n}\n\ninterface ShortcutEntry {\n\tdescription: string;\n\tkeyCombination: KeyCombination;\n}\n\nconst SHORTCUTS: ShortcutEntry[] = [\n\t{\n\t\tdescription: __( 'Undo' ),\n\t\tkeyCombination: { modifier: 'primary', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Redo' ),\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Pan' ),\n\t\tkeyCombination: {\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t\tariaLabel: __( 'Arrow keys' ),\n\t\t},\n\t},\n\t{\n\t\tdescription: __( 'Zoom in' ),\n\t\tkeyCombination: { character: '+' },\n\t},\n\t{\n\t\tdescription: __( 'Zoom out' ),\n\t\tkeyCombination: { character: '-' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° clockwise' ),\n\t\tkeyCombination: { character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° counter-clockwise' ),\n\t\tkeyCombination: { modifier: 'shift', character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Flip horizontal' ),\n\t\tkeyCombination: { character: 'H' },\n\t},\n\t{\n\t\tdescription: __( 'Flip vertical' ),\n\t\tkeyCombination: { character: 'V' },\n\t},\n\t{\n\t\tdescription: __( 'Pan or resize crop (large step)' ),\n\t\tkeyCombination: {\n\t\t\tmodifier: 'shift',\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t\tariaLabel: __( 'Shift + Arrow keys' ),\n\t\t},\n\t},\n];\n\nfunction KeyCombinationDisplay( {\n\tkeyCombination,\n}: {\n\tkeyCombination: KeyCombination;\n} ) {\n\tconst { modifier, character, ariaLabel } = keyCombination;\n\n\tlet keys: string[];\n\tif ( Array.isArray( character ) ) {\n\t\tif ( modifier ) {\n\t\t\t// Get the modifier prefix (e.g. ['⇧', '+']) from the first char,\n\t\t\t// then replace the last element with all the individual chars.\n\t\t\tconst sample = displayShortcutList[ modifier ]( character[ 0 ] );\n\t\t\tkeys = [ ...sample.slice( 0, -1 ), ...character ];\n\t\t} else {\n\t\t\tkeys = character;\n\t\t}\n\t} else {\n\t\tkeys = modifier\n\t\t\t? displayShortcutList[ modifier ]( character )\n\t\t\t: [ character ];\n\t}\n\n\tconst charString = Array.isArray( character )\n\t\t? character.join( '' )\n\t\t: character;\n\tlet label: string;\n\tif ( ariaLabel ) {\n\t\tlabel = ariaLabel;\n\t} else if ( modifier ) {\n\t\tlabel = shortcutAriaLabel[ modifier ]( charString );\n\t} else {\n\t\tlabel = charString;\n\t}\n\n\treturn (\n\t\t<kbd\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-term\"\n\t\t\taria-label={ label }\n\t\t>\n\t\t\t{ keys.map( ( key, index ) =>\n\t\t\t\tkey === '+' && modifier ? (\n\t\t\t\t\t<Fragment key={ index }>{ key }</Fragment>\n\t\t\t\t) : (\n\t\t\t\t\t<kbd\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-key\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ key }\n\t\t\t\t\t</kbd>\n\t\t\t\t)\n\t\t\t) }\n\t\t</kbd>\n\t);\n}\n\ninterface MediaEditorKeyboardShortcutsModalProps {\n\tonClose: () => void;\n}\n\nexport default function MediaEditorKeyboardShortcutsModal( {\n\tonClose,\n}: MediaEditorKeyboardShortcutsModalProps ) {\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p className=\"media-editor-keyboard-shortcuts-modal__note\">\n\t\t\t\t{ __(\n\t\t\t\t\t'These shortcuts work when the image editor has focus.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */ }\n\t\t\t{ /* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-list\"\n\t\t\t\trole=\"list\"\n\t\t\t>\n\t\t\t\t{ SHORTCUTS.map( ( { description, keyCombination }, index ) => (\n\t\t\t\t\t<li\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"media-editor-keyboard-shortcuts-modal__shortcut-description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<KeyCombinationDisplay\n\t\t\t\t\t\t\tkeyCombination={ keyCombination }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable js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A,QAMA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAK;AAAA,YAEH,oBAAU,IAAK,CAAE,EAAE,aAAa,eAAe,GAAG,UACnD;AAAA,cAAC;AAAA;AAAA,gBAEA,WAAU;AAAA,gBAEV;AAAA,8DAAC,UAAK,WAAU,+DACb,uBACH;AAAA,kBACA;AAAA,oBAAC;AAAA;AAAA,sBACA;AAAA;AAAA,kBACD;AAAA;AAAA;AAAA,cARM;AAAA,YASP,CACC;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAED;AAEF;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.cjs","names":["__","displayShortcutList","shortcutAriaLabel","Fragment","Modal"],"sources":["../../../src/components/media-editor-keyboard-shortcuts-modal/index.tsx"],"sourcesContent":["import { Modal } from '@wordpress/components';\nimport { Fragment } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tdisplayShortcutList,\n\tshortcutAriaLabel,\n\ttype WPKeycodeModifier,\n} from '@wordpress/keycodes';\n\ninterface KeyCombination {\n\t/** Modifier for cross-platform display (e.g. 'primary', 'primaryShift', 'shift'). */\n\tmodifier?: WPKeycodeModifier;\n\t/** The key character(s) to display. Pass an array to render each as its own key. */\n\tcharacter: string | string[];\n\t/** Optional aria-label override (used when character is a symbol). */\n\tariaLabel?: string;\n}\n\ninterface ShortcutEntry {\n\tdescription: string;\n\tkeyCombination: KeyCombination;\n}\n\nconst SHORTCUTS: ShortcutEntry[] = [\n\t{\n\t\tdescription: __( 'Undo' ),\n\t\tkeyCombination: { modifier: 'primary', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Redo' ),\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Pan' ),\n\t\tkeyCombination: {\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t\tariaLabel: __( 'Arrow keys' ),\n\t\t},\n\t},\n\t{\n\t\tdescription: __( 'Zoom in' ),\n\t\tkeyCombination: { character: '+' },\n\t},\n\t{\n\t\tdescription: __( 'Zoom out' ),\n\t\tkeyCombination: { character: '-' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° clockwise' ),\n\t\tkeyCombination: { character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° counter-clockwise' ),\n\t\tkeyCombination: { modifier: 'shift', character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Flip horizontal' ),\n\t\tkeyCombination: { character: 'H' },\n\t},\n\t{\n\t\tdescription: __( 'Flip vertical' ),\n\t\tkeyCombination: { character: 'V' },\n\t},\n\t{\n\t\tdescription: __( 'Pan or resize crop (large step)' ),\n\t\tkeyCombination: {\n\t\t\tmodifier: 'shift',\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t\tariaLabel: __( 'Shift + Arrow keys' ),\n\t\t},\n\t},\n];\n\nfunction KeyCombinationDisplay( {\n\tkeyCombination,\n}: {\n\tkeyCombination: KeyCombination;\n} ) {\n\tconst { modifier, character, ariaLabel } = keyCombination;\n\n\tlet keys: string[];\n\tif ( Array.isArray( character ) ) {\n\t\tif ( modifier ) {\n\t\t\t// Get the modifier prefix (e.g. ['⇧', '+']) from the first char,\n\t\t\t// then replace the last element with all the individual chars.\n\t\t\tconst sample = displayShortcutList[ modifier ]( character[ 0 ] );\n\t\t\tkeys = [ ...sample.slice( 0, -1 ), ...character ];\n\t\t} else {\n\t\t\tkeys = character;\n\t\t}\n\t} else {\n\t\tkeys = modifier\n\t\t\t? displayShortcutList[ modifier ]( character )\n\t\t\t: [ character ];\n\t}\n\n\tconst charString = Array.isArray( character )\n\t\t? character.join( '' )\n\t\t: character;\n\tlet label: string;\n\tif ( ariaLabel ) {\n\t\tlabel = ariaLabel;\n\t} else if ( modifier ) {\n\t\tlabel = shortcutAriaLabel[ modifier ]( charString );\n\t} else {\n\t\tlabel = charString;\n\t}\n\n\treturn (\n\t\t<kbd\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-term\"\n\t\t\taria-label={ label }\n\t\t>\n\t\t\t{ keys.map( ( key, index ) =>\n\t\t\t\tkey === '+' && modifier ? (\n\t\t\t\t\t<Fragment key={ index }>{ key }</Fragment>\n\t\t\t\t) : (\n\t\t\t\t\t<kbd\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-key\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ key }\n\t\t\t\t\t</kbd>\n\t\t\t\t)\n\t\t\t) }\n\t\t</kbd>\n\t);\n}\n\ninterface MediaEditorKeyboardShortcutsModalProps {\n\tonClose: () => void;\n}\n\nexport default function MediaEditorKeyboardShortcutsModal( {\n\tonClose,\n}: MediaEditorKeyboardShortcutsModalProps ) {\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p className=\"media-editor-keyboard-shortcuts-modal__note\">\n\t\t\t\t{ __(\n\t\t\t\t\t'These shortcuts work when the image editor has focus.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */ }\n\t\t\t{ /* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-list\"\n\t\t\t\trole=\"list\"\n\t\t\t>\n\t\t\t\t{ SHORTCUTS.map( ( { description, keyCombination }, index ) => (\n\t\t\t\t\t<li\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"media-editor-keyboard-shortcuts-modal__shortcut-description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<KeyCombinationDisplay\n\t\t\t\t\t\t\tkeyCombination={ keyCombination }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAuBA,MAAM,YAA6B;CAClC;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;EACxB,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;CACvD;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;EACxB,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAI;CAC5D;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,KAAM;EACvB,gBAAgB;GACf,WAAW;IAAE;IAAK;IAAK;IAAK;GAAI;GAChC,YAAA,GAAWA,gBAAAA,GAAAA,CAAI,YAAa;EAC7B;CACD;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,SAAU;EAC3B,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,UAAW;EAC5B,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,sBAAuB;EACxC,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;EAChD,gBAAgB;GAAE,UAAU;GAAS,WAAW;EAAI;CACrD;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,iBAAkB;EACnC,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,eAAgB;EACjC,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,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AAAA,GAAAA,CACD,uDACD;EACE,CAAA,GAMH,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;GACC,WAAU;GACV,MAAK;GAEH,UAAA,UAAU,KAAO,EAAE,aAAa,kBAAkB,UACnD,iBAAA,GAAA,kBAAA,KAAA,CAAC,MAAD;IAEC,WAAU;IAFX,UAAA,CAIC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,WAAU;KACb,UAAA;IACG,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,uBAAD,EACkB,eACjB,CAAA,CACE;GATG,GAAA,KASH,CACH;EACC,CAAA,CAEE;;AAET"}
@@ -1,91 +1,110 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/components/media-editor-modal/build-modifiers.ts
21
- var build_modifiers_exports = {};
22
- __export(build_modifiers_exports, {
23
- buildModifiers: () => buildModifiers
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(build_modifiers_exports);
26
- var import_camera = require("../../image-editor/core/camera.cjs");
27
- var CROP_TOLERANCE = 0.1;
28
- function buildModifiers(state, imageSize) {
29
- const modifiers = [];
30
- if (imageSize.width === 0 || imageSize.height === 0) {
31
- return modifiers;
32
- }
33
- const { cropRect, pan, zoom, flip } = state;
34
- const hasFlipH = flip.horizontal;
35
- const hasFlipV = flip.vertical;
36
- if (hasFlipH || hasFlipV) {
37
- modifiers.push({
38
- type: "flip",
39
- args: { flip: { horizontal: hasFlipH, vertical: hasFlipV } }
40
- });
41
- }
42
- const rawAngle = (state.rotation % 360 + 360) % 360;
43
- const singleAxisFlip = hasFlipH !== hasFlipV;
44
- const signedAngle = singleAxisFlip ? (360 - rawAngle) % 360 : rawAngle;
45
- if (signedAngle !== 0) {
46
- modifiers.push({ type: "rotate", args: { angle: signedAngle } });
47
- }
48
- const snapRotation = Math.round(state.rotation / 90) * 90;
49
- const { width: snapW, height: snapH } = (0, import_camera.getRotatedBBox)(
50
- imageSize.width,
51
- imageSize.height,
52
- snapRotation
53
- );
54
- const { width: fullW, height: fullH } = (0, import_camera.getRotatedBBox)(
55
- imageSize.width,
56
- imageSize.height,
57
- state.rotation
58
- );
59
- const imgLeft = 0.5 + pan.x - zoom / 2;
60
- const imgTop = 0.5 + pan.y - zoom / 2;
61
- const snapX = (cropRect.x - imgLeft) / zoom * snapW;
62
- const snapY = (cropRect.y - imgTop) / zoom * snapH;
63
- const widthPx = cropRect.width / zoom * snapW;
64
- const heightPx = cropRect.height / zoom * snapH;
65
- const offsetX = (fullW - snapW) / 2;
66
- const offsetY = (fullH - snapH) / 2;
67
- const fullX = snapX + offsetX;
68
- const fullY = snapY + offsetY;
69
- const leftPct = fullX / fullW * 100;
70
- const topPct = fullY / fullH * 100;
71
- const widthPct = widthPx / fullW * 100;
72
- const heightPct = heightPx / fullH * 100;
73
- const coversFullFrame = leftPct <= CROP_TOLERANCE && topPct <= CROP_TOLERANCE && widthPct >= 100 - CROP_TOLERANCE && heightPct >= 100 - CROP_TOLERANCE;
74
- if (!coversFullFrame) {
75
- modifiers.push({
76
- type: "crop",
77
- args: {
78
- left: leftPct,
79
- top: topPct,
80
- width: widthPct,
81
- height: heightPct
82
- }
83
- });
84
- }
85
- return modifiers;
6
+ let ______image_editor_core_camera_ts = require("../../image-editor/core/camera.cjs");
7
+ // packages/media-editor/src/components/media-editor-modal/build-modifiers.ts
8
+ /**
9
+ * Tolerance (percent) used to decide whether a crop rect is effectively
10
+ * full-frame. Sub-pixel / float-ulp deltas below this value are treated
11
+ * as no crop. Matches the historical threshold used by the legacy
12
+ * `use-save-image.js` (which compared against `99.9`).
13
+ */
14
+ const CROP_TOLERANCE = .1;
15
+ /**
16
+ * Build a Core-compatible modifiers array from the cropper state.
17
+ *
18
+ * Emits `[flip, rotate, crop]` in that order. Identity operations are
19
+ * pruned — an absent flip, a rotation that normalizes to 0°, and a crop
20
+ * rect that covers (within tolerance) the full post-rotate AABB each
21
+ * produce no modifier. An identity state (fresh image, no edits) returns
22
+ * an empty array; callers can use that to skip the `/edit` call.
23
+ *
24
+ * Frames and math:
25
+ *
26
+ * The cropper's `cropRect` is stored as fractions of the **snap-rotation**
27
+ * bounding box (the stencil-reference frame — see `createCamera` /
28
+ * `createExportCamera`). Pan is in that frame; zoom scales the image
29
+ * beneath a fixed stencil. Two conversions are needed to reach the frame
30
+ * Core's crop modifier applies against:
31
+ *
32
+ * 1. Express the stencil rect in snap-AABB **pixels**:
33
+ * Image screen-normalized top-left with zoom/pan is
34
+ * `(0.5 + pan - zoom/2)`; the stencil's pixel footprint is the
35
+ * inverse of that transform applied to `cropRect`.
36
+ *
37
+ * 2. Translate from snap-AABB coords to full-AABB coords. Both AABBs
38
+ * share the source-image center, so the conversion is a pure
39
+ * translation by `(fullCenter - snapCenter)`. Finally, express the
40
+ * translated rect as percentages of the full AABB.
41
+ *
42
+ * Rotation sign: the cropper composes `flip · R(θ)` on the source (see
43
+ * `createExportCamera` — rotate then flip). Core's `[flip, rotate]`
44
+ * applies the opposite order: `R(θ') · flip`. For both to land on the
45
+ * same pixels we invert the rotation sign when exactly one flip axis
46
+ * is set (`flip_h · R(θ) = R(-θ) · flip_h`). Both-or-neither flips
47
+ * leave the sign alone because `flip_h · flip_v = -I` commutes with
48
+ * rotation.
49
+ *
50
+ * @param cropper The cropper controller. The current edit and the loaded
51
+ * image's natural size are both read from its state.
52
+ * @return Ordered modifier array; empty when nothing is server-relevant or
53
+ * no image has loaded.
54
+ */
55
+ function buildModifiers(cropper) {
56
+ const modifiers = [];
57
+ const { state } = cropper;
58
+ const { image } = state;
59
+ if (!image || image.naturalWidth === 0 || image.naturalHeight === 0) return modifiers;
60
+ const imageSize = {
61
+ width: image.naturalWidth,
62
+ height: image.naturalHeight
63
+ };
64
+ const { cropRect, pan, zoom, flip } = state;
65
+ const hasFlipH = flip.horizontal;
66
+ const hasFlipV = flip.vertical;
67
+ if (hasFlipH || hasFlipV) modifiers.push({
68
+ type: "flip",
69
+ args: { flip: {
70
+ horizontal: hasFlipH,
71
+ vertical: hasFlipV
72
+ } }
73
+ });
74
+ const rawAngle = (state.rotation % 360 + 360) % 360;
75
+ const signedAngle = hasFlipH !== hasFlipV ? (360 - rawAngle) % 360 : rawAngle;
76
+ if (signedAngle !== 0) modifiers.push({
77
+ type: "rotate",
78
+ args: { angle: signedAngle }
79
+ });
80
+ const snapRotation = Math.round(state.rotation / 90) * 90;
81
+ const { width: snapW, height: snapH } = (0, ______image_editor_core_camera_ts.getRotatedBBox)(imageSize.width, imageSize.height, snapRotation);
82
+ const { width: fullW, height: fullH } = (0, ______image_editor_core_camera_ts.getRotatedBBox)(imageSize.width, imageSize.height, state.rotation);
83
+ const imgLeft = .5 + pan.x - zoom / 2;
84
+ const imgTop = .5 + pan.y - zoom / 2;
85
+ const snapX = (cropRect.x - imgLeft) / zoom * snapW;
86
+ const snapY = (cropRect.y - imgTop) / zoom * snapH;
87
+ const widthPx = cropRect.width / zoom * snapW;
88
+ const heightPx = cropRect.height / zoom * snapH;
89
+ const offsetX = (fullW - snapW) / 2;
90
+ const offsetY = (fullH - snapH) / 2;
91
+ const fullX = snapX + offsetX;
92
+ const fullY = snapY + offsetY;
93
+ const leftPct = fullX / fullW * 100;
94
+ const topPct = fullY / fullH * 100;
95
+ const widthPct = widthPx / fullW * 100;
96
+ const heightPct = heightPx / fullH * 100;
97
+ if (!(leftPct <= CROP_TOLERANCE && topPct <= CROP_TOLERANCE && widthPct >= 99.9 && heightPct >= 99.9)) modifiers.push({
98
+ type: "crop",
99
+ args: {
100
+ left: leftPct,
101
+ top: topPct,
102
+ width: widthPct,
103
+ height: heightPct
104
+ }
105
+ });
106
+ return modifiers;
86
107
  }
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- buildModifiers
90
- });
91
- //# sourceMappingURL=build-modifiers.cjs.map
108
+ exports.buildModifiers = buildModifiers;
109
+
110
+ //# sourceMappingURL=build-modifiers.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/media-editor-modal/build-modifiers.ts"],
4
- "sourcesContent": ["import type { CropperState, Size } from '../../image-editor';\nimport { getRotatedBBox } from '../../image-editor/core/camera';\n\n/**\n * A single modifier in the Core REST `/edit` payload. Order is\n * significant — the server applies modifiers sequentially (see\n * `WP_REST_Attachments_Controller::edit_media_item`).\n *\n * Shape/units:\n * - `flip`: booleans per axis. Applied first in this module's output.\n * - `rotate`: `angle` in degrees, clockwise-positive (matches the\n * cropper's own convention; Core negates it internally for\n * `WP_Image_Editor::rotate`, which is counterclockwise-positive).\n * - `crop`: percentages (0–100) of the image's dimensions **at the\n * moment the crop is applied**. Because modifiers are applied in\n * order, after a preceding `rotate` the server's\n * `WP_Image_Editor::get_size()` reports the full post-rotate AABB,\n * so the percentages are of that AABB. Origin is top-left.\n */\nexport type Modifier =\n\t| {\n\t\t\ttype: 'flip';\n\t\t\targs: { flip: { horizontal: boolean; vertical: boolean } };\n\t }\n\t| { type: 'rotate'; args: { angle: number } }\n\t| {\n\t\t\ttype: 'crop';\n\t\t\targs: { left: number; top: number; width: number; height: number };\n\t };\n\n/**\n * Tolerance (percent) used to decide whether a crop rect is effectively\n * full-frame. Sub-pixel / float-ulp deltas below this value are treated\n * as no crop. Matches the historical threshold used by the legacy\n * `use-save-image.js` (which compared against `99.9`).\n */\nconst CROP_TOLERANCE = 0.1;\n\n/**\n * Build a Core-compatible modifiers array from the cropper state.\n *\n * Emits `[flip, rotate, crop]` in that order. Identity operations are\n * pruned — an absent flip, a rotation that normalizes to 0°, and a crop\n * rect that covers (within tolerance) the full post-rotate AABB each\n * produce no modifier. An identity state (fresh image, no edits) returns\n * an empty array; callers can use that to skip the `/edit` call.\n *\n * Frames and math:\n *\n * The cropper's `cropRect` is stored as fractions of the **snap-rotation**\n * bounding box (the stencil-reference frame — see `createCamera` /\n * `createExportCamera`). Pan is in that frame; zoom scales the image\n * beneath a fixed stencil. Two conversions are needed to reach the frame\n * Core's crop modifier applies against:\n *\n * 1. Express the stencil rect in snap-AABB **pixels**:\n * Image screen-normalized top-left with zoom/pan is\n * `(0.5 + pan - zoom/2)`; the stencil's pixel footprint is the\n * inverse of that transform applied to `cropRect`.\n *\n * 2. Translate from snap-AABB coords to full-AABB coords. Both AABBs\n * share the source-image center, so the conversion is a pure\n * translation by `(fullCenter - snapCenter)`. Finally, express the\n * translated rect as percentages of the full AABB.\n *\n * Rotation sign: the cropper composes `flip · R(θ)` on the source (see\n * `createExportCamera` — rotate then flip). Core's `[flip, rotate]`\n * applies the opposite order: `R(θ') · flip`. For both to land on the\n * same pixels we invert the rotation sign when exactly one flip axis\n * is set (`flip_h · R(θ) = R(-θ) · flip_h`). Both-or-neither flips\n * leave the sign alone because `flip_h · flip_v = -I` commutes with\n * rotation.\n *\n * @param state Current cropper state.\n * @param imageSize Natural dimensions of the source image.\n * @return Ordered modifier array; empty when nothing is server-relevant.\n */\nexport function buildModifiers(\n\tstate: CropperState,\n\timageSize: Size\n): Modifier[] {\n\tconst modifiers: Modifier[] = [];\n\n\tif ( imageSize.width === 0 || imageSize.height === 0 ) {\n\t\treturn modifiers;\n\t}\n\n\tconst { cropRect, pan, zoom, flip } = state;\n\tconst hasFlipH = flip.horizontal;\n\tconst hasFlipV = flip.vertical;\n\n\tif ( hasFlipH || hasFlipV ) {\n\t\tmodifiers.push( {\n\t\t\ttype: 'flip',\n\t\t\targs: { flip: { horizontal: hasFlipH, vertical: hasFlipV } },\n\t\t} );\n\t}\n\n\tconst rawAngle = ( ( state.rotation % 360 ) + 360 ) % 360;\n\t// Invert the sign for single-axis flips so Core's `flip → rotate`\n\t// pipeline matches the cropper's `rotate → flip` composition.\n\tconst singleAxisFlip = hasFlipH !== hasFlipV;\n\tconst signedAngle = singleAxisFlip ? ( 360 - rawAngle ) % 360 : rawAngle;\n\tif ( signedAngle !== 0 ) {\n\t\tmodifiers.push( { type: 'rotate', args: { angle: signedAngle } } );\n\t}\n\n\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\tconst { width: snapW, height: snapH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\tconst { width: fullW, height: fullH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tstate.rotation\n\t);\n\n\t// Stencil rect in snap-AABB pixels. Inverts `createExportCamera`'s\n\t// pan/zoom composition to recover the pixel rectangle the stencil\n\t// framed in that frame.\n\tconst imgLeft = 0.5 + pan.x - zoom / 2;\n\tconst imgTop = 0.5 + pan.y - zoom / 2;\n\tconst snapX = ( ( cropRect.x - imgLeft ) / zoom ) * snapW;\n\tconst snapY = ( ( cropRect.y - imgTop ) / zoom ) * snapH;\n\tconst widthPx = ( cropRect.width / zoom ) * snapW;\n\tconst heightPx = ( cropRect.height / zoom ) * snapH;\n\n\t// Translate to the full AABB (both centered on source).\n\tconst offsetX = ( fullW - snapW ) / 2;\n\tconst offsetY = ( fullH - snapH ) / 2;\n\tconst fullX = snapX + offsetX;\n\tconst fullY = snapY + offsetY;\n\n\t// Percentages of the full AABB — Core's crop frame after rotate.\n\tconst leftPct = ( fullX / fullW ) * 100;\n\tconst topPct = ( fullY / fullH ) * 100;\n\tconst widthPct = ( widthPx / fullW ) * 100;\n\tconst heightPct = ( heightPx / fullH ) * 100;\n\n\tconst coversFullFrame =\n\t\tleftPct <= CROP_TOLERANCE &&\n\t\ttopPct <= CROP_TOLERANCE &&\n\t\twidthPct >= 100 - CROP_TOLERANCE &&\n\t\theightPct >= 100 - CROP_TOLERANCE;\n\n\tif ( ! coversFullFrame ) {\n\t\tmodifiers.push( {\n\t\t\ttype: 'crop',\n\t\t\targs: {\n\t\t\t\tleft: leftPct,\n\t\t\t\ttop: topPct,\n\t\t\t\twidth: widthPct,\n\t\t\t\theight: heightPct,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn modifiers;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAmC/B,IAAM,iBAAiB;AAyChB,SAAS,eACf,OACA,WACa;AACb,QAAM,YAAwB,CAAC;AAE/B,MAAK,UAAU,UAAU,KAAK,UAAU,WAAW,GAAI;AACtD,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,UAAU,KAAK,MAAM,KAAK,IAAI;AACtC,QAAM,WAAW,KAAK;AACtB,QAAM,WAAW,KAAK;AAEtB,MAAK,YAAY,UAAW;AAC3B,cAAU,KAAM;AAAA,MACf,MAAM;AAAA,MACN,MAAM,EAAE,MAAM,EAAE,YAAY,UAAU,UAAU,SAAS,EAAE;AAAA,IAC5D,CAAE;AAAA,EACH;AAEA,QAAM,YAAe,MAAM,WAAW,MAAQ,OAAQ;AAGtD,QAAM,iBAAiB,aAAa;AACpC,QAAM,cAAc,kBAAmB,MAAM,YAAa,MAAM;AAChE,MAAK,gBAAgB,GAAI;AACxB,cAAU,KAAM,EAAE,MAAM,UAAU,MAAM,EAAE,OAAO,YAAY,EAAE,CAAE;AAAA,EAClE;AAEA,QAAM,eAAe,KAAK,MAAO,MAAM,WAAW,EAAG,IAAI;AACzD,QAAM,EAAE,OAAO,OAAO,QAAQ,MAAM,QAAI;AAAA,IACvC,UAAU;AAAA,IACV,UAAU;AAAA,IACV;AAAA,EACD;AACA,QAAM,EAAE,OAAO,OAAO,QAAQ,MAAM,QAAI;AAAA,IACvC,UAAU;AAAA,IACV,UAAU;AAAA,IACV,MAAM;AAAA,EACP;AAKA,QAAM,UAAU,MAAM,IAAI,IAAI,OAAO;AACrC,QAAM,SAAS,MAAM,IAAI,IAAI,OAAO;AACpC,QAAM,SAAY,SAAS,IAAI,WAAY,OAAS;AACpD,QAAM,SAAY,SAAS,IAAI,UAAW,OAAS;AACnD,QAAM,UAAY,SAAS,QAAQ,OAAS;AAC5C,QAAM,WAAa,SAAS,SAAS,OAAS;AAG9C,QAAM,WAAY,QAAQ,SAAU;AACpC,QAAM,WAAY,QAAQ,SAAU;AACpC,QAAM,QAAQ,QAAQ;AACtB,QAAM,QAAQ,QAAQ;AAGtB,QAAM,UAAY,QAAQ,QAAU;AACpC,QAAM,SAAW,QAAQ,QAAU;AACnC,QAAM,WAAa,UAAU,QAAU;AACvC,QAAM,YAAc,WAAW,QAAU;AAEzC,QAAM,kBACL,WAAW,kBACX,UAAU,kBACV,YAAY,MAAM,kBAClB,aAAa,MAAM;AAEpB,MAAK,CAAE,iBAAkB;AACxB,cAAU,KAAM;AAAA,MACf,MAAM;AAAA,MACN,MAAM;AAAA,QACL,MAAM;AAAA,QACN,KAAK;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,MACT;AAAA,IACD,CAAE;AAAA,EACH;AAEA,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"build-modifiers.cjs","names":["getRotatedBBox"],"sources":["../../../src/components/media-editor-modal/build-modifiers.ts"],"sourcesContent":["import type { CropperController } from '../../image-editor';\nimport { getRotatedBBox } from '../../image-editor/core/camera';\n\n/**\n * A single modifier in the Core REST `/edit` payload. Order is\n * significant — the server applies modifiers sequentially (see\n * `WP_REST_Attachments_Controller::edit_media_item`).\n *\n * Shape/units:\n * - `flip`: booleans per axis. Applied first in this module's output.\n * - `rotate`: `angle` in degrees, clockwise-positive (matches the\n * cropper's own convention; Core negates it internally for\n * `WP_Image_Editor::rotate`, which is counterclockwise-positive).\n * - `crop`: percentages (0–100) of the image's dimensions **at the\n * moment the crop is applied**. Because modifiers are applied in\n * order, after a preceding `rotate` the server's\n * `WP_Image_Editor::get_size()` reports the full post-rotate AABB,\n * so the percentages are of that AABB. Origin is top-left.\n */\nexport type Modifier =\n\t| {\n\t\t\ttype: 'flip';\n\t\t\targs: { flip: { horizontal: boolean; vertical: boolean } };\n\t }\n\t| { type: 'rotate'; args: { angle: number } }\n\t| {\n\t\t\ttype: 'crop';\n\t\t\targs: { left: number; top: number; width: number; height: number };\n\t };\n\n/**\n * Tolerance (percent) used to decide whether a crop rect is effectively\n * full-frame. Sub-pixel / float-ulp deltas below this value are treated\n * as no crop. Matches the historical threshold used by the legacy\n * `use-save-image.js` (which compared against `99.9`).\n */\nconst CROP_TOLERANCE = 0.1;\n\n/**\n * Build a Core-compatible modifiers array from the cropper state.\n *\n * Emits `[flip, rotate, crop]` in that order. Identity operations are\n * pruned — an absent flip, a rotation that normalizes to 0°, and a crop\n * rect that covers (within tolerance) the full post-rotate AABB each\n * produce no modifier. An identity state (fresh image, no edits) returns\n * an empty array; callers can use that to skip the `/edit` call.\n *\n * Frames and math:\n *\n * The cropper's `cropRect` is stored as fractions of the **snap-rotation**\n * bounding box (the stencil-reference frame — see `createCamera` /\n * `createExportCamera`). Pan is in that frame; zoom scales the image\n * beneath a fixed stencil. Two conversions are needed to reach the frame\n * Core's crop modifier applies against:\n *\n * 1. Express the stencil rect in snap-AABB **pixels**:\n * Image screen-normalized top-left with zoom/pan is\n * `(0.5 + pan - zoom/2)`; the stencil's pixel footprint is the\n * inverse of that transform applied to `cropRect`.\n *\n * 2. Translate from snap-AABB coords to full-AABB coords. Both AABBs\n * share the source-image center, so the conversion is a pure\n * translation by `(fullCenter - snapCenter)`. Finally, express the\n * translated rect as percentages of the full AABB.\n *\n * Rotation sign: the cropper composes `flip · R(θ)` on the source (see\n * `createExportCamera` — rotate then flip). Core's `[flip, rotate]`\n * applies the opposite order: `R(θ') · flip`. For both to land on the\n * same pixels we invert the rotation sign when exactly one flip axis\n * is set (`flip_h · R(θ) = R(-θ) · flip_h`). Both-or-neither flips\n * leave the sign alone because `flip_h · flip_v = -I` commutes with\n * rotation.\n *\n * @param cropper The cropper controller. The current edit and the loaded\n * image's natural size are both read from its state.\n * @return Ordered modifier array; empty when nothing is server-relevant or\n * no image has loaded.\n */\nexport function buildModifiers(\n\tcropper: Pick< CropperController, 'state' >\n): Modifier[] {\n\tconst modifiers: Modifier[] = [];\n\tconst { state } = cropper;\n\tconst { image } = state;\n\n\tif ( ! image || image.naturalWidth === 0 || image.naturalHeight === 0 ) {\n\t\treturn modifiers;\n\t}\n\n\tconst imageSize = {\n\t\twidth: image.naturalWidth,\n\t\theight: image.naturalHeight,\n\t};\n\tconst { cropRect, pan, zoom, flip } = state;\n\tconst hasFlipH = flip.horizontal;\n\tconst hasFlipV = flip.vertical;\n\n\tif ( hasFlipH || hasFlipV ) {\n\t\tmodifiers.push( {\n\t\t\ttype: 'flip',\n\t\t\targs: { flip: { horizontal: hasFlipH, vertical: hasFlipV } },\n\t\t} );\n\t}\n\n\tconst rawAngle = ( ( state.rotation % 360 ) + 360 ) % 360;\n\t// Invert the sign for single-axis flips so Core's `flip → rotate`\n\t// pipeline matches the cropper's `rotate → flip` composition.\n\tconst singleAxisFlip = hasFlipH !== hasFlipV;\n\tconst signedAngle = singleAxisFlip ? ( 360 - rawAngle ) % 360 : rawAngle;\n\tif ( signedAngle !== 0 ) {\n\t\tmodifiers.push( { type: 'rotate', args: { angle: signedAngle } } );\n\t}\n\n\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\tconst { width: snapW, height: snapH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\tconst { width: fullW, height: fullH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tstate.rotation\n\t);\n\n\t// Stencil rect in snap-AABB pixels. Inverts `createExportCamera`'s\n\t// pan/zoom composition to recover the pixel rectangle the stencil\n\t// framed in that frame.\n\tconst imgLeft = 0.5 + pan.x - zoom / 2;\n\tconst imgTop = 0.5 + pan.y - zoom / 2;\n\tconst snapX = ( ( cropRect.x - imgLeft ) / zoom ) * snapW;\n\tconst snapY = ( ( cropRect.y - imgTop ) / zoom ) * snapH;\n\tconst widthPx = ( cropRect.width / zoom ) * snapW;\n\tconst heightPx = ( cropRect.height / zoom ) * snapH;\n\n\t// Translate to the full AABB (both centered on source).\n\tconst offsetX = ( fullW - snapW ) / 2;\n\tconst offsetY = ( fullH - snapH ) / 2;\n\tconst fullX = snapX + offsetX;\n\tconst fullY = snapY + offsetY;\n\n\t// Percentages of the full AABB — Core's crop frame after rotate.\n\tconst leftPct = ( fullX / fullW ) * 100;\n\tconst topPct = ( fullY / fullH ) * 100;\n\tconst widthPct = ( widthPx / fullW ) * 100;\n\tconst heightPct = ( heightPx / fullH ) * 100;\n\n\tconst coversFullFrame =\n\t\tleftPct <= CROP_TOLERANCE &&\n\t\ttopPct <= CROP_TOLERANCE &&\n\t\twidthPct >= 100 - CROP_TOLERANCE &&\n\t\theightPct >= 100 - CROP_TOLERANCE;\n\n\tif ( ! coversFullFrame ) {\n\t\tmodifiers.push( {\n\t\t\ttype: 'crop',\n\t\t\targs: {\n\t\t\t\tleft: leftPct,\n\t\t\t\ttop: topPct,\n\t\t\t\twidth: widthPct,\n\t\t\t\theight: heightPct,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn modifiers;\n}\n"],"mappings":";;;;;;;;;;;;;AAoCA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CvB,SAAgB,eACf,SACa;CACb,MAAM,YAAwB,CAAC;CAC/B,MAAM,EAAE,UAAU;CAClB,MAAM,EAAE,UAAU;CAElB,IAAK,CAAE,SAAS,MAAM,iBAAiB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