@wordpress/media-editor 0.22.0 → 0.24.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 (391) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/build/components/media-editor/index.cjs +229 -126
  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 +41 -11
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +15 -18
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +26 -8
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +13 -12
  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 +33 -33
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs +10 -7
  19. package/build/components/media-editor-modal/index.cjs.map +1 -1
  20. package/build/components/media-editor-panel/error-boundary.cjs +68 -0
  21. package/build/components/media-editor-panel/error-boundary.cjs.map +1 -0
  22. package/build/components/media-editor-panel/index.cjs +158 -0
  23. package/build/components/media-editor-panel/index.cjs.map +1 -0
  24. package/build/components/media-form/index.cjs +7 -1
  25. package/build/components/media-form/index.cjs.map +1 -1
  26. package/build/components/media-preview/index.cjs +143 -37
  27. package/build/components/media-preview/index.cjs.map +1 -1
  28. package/build/components/rotation-ruler/index.cjs +9 -7
  29. package/build/components/rotation-ruler/index.cjs.map +1 -1
  30. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -1
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -1
  32. package/build/index.cjs +10 -8
  33. package/build/private-apis.cjs.map +1 -1
  34. package/build/state/aspect-ratio-presets.cjs +12 -6
  35. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  36. package/build/state/composite-reducer.cjs +41 -74
  37. package/build/state/composite-reducer.cjs.map +1 -1
  38. package/build/state/index.cjs +0 -39
  39. package/build/state/types.cjs +1 -2
  40. package/build/state/types.cjs.map +1 -1
  41. package/build/state/use-media-editor-state.cjs +70 -106
  42. package/build/state/use-media-editor-state.cjs.map +1 -1
  43. package/build/store/index.cjs +11 -9
  44. package/build/store/index.cjs.map +1 -1
  45. package/build/utils/get-media-type.cjs +8 -0
  46. package/build/utils/get-media-type.cjs.map +1 -1
  47. package/build/utils/index.cjs +6 -0
  48. package/build-module/components/media-editor/index.mjs +217 -117
  49. package/build-module/components/media-editor/index.mjs.map +1 -1
  50. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  51. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  52. package/build-module/components/media-editor/use-save-media-editor.mjs +32 -4
  53. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  54. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  55. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  56. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  57. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  58. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  59. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  60. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  61. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  62. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +33 -33
  63. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  64. package/build-module/components/media-editor-modal/index.mjs +1 -0
  65. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  66. package/build-module/components/media-editor-panel/error-boundary.mjs +63 -0
  67. package/build-module/components/media-editor-panel/error-boundary.mjs.map +1 -0
  68. package/build-module/components/media-editor-panel/index.mjs +123 -0
  69. package/build-module/components/media-editor-panel/index.mjs.map +1 -0
  70. package/build-module/components/media-form/index.mjs +7 -1
  71. package/build-module/components/media-form/index.mjs.map +1 -1
  72. package/build-module/components/media-preview/index.mjs +123 -41
  73. package/build-module/components/media-preview/index.mjs.map +1 -1
  74. package/build-module/state/aspect-ratio-presets.mjs +12 -7
  75. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  76. package/build-module/state/composite-reducer.mjs +32 -67
  77. package/build-module/state/composite-reducer.mjs.map +1 -1
  78. package/build-module/state/index.mjs +2 -5
  79. package/build-module/state/types.mjs +1 -2
  80. package/build-module/state/types.mjs.map +1 -1
  81. package/build-module/state/use-media-editor-state.mjs +70 -105
  82. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  83. package/build-module/utils/get-media-type.mjs +8 -1
  84. package/build-module/utils/get-media-type.mjs.map +1 -1
  85. package/build-module/utils/index.mjs +1 -1
  86. package/build-style/style-rtl.css +122 -87
  87. package/build-style/style.css +121 -87
  88. package/build-types/components/media-editor/index.d.ts +25 -3
  89. package/build-types/components/media-editor/index.d.ts.map +1 -1
  90. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  91. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  92. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  93. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  94. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  95. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  96. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  97. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  98. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  99. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  100. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  101. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  102. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  103. package/build-types/components/media-editor-panel/error-boundary.d.ts +23 -0
  104. package/build-types/components/media-editor-panel/error-boundary.d.ts.map +1 -0
  105. package/build-types/components/media-editor-panel/index.d.ts +46 -0
  106. package/build-types/components/media-editor-panel/index.d.ts.map +1 -0
  107. package/build-types/components/media-form/index.d.ts.map +1 -1
  108. package/build-types/components/media-preview/index.d.ts.map +1 -1
  109. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  110. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  111. package/build-types/state/composite-reducer.d.ts +17 -19
  112. package/build-types/state/composite-reducer.d.ts.map +1 -1
  113. package/build-types/state/index.d.ts +2 -5
  114. package/build-types/state/index.d.ts.map +1 -1
  115. package/build-types/state/types.d.ts +20 -64
  116. package/build-types/state/types.d.ts.map +1 -1
  117. package/build-types/state/use-media-editor-state.d.ts +40 -54
  118. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  119. package/build-types/utils/get-media-type.d.ts +3 -1
  120. package/build-types/utils/get-media-type.d.ts.map +1 -1
  121. package/build-types/utils/index.d.ts +1 -1
  122. package/build-types/utils/index.d.ts.map +1 -1
  123. package/package.json +27 -24
  124. package/src/components/media-editor/index.tsx +372 -142
  125. package/src/components/media-editor/style.scss +21 -1
  126. package/src/components/media-editor/use-crop-options.ts +7 -11
  127. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  128. package/src/components/media-editor-canvas/index.tsx +15 -26
  129. package/src/components/media-editor-canvas/style.scss +6 -6
  130. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  131. package/src/components/media-editor-crop-panel/style.scss +21 -0
  132. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  133. package/src/components/media-editor-image-controls/index.tsx +11 -9
  134. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +56 -63
  135. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  136. package/src/components/media-editor-modal/index.tsx +4 -1
  137. package/src/components/media-editor-panel/error-boundary.tsx +88 -0
  138. package/src/components/media-editor-panel/index.tsx +211 -0
  139. package/src/components/media-form/index.tsx +7 -1
  140. package/src/components/media-preview/index.tsx +195 -37
  141. package/src/components/media-preview/style.scss +11 -32
  142. package/src/components/rotation-ruler/style.scss +3 -3
  143. package/src/state/README.md +34 -0
  144. package/src/state/aspect-ratio-presets.ts +22 -3
  145. package/src/state/composite-reducer.ts +42 -80
  146. package/src/state/index.ts +2 -18
  147. package/src/state/types.ts +18 -68
  148. package/src/state/use-media-editor-state.ts +162 -242
  149. package/src/style.scss +2 -1
  150. package/src/utils/get-media-type.ts +9 -1
  151. package/src/utils/index.ts +1 -1
  152. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  153. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  154. package/build/image-editor/core/camera.cjs +0 -277
  155. package/build/image-editor/core/camera.cjs.map +0 -1
  156. package/build/image-editor/core/constants.cjs +0 -133
  157. package/build/image-editor/core/constants.cjs.map +0 -1
  158. package/build/image-editor/core/containment.cjs +0 -289
  159. package/build/image-editor/core/containment.cjs.map +0 -1
  160. package/build/image-editor/core/crop-rect.cjs +0 -37
  161. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  162. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  163. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  164. package/build/image-editor/core/index.cjs +0 -89
  165. package/build/image-editor/core/interaction-controller.cjs +0 -591
  166. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  167. package/build/image-editor/core/math/rotation.cjs +0 -32
  168. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  169. package/build/image-editor/core/math/sanitize.cjs +0 -136
  170. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  171. package/build/image-editor/core/setter-helpers.cjs +0 -61
  172. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  173. package/build/image-editor/core/source-region.cjs +0 -236
  174. package/build/image-editor/core/source-region.cjs.map +0 -1
  175. package/build/image-editor/core/state.cjs +0 -296
  176. package/build/image-editor/core/state.cjs.map +0 -1
  177. package/build/image-editor/core/stencil-math.cjs +0 -203
  178. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  179. package/build/image-editor/core/transform-style.cjs +0 -43
  180. package/build/image-editor/core/transform-style.cjs.map +0 -1
  181. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  182. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  183. package/build/image-editor/core/types.cjs +0 -5
  184. package/build/image-editor/core/viewport-state.cjs +0 -36
  185. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  186. package/build/image-editor/index.cjs +0 -68
  187. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  188. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  189. package/build/image-editor/react/components/cropper.cjs +0 -595
  190. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  191. package/build/image-editor/react/components/index.cjs +0 -25
  192. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  193. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  194. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  195. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  196. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  197. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  198. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  199. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  200. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  201. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  202. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  203. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  204. package/build/image-editor/react/hooks/index.cjs +0 -19
  205. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  206. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  207. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  208. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  209. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  210. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  211. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  212. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  213. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  214. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  215. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  216. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  217. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  218. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  219. package/build-module/image-editor/core/camera.mjs +0 -265
  220. package/build-module/image-editor/core/camera.mjs.map +0 -1
  221. package/build-module/image-editor/core/constants.mjs +0 -115
  222. package/build-module/image-editor/core/constants.mjs.map +0 -1
  223. package/build-module/image-editor/core/containment.mjs +0 -281
  224. package/build-module/image-editor/core/containment.mjs.map +0 -1
  225. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  226. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  227. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  228. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  229. package/build-module/image-editor/core/index.mjs +0 -7
  230. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  231. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  232. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  233. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  234. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  235. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  236. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  237. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  238. package/build-module/image-editor/core/source-region.mjs +0 -228
  239. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  240. package/build-module/image-editor/core/state.mjs +0 -288
  241. package/build-module/image-editor/core/state.mjs.map +0 -1
  242. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  243. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  244. package/build-module/image-editor/core/transform-style.mjs +0 -38
  245. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  246. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  247. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  248. package/build-module/image-editor/core/types.mjs +0 -0
  249. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  250. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  251. package/build-module/image-editor/index.mjs +0 -4
  252. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  253. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  254. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  255. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  256. package/build-module/image-editor/react/components/index.mjs +0 -3
  257. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  258. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  259. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  260. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  261. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  262. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  263. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  264. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  265. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  266. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  267. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  268. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  269. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  270. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  271. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  272. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  273. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  274. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  275. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  276. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  277. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  278. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  279. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  280. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  281. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  282. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  283. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  284. package/build-types/image-editor/core/camera.d.ts +0 -128
  285. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  286. package/build-types/image-editor/core/constants.d.ts +0 -98
  287. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  288. package/build-types/image-editor/core/containment.d.ts +0 -72
  289. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  290. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  291. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  292. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  293. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  294. package/build-types/image-editor/core/index.d.ts +0 -10
  295. package/build-types/image-editor/core/index.d.ts.map +0 -1
  296. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  297. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  298. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  299. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  300. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  301. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  302. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  303. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  304. package/build-types/image-editor/core/source-region.d.ts +0 -94
  305. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  306. package/build-types/image-editor/core/state.d.ts +0 -51
  307. package/build-types/image-editor/core/state.d.ts.map +0 -1
  308. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  309. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  310. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  311. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  312. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  313. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  314. package/build-types/image-editor/core/types.d.ts +0 -269
  315. package/build-types/image-editor/core/types.d.ts.map +0 -1
  316. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  317. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  318. package/build-types/image-editor/index.d.ts +0 -17
  319. package/build-types/image-editor/index.d.ts.map +0 -1
  320. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  321. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  322. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  323. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  324. package/build-types/image-editor/react/components/index.d.ts +0 -4
  325. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  326. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  327. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  328. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  329. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  330. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  331. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  332. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  333. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  334. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  335. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  336. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  337. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  338. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  339. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  340. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  341. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  342. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  343. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  344. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  345. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  346. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  347. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  348. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  349. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  350. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  351. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  352. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  353. package/src/image-editor/README.md +0 -61
  354. package/src/image-editor/core/camera.ts +0 -429
  355. package/src/image-editor/core/constants.ts +0 -137
  356. package/src/image-editor/core/containment.ts +0 -469
  357. package/src/image-editor/core/crop-rect.ts +0 -42
  358. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  359. package/src/image-editor/core/index.ts +0 -43
  360. package/src/image-editor/core/interaction-controller.ts +0 -976
  361. package/src/image-editor/core/math/rotation.ts +0 -26
  362. package/src/image-editor/core/math/sanitize.ts +0 -155
  363. package/src/image-editor/core/setter-helpers.ts +0 -63
  364. package/src/image-editor/core/source-region.ts +0 -367
  365. package/src/image-editor/core/state.ts +0 -484
  366. package/src/image-editor/core/stencil-math.ts +0 -379
  367. package/src/image-editor/core/transform-style.ts +0 -56
  368. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  369. package/src/image-editor/core/types.ts +0 -230
  370. package/src/image-editor/core/viewport-state.ts +0 -30
  371. package/src/image-editor/docs/architecture.md +0 -63
  372. package/src/image-editor/docs/recipes.md +0 -184
  373. package/src/image-editor/index.ts +0 -43
  374. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  375. package/src/image-editor/react/components/cropper.scss +0 -259
  376. package/src/image-editor/react/components/cropper.tsx +0 -1108
  377. package/src/image-editor/react/components/index.ts +0 -3
  378. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  379. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  380. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  381. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  382. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  383. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  384. package/src/image-editor/react/hooks/index.ts +0 -4
  385. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  386. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  387. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  388. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  389. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  390. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  391. package/src/image-editor/style.scss +0 -1
@@ -1,30 +0,0 @@
1
- import type { ViewportState, ViewportAction } from './types';
2
-
3
- export const DEFAULT_VIEWPORT_STATE: ViewportState = {
4
- zoom: 1,
5
- pan: { x: 0, y: 0 },
6
- };
7
-
8
- export function viewportReducer(
9
- state: ViewportState,
10
- action: ViewportAction
11
- ): ViewportState {
12
- switch ( action.type ) {
13
- case 'SET_VIEWPORT_ZOOM': {
14
- const zoom = Math.min( 4, Math.max( 0.1, action.payload ) );
15
- return zoom === state.zoom ? state : { ...state, zoom };
16
- }
17
- case 'SET_VIEWPORT_PAN': {
18
- const { x, y } = action.payload;
19
- return x === state.pan.x && y === state.pan.y
20
- ? state
21
- : { ...state, pan: action.payload };
22
- }
23
- case 'RESET_VIEWPORT':
24
- return state.zoom === DEFAULT_VIEWPORT_STATE.zoom &&
25
- state.pan.x === DEFAULT_VIEWPORT_STATE.pan.x &&
26
- state.pan.y === DEFAULT_VIEWPORT_STATE.pan.y
27
- ? state
28
- : DEFAULT_VIEWPORT_STATE;
29
- }
30
- }
@@ -1,63 +0,0 @@
1
- # Image Editor Architecture
2
-
3
- ## Layers
4
-
5
- | Layer | Files | Responsibility |
6
- | --- | --- | --- |
7
- | Core cropper | `src/image-editor/core/` | Pure state, camera math, containment, source-region, transforms, and canvas export. |
8
- | React cropper | `src/image-editor/react/` | DOM measurement, interaction hooks, overlays, stencil rendering, and the pure `useCropperController` hook. |
9
- | Media editor state | `src/state/` | Composite state for the media editor: cropper state, crop options, undo/redo, and gesture boundaries. |
10
-
11
- The cropper layer does not own editor history. History belongs to the media editor session because sidebar controls and cropper gestures need one shared undo stack.
12
-
13
- ## Coordinate Spaces
14
-
15
- | Space | What lives here | Coordinates |
16
- | --- | --- | --- |
17
- | World | Image and crop rectangle | Normalized 0-1, origin at the top-left of the image. |
18
- | Camera | Pan, zoom, rotation, and flip transform | `mat2d` mapping world to screen. |
19
- | Screen | DOM container, pointer events, CSS transforms | Pixels relative to the cropper canvas. |
20
- | Viewport | Display-only pan/zoom of the cropper stage | CSS pixels; does not affect export. |
21
-
22
- ## Data Flow
23
-
24
- `MediaEditorState` delegates cropper actions to `cropperReducer()`. Containment keeps the image covering the crop rectangle. React components measure the DOM and render the resulting state.
25
-
26
- ## Design Decisions
27
-
28
- ### Containment
29
-
30
- Restriction logic projects crop corners through the camera and checks that they stay inside the image.
31
-
32
- ### Rendering
33
-
34
- The render path uses focused calculations for CSS transforms, stencil placement, dimming, and grid overlays.
35
-
36
- ### State
37
-
38
- The core reducer is framework-agnostic and serializable. React and media-editor layers add DOM measurement, gestures, undo/redo, save behavior, and UI state.
39
-
40
- ### Session
41
-
42
- `useMediaEditorState()` returns the media editor session. The session owns the source image, every editing slice, the shared undo/redo history, gesture boundaries, and whether the edits change the saved image (`hasOutputEdits`). The cropper is one participant: `session.cropper` is a geometry-only `CropperController` that a `<Cropper>` takes via its `controller` prop, and its `isDirty` covers geometry alone. Replacing the source image (`setSourceImage`, which the cropper's `setImage` also calls) starts a fresh session with default geometry and crop options, a clean baseline, and no history. Save code asks the session, not the cropper, whether image output needs saving.
43
-
44
- The session also holds named edits other than crop: `session.edits`, set with `session.setEdit( name, value )` and removed by passing `undefined`. They share the crop history, so undo, redo and gestures treat them like any crop change, and a different source image clears them. Values are plain data (`EditValue`: strings, numbers, booleans, `null`, and arrays and objects of those), because the session compares them by content to tell a real change from a no-op. Edits do not yet count towards `hasOutputEdits`; nothing saves them.
45
-
46
- `session.reset()` puts every slice back to its starting state in one undo entry: default geometry and crop options, no edits, same image. The Reset button calls it; it does not compose per-slice resets itself.
47
-
48
- ### Viewport
49
-
50
- Viewport pan/zoom lets the user inspect or follow the crop area without changing the crop output. It is not part of export and should not create undo entries.
51
-
52
- ## Internal Integration Points
53
-
54
- These APIs let code inside `@wordpress/media-editor` compose the cropper. They are not supported extension points for themes or plugins.
55
-
56
- | Task | API |
57
- | --- | --- |
58
- | Alternate crop UI inside media-editor | `stencil` prop implementing `StencilProps`. |
59
- | Programmatic edits | `TransformOperation[]`, `applyOperation`, or `stateFromPipeline`. |
60
- | Crop data for REST requests | `getSourceRegion()` and `getSourceRegionPercent()`. |
61
- | Canvas export | `exportCroppedImage()` or `applyToCanvas()`. |
62
- | Shared cropper state across internal components | `CropperProvider` / `useCropper()`. |
63
- | Media editor history | `useMediaEditorState()` session. |
@@ -1,184 +0,0 @@
1
- # Image Editor Recipes
2
-
3
- > **Status: internal.** Import from `../image-editor` only inside `@wordpress/media-editor`.
4
-
5
- ## Mount a Cropper
6
-
7
- ```tsx
8
- import { Cropper, useCropperController } from '../image-editor';
9
-
10
- function ImageCropper( { src }: { src: string } ) {
11
- const controller = useCropperController();
12
-
13
- return (
14
- <div style={ { width: 600, height: 400 } }>
15
- <Cropper
16
- src={ src }
17
- controller={ controller }
18
- freeformCrop
19
- showDimming
20
- showGrid="interactive"
21
- />
22
- </div>
23
- );
24
- }
25
- ```
26
-
27
- The cropper fills its parent. Always render it inside a sized container.
28
-
29
- ## Add Controls
30
-
31
- ```tsx
32
- function ImageCropperWithControls( { src }: { src: string } ) {
33
- const controller = useCropperController();
34
- const { state, setZoom, snapRotate90, toggleFlip, reset } = controller;
35
-
36
- return (
37
- <>
38
- <button onClick={ () => setZoom( state.zoom + 0.5 ) }>
39
- Zoom in
40
- </button>
41
- <button onClick={ () => snapRotate90( 1 ) }>Rotate right</button>
42
- <button onClick={ () => toggleFlip( 'horizontal' ) }>
43
- Flip horizontal
44
- </button>
45
- <button onClick={ () => reset() } disabled={ ! controller.isDirty }>
46
- Reset
47
- </button>
48
- <Cropper src={ src } controller={ controller } freeformCrop />
49
- </>
50
- );
51
- }
52
- ```
53
-
54
- When internal controls are split across components, use `CropperProvider`.
55
-
56
- ```tsx
57
- import { Cropper, CropperProvider, useCropper } from '../image-editor';
58
-
59
- function Editor( { src }: { src: string } ) {
60
- return (
61
- <CropperProvider>
62
- <Toolbar />
63
- <CropperPanel src={ src } />
64
- </CropperProvider>
65
- );
66
- }
67
-
68
- function Toolbar() {
69
- const { snapRotate90 } = useCropper();
70
- return <button onClick={ () => snapRotate90( 1 ) }>Rotate right</button>;
71
- }
72
-
73
- function CropperPanel( { src }: { src: string } ) {
74
- const controller = useCropper();
75
- return <Cropper src={ src } controller={ controller } freeformCrop />;
76
- }
77
- ```
78
-
79
- ## Use the Media Editor Session
80
-
81
- Use the media editor session when cropper state must share history with controls such as aspect ratio. The session owns history and gesture boundaries; pass its `cropper` controller to `<Cropper>`.
82
-
83
- ```tsx
84
- import { resolveAspectRatio, useMediaEditor } from '../../state';
85
- import { Cropper } from '../image-editor';
86
-
87
- function MediaEditorCanvas( { src }: { src: string } ) {
88
- const session = useMediaEditor();
89
- const aspectRatio = resolveAspectRatio(
90
- session.cropOptions.aspectRatioValue,
91
- session.cropper.state.image
92
- );
93
-
94
- return (
95
- <Cropper
96
- src={ src }
97
- controller={ session.cropper }
98
- aspectRatio={ aspectRatio }
99
- freeformCrop
100
- onGestureStart={ session.beginGesture }
101
- onGestureEnd={ session.endGesture }
102
- />
103
- );
104
- }
105
- ```
106
-
107
- ## Get Source Coordinates
108
-
109
- Use source-region helpers when saving crop data instead of rendering a `Blob`.
110
-
111
- ```ts
112
- import { getSourceRegion, getSourceRegionPercent } from '../image-editor';
113
-
114
- const imageSize = { width: naturalWidth, height: naturalHeight };
115
- const region = getSourceRegion( controller.state, imageSize );
116
- const percent = getSourceRegionPercent( controller.state, imageSize );
117
- ```
118
-
119
- `getSourceRegionPercent()` matches the crop data shape used by the WordPress attachments `/edit` endpoint.
120
-
121
- ## Export a Cropped Image
122
-
123
- ```ts
124
- const blob = await controller.getCroppedImage( 'image/jpeg', 0.9 );
125
- ```
126
-
127
- For a custom canvas pipeline, use `applyToCanvas()`.
128
-
129
- ```ts
130
- import { applyToCanvas } from '../image-editor';
131
-
132
- const output = applyToCanvas(
133
- processedCanvas,
134
- { width: processedCanvas.width, height: processedCanvas.height },
135
- controller.state
136
- );
137
- ```
138
-
139
- Canvas export is browser-only. Cross-origin images need valid CORS headers or the canvas will be tainted.
140
-
141
- ## Programmatic Edits
142
-
143
- `TransformOperation` values are plain JSON. Apply them one at a time or replay them from scratch.
144
-
145
- ```ts
146
- import { stateFromPipeline, type TransformOperation } from '../image-editor';
147
-
148
- const operations: TransformOperation[] = [
149
- { type: 'crop', rect: { x: 0.1, y: 0.1, width: 0.8, height: 0.8 } },
150
- { type: 'rotate', degrees: 5 },
151
- { type: 'flip', direction: 'horizontal' },
152
- ];
153
-
154
- for ( const operation of operations ) {
155
- controller.applyOperation( operation );
156
- }
157
-
158
- const finalState = stateFromPipeline( operations );
159
- ```
160
-
161
- ## Accessibility Notes
162
-
163
- - The crop area is focusable and keyboard-operable.
164
- - Resize handles are native buttons.
165
- - Arrow keys pan the image or resize the focused handle.
166
- - Shift increases keyboard pan/resize distance.
167
- - `R` performs a 90 degree rotation.
168
- - State changes are announced through an ARIA live region.
169
-
170
- ## Tests
171
-
172
- Run focused unit tests with:
173
-
174
- ```bash
175
- npm run test:unit packages/media-editor/src/image-editor -- --runInBand
176
- ```
177
-
178
- Useful test areas:
179
-
180
- - `core/test/camera.ts` for containment and camera invariants.
181
- - `core/test/state.ts` for reducer behavior.
182
- - `core/export/test/canvas-renderer.ts` for canvas export.
183
- - `react/components/test/cropper.tsx` for React cropper behavior.
184
- - `react/components/stencils/test/rectangle-stencil.tsx` for resize handles.
@@ -1,43 +0,0 @@
1
- /**
2
- * Public image editor contract.
3
- *
4
- * Keep this barrel explicit so implementation details from `core/`,
5
- * `react/hooks/`, or `react/components/` do not become supported API by
6
- * accident. The media editor's own state code imports the reducer-level
7
- * helpers from `./core` and `./react/hooks` directly, as the package's
8
- * components already do; everyone else uses what is here.
9
- */
10
-
11
- // React surface.
12
- export { useCropperController } from './react/hooks';
13
- export { Cropper, CropperProvider, useCropper } from './react/components';
14
- export type { CropperController } from './react/hooks';
15
- export type { CropperProps } from './react/components';
16
-
17
- // State and extension types.
18
- export type {
19
- CropperState,
20
- TransformOperation,
21
- NormalizedPoint,
22
- NormalizedRect,
23
- Size,
24
- Flip,
25
- StencilProps,
26
- HandlePosition,
27
- } from './core';
28
-
29
- // Deterministic helpers: where the crop lands in the source, the
30
- // replayable operation list, and export without a controller.
31
- export {
32
- ORIGINAL_ASPECT_RATIO,
33
- getSourceRegion,
34
- getSourceRegionPercent,
35
- stateFromPipeline,
36
- exportCroppedImage,
37
- applyToCanvas,
38
- } from './core';
39
- export type {
40
- AspectRatioPreset,
41
- SourceRegion,
42
- SourceRegionPercent,
43
- } from './core';
@@ -1,70 +0,0 @@
1
- import { createContext, useContext } from '@wordpress/element';
2
- import {
3
- useCropperController,
4
- type CropperController,
5
- } from '../hooks/use-cropper-controller';
6
- import type { CropperState } from '../../core/types';
7
-
8
- /**
9
- * The context value type for the CropperProvider.
10
- * Contains the cropper controller from useCropperController.
11
- */
12
- type CropperContextValue = CropperController | null;
13
-
14
- const CropperContext = createContext< CropperContextValue >( null );
15
-
16
- /**
17
- * Props for the CropperProvider component.
18
- */
19
- interface CropperProviderProps {
20
- /** Optional partial initial state to merge with defaults. */
21
- initialState?: Partial< CropperState >;
22
- /** Child components. */
23
- children: React.ReactNode;
24
- }
25
-
26
- /**
27
- * Convenience context provider that wraps `useCropperController`.
28
- *
29
- * Provides the pure cropper controller (state + setters, NO undo
30
- * history) to all descendant components via React context.
31
- *
32
- * History is a higher-layer concern owned by composite stores
33
- * (see `useMediaEditorState` in media-editor/state for the media
34
- * editor's composite controller with undo/redo).
35
- *
36
- * @param props
37
- * @param props.initialState
38
- * @param props.children
39
- * @return The provider element wrapping children.
40
- */
41
- export function CropperProvider( {
42
- initialState,
43
- children,
44
- }: CropperProviderProps ) {
45
- const cropperReturn = useCropperController( initialState );
46
-
47
- return (
48
- <CropperContext.Provider value={ cropperReturn }>
49
- { children }
50
- </CropperContext.Provider>
51
- );
52
- }
53
-
54
- /**
55
- * Hook to consume the CropperProvider context.
56
- *
57
- * Must be used within a CropperProvider. Throws if used outside
58
- * of the provider tree.
59
- *
60
- * @return The cropper controller.
61
- */
62
- export function useCropper(): CropperController {
63
- const context = useContext( CropperContext );
64
-
65
- if ( ! context ) {
66
- throw new Error( 'useCropper must be used within a CropperProvider.' );
67
- }
68
-
69
- return context;
70
- }
@@ -1,259 +0,0 @@
1
- @use "@wordpress/base-styles/colors" as *;
2
- @use "@wordpress/base-styles/variables" as *;
3
-
4
- // Handle touch target size — used for the handle ::before hit area. The
5
- // inner canvas inset must stay at least half this (22px) so the handles'
6
- // reach isn't clipped by the root.
7
- $handle-touch-target-size: 44px;
8
-
9
- // Geometry, not text direction: the camera and `stencil-math.ts` address
10
- // this canvas in physical pixels, and JS sets the image's `left` inline.
11
- // Mirrored, `nw` would resize the right edge and the image would pin to the
12
- // stage edge. ResizableBox ignores its own handle offsets for the same reason.
13
- /*!rtl:begin:ignore*/
14
- .wp-media-editor-image-editor {
15
- position: relative;
16
- overflow: hidden;
17
- width: 100%;
18
- height: 100%;
19
- touch-action: none;
20
- user-select: none;
21
- cursor: grab;
22
-
23
- // Inner gutter for resize handles. Handles use negative offsets and a
24
- // touch target that extends past the crop edge; the root clips overflow
25
- // (required for the dimming overlay's box-shadow trick), so a flush
26
- // handle would be clipped. The inner `__canvas` wrapper is inset to
27
- // reserve reach room on all sides while keeping the root as the clipping
28
- // boundary. `$grid-unit-30` (24px) ≥ half the 44px touch target, so the
29
- // handles still clear the edge.
30
- &__canvas {
31
- position: absolute;
32
- inset: $grid-unit-30;
33
- min-height: 100px;
34
- min-width: 100px;
35
-
36
- // Suppress the browser's default focus ring — the crop rectangle
37
- // border provides the custom keyboard-focus indicator instead.
38
- &:focus {
39
- outline: none;
40
- }
41
- }
42
-
43
- // Inner stage — receives the viewport pan transform so the canvas div
44
- // itself stays fixed, preventing the root background from showing through.
45
- &__stage {
46
- position: absolute;
47
- inset: 0;
48
- }
49
-
50
- &--dragging {
51
- cursor: grabbing;
52
- }
53
-
54
- &__image {
55
- position: absolute;
56
- top: 0;
57
- left: 0;
58
- will-change: transform;
59
- transform-origin: center center;
60
- }
61
-
62
- &__stencil {
63
- position: absolute;
64
- pointer-events: none;
65
- }
66
-
67
- &__dimming {
68
- position: absolute;
69
- pointer-events: none;
70
- /* Large shadow spread washes everything outside the crop area
71
- toward the canvas grey ($gray-200). Slightly stronger at rest
72
- for clear crop framing, lighter during drag so the user can see
73
- where they're panning. */
74
- box-shadow: 0 0 0 9999px rgba($gray-200, 0.6);
75
- transition: box-shadow 0.15s ease;
76
- }
77
-
78
- &--dragging &__dimming {
79
- box-shadow: 0 0 0 9999px rgba($gray-200, 0.4);
80
- }
81
-
82
- &__grid {
83
- position: absolute;
84
- pointer-events: none;
85
- overflow: hidden;
86
- transition: opacity 0.15s ease;
87
- }
88
-
89
- &__canvas--grid-interactive &__grid {
90
- opacity: 0;
91
- transition-delay: 0.1s;
92
- }
93
-
94
- &__canvas--show-grid &__grid {
95
- opacity: 1;
96
- transition-delay: 0s;
97
- }
98
-
99
- &__canvas--settling &__grid {
100
- opacity: 0;
101
- transition: none;
102
- }
103
-
104
- &__grid-line {
105
- position: absolute;
106
- background: rgba(255, 255, 255, 0.4);
107
-
108
- &--horizontal {
109
- left: 0;
110
- width: 100%;
111
- height: 1px;
112
- }
113
-
114
- &--vertical {
115
- top: 0;
116
- height: 100%;
117
- width: 1px;
118
- }
119
- }
120
-
121
- &__dimensions-tooltip {
122
- position: absolute;
123
- padding: 2px 6px;
124
- background: #fff;
125
- color: #1e1e1e;
126
- font-size: 11px;
127
- line-height: 1.4;
128
- font-variant-numeric: tabular-nums;
129
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.08);
130
- pointer-events: none;
131
- white-space: nowrap;
132
- z-index: 2;
133
- }
134
-
135
- &__stencil-rect {
136
- position: absolute;
137
- // Dark crop outline, matching the sidebar control/heading text so
138
- // the crop boundary stays legible against the light grey wash.
139
- border: 1px solid $gray-900;
140
- box-sizing: border-box;
141
- pointer-events: none;
142
- transition: border-color 0.15s ease, box-shadow 0.15s ease;
143
- }
144
-
145
- // Blue border on the crop rectangle when the canvas has keyboard focus.
146
- // Uses a JS-controlled class rather than :focus-visible — browsers can
147
- // restore :focus-visible across programmatic focus calls, making pure
148
- // CSS unreliable for pointer-to-keyboard transitions. The :focus check
149
- // on the canvas ensures the outline appears only when the canvas
150
- // itself is focused, not when focus is on a child handle.
151
- &__canvas--focus-visible:focus &__stencil-rect {
152
- border-color: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
153
- box-shadow: 0 0 0 1px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
154
- }
155
-
156
- &__handle {
157
- // Reset native <button> UA styles — the handle is a button for
158
- // accessibility (native keyboard focus, button semantics), but
159
- // it's styled as a small draggable circle.
160
- appearance: none;
161
- margin: 0;
162
- padding: 0;
163
- font: inherit;
164
- cursor: default;
165
-
166
- position: absolute;
167
- width: 12px;
168
- height: 12px;
169
- // Solid white fill with an accent-blue border so the handles read
170
- // clearly against the light grey wash.
171
- background: $white;
172
- border: 1px solid var(--wp-admin-theme-color, #3858e9);
173
- border-radius: 50%;
174
- box-sizing: border-box;
175
- pointer-events: auto;
176
- transition: background-color 0.15s ease, box-shadow 0.15s ease;
177
-
178
- &:focus {
179
- outline: none;
180
- }
181
-
182
- // Double ring (white inner + theme-color outer) for a clear
183
- // keyboard-focus state on the handle. Gated on the JS-controlled
184
- // keyboard-active class so that mouse interactions after a
185
- // keyboard session — e.g., clicking a handle to start a drag —
186
- // don't leave the active ring stuck on the handle.
187
- .wp-media-editor-image-editor__canvas--focus-visible &:focus {
188
- background: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
189
- border-color: transparent;
190
- box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
191
- }
192
-
193
- // Extend touch target to the minimum accessible hit area.
194
- &::before {
195
- content: "";
196
- position: absolute;
197
- top: 50%;
198
- left: 50%;
199
- width: $handle-touch-target-size;
200
- height: $handle-touch-target-size;
201
- transform: translate(-50%, -50%);
202
- }
203
-
204
- /* Offset by half the handle width (12px / 2 = 6px) to center on crop edge */
205
- &--n {
206
- top: -6px;
207
- left: 50%;
208
- margin-left: -6px;
209
- cursor: ns-resize;
210
- }
211
-
212
- &--s {
213
- bottom: -6px;
214
- left: 50%;
215
- margin-left: -6px;
216
- cursor: ns-resize;
217
- }
218
-
219
- &--e {
220
- top: 50%;
221
- right: -6px;
222
- margin-top: -6px;
223
- cursor: ew-resize;
224
- }
225
-
226
- &--w {
227
- top: 50%;
228
- left: -6px;
229
- margin-top: -6px;
230
- cursor: ew-resize;
231
- }
232
-
233
- &--nw {
234
- top: -6px;
235
- left: -6px;
236
- cursor: nwse-resize;
237
- }
238
-
239
- &--ne {
240
- top: -6px;
241
- right: -6px;
242
- cursor: nesw-resize;
243
- }
244
-
245
- &--sw {
246
- bottom: -6px;
247
- left: -6px;
248
- cursor: nesw-resize;
249
- }
250
-
251
- &--se {
252
- bottom: -6px;
253
- right: -6px;
254
- cursor: nwse-resize;
255
- }
256
- }
257
-
258
- }
259
- /*!rtl:end:ignore*/