@wordpress/media-editor 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +74 -21
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-crop-options.cjs +4 -5
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -1
  6. package/build/components/media-editor/use-save-media-editor.cjs +23 -3
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +6 -11
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +17 -1
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +4 -5
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  14. package/build/components/media-editor-image-controls/index.cjs +4 -6
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -1
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +1 -0
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs.map +1 -1
  19. package/build/components/media-form/index.cjs +7 -1
  20. package/build/components/media-form/index.cjs.map +1 -1
  21. package/build/components/media-preview/index.cjs +0 -1
  22. package/build/components/media-preview/index.cjs.map +1 -1
  23. package/build/state/aspect-ratio-presets.cjs +10 -4
  24. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  25. package/build/state/composite-reducer.cjs +32 -67
  26. package/build/state/composite-reducer.cjs.map +1 -1
  27. package/build/state/index.cjs +0 -39
  28. package/build/state/types.cjs +1 -2
  29. package/build/state/types.cjs.map +1 -1
  30. package/build/state/use-media-editor-state.cjs +70 -106
  31. package/build/state/use-media-editor-state.cjs.map +1 -1
  32. package/build-module/components/media-editor/index.mjs +78 -25
  33. package/build-module/components/media-editor/index.mjs.map +1 -1
  34. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  35. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  36. package/build-module/components/media-editor/use-save-media-editor.mjs +23 -3
  37. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  38. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  39. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  40. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  41. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  42. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  43. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  44. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  45. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  46. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +1 -0
  47. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  48. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  49. package/build-module/components/media-form/index.mjs +7 -1
  50. package/build-module/components/media-form/index.mjs.map +1 -1
  51. package/build-module/components/media-preview/index.mjs +0 -1
  52. package/build-module/components/media-preview/index.mjs.map +1 -1
  53. package/build-module/state/aspect-ratio-presets.mjs +10 -5
  54. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  55. package/build-module/state/composite-reducer.mjs +32 -67
  56. package/build-module/state/composite-reducer.mjs.map +1 -1
  57. package/build-module/state/index.mjs +2 -5
  58. package/build-module/state/types.mjs +1 -2
  59. package/build-module/state/types.mjs.map +1 -1
  60. package/build-module/state/use-media-editor-state.mjs +70 -105
  61. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  62. package/build-style/style-rtl.css +104 -57
  63. package/build-style/style.css +103 -57
  64. package/build-types/components/media-editor/index.d.ts +17 -3
  65. package/build-types/components/media-editor/index.d.ts.map +1 -1
  66. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  67. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  68. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  69. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  70. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  71. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  72. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  73. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  74. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  75. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  76. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  77. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  78. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  79. package/build-types/components/media-form/index.d.ts.map +1 -1
  80. package/build-types/components/media-preview/index.d.ts.map +1 -1
  81. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  82. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  83. package/build-types/state/composite-reducer.d.ts +17 -19
  84. package/build-types/state/composite-reducer.d.ts.map +1 -1
  85. package/build-types/state/index.d.ts +2 -5
  86. package/build-types/state/index.d.ts.map +1 -1
  87. package/build-types/state/types.d.ts +20 -64
  88. package/build-types/state/types.d.ts.map +1 -1
  89. package/build-types/state/use-media-editor-state.d.ts +33 -52
  90. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  91. package/package.json +22 -23
  92. package/src/components/media-editor/index.tsx +163 -28
  93. package/src/components/media-editor/use-crop-options.ts +7 -11
  94. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  95. package/src/components/media-editor-canvas/index.tsx +15 -26
  96. package/src/components/media-editor-canvas/style.scss +6 -6
  97. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  98. package/src/components/media-editor-crop-panel/style.scss +21 -0
  99. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  100. package/src/components/media-editor-image-controls/index.tsx +11 -9
  101. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  102. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  103. package/src/components/media-editor-modal/index.tsx +1 -1
  104. package/src/components/media-form/index.tsx +7 -1
  105. package/src/components/media-preview/index.tsx +0 -1
  106. package/src/components/rotation-ruler/style.scss +3 -3
  107. package/src/state/README.md +32 -0
  108. package/src/state/aspect-ratio-presets.ts +22 -3
  109. package/src/state/composite-reducer.ts +42 -80
  110. package/src/state/index.ts +2 -18
  111. package/src/state/types.ts +18 -68
  112. package/src/state/use-media-editor-state.ts +155 -240
  113. package/src/style.scss +2 -1
  114. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  115. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  116. package/build/image-editor/core/camera.cjs +0 -277
  117. package/build/image-editor/core/camera.cjs.map +0 -1
  118. package/build/image-editor/core/constants.cjs +0 -133
  119. package/build/image-editor/core/constants.cjs.map +0 -1
  120. package/build/image-editor/core/containment.cjs +0 -289
  121. package/build/image-editor/core/containment.cjs.map +0 -1
  122. package/build/image-editor/core/crop-rect.cjs +0 -37
  123. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  124. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  125. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  126. package/build/image-editor/core/index.cjs +0 -89
  127. package/build/image-editor/core/interaction-controller.cjs +0 -591
  128. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  129. package/build/image-editor/core/math/rotation.cjs +0 -32
  130. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  131. package/build/image-editor/core/math/sanitize.cjs +0 -136
  132. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  133. package/build/image-editor/core/setter-helpers.cjs +0 -61
  134. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  135. package/build/image-editor/core/source-region.cjs +0 -236
  136. package/build/image-editor/core/source-region.cjs.map +0 -1
  137. package/build/image-editor/core/state.cjs +0 -296
  138. package/build/image-editor/core/state.cjs.map +0 -1
  139. package/build/image-editor/core/stencil-math.cjs +0 -203
  140. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  141. package/build/image-editor/core/transform-style.cjs +0 -43
  142. package/build/image-editor/core/transform-style.cjs.map +0 -1
  143. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  144. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  145. package/build/image-editor/core/types.cjs +0 -5
  146. package/build/image-editor/core/viewport-state.cjs +0 -36
  147. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  148. package/build/image-editor/index.cjs +0 -68
  149. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  150. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  151. package/build/image-editor/react/components/cropper.cjs +0 -595
  152. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  153. package/build/image-editor/react/components/index.cjs +0 -25
  154. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  155. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  156. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  157. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  158. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  159. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  160. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  161. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  162. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  163. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  164. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  165. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  166. package/build/image-editor/react/hooks/index.cjs +0 -19
  167. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  168. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  169. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  170. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  171. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  172. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  173. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  174. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  175. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  176. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  177. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  178. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  179. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  180. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  181. package/build-module/image-editor/core/camera.mjs +0 -265
  182. package/build-module/image-editor/core/camera.mjs.map +0 -1
  183. package/build-module/image-editor/core/constants.mjs +0 -115
  184. package/build-module/image-editor/core/constants.mjs.map +0 -1
  185. package/build-module/image-editor/core/containment.mjs +0 -281
  186. package/build-module/image-editor/core/containment.mjs.map +0 -1
  187. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  188. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  189. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  190. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  191. package/build-module/image-editor/core/index.mjs +0 -7
  192. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  193. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  194. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  195. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  196. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  197. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  198. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  199. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  200. package/build-module/image-editor/core/source-region.mjs +0 -228
  201. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  202. package/build-module/image-editor/core/state.mjs +0 -288
  203. package/build-module/image-editor/core/state.mjs.map +0 -1
  204. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  205. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  206. package/build-module/image-editor/core/transform-style.mjs +0 -38
  207. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  208. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  209. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  210. package/build-module/image-editor/core/types.mjs +0 -0
  211. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  212. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  213. package/build-module/image-editor/index.mjs +0 -4
  214. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  215. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  216. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  217. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  218. package/build-module/image-editor/react/components/index.mjs +0 -3
  219. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  220. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  221. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  222. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  223. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  224. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  225. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  226. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  227. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  228. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  229. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  230. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  231. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  232. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  233. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  234. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  235. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  236. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  237. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  238. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  239. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  240. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  241. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  242. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  243. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  244. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  245. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  246. package/build-types/image-editor/core/camera.d.ts +0 -128
  247. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  248. package/build-types/image-editor/core/constants.d.ts +0 -98
  249. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  250. package/build-types/image-editor/core/containment.d.ts +0 -72
  251. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  252. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  253. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  254. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  255. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  256. package/build-types/image-editor/core/index.d.ts +0 -10
  257. package/build-types/image-editor/core/index.d.ts.map +0 -1
  258. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  259. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  260. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  261. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  262. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  263. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  264. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  265. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  266. package/build-types/image-editor/core/source-region.d.ts +0 -94
  267. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  268. package/build-types/image-editor/core/state.d.ts +0 -51
  269. package/build-types/image-editor/core/state.d.ts.map +0 -1
  270. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  271. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  272. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  273. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  274. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  275. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  276. package/build-types/image-editor/core/types.d.ts +0 -269
  277. package/build-types/image-editor/core/types.d.ts.map +0 -1
  278. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  279. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  280. package/build-types/image-editor/index.d.ts +0 -17
  281. package/build-types/image-editor/index.d.ts.map +0 -1
  282. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  283. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  284. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  285. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  286. package/build-types/image-editor/react/components/index.d.ts +0 -4
  287. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  288. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  289. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  290. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  291. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  292. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  293. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  294. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  295. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  296. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  297. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  298. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  299. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  300. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  301. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  302. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  303. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  304. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  305. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  306. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  307. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  308. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  309. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  310. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  311. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  312. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  313. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  314. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  315. package/src/image-editor/README.md +0 -61
  316. package/src/image-editor/core/camera.ts +0 -429
  317. package/src/image-editor/core/constants.ts +0 -137
  318. package/src/image-editor/core/containment.ts +0 -469
  319. package/src/image-editor/core/crop-rect.ts +0 -42
  320. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  321. package/src/image-editor/core/index.ts +0 -43
  322. package/src/image-editor/core/interaction-controller.ts +0 -976
  323. package/src/image-editor/core/math/rotation.ts +0 -26
  324. package/src/image-editor/core/math/sanitize.ts +0 -155
  325. package/src/image-editor/core/setter-helpers.ts +0 -63
  326. package/src/image-editor/core/source-region.ts +0 -367
  327. package/src/image-editor/core/state.ts +0 -484
  328. package/src/image-editor/core/stencil-math.ts +0 -379
  329. package/src/image-editor/core/transform-style.ts +0 -56
  330. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  331. package/src/image-editor/core/types.ts +0 -230
  332. package/src/image-editor/core/viewport-state.ts +0 -30
  333. package/src/image-editor/docs/architecture.md +0 -63
  334. package/src/image-editor/docs/recipes.md +0 -184
  335. package/src/image-editor/index.ts +0 -43
  336. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  337. package/src/image-editor/react/components/cropper.scss +0 -259
  338. package/src/image-editor/react/components/cropper.tsx +0 -1108
  339. package/src/image-editor/react/components/index.ts +0 -3
  340. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  341. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  342. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  343. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  344. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  345. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  346. package/src/image-editor/react/hooks/index.ts +0 -4
  347. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  348. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  349. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  350. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  351. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  352. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  353. package/src/image-editor/style.scss +0 -1
@@ -1,3 +0,0 @@
1
- export { Cropper } from './cropper';
2
- export type { CropperProps } from './cropper';
3
- export { CropperProvider, useCropper } from './cropper-provider';
@@ -1,262 +0,0 @@
1
- import { useLayoutEffect, useRef, useState } from '@wordpress/element';
2
- import type { HandlePosition, NormalizedRect, Size } from '../../../core/types';
3
-
4
- const HANDLE_GAP_PX = 12;
5
-
6
- /**
7
- * Which side of the handle a tooltip axis sits on. `before` places the
8
- * tooltip on the negative side of the handle (above for Y, left for X),
9
- * `after` on the positive side, `center` keeps it aligned with the handle.
10
- */
11
- type AxisSide = 'before' | 'center' | 'after';
12
-
13
- interface Anchor {
14
- x: AxisSide;
15
- y: AxisSide;
16
- }
17
-
18
- const TRANSLATE_PERCENT: Record< AxisSide, string > = {
19
- before: '-100%',
20
- center: '-50%',
21
- after: '0',
22
- };
23
-
24
- const GAP_DIRECTION: Record< AxisSide, number > = {
25
- before: -1,
26
- center: 0,
27
- after: 1,
28
- };
29
-
30
- const OPPOSITE_SIDE: Record< AxisSide, AxisSide > = {
31
- before: 'after',
32
- center: 'center',
33
- after: 'before',
34
- };
35
-
36
- /**
37
- * Preferred anchor for a handle, before edge-clipping is considered:
38
- * tooltip sits outward from the crop rectangle's center.
39
- *
40
- * @param handle
41
- */
42
- function preferredAnchor( handle: HandlePosition ): Anchor {
43
- let x: AxisSide = 'center';
44
- if ( handle.includes( 'w' ) ) {
45
- x = 'before';
46
- } else if ( handle.includes( 'e' ) ) {
47
- x = 'after';
48
- }
49
-
50
- let y: AxisSide = 'center';
51
- if ( handle.includes( 'n' ) ) {
52
- y = 'before';
53
- } else if ( handle.includes( 's' ) ) {
54
- y = 'after';
55
- }
56
-
57
- return { x, y };
58
- }
59
-
60
- /**
61
- * Start coordinate of a tooltip placed on the given side of `handlePos`,
62
- * accounting for the per-side handle gap and the tooltip's own length.
63
- *
64
- * @param side
65
- * @param handlePos
66
- * @param length
67
- */
68
- function sideStart(
69
- side: AxisSide,
70
- handlePos: number,
71
- length: number
72
- ): number {
73
- if ( side === 'before' ) {
74
- return handlePos - HANDLE_GAP_PX - length;
75
- }
76
- if ( side === 'after' ) {
77
- return handlePos + HANDLE_GAP_PX;
78
- }
79
- return handlePos - length / 2;
80
- }
81
-
82
- /**
83
- * Picks a side that keeps the tooltip inside the container along one
84
- * axis, preferring the supplied side and falling back to its opposite,
85
- * then center.
86
- *
87
- * @param preferred
88
- * @param handlePos
89
- * @param length
90
- * @param containerLength
91
- */
92
- function fittingSide(
93
- preferred: AxisSide,
94
- handlePos: number,
95
- length: number,
96
- containerLength: number
97
- ): AxisSide {
98
- const fits = ( side: AxisSide ) => {
99
- const start = sideStart( side, handlePos, length );
100
- return start >= 0 && start + length <= containerLength;
101
- };
102
-
103
- if ( fits( preferred ) ) {
104
- return preferred;
105
- }
106
- const opposite = OPPOSITE_SIDE[ preferred ];
107
- if ( opposite !== preferred && fits( opposite ) ) {
108
- return opposite;
109
- }
110
- if ( preferred !== 'center' && fits( 'center' ) ) {
111
- return 'center';
112
- }
113
- // None of the candidates fully fit — pick the one that pushes the
114
- // least past the container edge. Without this, the chain falls back
115
- // to `preferred`, which is the off-canvas side that triggered the
116
- // flip in the first place, so the tooltip ends up clipped.
117
- const overflow = ( side: AxisSide ) => {
118
- const start = sideStart( side, handlePos, length );
119
- return (
120
- Math.max( 0, -start ) +
121
- Math.max( 0, start + length - containerLength )
122
- );
123
- };
124
- const candidates: AxisSide[] = [ preferred, opposite, 'center' ];
125
- return candidates.reduce( ( best, side ) =>
126
- overflow( side ) < overflow( best ) ? side : best
127
- );
128
- }
129
-
130
- interface DimensionsOverlayProps {
131
- /** Crop rectangle in normalized coordinates. */
132
- cropRect: NormalizedRect;
133
- /** Container element dimensions in pixels. */
134
- containerSize: Size;
135
- /** Rendered image dimensions in pixels within the container. */
136
- imageSize: Size;
137
- /** Currently-dragged handle, or null when no pointer drag is active. */
138
- activeHandle: HandlePosition | null;
139
- /** Output crop width in source pixels. */
140
- outputWidth: number;
141
- /** Output crop height in source pixels. */
142
- outputHeight: number;
143
- }
144
-
145
- /**
146
- * Tooltip that follows the active resize handle during a pointer drag,
147
- * showing the current output dimensions of the crop in source pixels.
148
- *
149
- * Renders nothing outside of a pointer-driven resize, so keyboard
150
- * arrow-key adjustments and pan/zoom gestures stay quiet.
151
- *
152
- * @param props
153
- * @param props.cropRect
154
- * @param props.containerSize
155
- * @param props.imageSize
156
- * @param props.activeHandle
157
- * @param props.outputWidth
158
- * @param props.outputHeight
159
- */
160
- export function DimensionsOverlay( {
161
- cropRect,
162
- containerSize,
163
- imageSize,
164
- activeHandle,
165
- outputWidth,
166
- outputHeight,
167
- }: DimensionsOverlayProps ) {
168
- const tooltipRef = useRef< HTMLDivElement >( null );
169
- const [ tooltipSize, setTooltipSize ] = useState< Size | null >( null );
170
-
171
- // Measure the rendered tooltip so we can flip its anchor when it
172
- // would otherwise be clipped by the cropper's `overflow: hidden`
173
- // root. Runs synchronously before paint, so the user never sees
174
- // the un-flipped position. Tracks `outputWidth`/`outputHeight`
175
- // because they drive the digit count, the only thing that changes
176
- // the tooltip's intrinsic size during a drag.
177
- useLayoutEffect( () => {
178
- if ( ! tooltipRef.current ) {
179
- return;
180
- }
181
- const rect = tooltipRef.current.getBoundingClientRect();
182
- setTooltipSize( ( prev ) => {
183
- if (
184
- prev &&
185
- prev.width === rect.width &&
186
- prev.height === rect.height
187
- ) {
188
- return prev;
189
- }
190
- return { width: rect.width, height: rect.height };
191
- } );
192
- }, [ outputWidth, outputHeight ] );
193
-
194
- if (
195
- ! activeHandle ||
196
- containerSize.width === 0 ||
197
- containerSize.height === 0
198
- ) {
199
- return null;
200
- }
201
-
202
- const offsetX = ( containerSize.width - imageSize.width ) / 2;
203
- const offsetY = ( containerSize.height - imageSize.height ) / 2;
204
- const left = offsetX + cropRect.x * imageSize.width;
205
- const top = offsetY + cropRect.y * imageSize.height;
206
- const width = cropRect.width * imageSize.width;
207
- const height = cropRect.height * imageSize.height;
208
-
209
- // Handle pixel position within the container. Same math as the
210
- // stencil's handle layout, just keyed by direction here so the
211
- // tooltip can anchor to any of the eight.
212
- let handleX = left + width / 2;
213
- if ( activeHandle.includes( 'w' ) ) {
214
- handleX = left;
215
- } else if ( activeHandle.includes( 'e' ) ) {
216
- handleX = left + width;
217
- }
218
- let handleY = top + height / 2;
219
- if ( activeHandle.includes( 'n' ) ) {
220
- handleY = top;
221
- } else if ( activeHandle.includes( 's' ) ) {
222
- handleY = top + height;
223
- }
224
-
225
- const preferred = preferredAnchor( activeHandle );
226
- const anchor: Anchor = tooltipSize
227
- ? {
228
- x: fittingSide(
229
- preferred.x,
230
- handleX,
231
- tooltipSize.width,
232
- containerSize.width
233
- ),
234
- y: fittingSide(
235
- preferred.y,
236
- handleY,
237
- tooltipSize.height,
238
- containerSize.height
239
- ),
240
- }
241
- : preferred;
242
-
243
- return (
244
- <div
245
- ref={ tooltipRef }
246
- className="wp-media-editor-image-editor__dimensions-tooltip"
247
- data-testid="cropper-dimensions-tooltip"
248
- style={ {
249
- left: handleX + GAP_DIRECTION[ anchor.x ] * HANDLE_GAP_PX,
250
- top: handleY + GAP_DIRECTION[ anchor.y ] * HANDLE_GAP_PX,
251
- transform: `translate(${ TRANSLATE_PERCENT[ anchor.x ] }, ${
252
- TRANSLATE_PERCENT[ anchor.y ]
253
- })`,
254
- } }
255
- aria-hidden="true"
256
- >
257
- { `W: ${ Math.round( outputWidth ) }px H: ${ Math.round(
258
- outputHeight
259
- ) }px` }
260
- </div>
261
- );
262
- }
@@ -1,55 +0,0 @@
1
- import type { NormalizedRect, Size } from '../../../core/types';
2
-
3
- /**
4
- * Props for the DimmingOverlay component.
5
- */
6
- interface DimmingOverlayProps {
7
- /** The crop rectangle in normalized coordinates. */
8
- cropRect: NormalizedRect;
9
- /** The container element dimensions in pixels. */
10
- containerSize: Size;
11
- /** The rendered image dimensions in pixels within the container. */
12
- imageSize: Size;
13
- /** CSS transition string, e.g. during settle animation. */
14
- transition?: string;
15
- }
16
-
17
- // Renders a semi-transparent overlay outside the crop rectangle using a
18
- // box-shadow that dims everything outside the crop rect position.
19
- export function DimmingOverlay( {
20
- cropRect,
21
- containerSize,
22
- imageSize,
23
- transition,
24
- }: DimmingOverlayProps ) {
25
- if ( containerSize.width === 0 || containerSize.height === 0 ) {
26
- return null;
27
- }
28
-
29
- const offsetX = ( containerSize.width - imageSize.width ) / 2;
30
- const offsetY = ( containerSize.height - imageSize.height ) / 2;
31
- const left = offsetX + cropRect.x * imageSize.width;
32
- const top = offsetY + cropRect.y * imageSize.height;
33
- const width = cropRect.width * imageSize.width;
34
- const height = cropRect.height * imageSize.height;
35
-
36
- // Compose any incoming transition with the stylesheet's box-shadow
37
- // transition so the drag-dimming effect isn't overwritten.
38
- const composedTransition = transition
39
- ? `${ transition }, box-shadow 0.15s ease`
40
- : undefined;
41
-
42
- return (
43
- <div
44
- className="wp-media-editor-image-editor__dimming"
45
- data-testid="cropper-dimming"
46
- style={ {
47
- left,
48
- top,
49
- width,
50
- height,
51
- transition: composedTransition,
52
- } }
53
- />
54
- );
55
- }
@@ -1,77 +0,0 @@
1
- import type { NormalizedRect, Size } from '../../../core/types';
2
-
3
- /**
4
- * Props for the GridOverlay component.
5
- */
6
- interface GridOverlayProps {
7
- /** The crop rectangle in normalized coordinates. */
8
- cropRect: NormalizedRect;
9
- /** The container element dimensions in pixels. */
10
- containerSize: Size;
11
- /** The rendered image dimensions in pixels within the container. */
12
- imageSize: Size;
13
- }
14
-
15
- /**
16
- * Renders a rule-of-thirds grid inside the crop rectangle.
17
- *
18
- * Displays 2 horizontal and 2 vertical lines at 1/3 and 2/3
19
- * positions within the crop area.
20
- *
21
- * @param props Component props.
22
- * @param props.cropRect The crop rectangle in normalized coordinates.
23
- * @param props.containerSize The container element dimensions in pixels.
24
- * @param props.imageSize The rendered image dimensions in pixels.
25
- * @return The grid overlay element.
26
- */
27
- export function GridOverlay( {
28
- cropRect,
29
- containerSize,
30
- imageSize,
31
- }: GridOverlayProps ) {
32
- if ( containerSize.width === 0 || containerSize.height === 0 ) {
33
- return null;
34
- }
35
-
36
- const offsetX = ( containerSize.width - imageSize.width ) / 2;
37
- const offsetY = ( containerSize.height - imageSize.height ) / 2;
38
- const left = offsetX + cropRect.x * imageSize.width;
39
- const top = offsetY + cropRect.y * imageSize.height;
40
- const width = cropRect.width * imageSize.width;
41
- const height = cropRect.height * imageSize.height;
42
-
43
- const thirdW = width / 3;
44
- const thirdH = height / 3;
45
-
46
- return (
47
- <div
48
- className="wp-media-editor-image-editor__grid"
49
- data-testid="cropper-grid"
50
- style={ {
51
- left,
52
- top,
53
- width,
54
- height,
55
- } }
56
- >
57
- { /* Horizontal lines at 1/3 and 2/3 */ }
58
- <div
59
- className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal"
60
- style={ { top: thirdH } }
61
- />
62
- <div
63
- className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal"
64
- style={ { top: thirdH * 2 } }
65
- />
66
- { /* Vertical lines at 1/3 and 2/3 */ }
67
- <div
68
- className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical"
69
- style={ { left: thirdW } }
70
- />
71
- <div
72
- className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical"
73
- style={ { left: thirdW * 2 } }
74
- />
75
- </div>
76
- );
77
- }