@wordpress/media-editor 0.10.0 → 0.11.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 (140) hide show
  1. package/build/components/media-editor/index.cjs +185 -42
  2. package/build/components/media-editor/index.cjs.map +3 -3
  3. package/build/components/media-editor/use-crop-options.cjs +2 -26
  4. package/build/components/media-editor/use-crop-options.cjs.map +2 -2
  5. package/build/components/media-editor-canvas/index.cjs +2 -2
  6. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  7. package/build/components/media-editor-crop-panel/index.cjs +24 -21
  8. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  9. package/build/components/media-editor-fine-rotation/index.cjs +81 -0
  10. package/build/components/media-editor-fine-rotation/index.cjs.map +7 -0
  11. package/build/components/media-editor-modal/index.cjs +25 -7
  12. package/build/components/media-editor-modal/index.cjs.map +2 -2
  13. package/build/components/media-editor-transform-controls/index.cjs +84 -0
  14. package/build/components/media-editor-transform-controls/index.cjs.map +7 -0
  15. package/build/hooks/use-crop-gesture-handlers.cjs +1 -1
  16. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  17. package/build/image-editor/react/components/cropper.cjs +1 -1
  18. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  19. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +1 -1
  20. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  21. package/build/image-editor/react/hooks/use-aria-announcer.cjs +1 -3
  22. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  23. package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
  24. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  25. package/build/state/composite-reducer.cjs +2 -14
  26. package/build/state/composite-reducer.cjs.map +2 -2
  27. package/build/state/types.cjs +1 -2
  28. package/build/state/types.cjs.map +2 -2
  29. package/build/state/use-media-editor-state.cjs +0 -11
  30. package/build/state/use-media-editor-state.cjs.map +2 -2
  31. package/build/store/actions.cjs +4 -2
  32. package/build/store/actions.cjs.map +2 -2
  33. package/build/store/reducer.cjs +5 -3
  34. package/build/store/reducer.cjs.map +2 -2
  35. package/build/store/selectors.cjs +5 -0
  36. package/build/store/selectors.cjs.map +2 -2
  37. package/build-module/components/media-editor/index.mjs +191 -44
  38. package/build-module/components/media-editor/index.mjs.map +2 -2
  39. package/build-module/components/media-editor/use-crop-options.mjs +3 -27
  40. package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
  41. package/build-module/components/media-editor-canvas/index.mjs +2 -2
  42. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  43. package/build-module/components/media-editor-crop-panel/index.mjs +25 -26
  44. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  45. package/build-module/components/media-editor-fine-rotation/index.mjs +50 -0
  46. package/build-module/components/media-editor-fine-rotation/index.mjs.map +7 -0
  47. package/build-module/components/media-editor-modal/index.mjs +26 -8
  48. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  49. package/build-module/components/media-editor-transform-controls/index.mjs +68 -0
  50. package/build-module/components/media-editor-transform-controls/index.mjs.map +7 -0
  51. package/build-module/hooks/use-crop-gesture-handlers.mjs +1 -1
  52. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  53. package/build-module/image-editor/react/components/cropper.mjs +1 -1
  54. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  55. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +1 -1
  56. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  57. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +1 -3
  58. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  59. package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
  60. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  61. package/build-module/state/composite-reducer.mjs +2 -14
  62. package/build-module/state/composite-reducer.mjs.map +2 -2
  63. package/build-module/state/types.mjs +1 -2
  64. package/build-module/state/types.mjs.map +2 -2
  65. package/build-module/state/use-media-editor-state.mjs +0 -11
  66. package/build-module/state/use-media-editor-state.mjs.map +2 -2
  67. package/build-module/store/actions.mjs +4 -2
  68. package/build-module/store/actions.mjs.map +2 -2
  69. package/build-module/store/reducer.mjs +5 -3
  70. package/build-module/store/reducer.mjs.map +2 -2
  71. package/build-module/store/selectors.mjs +4 -0
  72. package/build-module/store/selectors.mjs.map +2 -2
  73. package/build-style/style-rtl.css +51 -35
  74. package/build-style/style.css +51 -35
  75. package/build-types/components/media-editor/index.d.ts +14 -2
  76. package/build-types/components/media-editor/index.d.ts.map +1 -1
  77. package/build-types/components/media-editor/use-crop-options.d.ts +3 -5
  78. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  79. package/build-types/components/media-editor-crop-panel/index.d.ts +3 -10
  80. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  81. package/build-types/components/media-editor-fine-rotation/index.d.ts +14 -0
  82. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -0
  83. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  84. package/build-types/components/media-editor-transform-controls/index.d.ts +8 -0
  85. package/build-types/components/media-editor-transform-controls/index.d.ts.map +1 -0
  86. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  87. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  88. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  89. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  90. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  91. package/build-types/state/composite-reducer.d.ts.map +1 -1
  92. package/build-types/state/types.d.ts +3 -11
  93. package/build-types/state/types.d.ts.map +1 -1
  94. package/build-types/state/use-media-editor-state.d.ts +2 -5
  95. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  96. package/build-types/store/actions.d.ts +3 -1
  97. package/build-types/store/actions.d.ts.map +1 -1
  98. package/build-types/store/reducer.d.ts +3 -0
  99. package/build-types/store/reducer.d.ts.map +1 -1
  100. package/build-types/store/selectors.d.ts +1 -0
  101. package/build-types/store/selectors.d.ts.map +1 -1
  102. package/package.json +20 -19
  103. package/src/components/media-editor/index.tsx +226 -57
  104. package/src/components/media-editor/style.scss +0 -9
  105. package/src/components/media-editor/test/use-crop-options.tsx +1 -55
  106. package/src/components/media-editor/use-crop-options.ts +6 -42
  107. package/src/components/media-editor-canvas/index.tsx +2 -2
  108. package/src/components/media-editor-crop-panel/index.tsx +35 -33
  109. package/src/components/media-editor-crop-panel/test/index.tsx +39 -20
  110. package/src/components/media-editor-fine-rotation/index.tsx +74 -0
  111. package/src/components/media-editor-modal/index.tsx +20 -4
  112. package/src/components/media-editor-modal/style.scss +80 -0
  113. package/src/components/media-editor-modal/test/index.tsx +3 -0
  114. package/src/components/media-editor-transform-controls/index.tsx +70 -0
  115. package/src/components/media-editor-transform-controls/style.scss +8 -0
  116. package/src/hooks/use-crop-gesture-handlers.ts +1 -3
  117. package/src/image-editor/docs/recipes.md +2 -2
  118. package/src/image-editor/react/components/cropper.tsx +1 -3
  119. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +1 -3
  120. package/src/image-editor/react/hooks/use-aria-announcer.ts +1 -3
  121. package/src/image-editor/react/hooks/use-interaction.ts +2 -3
  122. package/src/state/composite-reducer.ts +2 -17
  123. package/src/state/test/use-media-editor-state.ts +3 -75
  124. package/src/state/types.ts +3 -9
  125. package/src/state/use-media-editor-state.ts +3 -19
  126. package/src/store/actions.ts +3 -0
  127. package/src/store/reducer.ts +6 -1
  128. package/src/store/selectors.ts +4 -0
  129. package/src/store/test/reducer.ts +9 -0
  130. package/src/style.scss +1 -1
  131. package/tsconfig.json +1 -0
  132. package/tsconfig.tsbuildinfo +1 -1
  133. package/build/components/media-editor-toolbar/index.cjs +0 -218
  134. package/build/components/media-editor-toolbar/index.cjs.map +0 -7
  135. package/build-module/components/media-editor-toolbar/index.mjs +0 -194
  136. package/build-module/components/media-editor-toolbar/index.mjs.map +0 -7
  137. package/build-types/components/media-editor-toolbar/index.d.ts +0 -24
  138. package/build-types/components/media-editor-toolbar/index.d.ts.map +0 -1
  139. package/src/components/media-editor-toolbar/index.tsx +0 -213
  140. package/src/components/media-editor-toolbar/style.scss +0 -49
@@ -9,6 +9,7 @@ import {
9
9
  privateApis as componentsPrivateApis,
10
10
  } from '@wordpress/components';
11
11
  import { Stack } from '@wordpress/ui';
12
+ import { useViewportMatch } from '@wordpress/compose';
12
13
  import { useDispatch, useSelect } from '@wordpress/data';
13
14
  import { store as coreStore } from '@wordpress/core-data';
14
15
  import {
@@ -21,8 +22,12 @@ import {
21
22
  useState,
22
23
  } from '@wordpress/element';
23
24
  import { __ } from '@wordpress/i18n';
24
- import { close, drawerRight, keyboard } from '@wordpress/icons';
25
- import { isAppleOS, isKeyboardEvent } from '@wordpress/keycodes';
25
+ import { close, drawerRight, keyboard, redo, undo } from '@wordpress/icons';
26
+ import {
27
+ displayShortcut,
28
+ isAppleOS,
29
+ isKeyboardEvent,
30
+ } from '@wordpress/keycodes';
26
31
  import { SnackbarNotices, store as noticesStore } from '@wordpress/notices';
27
32
  import type { Field } from '@wordpress/dataviews';
28
33
  import {
@@ -32,11 +37,7 @@ import {
32
37
  // No type declarations available for @wordpress/interface.
33
38
  // @ts-expect-error
34
39
  } from '@wordpress/interface';
35
- import type {
36
- JSX,
37
- KeyboardEvent as ReactKeyboardEvent,
38
- ReactNode,
39
- } from 'react';
40
+ import type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';
40
41
 
41
42
  /**
42
43
  * Internal dependencies
@@ -45,7 +46,8 @@ import { MediaEditorProvider } from '../media-editor-provider';
45
46
  import type { Media } from '../media-editor-provider';
46
47
  import MediaPreview from '../media-preview';
47
48
  import MediaEditorCanvas from '../media-editor-canvas';
48
- import MediaEditorToolbar from '../media-editor-toolbar';
49
+ import MediaEditorFineRotation from '../media-editor-fine-rotation';
50
+ import MediaEditorTransformControls from '../media-editor-transform-controls';
49
51
  import MediaEditorCropPanel from '../media-editor-crop-panel';
50
52
  import MediaForm from '../media-form';
51
53
  import { unlock } from '../../lock-unlock';
@@ -81,6 +83,18 @@ interface EditorTab {
81
83
  export interface MediaEditorFrameProps {
82
84
  children: ReactNode;
83
85
  headerActions: ReactNode;
86
+ footerActions: ReactNode;
87
+ /**
88
+ * Footer layout selector. Frames apply this to the footer container
89
+ * as a modifier class.
90
+ *
91
+ * - `wide` — single row: History | Ruler | Transform | Cancel/Save.
92
+ * - `medium` — two rows: ruler on top; History | Transform | Cancel/Save
93
+ * beneath.
94
+ * - `narrow` — three rows: ruler; transform (centered); History |
95
+ * Cancel/Save.
96
+ */
97
+ footerLayout: 'wide' | 'medium' | 'narrow';
84
98
  onRequestClose: () => void;
85
99
  onKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;
86
100
  shouldCloseOnClickOutside: boolean;
@@ -143,24 +157,17 @@ function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
143
157
 
144
158
  interface HeaderActionsProps {
145
159
  isSaving: boolean;
146
- hasMedia: boolean;
147
- hasChanges: boolean;
148
160
  isImage: boolean;
149
161
  showCloseButton?: boolean;
150
162
  onCancel: () => void;
151
- onSave: () => void;
152
163
  }
153
164
 
154
165
  function HeaderActions( {
155
166
  isSaving,
156
- hasMedia,
157
- hasChanges,
158
167
  isImage,
159
168
  showCloseButton = false,
160
169
  onCancel,
161
- onSave,
162
170
  }: HeaderActionsProps ) {
163
- const saveDisabled = isSaving || ! hasMedia || ! hasChanges;
164
171
  const [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );
165
172
  return (
166
173
  <Flex
@@ -178,8 +185,130 @@ function HeaderActions( {
178
185
  />
179
186
  ) }
180
187
  <PinnedItems.Slot scope="media-editor" />
188
+ { showCloseButton && (
189
+ <Button
190
+ size="compact"
191
+ icon={ close }
192
+ label={ __( 'Close' ) }
193
+ onClick={ onCancel }
194
+ disabled={ isSaving }
195
+ accessibleWhenDisabled
196
+ />
197
+ ) }
198
+ { isShortcutsModalOpen && (
199
+ <MediaEditorKeyboardShortcutsModal
200
+ onClose={ () => setIsShortcutsModalOpen( false ) }
201
+ />
202
+ ) }
203
+ </Flex>
204
+ );
205
+ }
206
+
207
+ interface HistoryActionsProps {
208
+ isUndoRedoDisabled?: boolean;
209
+ onReset: () => void;
210
+ }
211
+
212
+ function HistoryActions( {
213
+ isUndoRedoDisabled = false,
214
+ onReset,
215
+ }: HistoryActionsProps ) {
216
+ const {
217
+ reset,
218
+ isDirty,
219
+ hasUndo,
220
+ hasRedo,
221
+ undo: undoCrop,
222
+ redo: redoCrop,
223
+ beginGesture,
224
+ endGesture,
225
+ } = useMediaEditor();
226
+ const handleUndo = () => {
227
+ if ( isUndoRedoDisabled ) {
228
+ return;
229
+ }
230
+ undoCrop();
231
+ };
232
+ const handleRedo = () => {
233
+ if ( isUndoRedoDisabled ) {
234
+ return;
235
+ }
236
+ redoCrop();
237
+ };
238
+ const handleReset = () => {
239
+ beginGesture();
240
+ reset();
241
+ onReset();
242
+ endGesture();
243
+ };
244
+ return (
245
+ <Flex
246
+ className="media-editor__history-actions"
247
+ expanded={ false }
248
+ gap={ 2 }
249
+ >
250
+ <Button
251
+ size="compact"
252
+ icon={ undo }
253
+ label={ __( 'Undo' ) }
254
+ showTooltip
255
+ shortcut={ displayShortcut.primary( 'z' ) }
256
+ disabled={ isUndoRedoDisabled || ! hasUndo }
257
+ accessibleWhenDisabled
258
+ onClick={ handleUndo }
259
+ />
181
260
  <Button
182
261
  size="compact"
262
+ icon={ redo }
263
+ label={ __( 'Redo' ) }
264
+ showTooltip
265
+ shortcut={
266
+ isAppleOS()
267
+ ? displayShortcut.primaryShift( 'z' )
268
+ : displayShortcut.primary( 'y' )
269
+ }
270
+ disabled={ isUndoRedoDisabled || ! hasRedo }
271
+ accessibleWhenDisabled
272
+ onClick={ handleRedo }
273
+ />
274
+ <Button
275
+ size="compact"
276
+ variant="tertiary"
277
+ disabled={ ! isDirty }
278
+ accessibleWhenDisabled
279
+ onClick={ handleReset }
280
+ >
281
+ { __( 'Reset' ) }
282
+ </Button>
283
+ </Flex>
284
+ );
285
+ }
286
+
287
+ interface FooterActionsProps {
288
+ isSaving: boolean;
289
+ hasMedia: boolean;
290
+ hasChanges: boolean;
291
+ onCancel: () => void;
292
+ onSave: () => void;
293
+ }
294
+
295
+ function FooterActions( {
296
+ isSaving,
297
+ hasMedia,
298
+ hasChanges,
299
+ onCancel,
300
+ onSave,
301
+ }: FooterActionsProps ) {
302
+ const saveDisabled = isSaving || ! hasMedia || ! hasChanges;
303
+ return (
304
+ <Flex
305
+ className="media-editor__footer-actions"
306
+ justify="flex-end"
307
+ expanded={ false }
308
+ gap={ 2 }
309
+ >
310
+ <Button
311
+ __next40pxDefaultSize
183
312
  variant="tertiary"
184
313
  onClick={ onCancel }
185
314
  disabled={ isSaving }
@@ -188,7 +317,7 @@ function HeaderActions( {
188
317
  { __( 'Cancel' ) }
189
318
  </Button>
190
319
  <Button
191
- size="compact"
320
+ __next40pxDefaultSize
192
321
  variant="primary"
193
322
  onClick={ onSave }
194
323
  isBusy={ isSaving }
@@ -197,21 +326,6 @@ function HeaderActions( {
197
326
  >
198
327
  { __( 'Save' ) }
199
328
  </Button>
200
- { showCloseButton && (
201
- <Button
202
- size="compact"
203
- icon={ close }
204
- label={ __( 'Close' ) }
205
- onClick={ onCancel }
206
- disabled={ isSaving }
207
- accessibleWhenDisabled
208
- />
209
- ) }
210
- { isShortcutsModalOpen && (
211
- <MediaEditorKeyboardShortcutsModal
212
- onClose={ () => setIsShortcutsModalOpen( false ) }
213
- />
214
- ) }
215
329
  </Flex>
216
330
  );
217
331
  }
@@ -229,6 +343,19 @@ function MediaEditorContent( {
229
343
  shouldCloseOnEsc = false,
230
344
  }: MediaEditorProps ) {
231
345
  const cropper = useMediaEditor();
346
+ // Three footer layouts, picked from the viewport so DOM order matches
347
+ // visual order in all three (no `order` reshuffling needed):
348
+ // wide (≥ xlarge): single row.
349
+ // medium (≥ medium): ruler on top; rest beneath.
350
+ // narrow (< medium): ruler, then transform centered, then history/save.
351
+ const isWideViewport = useViewportMatch( 'xlarge' );
352
+ const isMediumViewport = useViewportMatch( 'medium' );
353
+ let footerLayout: 'wide' | 'medium' | 'narrow' = 'narrow';
354
+ if ( isWideViewport ) {
355
+ footerLayout = 'wide';
356
+ } else if ( isMediumViewport ) {
357
+ footerLayout = 'medium';
358
+ }
232
359
 
233
360
  const { media, hasEdits } = useSelect(
234
361
  ( select ) => {
@@ -273,9 +400,8 @@ function MediaEditorContent( {
273
400
  const [ isPlacementActive, setIsPlacementActive ] = useState( false );
274
401
  const [ isCanvasGestureActive, setIsCanvasGestureActive ] =
275
402
  useState( false );
276
- const placementControlTimerRef = useRef<
277
- ReturnType< typeof setTimeout > | undefined
278
- >( undefined );
403
+ const placementControlTimerRef =
404
+ useRef< ReturnType< typeof setTimeout > >();
279
405
 
280
406
  const signalPlacementControlInteraction = useCallback( () => {
281
407
  setIsPlacementActive( true );
@@ -321,8 +447,6 @@ function MediaEditorContent( {
321
447
  aspectRatioValue,
322
448
  setAspectRatioValue,
323
449
  aspectRatioOptions,
324
- freeformCrop,
325
- setFreeformCrop,
326
450
  resetCropOptions,
327
451
  } = useCropOptions( {
328
452
  aspectRatioPresets,
@@ -365,8 +489,6 @@ function MediaEditorContent( {
365
489
  <MediaEditorCropPanel
366
490
  aspectRatioValue={ aspectRatioValue }
367
491
  onAspectRatioChange={ setAspectRatioValue }
368
- freeformCrop={ freeformCrop }
369
- onFreeformChange={ setFreeformCrop }
370
492
  onPlacementControlInteraction={
371
493
  signalPlacementControlInteraction
372
494
  }
@@ -381,8 +503,6 @@ function MediaEditorContent( {
381
503
  isImage,
382
504
  aspectRatioValue,
383
505
  setAspectRatioValue,
384
- freeformCrop,
385
- setFreeformCrop,
386
506
  aspectRatioOptions,
387
507
  signalPlacementControlInteraction,
388
508
  ] );
@@ -478,7 +598,6 @@ function MediaEditorContent( {
478
598
  ? __( 'Image editor' )
479
599
  : __( 'Media preview' ),
480
600
  sidebar: __( 'Media details' ),
481
- footer: __( 'Image editing tools' ),
482
601
  } }
483
602
  content={
484
603
  <div className="media-editor__canvas">
@@ -500,19 +619,6 @@ function MediaEditorContent( {
500
619
  ) }
501
620
  </div>
502
621
  }
503
- footer={
504
- isImage ? (
505
- <MediaEditorToolbar
506
- onReset={ resetCropOptions }
507
- onPlacementControlInteraction={
508
- signalPlacementControlInteraction
509
- }
510
- isUndoRedoDisabled={
511
- isCropInteractionActive
512
- }
513
- />
514
- ) : undefined
515
- }
516
622
  sidebar={
517
623
  <ComplementaryArea.Slot scope="media-editor" />
518
624
  }
@@ -540,19 +646,82 @@ function MediaEditorContent( {
540
646
  </MediaEditorProvider>
541
647
  );
542
648
 
649
+ const history = isImage ? (
650
+ <HistoryActions
651
+ isUndoRedoDisabled={ isCropInteractionActive }
652
+ onReset={ resetCropOptions }
653
+ />
654
+ ) : null;
655
+ const ruler = isImage ? (
656
+ <MediaEditorFineRotation
657
+ onPlacementControlInteraction={ signalPlacementControlInteraction }
658
+ />
659
+ ) : null;
660
+ const transform = isImage ? <MediaEditorTransformControls /> : null;
661
+ const actions = (
662
+ <FooterActions
663
+ isSaving={ isSaving }
664
+ hasMedia={ !! media }
665
+ hasChanges={ hasChanges }
666
+ onCancel={ handleRequestClose }
667
+ onSave={ saveMediaEditor }
668
+ />
669
+ );
670
+
671
+ // One JSX tree per layout. DOM order matches visual order in all three.
672
+ // `.media-editor-modal__footer-toolbar` (wide only) groups ruler +
673
+ // transform with the centered cluster and divider that the wide layout
674
+ // has always had.
675
+ let footerActions: ReactNode;
676
+ if ( footerLayout === 'wide' ) {
677
+ footerActions = (
678
+ <>
679
+ { history }
680
+ { isImage && (
681
+ <div className="media-editor-modal__footer-toolbar">
682
+ { ruler }
683
+ { transform }
684
+ </div>
685
+ ) }
686
+ { actions }
687
+ </>
688
+ );
689
+ } else if ( footerLayout === 'medium' ) {
690
+ footerActions = (
691
+ <>
692
+ { ruler }
693
+ <div className="media-editor-modal__footer-row">
694
+ { history }
695
+ { transform }
696
+ { actions }
697
+ </div>
698
+ </>
699
+ );
700
+ } else {
701
+ footerActions = (
702
+ <>
703
+ { ruler }
704
+ { transform }
705
+ <div className="media-editor-modal__footer-row">
706
+ { history }
707
+ { actions }
708
+ </div>
709
+ </>
710
+ );
711
+ }
712
+
543
713
  return renderFrame( {
544
714
  children,
545
715
  headerActions: (
546
716
  <HeaderActions
547
717
  isSaving={ isSaving }
548
- hasMedia={ !! media }
549
- hasChanges={ hasChanges }
550
718
  isImage={ isImage }
551
719
  showCloseButton={ showCloseButton }
552
720
  onCancel={ handleRequestClose }
553
- onSave={ saveMediaEditor }
554
721
  />
555
722
  ),
723
+ footerActions,
724
+ footerLayout,
556
725
  onRequestClose: handleRequestClose,
557
726
  onKeyDown: handleKeyDown,
558
727
  shouldCloseOnClickOutside: ! hasChanges && ! isSaving,
@@ -33,15 +33,6 @@
33
33
  flex: 1;
34
34
  }
35
35
 
36
- .interface-interface-skeleton__footer {
37
- position: relative;
38
- display: flex;
39
- }
40
-
41
- .interface-interface-skeleton.has-footer .interface-interface-skeleton__body {
42
- padding-bottom: 0;
43
- }
44
-
45
36
  .media-editor__canvas {
46
37
  display: flex;
47
38
  align-items: center;
@@ -23,9 +23,6 @@ function CropOptionsHarness() {
23
23
  <div data-testid="aspect-ratio-value">
24
24
  { cropOptions.aspectRatioValue }
25
25
  </div>
26
- <div data-testid="freeform-crop">
27
- { cropOptions.freeformCrop ? 'true' : 'false' }
28
- </div>
29
26
  <div data-testid="resolved-aspect-ratio">
30
27
  { cropOptions.resolvedAspectRatio ?? 'undefined' }
31
28
  </div>
@@ -49,9 +46,6 @@ function CropOptionsHarness() {
49
46
  <button onClick={ () => cropOptions.setAspectRatioValue( '0' ) }>
50
47
  Free
51
48
  </button>
52
- <button onClick={ () => cropOptions.setFreeformCrop( false ) }>
53
- Disable handles
54
- </button>
55
49
  <button onClick={ cropOptions.resetCropOptions }>Reset</button>
56
50
  </div>
57
51
  );
@@ -103,62 +97,14 @@ describe( 'useCropOptions', () => {
103
97
  ).toHaveTextContent( 'undefined' );
104
98
  } );
105
99
 
106
- it( 'picking Free auto-enables freeform when it was off', () => {
100
+ it( 'reset returns cropOptions to defaults', () => {
107
101
  renderHarness();
108
102
 
109
- // Pick a non-Free preset and turn freeform off.
110
103
  fireEvent.click( screen.getByRole( 'button', { name: 'Square' } ) );
111
- fireEvent.click(
112
- screen.getByRole( 'button', { name: 'Disable handles' } )
113
- );
114
-
115
- expect( screen.getByTestId( 'freeform-crop' ) ).toHaveTextContent(
116
- 'false'
117
- );
118
- expect( screen.getByTestId( 'aspect-ratio-value' ) ).toHaveTextContent(
119
- '1'
120
- );
121
-
122
- // Picking Free re-enables freeform — picking Free implies the
123
- // user wants to freeform-edit and there'd otherwise be no
124
- // visible affordance.
125
- fireEvent.click( screen.getByRole( 'button', { name: 'Free' } ) );
126
-
127
- expect( screen.getByTestId( 'aspect-ratio-value' ) ).toHaveTextContent(
128
- '0'
129
- );
130
- expect( screen.getByTestId( 'freeform-crop' ) ).toHaveTextContent(
131
- 'true'
132
- );
133
- } );
134
-
135
- it( 'picking Free leaves freeform alone if it was already on', () => {
136
- renderHarness();
137
-
138
- // Start clean: freeform is true by default.
139
- fireEvent.click( screen.getByRole( 'button', { name: 'Square' } ) );
140
- // Don't turn freeform off — pick Free directly.
141
- fireEvent.click( screen.getByRole( 'button', { name: 'Free' } ) );
142
-
143
- expect( screen.getByTestId( 'freeform-crop' ) ).toHaveTextContent(
144
- 'true'
145
- );
146
- } );
147
-
148
- it( 'reset returns cropOptions to defaults (Free + freeform on)', () => {
149
- renderHarness();
150
-
151
- fireEvent.click( screen.getByRole( 'button', { name: 'Square' } ) );
152
- fireEvent.click(
153
- screen.getByRole( 'button', { name: 'Disable handles' } )
154
- );
155
104
  fireEvent.click( screen.getByRole( 'button', { name: 'Reset' } ) );
156
105
 
157
106
  expect( screen.getByTestId( 'aspect-ratio-value' ) ).toHaveTextContent(
158
107
  '0'
159
108
  );
160
- expect( screen.getByTestId( 'freeform-crop' ) ).toHaveTextContent(
161
- 'true'
162
- );
163
109
  } );
164
110
  } );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useCallback, useMemo } from '@wordpress/element';
4
+ import { useMemo } from '@wordpress/element';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -10,9 +10,6 @@ import { DEFAULT_ASPECT_RATIOS } from '../../image-editor/core/constants';
10
10
  import type { AspectRatioPreset } from '../../image-editor/core/constants';
11
11
  import { useMediaEditor, resolveAspectRatio } from '../../state';
12
12
 
13
- /** Preset key for "Free" — no aspect lock. Round-trips through SelectControl. */
14
- const FREE_ASPECT_RATIO_VALUE = '0';
15
-
16
13
  interface UseCropOptionsArgs {
17
14
  aspectRatioPresets?: AspectRatioPreset[];
18
15
  }
@@ -21,8 +18,6 @@ interface UseCropOptionsReturn {
21
18
  aspectRatioValue: string;
22
19
  setAspectRatioValue: ( value: string ) => void;
23
20
  aspectRatioOptions: AspectRatioPreset[];
24
- freeformCrop: boolean;
25
- setFreeformCrop: ( value: boolean ) => void;
26
21
  resolvedAspectRatio: number | undefined;
27
22
  resetCropOptions: () => void;
28
23
  }
@@ -47,9 +42,9 @@ export function getAspectRatioOptions(
47
42
 
48
43
  /**
49
44
  * Thin selector over the composite media-editor store for the Crop
50
- * sidebar tab. Reads the cropOptions slice (preset key, freeform) and
51
- * exposes the corresponding setters plus a render-time
52
- * `resolvedAspectRatio` derivation.
45
+ * sidebar tab. Reads the cropOptions slice (preset key) and exposes
46
+ * the corresponding setters plus a render-time `resolvedAspectRatio`
47
+ * derivation.
53
48
  *
54
49
  * No local React state, no refs, no synchronization effects — the
55
50
  * composite store is the single source of truth.
@@ -61,7 +56,7 @@ export function useCropOptions( {
61
56
  aspectRatioPresets,
62
57
  }: UseCropOptionsArgs = {} ): UseCropOptionsReturn {
63
58
  const controller = useMediaEditor();
64
- const { aspectRatioValue, freeformCrop } = controller.cropOptions;
59
+ const { aspectRatioValue } = controller.cropOptions;
65
60
  const cropperImage = controller.state.image;
66
61
 
67
62
  const aspectRatioOptions = useMemo(
@@ -74,41 +69,10 @@ export function useCropOptions( {
74
69
  [ aspectRatioValue, cropperImage ]
75
70
  );
76
71
 
77
- // Sidebar UX rule: picking Free auto-enables Resize-crop (freeform)
78
- // when it's currently off — picking Free implies the user wants to
79
- // freeform-edit, and there'd otherwise be no visible affordance for
80
- // it. Wrapped in a gesture so the two dispatches collapse into a
81
- // single undo step.
82
- const { beginGesture, endGesture, setAspectRatioValue, setFreeformCrop } =
83
- controller;
84
- const setAspectRatioValueWithFreeformSync = useCallback(
85
- ( value: string ) => {
86
- const shouldReenableFreeform =
87
- value === FREE_ASPECT_RATIO_VALUE && ! freeformCrop;
88
- if ( ! shouldReenableFreeform ) {
89
- setAspectRatioValue( value );
90
- return;
91
- }
92
- beginGesture();
93
- setAspectRatioValue( value );
94
- setFreeformCrop( true );
95
- endGesture();
96
- },
97
- [
98
- freeformCrop,
99
- beginGesture,
100
- endGesture,
101
- setAspectRatioValue,
102
- setFreeformCrop,
103
- ]
104
- );
105
-
106
72
  return {
107
73
  aspectRatioValue,
108
- setAspectRatioValue: setAspectRatioValueWithFreeformSync,
74
+ setAspectRatioValue: controller.setAspectRatioValue,
109
75
  aspectRatioOptions,
110
- freeformCrop,
111
- setFreeformCrop: controller.setFreeformCrop,
112
76
  resolvedAspectRatio,
113
77
  resetCropOptions: controller.resetCropOptions,
114
78
  };
@@ -44,7 +44,7 @@ export default function MediaEditorCanvas( {
44
44
  }: MediaEditorCanvasProps ) {
45
45
  const { media } = useMediaEditorContext();
46
46
  const controller = useMediaEditor();
47
- const { aspectRatioValue, freeformCrop } = controller.cropOptions;
47
+ const { aspectRatioValue } = controller.cropOptions;
48
48
  const cropperImage = controller.state.image;
49
49
  const { beginGesture, endGesture, setImage } = controller;
50
50
 
@@ -100,7 +100,7 @@ export default function MediaEditorCanvas( {
100
100
  src={ mediaUrl }
101
101
  controller={ controller }
102
102
  aspectRatio={ aspectRatio }
103
- freeformCrop={ freeformCrop }
103
+ freeformCrop
104
104
  focusOnMount={ focusOnMount }
105
105
  showGrid="interactive"
106
106
  isPlacementActive={ isPlacementActive }