@wordpress/media-editor 0.17.0 → 0.17.2-next.v.202609031004.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 (53) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/build/components/media-editor/index.cjs +152 -133
  3. package/build/components/media-editor/index.cjs.map +3 -3
  4. package/build/components/media-editor-crop-panel/index.cjs +2 -3
  5. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  6. package/build/components/media-editor-modal/index.cjs +7 -21
  7. package/build/components/media-editor-modal/index.cjs.map +2 -2
  8. package/build-module/components/media-editor/index.mjs +154 -140
  9. package/build-module/components/media-editor/index.mjs.map +2 -2
  10. package/build-module/components/media-editor-crop-panel/index.mjs +2 -3
  11. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  12. package/build-module/components/media-editor-modal/index.mjs +9 -23
  13. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  14. package/build-style/style-rtl.css +66 -106
  15. package/build-style/style.css +66 -106
  16. package/build-types/components/media-editor/index.d.ts +7 -14
  17. package/build-types/components/media-editor/index.d.ts.map +1 -1
  18. package/build-types/components/media-editor-crop-panel/index.d.ts +4 -11
  19. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  20. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  21. package/package.json +21 -21
  22. package/src/components/media-editor/index.tsx +276 -200
  23. package/src/components/media-editor/style.scss +136 -134
  24. package/src/components/media-editor-crop-panel/index.tsx +4 -12
  25. package/src/components/media-editor-crop-panel/test/{index.tsx → index.jsdom.test.tsx} +2 -10
  26. package/src/components/media-editor-modal/index.tsx +9 -29
  27. package/src/components/media-editor-modal/style.scss +8 -49
  28. package/src/components/media-editor-modal/test/build-modifiers.test.ts +24 -14
  29. package/src/components/rotation-ruler/style.scss +1 -1
  30. package/src/image-editor/core/math/test/sanitize.ts +1 -0
  31. package/src/image-editor/core/test/camera.ts +2 -3
  32. package/src/image-editor/core/test/interaction-controller.ts +50 -40
  33. package/src/image-editor/core/test/preview-export-parity.ts +31 -23
  34. package/src/image-editor/core/test/render-camera-bridge.ts +1 -0
  35. package/src/image-editor/core/test/state.ts +1 -0
  36. package/src/image-editor/core/test/stencil-math.ts +1 -0
  37. package/src/image-editor/core/transforms/test/pipeline.ts +1 -0
  38. package/src/store/test/reducer.ts +9 -8
  39. package/tsconfig.build.json +1 -1
  40. package/tsconfig.build.tsbuildinfo +1 -1
  41. package/tsconfig.json +3 -3
  42. /package/src/components/media-editor/test/{use-crop-options.tsx → use-crop-options.jsdom.test.tsx} +0 -0
  43. /package/src/components/media-editor-image-controls/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  44. /package/src/components/media-editor-modal/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  45. /package/src/components/rotation-ruler/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  46. /package/src/image-editor/core/export/test/{canvas-renderer.ts → canvas-renderer.jsdom.test.ts} +0 -0
  47. /package/src/image-editor/react/components/stencils/test/{rectangle-stencil.tsx → rectangle-stencil.jsdom.test.tsx} +0 -0
  48. /package/src/image-editor/react/components/test/{cropper.tsx → cropper.jsdom.test.tsx} +0 -0
  49. /package/src/image-editor/react/hooks/test/{use-aria-announcer.ts → use-aria-announcer.jsdom.test.ts} +0 -0
  50. /package/src/image-editor/react/hooks/test/{use-cropper-reducer.ts → use-cropper-reducer.jsdom.test.ts} +0 -0
  51. /package/src/image-editor/react/hooks/test/{use-interaction.ts → use-interaction.jsdom.test.ts} +0 -0
  52. /package/src/image-editor/react/hooks/test/{use-transform-style.ts → use-transform-style.jsdom.test.ts} +0 -0
  53. /package/src/state/test/{use-media-editor-state.ts → use-media-editor-state.jsdom.test.ts} +0 -0
@@ -1,4 +1,4 @@
1
- @use "@wordpress/base-styles/breakpoints" as breakpoints;
1
+ @use "@wordpress/base-styles/breakpoints" as *;
2
2
  @use "@wordpress/base-styles/colors" as *;
3
3
  @use "@wordpress/base-styles/mixins" as *;
4
4
  @use "@wordpress/base-styles/variables" as *;
@@ -17,72 +17,96 @@
17
17
  justify-content: center;
18
18
  }
19
19
 
20
- .interface-interface-skeleton {
21
- position: relative;
22
- top: auto;
23
- right: auto;
24
- bottom: auto;
25
- left: auto;
26
- height: 100%;
27
- max-height: none;
28
- flex: 1;
29
- flex-direction: column;
30
- }
31
-
32
- // The skeleton must always sit in the modal's flow (`top: auto`). The reset
33
- // above sets that, but `@wordpress/interface` offsets every
34
- // `.interface-interface-skeleton` below the admin bar in fullscreen mode via
35
- // `.is-fullscreen-mode .interface-interface-skeleton { top: ... }`. That
36
- // selector ties the reset's specificity, so source order lets it win and
37
- // pushes the editor (and the fine-rotation ruler under the canvas) down
38
- // inside our full-screen modal that already overlays the admin bar.
39
- // Re-assert `top` at a specificity that beats it, anchored on the modal
40
- // frame (`.media-editor` only ever renders inside `.media-editor-modal`).
41
- .media-editor-modal & .interface-interface-skeleton.interface-interface-skeleton {
42
- top: auto;
43
- }
44
-
45
- .interface-interface-skeleton__editor {
46
- min-width: 0;
20
+ // The media editor owns this layout rather than borrowing
21
+ // `InterfaceSkeleton`, whose header/footer/secondary-sidebar slots,
22
+ // distraction-free mode and admin-bar offsets were all unused here and had
23
+ // to be reset in CSS.
24
+ //
25
+ // Below `small` one view fills it at a time, switched from the header.
26
+ // From `small` up the canvas and the panel are columns side by side.
27
+ //
28
+ // A containment context, so the canvas can size itself against the room
29
+ // it actually has rather than the viewport. The two differ by whatever
30
+ // chrome the host puts beside the editor: none in the modal, but 160px
31
+ // of wp-admin menu in the route until it folds at 960px.
32
+ .media-editor__body {
33
+ container-type: inline-size;
34
+ container-name: media-editor-body;
35
+ display: flex;
47
36
  flex: 1;
37
+ min-height: 0;
48
38
  }
49
39
 
50
- // Canvas column: image fills the available height; in panel mode the
51
- // fine-rotation ruler sits directly beneath it.
40
+ // Canvas column: the grey stage on top, the controls that act on it
41
+ // beneath. The column itself is transparent — only the stage is grey.
52
42
  .media-editor__content {
53
43
  display: flex;
54
44
  flex: 1;
55
45
  flex-direction: column;
46
+ min-width: 0;
56
47
  min-height: 0;
57
- // Inset the canvas + fine-rotation ruler as one rounded grey panel
58
- // with a horizontal-only gutter. The ruler is always a child here
59
- // (never the footer), so the two share a container and the panel is
60
- // fully rounded at every viewport.
61
- margin: 0 $grid-unit-30;
62
- border-radius: $radius-large;
63
- overflow: hidden;
48
+ margin: $grid-unit-30 $grid-unit-30 $grid-unit-10 $grid-unit-30;
49
+
50
+ // The panel docks from `small`, so between there and `large` the
51
+ // canvas takes whatever the 320px panel leaves — about 200px at
52
+ // 600px, 380px at 782px. Cramped, but a cramped preview beside
53
+ // reachable controls beats a panel that hides the image outright.
54
+ @include break-small() {
55
+ margin: 0 $grid-unit-30;
56
+ }
57
+
58
+ // Promise the canvas a floor only where the body is wide enough to
59
+ // keep it: 520px canvas + 320px panel + this column's 24px gutter.
60
+ // Asking for it below that pushes the layout past its container
61
+ // instead of shrinking the canvas, which is what put a scrollbar on
62
+ // the route between 961px and 1024px — wide enough for the floor by
63
+ // viewport, but not once the wp-admin menu had taken its 160px.
64
+ @container media-editor-body (min-width: #{520px + 320px + $grid-unit-30}) {
65
+ min-width: 520px;
66
+ }
64
67
  }
65
68
 
69
+ // The fine-rotation ruler and, below `small`, the rotate/flip/zoom
70
+ // controls: ruler on top, controls below, centred. Sized to its content
71
+ // (`flex: 0 0 auto`) so the stage above keeps every pixel the toolbar
72
+ // doesn't need. Transparent itself — only the ruler takes the grey.
66
73
  .media-editor__canvas-toolbar {
67
74
  display: flex;
68
- flex-shrink: 0;
69
- justify-content: center;
70
- // Share the canvas grey so the ruler strip blends into the same
71
- // surface as the area around the image.
72
- background: $gray-200;
73
- padding: $grid-unit-10 $grid-unit-20;
75
+ flex: 0 0 auto;
76
+ flex-direction: column;
77
+ align-items: center;
78
+ gap: $grid-unit-15;
74
79
 
80
+ // The ruler strip carries the canvas grey, as on trunk, so it reads as
81
+ // the same surface the image sits on: the band spans the column while
82
+ // the ruler itself is capped and centred within it. The controls
83
+ // below stay on the modal's own background — they act on the image
84
+ // but are not part of it.
75
85
  .media-editor-fine-rotation {
76
- flex: 0 1 360px;
77
- min-width: 0;
86
+ display: flex;
87
+ justify-content: center;
88
+ align-self: stretch;
89
+ background: $gray-200;
90
+ border-radius: 0 0 $radius-large $radius-large;
91
+ padding: $grid-unit-10 $grid-unit-20;
92
+
93
+ // Trunk's measure for the ruler itself (`flex: 0 1 360px` there,
94
+ // where the strip was a row); the grey band around it spans.
95
+ .rotation-ruler {
96
+ flex: 0 1 360px;
97
+ min-width: 0;
98
+ }
78
99
  }
79
100
  }
80
101
 
102
+ // The stage: the surface the image sits on. Fully rounded on its own —
103
+ // non-image media has no ruler band beneath it (see `:has` below).
81
104
  .media-editor__canvas-area {
82
105
  display: flex;
83
106
  align-items: center;
84
107
  justify-content: center;
85
108
  background: $gray-200;
109
+ border-radius: $radius-large;
86
110
  overflow: auto;
87
111
  flex: 1;
88
112
  min-height: 0;
@@ -99,114 +123,92 @@
99
123
  }
100
124
  }
101
125
 
126
+ // Settings panel. Below `small` it takes the whole body: there is no room
127
+ // to put a 320px column beside a canvas worth looking at, and that is
128
+ // also where the transform controls fall back to a row under the canvas.
129
+ // From `small` up it docks as a column, so cropping and previewing happen
130
+ // together — the canvas is tight at the bottom of that range but present,
131
+ // where a full-screen panel would have hidden it completely.
102
132
  .media-editor__sidebar {
103
- @include reset;
133
+ display: flex;
134
+ flex: 1;
135
+ flex-direction: column;
136
+ min-width: 0;
137
+ min-height: 0;
138
+ // No scrolling here: the tab strip has to stay put while the fields
139
+ // move, so the open pane is the scroll container instead.
140
+ overflow: hidden;
104
141
 
105
- // Equal inline gutter so focus rings (outline + offset) and the zoom
106
- // slider thumb at its minimum sit inside the sidebar without shifting
107
- // the panel toward one edge. The complementary area uses overflow: auto
108
- // and the skeleton sidebar overflow: hidden, so a 1px-only left inset
109
- // still clips the 2px focus outline.
142
+ // The `sm` surface-width token, up from the 280px `$sidebar-width`
143
+ // this used to inherit: #81121 reports the panel reading as squished
144
+ // at roughly 250px, with four editable fields stacked above six
145
+ // read-only facts.
110
146
  @include break-small() {
111
- padding-inline: $grid-unit-10;
147
+ flex: none;
148
+ width: var(--wpds-dimension-surface-width-sm);
112
149
  }
113
150
  }
114
151
 
115
- .media-editor__sidebar-panel {
116
- padding-bottom: $grid-unit-30;
152
+ // The strip and the open pane, stacked. No inline padding: the pane below
153
+ // scrolls, and a gutter here would inset its scrollbar from the sidebar
154
+ // edge. The strip and the pane carry their own instead.
155
+ .media-editor__tabs {
156
+ display: flex;
157
+ flex: 1;
158
+ flex-direction: column;
159
+ min-height: 0;
117
160
  }
118
161
 
119
- // Borderless controls panel: clear the InterfaceSkeleton sidebar's
120
- // default top border, left box-shadow, and high-contrast outline so the
121
- // panel sits flush with no divider lines.
122
- // NOTE: overrides @wordpress/interface internals. The sidebar region has
123
- // no className prop, so this targets `interface-interface-skeleton__sidebar`
124
- // directly — update here if that class is renamed upstream.
125
- .interface-interface-skeleton__sidebar {
126
- border-top: 0;
127
- box-shadow: none;
128
- outline: 1px solid transparent;
162
+ // Wraps `Tabs.List`, which sizes itself to its tabs and so cannot carry a
163
+ // rule across the strip. A sibling of the scrolling pane rather than a
164
+ // sticky box inside it, so it holds its place without joining the scroll
165
+ // container — which is what lets the pane's scrollbar reach the edge.
166
+ //
167
+ // Margin, not padding: the rule below is drawn on this box's edge, so an
168
+ // inset from inside would still run the sidebar's full width. The margin
169
+ // pulls the box in instead, ending the rule where the tabs and the fields
170
+ // below it start.
171
+ .media-editor__tablist {
172
+ flex-shrink: 0;
173
+ margin-inline: $grid-unit-30;
174
+ background: $white;
175
+ border-bottom: $border-width solid $gray-300;
129
176
  }
130
177
 
131
- // Below `small` the sidebar is a full-width overlay, so the panel carries
132
- // its own all-around gutter. From `small` up it's the right-hand column and
133
- // drops its left/bottom padding (the sidebar supplies the left gutter).
178
+ // The scrolling pane. Full width so its scrollbar sits against the
179
+ // sidebar edge; the gutter is padding here rather than margin so the
180
+ // scrollbar stays outside it. Matches the canvas column's inline margin,
181
+ // so the fields line up with the image when the panel is closed.
134
182
  .media-editor__panel {
135
- padding: $grid-unit-20;
136
-
137
- @include break-small() {
138
- padding: $grid-unit-30 $grid-unit-30 0 0;
139
- }
183
+ flex: 1;
184
+ min-height: 0;
185
+ overflow-y: auto;
186
+ padding-block: $grid-unit-30;
187
+ padding-inline: $grid-unit-30;
140
188
  }
141
189
 
142
- // NOTE: overrides @wordpress/components Panel/Button internals to align
143
- // the sidebar header (tabs + close button). Targets their classes
144
- // directly; update here if they are renamed upstream.
145
- .components-panel__header.media-editor__sidebar-header {
146
- padding-left: 0;
147
- padding-right: $grid-unit-10;
148
- margin-right: $grid-unit-30;
149
- margin-right: 0;
150
-
151
- // When the sidebar is not a full page column, we offset the header to match the overall gutter.
152
- @include break-small() {
153
- margin-right: $grid-unit-30;
154
- }
155
- .components-button.has-icon {
156
- padding: 0;
157
-
158
- @include break-small() {
159
- display: flex;
160
- }
161
- }
190
+ // The ruler band shares the canvas grey and sits flush under it, so the
191
+ // two are one panel with four rounded corners rather than two stacked
192
+ // cards: the canvas gives up its bottom corners and the band takes them.
193
+ // Keyed on the band actually being there — non-image media has no ruler,
194
+ // and its canvas stays rounded all round.
195
+ .media-editor__content:has(.media-editor-fine-rotation) .media-editor__canvas-area {
196
+ border-end-start-radius: 0;
197
+ border-end-end-radius: 0;
162
198
  }
163
199
 
164
- // `ComplementaryArea`'s "mobile" mode is hard-coded to the `medium`
165
- // breakpoint: below 782px it renders an animated fill wrapper and writes
166
- // `width: 100vw` inline on both it and the inner panel. We want the sidebar
167
- // to mirror InterfaceSkeleton's column/overlay collapse but shifted to
168
- // `small`, so we override that inline width by breakpoint (`!important` is
169
- // the only way to beat an inline style). `:has(__fill)` scopes the changes
170
- // to when the panel is actually open: the skeleton sidebar wrapper is always
171
- // present (empty when closed), so touching it unconditionally would paint an
172
- // empty box over the canvas.
173
-
174
- // Column (small–medium): between 600px and 782px `ComplementaryArea` is
175
- // still in its mobile mode (inline `100vw`, see above) and the skeleton
176
- // sidebar is absolutely positioned, so pull the open panel back in-flow at
177
- // the sidebar width to sit it beside the canvas as a column.
178
- //
179
- // Bounded *below* the medium breakpoint on purpose. From 782px up,
180
- // `InterfaceSkeleton` already makes the sidebar a `position: relative`,
181
- // `width: auto` column and `ComplementaryArea` animates its width to
182
- // `$sidebar-width` — exactly like the main editor. Pinning the width with
183
- // `!important` there would freeze that open/close tween (the panel would
184
- // sit mounted and unchanged for the animation's duration, then pop in or
185
- // out), so we leave it to the skeleton. Below 782px there's nothing to
186
- // freeze: `ComplementaryArea` zeroes the animation duration in mobile mode.
187
- @media (min-width: #{ breakpoints.$break-small }) and (max-width: #{ (breakpoints.$break-medium - 1) }) {
188
- .interface-interface-skeleton__sidebar:has(.interface-complementary-area__fill) {
189
- position: relative !important;
190
- }
200
+ // Below `small` an open panel owns the body, so the canvas steps aside
201
+ // rather than being squeezed into an unusable sliver. Keyed on any panel
202
+ // being open rather than on which one: no rule needs to tell them apart.
203
+ .media-editor__body.has-panel-open .media-editor__content {
204
+ display: none;
191
205
 
192
- .interface-complementary-area__fill,
193
- .interface-complementary-area {
194
- width: $sidebar-width !important;
206
+ @include break-small() {
207
+ display: flex;
208
+ margin: 0 0 0 $grid-unit-30;
195
209
  }
196
210
  }
197
211
 
198
- // Overlay (< small): the open panel fills the modal width (it would
199
- // otherwise shrink-wrap, since the inline `100vw` is overridden below).
200
- @media (max-width: #{ (breakpoints.$break-small - 1) }) {
201
- .interface-interface-skeleton__sidebar:has(.interface-complementary-area__fill) {
202
- width: 100%;
203
- }
204
-
205
- .interface-complementary-area__fill,
206
- .interface-complementary-area {
207
- width: 100% !important;
208
- }
209
- }
210
212
  }
211
213
 
212
214
  .media-editor__snackbar {
@@ -16,29 +16,21 @@ export interface MediaEditorCropPanelProps {
16
16
  onAspectRatioChange: ( value: string ) => void;
17
17
  /** Aspect-ratio presets to display in the selector. */
18
18
  aspectRatioOptions: AspectRatioPreset[];
19
- /**
20
- * When `true`, render the rotate/flip/zoom image controls at the top of
21
- * the panel. Used on wide viewports where the footer no longer carries
22
- * them.
23
- */
24
- showTransformControls?: boolean;
25
19
  }
26
20
 
27
21
  /**
28
- * Sidebar panel for crop controls. Renders the aspect-ratio selector, plus the
29
- * rotate/flip and zoom controls on wide viewports (these move to the footer
30
- * toolbar when the sidebar collapses).
22
+ * Sidebar panel for crop controls: rotate, flip and zoom above the
23
+ * aspect-ratio selector. Rendered where the panel docks; below that the
24
+ * transform controls sit under the canvas instead, placed by the editor.
31
25
  * @param props
32
26
  * @param props.aspectRatioValue
33
27
  * @param props.onAspectRatioChange
34
28
  * @param props.aspectRatioOptions
35
- * @param props.showTransformControls
36
29
  */
37
30
  export default function MediaEditorCropPanel( {
38
31
  aspectRatioValue,
39
32
  onAspectRatioChange,
40
33
  aspectRatioOptions,
41
- showTransformControls = false,
42
34
  }: MediaEditorCropPanelProps ) {
43
35
  return (
44
36
  // Tag the whole panel as a crop-control region so the modal's
@@ -52,7 +44,7 @@ export default function MediaEditorCropPanel( {
52
44
  <VisuallyHidden render={ <h2 /> }>
53
45
  { __( 'Crop options' ) }
54
46
  </VisuallyHidden>
55
- { showTransformControls && <MediaEditorImageControls withLabels /> }
47
+ <MediaEditorImageControls withLabels />
56
48
  <SelectControl
57
49
  label={ __( 'Aspect ratio' ) }
58
50
  value={ aspectRatioValue }
@@ -44,17 +44,9 @@ describe( 'MediaEditorCropPanel', () => {
44
44
  ).toBe( '0' );
45
45
  } );
46
46
 
47
- it( 'omits the image controls by default', () => {
47
+ it( 'renders rotate, flip and zoom controls', () => {
48
48
  setupCropPanel();
49
49
 
50
- expect( screen.queryByText( 'Rotate' ) ).not.toBeInTheDocument();
51
- expect( screen.queryByText( 'Flip' ) ).not.toBeInTheDocument();
52
- expect( screen.queryByText( 'Zoom' ) ).not.toBeInTheDocument();
53
- } );
54
-
55
- it( 'renders rotate, flip and zoom controls when showTransformControls is set', () => {
56
- setupCropPanel( { showTransformControls: true } );
57
-
58
50
  expect( screen.getByText( 'Rotate' ) ).toBeInTheDocument();
59
51
  expect( screen.getByText( 'Flip' ) ).toBeInTheDocument();
60
52
  expect( screen.getByText( 'Zoom' ) ).toBeInTheDocument();
@@ -67,7 +59,7 @@ describe( 'MediaEditorCropPanel', () => {
67
59
  } );
68
60
 
69
61
  it( 'renders the image controls above the aspect-ratio selector', () => {
70
- setupCropPanel( { showTransformControls: true } );
62
+ setupCropPanel();
71
63
 
72
64
  const rotate = screen.getByText( 'Rotate' );
73
65
  const aspectRatio = screen.getByLabelText( 'Aspect ratio' );
@@ -26,40 +26,21 @@ interface MediaEditorModalProps {
26
26
  aspectRatioPresets?: AspectRatioPreset[];
27
27
  }
28
28
 
29
- interface ModalFooterProps {
30
- layout: 'wide' | 'narrow';
31
- }
32
-
33
29
  /**
34
- * The modal's footer chrome. The fine-rotation ruler always lives under the
35
- * canvas (in `media-editor__content`), never here, so it stays constrained to
36
- * the canvas column at every viewport. One JSX tree per layout; DOM order
37
- * matches visual order.
30
+ * The modal's footer chrome. The fine-rotation ruler and the image controls
31
+ * both live under the canvas (in `media-editor__content`), never here, so the
32
+ * footer has one layout at every width: History on the left, Cancel/Save on
33
+ * the right.
38
34
  */
39
- function ModalFooter( { layout }: ModalFooterProps ) {
35
+ function ModalFooter() {
40
36
  return (
41
37
  <div
42
- className={ `media-editor-modal__footer is-${ layout }` }
38
+ className="media-editor-modal__footer"
43
39
  role="region"
44
40
  aria-label={ __( 'Editor actions' ) }
45
41
  >
46
- { layout === 'wide' ? (
47
- // Sidebar is a column: the image controls live in the Crop
48
- // panel, so the footer is just History + Cancel/Save.
49
- <>
50
- <MediaEditor.HistoryActions />
51
- <MediaEditor.SaveActions />
52
- </>
53
- ) : (
54
- // Sidebar collapsed: the image controls drop into the footer.
55
- <>
56
- <MediaEditor.ImageControls />
57
- <div className="media-editor-modal__footer-row">
58
- <MediaEditor.HistoryActions />
59
- <MediaEditor.SaveActions />
60
- </div>
61
- </>
62
- ) }
42
+ <MediaEditor.HistoryActions />
43
+ <MediaEditor.SaveActions />
63
44
  </div>
64
45
  );
65
46
  }
@@ -144,7 +125,6 @@ export function MediaEditorModal( {
144
125
  } }
145
126
  renderFrame={ ( {
146
127
  children,
147
- layout,
148
128
  onRequestClose,
149
129
  onKeyDown,
150
130
  shouldCloseOnClickOutside,
@@ -166,7 +146,7 @@ export function MediaEditorModal( {
166
146
  }
167
147
  >
168
148
  { children }
169
- <ModalFooter layout={ layout } />
149
+ <ModalFooter />
170
150
  </Modal>
171
151
  </ShortcutProvider>
172
152
  ) }
@@ -21,61 +21,20 @@
21
21
  min-height: 0;
22
22
  }
23
23
 
24
- // Footer chrome — two layouts driven by `is-wide` / `is-narrow` modifier
25
- // classes set from the media editor at the sidebar-collapse breakpoint.
26
- // Wide is a single flex row (History | Cancel/Save); narrow stacks via
27
- // `flex-direction: column` (image controls above the History |
28
- // Cancel/Save row). Each layout has its own JSX tree (not `order`
29
- // reshuffling, which the project's stylelint rule treats as an a11y red
30
- // flag), so DOM order always matches visual order.
24
+ // Footer chrome. The image controls live under the canvas at every viewport,
25
+ // so the footer has a single layout at every width: History on the left,
26
+ // Cancel/Save on the right.
31
27
  .media-editor-modal.components-modal__frame .media-editor-modal__footer {
32
28
  flex-shrink: 0;
33
29
  display: flex;
34
- gap: $grid-unit-20;
35
- // Borderless: sections are demarcated by the inset canvas panel and
36
- // spacing, not divider lines. 16px top / 32px sides / 24px bottom.
37
- padding: $grid-unit-20 $grid-unit-40 $grid-unit-30;
38
- background: $white;
39
- // Above the `.interface-interface-skeleton__sidebar` which has a z-index of 100000.
40
- z-index: z-index(".media-editor-modal__footer");
41
-
42
- &.is-wide {
43
- flex-direction: row;
44
- align-items: center;
45
-
46
- // Panel mode: the footer holds only History (left) and
47
- // Cancel/Save (right). `margin-left: auto` pins the actions to the
48
- // right edge whether or not History renders (e.g. non-image
49
- // attachments show only `SaveActions`).
50
- .media-editor__save-actions {
51
- margin-left: auto;
52
- }
53
- }
54
-
55
- &.is-narrow {
56
- flex-direction: column;
57
- }
58
-
59
- // Narrow only: image controls sit on their own row, centered.
60
- &.is-narrow > .media-editor-image-controls {
61
- align-self: center;
62
- }
63
- }
64
-
65
- // Secondary row used by medium (History + Image controls + Cancel/Save) and
66
- // narrow (History + Cancel/Save). `margin-left: auto` on the image controls
67
- // cluster and on Cancel/Save splits any free space — History gets the
68
- // left edge, Cancel/Save the right edge, and the image controls (when
69
- // present, i.e. medium only) approximately centers. Exact centering only
70
- // holds when History and Cancel/Save have matching widths; in practice
71
- // they're close enough that the offset is imperceptible.
72
- .media-editor-modal__footer-row {
73
- display: flex;
74
- flex-wrap: wrap;
30
+ flex-direction: row;
75
31
  align-items: center;
76
32
  gap: $grid-unit-20;
33
+ padding: $grid-unit-30;
34
+ background: $white;
77
35
 
78
- .media-editor-image-controls,
36
+ // `margin-left: auto` pins the actions to the right edge whether or not
37
+ // History renders (e.g. non-image attachments show only `SaveActions`).
79
38
  .media-editor__save-actions {
80
39
  margin-left: auto;
81
40
  }
@@ -52,6 +52,8 @@
52
52
  * `serverSourcePixel` to undo it, and add values to the grid in
53
53
  * `buildRows`. The probes don't need to change.
54
54
  */
55
+
56
+ import { describe, expect, it } from 'vitest';
55
57
  import { mat2d, vec2 } from 'gl-matrix';
56
58
  import { buildModifiers } from '../build-modifiers';
57
59
  import type { Modifier } from '../build-modifiers';
@@ -329,21 +331,29 @@ function outputSizeFor( modifiers: Modifier[], imageSize: Size ): Size {
329
331
  describe( 'buildModifiers ↔ Export-camera parity', () => {
330
332
  const rows = buildRows();
331
333
 
332
- it.each( rows )( '$label', ( { state, u, v } ) => {
333
- const modifiers = buildModifiers( state, IMAGE );
334
+ for ( const { label, state, u, v } of rows ) {
335
+ it( label, () => {
336
+ const modifiers = buildModifiers( state, IMAGE );
334
337
 
335
- // Output canvas is whatever the server would emit: the crop rect
336
- // if present, otherwise the full rotated AABB. This makes (u, v)
337
- // map to the same *output* pixel on both paths.
338
- const outputSize = outputSizeFor( modifiers, IMAGE );
338
+ // Output canvas is whatever the server would emit: the crop rect
339
+ // if present, otherwise the full rotated AABB. This makes (u, v)
340
+ // map to the same *output* pixel on both paths.
341
+ const outputSize = outputSizeFor( modifiers, IMAGE );
339
342
 
340
- const exported = exportSourcePixel( state, IMAGE, outputSize, u, v );
341
- const server = serverSourcePixel( modifiers, IMAGE, u, v );
343
+ const exported = exportSourcePixel(
344
+ state,
345
+ IMAGE,
346
+ outputSize,
347
+ u,
348
+ v
349
+ );
350
+ const server = serverSourcePixel( modifiers, IMAGE, u, v );
342
351
 
343
- // Tolerance of 1 source pixel. The two paths compose rotations
344
- // and scales in different orders, so sub-pixel disagreement is
345
- // expected from floating-point. Anything larger is a real bug.
346
- expect( server.x ).toBeCloseTo( exported.x, 0 );
347
- expect( server.y ).toBeCloseTo( exported.y, 0 );
348
- } );
352
+ // Tolerance of 1 source pixel. The two paths compose rotations
353
+ // and scales in different orders, so sub-pixel disagreement is
354
+ // expected from floating-point. Anything larger is a real bug.
355
+ expect( server.x ).toBeCloseTo( exported.x, 0 );
356
+ expect( server.y ).toBeCloseTo( exported.y, 0 );
357
+ } );
358
+ }
349
359
  } );
@@ -47,7 +47,7 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
47
47
  margin: -1px;
48
48
  padding: 0;
49
49
  border: 0;
50
- clip: rect(0 0 0 0);
50
+ clip-path: inset(50%);
51
51
  overflow: hidden;
52
52
  white-space: nowrap;
53
53
  }
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import {
2
3
  isValidSize,
3
4
  safeBoundedNumber,
@@ -1,3 +1,5 @@
1
+ import { mat2d as m2d, vec2 } from 'gl-matrix';
2
+ import { describe, expect, it } from 'vitest';
1
3
  import {
2
4
  createCamera,
3
5
  worldToScreen,
@@ -302,7 +304,6 @@ describe( 'createExportCamera', () => {
302
304
  const state = makeState();
303
305
  const outputSize = { width: 400, height: 225 };
304
306
  const camera = createExportCamera( state, IMAGE, outputSize );
305
- const { vec2 } = require( 'gl-matrix' );
306
307
  const out = vec2.create();
307
308
  vec2.transformMat2d(
308
309
  out,
@@ -317,7 +318,6 @@ describe( 'createExportCamera', () => {
317
318
  const state = makeState();
318
319
  const outputSize = { width: IMAGE.width, height: IMAGE.height };
319
320
  const camera = createExportCamera( state, IMAGE, outputSize );
320
- const { vec2 } = require( 'gl-matrix' );
321
321
  const topLeft = vec2.create();
322
322
  vec2.transformMat2d( topLeft, [ 0, 0 ], camera );
323
323
  expect( topLeft[ 0 ] ).toBeCloseTo( 0, 0 );
@@ -381,7 +381,6 @@ describe( 'createExportCamera', () => {
381
381
  // output canvas.
382
382
  const outputSize = { width: 400, height: 300 };
383
383
  const exportCamera = createExportCamera( state, IMAGE, outputSize );
384
- const { mat2d: m2d, vec2 } = require( 'gl-matrix' );
385
384
  const inv = m2d.create();
386
385
  m2d.invert( inv, exportCamera );
387
386
  const exportPxVec = vec2.create();