@wordpress/media-editor 0.8.0 → 0.8.1-next.v.202605131032.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 (217) hide show
  1. package/build/components/media-editor/index.cjs +560 -0
  2. package/build/components/media-editor/index.cjs.map +7 -0
  3. package/build/components/media-editor-canvas/index.cjs +14 -2
  4. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  5. package/build/components/media-editor-crop-panel/index.cjs +34 -27
  6. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  7. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +162 -0
  8. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +7 -0
  9. package/build/components/media-editor-modal/index.cjs +42 -430
  10. package/build/components/media-editor-modal/index.cjs.map +3 -3
  11. package/build/components/media-editor-toolbar/index.cjs +143 -75
  12. package/build/components/media-editor-toolbar/index.cjs.map +3 -3
  13. package/build/components/media-form/index.cjs +3 -0
  14. package/build/components/media-form/index.cjs.map +2 -2
  15. package/build/components/rotation-ruler/index.cjs +197 -0
  16. package/build/components/rotation-ruler/index.cjs.map +7 -0
  17. package/build/components/rotation-ruler/use-ruler-drag.cjs +154 -0
  18. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +7 -0
  19. package/build/hooks/use-crop-gesture-handlers.cjs +43 -0
  20. package/build/hooks/use-crop-gesture-handlers.cjs.map +7 -0
  21. package/build/image-editor/core/constants.cjs +9 -0
  22. package/build/image-editor/core/constants.cjs.map +2 -2
  23. package/build/image-editor/core/containment.cjs +7 -13
  24. package/build/image-editor/core/containment.cjs.map +2 -2
  25. package/build/image-editor/core/interaction-controller.cjs +43 -7
  26. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  27. package/build/image-editor/core/state.cjs +5 -1
  28. package/build/image-editor/core/state.cjs.map +2 -2
  29. package/build/image-editor/core/transform-style.cjs.map +1 -1
  30. package/build/image-editor/core/types.cjs.map +1 -1
  31. package/build/image-editor/core/viewport-state.cjs +50 -0
  32. package/build/image-editor/core/viewport-state.cjs.map +7 -0
  33. package/build/image-editor/react/components/cropper.cjs +192 -72
  34. package/build/image-editor/react/components/cropper.cjs.map +3 -3
  35. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +5 -2
  36. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +2 -2
  37. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +16 -4
  38. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  39. package/build/image-editor/react/components/viewport-provider.cjs +51 -0
  40. package/build/image-editor/react/components/viewport-provider.cjs.map +7 -0
  41. package/build/image-editor/react/hooks/use-aria-announcer.cjs +53 -6
  42. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  43. package/build/image-editor/react/hooks/use-cropper-state.cjs +127 -8
  44. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +2 -2
  45. package/build/image-editor/react/hooks/use-interaction.cjs +26 -5
  46. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  47. package/build/image-editor/react/hooks/use-viewport-state.cjs +51 -0
  48. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +7 -0
  49. package/build/image-editor/react/visually-hidden-style.cjs +41 -0
  50. package/build/image-editor/react/visually-hidden-style.cjs.map +7 -0
  51. package/build/private-apis.cjs +2 -0
  52. package/build/private-apis.cjs.map +2 -2
  53. package/build-module/components/media-editor/index.mjs +545 -0
  54. package/build-module/components/media-editor/index.mjs.map +7 -0
  55. package/build-module/components/media-editor-canvas/index.mjs +14 -2
  56. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  57. package/build-module/components/media-editor-crop-panel/index.mjs +35 -28
  58. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  59. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +144 -0
  60. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +7 -0
  61. package/build-module/components/media-editor-modal/index.mjs +46 -455
  62. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  63. package/build-module/components/media-editor-toolbar/index.mjs +137 -77
  64. package/build-module/components/media-editor-toolbar/index.mjs.map +2 -2
  65. package/build-module/components/media-form/index.mjs +3 -0
  66. package/build-module/components/media-form/index.mjs.map +2 -2
  67. package/build-module/components/rotation-ruler/index.mjs +166 -0
  68. package/build-module/components/rotation-ruler/index.mjs.map +7 -0
  69. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +126 -0
  70. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +7 -0
  71. package/build-module/hooks/use-crop-gesture-handlers.mjs +17 -0
  72. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +7 -0
  73. package/build-module/image-editor/core/constants.mjs +6 -0
  74. package/build-module/image-editor/core/constants.mjs.map +2 -2
  75. package/build-module/image-editor/core/containment.mjs +6 -12
  76. package/build-module/image-editor/core/containment.mjs.map +2 -2
  77. package/build-module/image-editor/core/interaction-controller.mjs +50 -8
  78. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  79. package/build-module/image-editor/core/state.mjs +5 -1
  80. package/build-module/image-editor/core/state.mjs.map +2 -2
  81. package/build-module/image-editor/core/transform-style.mjs.map +1 -1
  82. package/build-module/image-editor/core/viewport-state.mjs +24 -0
  83. package/build-module/image-editor/core/viewport-state.mjs.map +7 -0
  84. package/build-module/image-editor/react/components/cropper.mjs +195 -73
  85. package/build-module/image-editor/react/components/cropper.mjs.map +3 -3
  86. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +5 -2
  87. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +2 -2
  88. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +26 -5
  89. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  90. package/build-module/image-editor/react/components/viewport-provider.mjs +27 -0
  91. package/build-module/image-editor/react/components/viewport-provider.mjs.map +7 -0
  92. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +59 -7
  93. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  94. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +134 -9
  95. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +2 -2
  96. package/build-module/image-editor/react/hooks/use-interaction.mjs +26 -5
  97. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  98. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +29 -0
  99. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +7 -0
  100. package/build-module/image-editor/react/visually-hidden-style.mjs +16 -0
  101. package/build-module/image-editor/react/visually-hidden-style.mjs.map +7 -0
  102. package/build-module/private-apis.mjs +2 -0
  103. package/build-module/private-apis.mjs.map +2 -2
  104. package/build-style/style-rtl.css +254 -29
  105. package/build-style/style.css +254 -29
  106. package/build-types/components/media-editor/index.d.ts +34 -0
  107. package/build-types/components/media-editor/index.d.ts.map +1 -0
  108. package/build-types/components/media-editor-canvas/index.d.ts +10 -1
  109. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  110. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  111. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  112. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts +6 -0
  113. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -0
  114. package/build-types/components/media-editor-modal/index.d.ts +2 -2
  115. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  116. package/build-types/components/media-editor-provider/index.d.ts +1 -1
  117. package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
  118. package/build-types/components/media-editor-toolbar/index.d.ts +4 -1
  119. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -1
  120. package/build-types/components/media-form/index.d.ts +1 -1
  121. package/build-types/components/media-form/index.d.ts.map +1 -1
  122. package/build-types/components/rotation-ruler/index.d.ts +46 -0
  123. package/build-types/components/rotation-ruler/index.d.ts.map +1 -0
  124. package/build-types/components/rotation-ruler/stories/index.story.d.ts +14 -0
  125. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +1 -0
  126. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts +61 -0
  127. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -0
  128. package/build-types/hooks/use-crop-gesture-handlers.d.ts +42 -0
  129. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -0
  130. package/build-types/image-editor/core/constants.d.ts +9 -0
  131. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  132. package/build-types/image-editor/core/containment.d.ts +11 -7
  133. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  134. package/build-types/image-editor/core/interaction-controller.d.ts +14 -2
  135. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  136. package/build-types/image-editor/core/state.d.ts.map +1 -1
  137. package/build-types/image-editor/core/transform-style.d.ts +1 -1
  138. package/build-types/image-editor/core/types.d.ts +25 -0
  139. package/build-types/image-editor/core/types.d.ts.map +1 -1
  140. package/build-types/image-editor/core/viewport-state.d.ts +7 -0
  141. package/build-types/image-editor/core/viewport-state.d.ts.map +1 -0
  142. package/build-types/image-editor/react/components/cropper-provider.d.ts +1 -1
  143. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  144. package/build-types/image-editor/react/components/cropper.d.ts +2 -1
  145. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  146. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +3 -13
  147. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -1
  148. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +1 -1
  149. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -1
  150. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +1 -1
  151. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  152. package/build-types/image-editor/react/components/viewport-provider.d.ts +9 -0
  153. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -0
  154. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  155. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +29 -0
  156. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -1
  157. package/build-types/image-editor/react/hooks/use-interaction.d.ts +5 -2
  158. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  159. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +19 -0
  160. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -0
  161. package/build-types/image-editor/react/visually-hidden-style.d.ts +6 -0
  162. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +1 -0
  163. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
  164. package/build-types/private-apis.d.ts.map +1 -1
  165. package/build-types/store/actions.d.ts +3 -3
  166. package/build-types/store/actions.d.ts.map +1 -1
  167. package/package.json +16 -15
  168. package/src/components/media-editor/index.tsx +709 -0
  169. package/src/components/media-editor/style.scss +89 -0
  170. package/src/components/media-editor-canvas/index.tsx +24 -0
  171. package/src/components/media-editor-crop-panel/index.tsx +39 -27
  172. package/src/components/media-editor-crop-panel/test/index.tsx +109 -0
  173. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +177 -0
  174. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +53 -0
  175. package/src/components/media-editor-modal/index.tsx +49 -589
  176. package/src/components/media-editor-modal/style.scss +13 -112
  177. package/src/components/media-editor-toolbar/index.tsx +122 -63
  178. package/src/components/media-editor-toolbar/style.scss +39 -11
  179. package/src/components/media-form/index.tsx +5 -0
  180. package/src/components/rotation-ruler/README.md +37 -0
  181. package/src/components/rotation-ruler/index.tsx +266 -0
  182. package/src/components/rotation-ruler/stories/index.story.tsx +54 -0
  183. package/src/components/rotation-ruler/style.scss +147 -0
  184. package/src/components/rotation-ruler/test/index.tsx +109 -0
  185. package/src/components/rotation-ruler/use-ruler-drag.ts +230 -0
  186. package/src/hooks/use-crop-gesture-handlers.ts +54 -0
  187. package/src/image-editor/core/constants.ts +12 -0
  188. package/src/image-editor/core/containment.ts +16 -28
  189. package/src/image-editor/core/interaction-controller.ts +66 -10
  190. package/src/image-editor/core/state.ts +15 -8
  191. package/src/image-editor/core/test/camera.ts +15 -26
  192. package/src/image-editor/core/test/interaction-controller.ts +158 -7
  193. package/src/image-editor/core/test/state.ts +21 -1
  194. package/src/image-editor/core/transform-style.ts +1 -1
  195. package/src/image-editor/core/types.ts +16 -0
  196. package/src/image-editor/core/viewport-state.ts +33 -0
  197. package/src/image-editor/docs/architecture.md +1 -1
  198. package/src/image-editor/docs/recipes.md +2 -2
  199. package/src/image-editor/react/components/cropper.scss +28 -0
  200. package/src/image-editor/react/components/cropper.tsx +268 -72
  201. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +12 -12
  202. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +27 -8
  203. package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +29 -3
  204. package/src/image-editor/react/components/test/cropper.tsx +294 -5
  205. package/src/image-editor/react/components/viewport-provider.tsx +39 -0
  206. package/src/image-editor/react/hooks/test/use-aria-announcer.ts +81 -0
  207. package/src/image-editor/react/hooks/test/use-cropper-state.ts +286 -0
  208. package/src/image-editor/react/hooks/test/use-interaction.ts +1 -0
  209. package/src/image-editor/react/hooks/use-aria-announcer.ts +68 -7
  210. package/src/image-editor/react/hooks/use-cropper-state.ts +230 -11
  211. package/src/image-editor/react/hooks/use-interaction.ts +36 -6
  212. package/src/image-editor/react/hooks/use-viewport-state.ts +48 -0
  213. package/src/image-editor/react/visually-hidden-style.ts +15 -0
  214. package/src/private-apis.ts +2 -0
  215. package/src/style.scss +3 -0
  216. package/tsconfig.json +1 -0
  217. package/tsconfig.tsbuildinfo +1 -1
@@ -3,126 +3,27 @@
3
3
  @use "@wordpress/base-styles/variables" as *;
4
4
  @use "@wordpress/base-styles/z-index" as *;
5
5
 
6
- // `className` on `<Modal>` is applied to `.components-modal__frame`, so the
7
- // compound selector below bumps specificity over the shipped rule at
8
- // `.components-modal__frame.is-full-screen :where(.components-modal__content)`
9
- // and lets the InterfaceSkeleton run edge-to-edge inside the modal.
6
+ // `className` on `<Modal>` is applied to `.components-modal__frame`, so this
7
+ // bumps specificity over the shipped full-screen modal content rule and lets
8
+ // the media editor run edge-to-edge inside the modal.
10
9
  .media-editor-modal.components-modal__frame .components-modal__content {
11
10
  padding: 0;
12
11
  margin-bottom: 0;
12
+ display: flex;
13
+ flex-direction: column;
14
+ min-height: 0;
13
15
  }
14
16
 
15
- .media-editor-modal {
17
+ .media-editor-modal.components-modal__frame .components-modal__children-container {
16
18
  display: flex;
19
+ flex: 1;
17
20
  flex-direction: column;
21
+ min-height: 0;
22
+ }
18
23
 
19
- // Center the loading spinner in the modal body while media data is
20
- // resolving, before the InterfaceSkeleton mounts. The wrapper sits
21
- // inside `.components-modal__children-container`, which isn't a flex
22
- // container — `height: 100%` (rather than `flex: 1`) makes it fill
23
- // the body so the inner flex can center the spinner.
24
- .media-editor-modal__loading {
25
- height: 100%;
26
- display: flex;
27
- align-items: center;
28
- justify-content: center;
29
- }
30
-
31
- // InterfaceSkeleton defaults to position: fixed for full-viewport usage.
32
- // Reset it so the skeleton flows inside the modal's content area. Stack
33
- // children vertically (header/body/footer) since the default row layout
34
- // assumes an absolutely positioned footer that overlays the bottom.
35
- .interface-interface-skeleton {
36
- position: relative;
37
- top: auto;
38
- right: auto;
39
- bottom: auto;
40
- left: auto;
41
- height: 100%;
42
- max-height: none;
43
- flex: 1;
44
- flex-direction: column;
45
- }
46
-
47
- .interface-interface-skeleton__editor {
48
- min-width: 0;
49
- flex: 1;
50
- }
51
-
52
- // The skeleton's default footer is `position: absolute; bottom: 0` with
53
- // a small fixed padding-bottom on the body to compensate. Our bottom
54
- // bar is taller than that default, so it would overlap the cropper's
55
- // resize handles. Put the footer in flow so it claims its own row and
56
- // the canvas (and sidebar) resize to fit above it. The skeleton also
57
- // hides the footer below the medium breakpoint by default; force it
58
- // visible so the bottom-bar controls remain accessible on narrow
59
- // viewports.
60
- .interface-interface-skeleton__footer {
61
- position: relative;
62
- display: flex;
63
- }
64
-
65
- .interface-interface-skeleton.has-footer .interface-interface-skeleton__body {
66
- padding-bottom: 0;
67
- }
68
-
69
- .media-editor-modal__canvas {
70
- display: flex;
71
- align-items: center;
72
- justify-content: center;
73
- background: $gray-100;
74
- overflow: auto;
75
- height: 100%;
76
-
77
- // MediaPreview uses `min-height: 100%` so it can grow when needed in
78
- // other contexts. Inside the modal canvas we need a definite height
79
- // so the image/video's `max-height: 100%` resolves and the preview
80
- // is contained vertically.
81
- .media-editor-preview {
82
- height: 100%;
83
- }
84
-
85
- img,
86
- video {
87
- max-width: 100%;
88
- max-height: 100%;
89
- object-fit: contain;
90
- }
91
- }
92
-
93
- // Matches the post editor's `.editor-sidebar` container (see
94
- // `packages/editor/src/components/sidebar/style.scss`): `@include reset`
95
- // sets `box-sizing: border-box` and makes all descendants inherit it.
96
- // Without this, descendants (notably the active-tab underline inside
97
- // `<Tabs>`) fall back to `content-box` sizing that shortens the
98
- // indicator under the selected tab label.
99
- .media-editor-modal__sidebar {
100
- @include reset;
101
- }
102
-
103
- // Mirror the editor's `PostPanelSection` padding for tab body content,
104
- // so the form inside the Details tab has breathing room.
105
- .media-editor-modal__panel {
106
- padding: $grid-unit-20;
107
- }
108
-
109
- // Match the post editor's sidebar header treatment
110
- // (see `packages/editor/src/components/sidebar/style.scss`): when the tab
111
- // list is rendered as `ComplementaryArea`'s header, zero the default
112
- // panel-header padding so tabs sit flush to the edge and the active-tab
113
- // underline can span the full tab label width.
114
- .components-panel__header.media-editor-modal__sidebar-header {
115
- padding-left: 0;
116
- padding-right: $grid-unit-10;
117
-
118
- .components-button.has-icon {
119
- padding: 0;
120
-
121
- @include break-medium() {
122
- display: flex;
123
- }
124
- }
125
- }
24
+ .media-editor-modal {
25
+ display: flex;
26
+ flex-direction: column;
126
27
  }
127
28
 
128
29
  // `<SnackbarNotices>` renders `.components-snackbar-list` with
@@ -1,21 +1,26 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { Button, RangeControl } from '@wordpress/components';
4
+ import { Button } from '@wordpress/components';
5
5
  import { Stack } from '@wordpress/ui';
6
6
  import { __ } from '@wordpress/i18n';
7
+ import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
7
8
  import {
8
9
  rotateLeft,
9
10
  rotateRight,
10
11
  flipHorizontal,
11
12
  flipVertical,
13
+ undo,
14
+ redo,
12
15
  } from '@wordpress/icons';
13
16
 
14
17
  /**
15
18
  * Internal dependencies
16
19
  */
17
20
  import { useCropper } from '../../image-editor';
21
+ import { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';
18
22
  import { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants';
23
+ import RotationRuler from '../rotation-ruler';
19
24
 
20
25
  export interface MediaEditorToolbarProps {
21
26
  /**
@@ -26,6 +31,8 @@ export interface MediaEditorToolbarProps {
26
31
  onReset?: () => void;
27
32
  /** Signal that a placement-oriented control is being adjusted. */
28
33
  onPlacementControlInteraction?: () => void;
34
+ /** Whether undo/redo should be unavailable during an active gesture. */
35
+ isUndoRedoDisabled?: boolean;
29
36
  }
30
37
 
31
38
  /**
@@ -36,18 +43,48 @@ export interface MediaEditorToolbarProps {
36
43
  * @param props
37
44
  * @param props.onReset
38
45
  * @param props.onPlacementControlInteraction
46
+ * @param props.isUndoRedoDisabled
39
47
  */
40
48
  export default function MediaEditorToolbar( {
41
49
  onReset,
42
50
  onPlacementControlInteraction,
51
+ isUndoRedoDisabled = false,
43
52
  }: MediaEditorToolbarProps ) {
44
- const { state, setRotation, setFlip, snapRotate90, reset, isDirty } =
45
- useCropper();
53
+ const {
54
+ state,
55
+ setRotation,
56
+ setFlip,
57
+ snapRotate90,
58
+ reset,
59
+ isDirty,
60
+ hasUndo,
61
+ hasRedo,
62
+ undo: undoCrop,
63
+ redo: redoCrop,
64
+ } = useCropper();
65
+ // `commitOnKeyUp: false` keeps rapid arrow-key adjustments coalesced
66
+ // into a single undo entry by the state-change debounce. Pointer-up
67
+ // still commits immediately so each drag is its own undo step.
68
+ const rotationGestureHandlers = useCropGestureHandlers( {
69
+ commitOnKeyUp: false,
70
+ } );
46
71
 
47
72
  const handleReset = () => {
48
73
  reset();
49
74
  onReset?.();
50
75
  };
76
+ const handleUndo = () => {
77
+ if ( isUndoRedoDisabled ) {
78
+ return;
79
+ }
80
+ undoCrop();
81
+ };
82
+ const handleRedo = () => {
83
+ if ( isUndoRedoDisabled ) {
84
+ return;
85
+ }
86
+ redoCrop();
87
+ };
51
88
 
52
89
  // `setRotation` is an absolute-angle setter. When a single flip is active
53
90
  // the visual direction inverts, so slider input must flip sign to match
@@ -57,10 +94,7 @@ export default function MediaEditorToolbar( {
57
94
  const visualDir = singleFlip ? -1 : 1;
58
95
  const fineOffset = ( state.rotation - baseAngle ) * visualDir;
59
96
 
60
- const handleRotationSlider = ( value: number | undefined ) => {
61
- if ( value === undefined ) {
62
- return;
63
- }
97
+ const handleRotationSlider = ( value: number ) => {
64
98
  // Clamp strictly inside [-MAX, MAX). Exactly ±MAX lands state on a
65
99
  // 90° midpoint and flips the derived baseAngle on the next render,
66
100
  // causing subsequent events to spiral.
@@ -82,69 +116,94 @@ export default function MediaEditorToolbar( {
82
116
  gap="sm"
83
117
  wrap="wrap"
84
118
  >
85
- <Button
86
- size="compact"
87
- icon={ rotateLeft }
88
- label={ __( 'Rotate 90° counter-clockwise' ) }
89
- showTooltip
90
- onClick={ () => snapRotate90( -1 ) }
91
- />
92
- <Button
93
- size="compact"
94
- icon={ rotateRight }
95
- label={ __( 'Rotate 90° clockwise' ) }
96
- showTooltip
97
- onClick={ () => snapRotate90( 1 ) }
98
- />
99
- <Button
100
- size="compact"
101
- icon={ flipHorizontal }
102
- label={ __( 'Flip horizontal' ) }
103
- showTooltip
104
- isPressed={ state.flip.horizontal }
105
- onClick={ () =>
106
- setFlip( {
107
- horizontal: ! state.flip.horizontal,
108
- vertical: state.flip.vertical,
109
- } )
110
- }
111
- />
112
- <Button
113
- size="compact"
114
- icon={ flipVertical }
115
- label={ __( 'Flip vertical' ) }
116
- showTooltip
117
- isPressed={ state.flip.vertical }
118
- onClick={ () =>
119
- setFlip( {
120
- horizontal: state.flip.horizontal,
121
- vertical: ! state.flip.vertical,
122
- } )
123
- }
124
- />
125
- <div className="media-editor-toolbar__rotation-slider">
126
- <RangeControl
127
- __next40pxDefaultSize
128
- __nextHasNoMarginBottom
119
+ <div
120
+ role="presentation"
121
+ className="media-editor-toolbar__rotation-slider"
122
+ { ...rotationGestureHandlers }
123
+ >
124
+ <RotationRuler
129
125
  label={ __( 'Fine rotation' ) }
130
- hideLabelFromVision
131
126
  min={ -MAX_ROTATION_OFFSET }
132
127
  max={ MAX_ROTATION_OFFSET }
133
- step={ 0.5 }
134
128
  value={ fineOffset }
135
129
  onChange={ handleRotationSlider }
136
- showTooltip={ false }
137
130
  />
138
131
  </div>
139
- <Button
140
- size="compact"
141
- variant="tertiary"
142
- disabled={ ! isDirty }
143
- accessibleWhenDisabled
144
- onClick={ handleReset }
145
- >
146
- { __( 'Reset' ) }
147
- </Button>
132
+ <div className="media-editor-toolbar__action-cluster">
133
+ <Button
134
+ size="compact"
135
+ icon={ rotateLeft }
136
+ label={ __( 'Rotate 90° counter-clockwise' ) }
137
+ showTooltip
138
+ onClick={ () => snapRotate90( -1 ) }
139
+ />
140
+ <Button
141
+ size="compact"
142
+ icon={ rotateRight }
143
+ label={ __( 'Rotate 90° clockwise' ) }
144
+ showTooltip
145
+ onClick={ () => snapRotate90( 1 ) }
146
+ />
147
+ <Button
148
+ size="compact"
149
+ icon={ flipHorizontal }
150
+ label={ __( 'Flip horizontal' ) }
151
+ showTooltip
152
+ isPressed={ state.flip.horizontal }
153
+ onClick={ () =>
154
+ setFlip( {
155
+ horizontal: ! state.flip.horizontal,
156
+ vertical: state.flip.vertical,
157
+ } )
158
+ }
159
+ />
160
+ <Button
161
+ size="compact"
162
+ icon={ flipVertical }
163
+ label={ __( 'Flip vertical' ) }
164
+ showTooltip
165
+ isPressed={ state.flip.vertical }
166
+ onClick={ () =>
167
+ setFlip( {
168
+ horizontal: state.flip.horizontal,
169
+ vertical: ! state.flip.vertical,
170
+ } )
171
+ }
172
+ />
173
+ <Button
174
+ size="compact"
175
+ icon={ undo }
176
+ label={ __( 'Undo' ) }
177
+ showTooltip
178
+ shortcut={ displayShortcut.primary( 'z' ) }
179
+ disabled={ isUndoRedoDisabled || ! hasUndo }
180
+ accessibleWhenDisabled
181
+ onClick={ handleUndo }
182
+ />
183
+ <Button
184
+ size="compact"
185
+ icon={ redo }
186
+ label={ __( 'Redo' ) }
187
+ showTooltip
188
+ shortcut={
189
+ isAppleOS()
190
+ ? displayShortcut.primaryShift( 'z' )
191
+ : displayShortcut.primary( 'y' )
192
+ }
193
+ disabled={ isUndoRedoDisabled || ! hasRedo }
194
+ accessibleWhenDisabled
195
+ onClick={ handleRedo }
196
+ />
197
+ <Button
198
+ size="compact"
199
+ variant="tertiary"
200
+ disabled={ ! isDirty }
201
+ accessibleWhenDisabled
202
+ onClick={ handleReset }
203
+ >
204
+ { __( 'Reset' ) }
205
+ </Button>
206
+ </div>
148
207
  </Stack>
149
208
  );
150
209
  }
@@ -1,21 +1,49 @@
1
- @use "@wordpress/base-styles/variables" as *;
2
1
  @use "@wordpress/base-styles/breakpoints" as *;
2
+ @use "@wordpress/base-styles/colors" as *;
3
+ @use "@wordpress/base-styles/variables" as *;
3
4
 
4
5
  .media-editor-toolbar {
5
6
  width: 100%;
6
7
  padding: $grid-unit-10 $grid-unit-20;
8
+ }
7
9
 
8
- // Let the rotation slider absorb extra horizontal space (so it grows
9
- // between the icon buttons and Reset) while capping its width so it
10
- // doesn't dominate on wide viewports.
10
+ // Two flex items: the fine-rotation slider (left, grows) and the
11
+ // action cluster (right, fixed). At narrow widths each takes a full
12
+ // row with the slider on top.
13
+ .media-editor-toolbar__rotation-slider {
14
+ flex: 1 1 280px;
15
+ min-width: 0;
16
+ max-width: 360px;
17
+ }
18
+
19
+ .media-editor-toolbar__action-cluster {
20
+ display: flex;
21
+ flex-wrap: nowrap;
22
+ align-items: center;
23
+ gap: $grid-unit-10;
24
+ }
25
+
26
+ // Above break-medium, when the slider and action cluster share a row,
27
+ // divide them with a thin rule. Below the breakpoint they stack — no
28
+ // divider.
29
+ @media (min-width: $break-medium) {
30
+ .media-editor-toolbar__action-cluster {
31
+ border-left: 1px solid $gray-300;
32
+ padding-left: $grid-unit-15;
33
+ }
34
+ }
35
+
36
+ // Below the modal-sidebar full-page breakpoint, force a deterministic
37
+ // two-row layout: slider on top, action cluster beneath. Mirrors the
38
+ // InterfaceSkeleton's own side-by-side → stacked flip at break-medium.
39
+ @media (max-width: #{ $break-medium - 1 }) {
11
40
  .media-editor-toolbar__rotation-slider {
12
- flex: 1 1 auto;
13
- max-width: 240px;
41
+ flex-basis: 100%;
42
+ max-width: none;
43
+ }
14
44
 
15
- // At narrow widths the slider is too cramped to aim precisely;
16
- // the 90° rotate buttons cover the essential need.
17
- @media (max-width: #{ $break-mobile }) {
18
- display: none;
19
- }
45
+ .media-editor-toolbar__action-cluster {
46
+ flex-basis: 100%;
47
+ justify-content: center;
20
48
  }
21
49
  }
@@ -4,6 +4,8 @@
4
4
  import { DataForm } from '@wordpress/dataviews';
5
5
  import type { Form, Field } from '@wordpress/dataviews';
6
6
  import { Spinner, __experimentalVStack as VStack } from '@wordpress/components';
7
+ import { VisuallyHidden } from '@wordpress/ui';
8
+ import { __ } from '@wordpress/i18n';
7
9
  import type { ReactNode } from 'react';
8
10
 
9
11
  /**
@@ -74,6 +76,9 @@ export default function MediaForm( {
74
76
  return (
75
77
  <div className="media-editor-form">
76
78
  <VStack spacing={ 4 }>
79
+ <VisuallyHidden render={ <h2 /> }>
80
+ { __( 'Media details' ) }
81
+ </VisuallyHidden>
77
82
  { header }
78
83
  <DataForm
79
84
  data={ media }
@@ -0,0 +1,37 @@
1
+ # RotationRuler
2
+
3
+ Private to `@wordpress/media-editor`. A horizontal ruler-slider for
4
+ fine-grained numeric values (used for fine-tune rotation in the media
5
+ editor toolbar). Drag the ruler to scrub; the current value is shown
6
+ in an active label sitting over the centered pointer triangle, with
7
+ labelled major ticks running through the strip behind it. A visually
8
+ hidden `<input type="range">` underneath provides keyboard access and
9
+ accessibility. Drag values quantize to multiples of `step`.
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ <RotationRuler
15
+ value={ rotation }
16
+ onChange={ setRotation }
17
+ label={ __( 'Fine rotation' ) }
18
+ min={ -45 }
19
+ max={ 45 }
20
+ />
21
+ ```
22
+
23
+ ## Props
24
+
25
+ See `index.tsx` for the full `RotationRulerProps` interface. The
26
+ component is controlled (`value` / `onChange`); callers own state and
27
+ clamp/transform values as they wish before passing them in.
28
+
29
+ ## Keyboard
30
+
31
+ - **← / ↓** — decrement by `step`
32
+ - **→ / ↑** — increment by `step`
33
+ - **Shift + arrow** — half-step (e.g. 0.5° when `step` is 1°), for
34
+ keyboard precision when the integer drag-step is too coarse.
35
+ **Shift + drag** does the same on the pointer.
36
+ - **Home / End** — min / max
37
+ - **PageUp / PageDown** — ±10% of range (native input behaviour)