@wordpress/media-editor 0.16.0 → 0.17.2-next.v.202608281122.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.
- package/CHANGELOG.md +25 -1
- package/build/components/media-editor/index.cjs +188 -183
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor-canvas/index.cjs +0 -2
- package/build/components/media-editor-canvas/index.cjs.map +2 -2
- package/build/components/media-editor-crop-panel/index.cjs +2 -3
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build/components/media-editor-modal/index.cjs +16 -14
- package/build/components/media-editor-modal/index.cjs.map +3 -3
- package/build-module/components/media-editor/index.mjs +192 -190
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor-canvas/index.mjs +0 -2
- package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +2 -3
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-modal/index.mjs +16 -14
- package/build-module/components/media-editor-modal/index.mjs.map +2 -2
- package/build-style/style-rtl.css +62 -95
- package/build-style/style.css +62 -95
- package/build-types/components/media-editor/index.d.ts +39 -11
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor-canvas/index.d.ts +1 -4
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts +4 -11
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/global.d.ts +5 -0
- package/package.json +23 -22
- package/src/components/media-editor/index.tsx +381 -271
- package/src/components/media-editor/style.scss +136 -131
- package/src/components/media-editor-canvas/index.tsx +5 -9
- package/src/components/media-editor-crop-panel/index.tsx +4 -12
- package/src/components/media-editor-crop-panel/test/index.tsx +2 -10
- package/src/components/media-editor-modal/index.tsx +23 -12
- package/src/components/media-editor-modal/style.scss +14 -51
- package/src/image-editor/stories/rectangle-crop.story.tsx +15 -0
- package/tsconfig.build.json +26 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +23 -16
- package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -8
- package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -10
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@use "@wordpress/base-styles/breakpoints" as
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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:
|
|
51
|
-
//
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
77
|
-
|
|
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,111 +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
|
-
|
|
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
|
-
//
|
|
106
|
-
//
|
|
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.
|
|
107
146
|
@include break-small() {
|
|
108
|
-
|
|
147
|
+
flex: none;
|
|
148
|
+
width: var(--wpds-dimension-surface-width-sm);
|
|
109
149
|
}
|
|
110
150
|
}
|
|
111
151
|
|
|
112
|
-
.
|
|
113
|
-
|
|
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;
|
|
114
160
|
}
|
|
115
161
|
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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;
|
|
126
176
|
}
|
|
127
177
|
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
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.
|
|
131
182
|
.media-editor__panel {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
183
|
+
flex: 1;
|
|
184
|
+
min-height: 0;
|
|
185
|
+
overflow-y: auto;
|
|
186
|
+
padding-block: $grid-unit-30;
|
|
187
|
+
padding-inline: $grid-unit-30;
|
|
137
188
|
}
|
|
138
189
|
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
// When the sidebar is not a full page column, we offset the header to match the overall gutter.
|
|
149
|
-
@include break-small() {
|
|
150
|
-
margin-right: $grid-unit-30;
|
|
151
|
-
}
|
|
152
|
-
.components-button.has-icon {
|
|
153
|
-
padding: 0;
|
|
154
|
-
|
|
155
|
-
@include break-small() {
|
|
156
|
-
display: flex;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
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;
|
|
159
198
|
}
|
|
160
199
|
|
|
161
|
-
// `
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// the only way to beat an inline style). `:has(__fill)` scopes the changes
|
|
167
|
-
// to when the panel is actually open: the skeleton sidebar wrapper is always
|
|
168
|
-
// present (empty when closed), so touching it unconditionally would paint an
|
|
169
|
-
// empty box over the canvas.
|
|
170
|
-
|
|
171
|
-
// Column (small–medium): between 600px and 782px `ComplementaryArea` is
|
|
172
|
-
// still in its mobile mode (inline `100vw`, see above) and the skeleton
|
|
173
|
-
// sidebar is absolutely positioned, so pull the open panel back in-flow at
|
|
174
|
-
// the sidebar width to sit it beside the canvas as a column.
|
|
175
|
-
//
|
|
176
|
-
// Bounded *below* the medium breakpoint on purpose. From 782px up,
|
|
177
|
-
// `InterfaceSkeleton` already makes the sidebar a `position: relative`,
|
|
178
|
-
// `width: auto` column and `ComplementaryArea` animates its width to
|
|
179
|
-
// `$sidebar-width` — exactly like the main editor. Pinning the width with
|
|
180
|
-
// `!important` there would freeze that open/close tween (the panel would
|
|
181
|
-
// sit mounted and unchanged for the animation's duration, then pop in or
|
|
182
|
-
// out), so we leave it to the skeleton. Below 782px there's nothing to
|
|
183
|
-
// freeze: `ComplementaryArea` zeroes the animation duration in mobile mode.
|
|
184
|
-
@media (min-width: #{ breakpoints.$break-small }) and (max-width: #{ (breakpoints.$break-medium - 1) }) {
|
|
185
|
-
.interface-interface-skeleton__sidebar:has(.interface-complementary-area__fill) {
|
|
186
|
-
position: relative !important;
|
|
187
|
-
}
|
|
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;
|
|
188
205
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
206
|
+
@include break-small() {
|
|
207
|
+
display: flex;
|
|
208
|
+
margin: 0 0 0 $grid-unit-30;
|
|
192
209
|
}
|
|
193
210
|
}
|
|
194
211
|
|
|
195
|
-
// Overlay (< small): the open panel fills the modal width (it would
|
|
196
|
-
// otherwise shrink-wrap, since the inline `100vw` is overridden below).
|
|
197
|
-
@media (max-width: #{ (breakpoints.$break-small - 1) }) {
|
|
198
|
-
.interface-interface-skeleton__sidebar:has(.interface-complementary-area__fill) {
|
|
199
|
-
width: 100%;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.interface-complementary-area__fill,
|
|
203
|
-
.interface-complementary-area {
|
|
204
|
-
width: 100% !important;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
212
|
}
|
|
208
213
|
|
|
209
214
|
.media-editor__snackbar {
|
|
@@ -8,8 +8,6 @@ import { Cropper } from '../../image-editor';
|
|
|
8
8
|
import { useMediaEditor, resolveAspectRatio } from '../../state';
|
|
9
9
|
|
|
10
10
|
export interface MediaEditorCanvasProps {
|
|
11
|
-
/** Focus the crop area when the canvas mounts. */
|
|
12
|
-
focusOnMount?: boolean;
|
|
13
11
|
/** Whether external placement activity should reveal the grid. */
|
|
14
12
|
isPlacementActive?: boolean;
|
|
15
13
|
/** Fires when a canvas cropper gesture begins. */
|
|
@@ -27,13 +25,11 @@ export interface MediaEditorCanvasProps {
|
|
|
27
25
|
* guards can render a spinner or fall through to `<MediaPreview>`.
|
|
28
26
|
*
|
|
29
27
|
* @param props
|
|
30
|
-
* @param props.focusOnMount
|
|
31
28
|
* @param props.isPlacementActive
|
|
32
29
|
* @param props.onGestureStart
|
|
33
30
|
* @param props.onGestureEnd
|
|
34
31
|
*/
|
|
35
32
|
export default function MediaEditorCanvas( {
|
|
36
|
-
focusOnMount,
|
|
37
33
|
isPlacementActive = false,
|
|
38
34
|
onGestureStart,
|
|
39
35
|
onGestureEnd,
|
|
@@ -143,10 +139,11 @@ export default function MediaEditorCanvas( {
|
|
|
143
139
|
* The cropper stays mounted while loading (hidden behind the
|
|
144
140
|
* spinner) so the image decodes off-screen and reveals in one paint
|
|
145
141
|
* instead of streaming in top-to-bottom. Until it's revealed it's
|
|
146
|
-
* non-interactive (`pointer-events: none` in CSS)
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
142
|
+
* non-interactive (`pointer-events: none` in CSS).
|
|
143
|
+
*
|
|
144
|
+
* The crop area is never focused programmatically: the modal keeps
|
|
145
|
+
* initial focus on the dialog frame, and users reach the crop area
|
|
146
|
+
* by tabbing to it.
|
|
150
147
|
*/ }
|
|
151
148
|
<div
|
|
152
149
|
className={ clsx( 'media-editor-canvas__cropper', {
|
|
@@ -158,7 +155,6 @@ export default function MediaEditorCanvas( {
|
|
|
158
155
|
controller={ controller }
|
|
159
156
|
aspectRatio={ aspectRatio }
|
|
160
157
|
freeformCrop
|
|
161
|
-
focusOnMount={ focusOnMount && status === 'loaded' }
|
|
162
158
|
showGrid="interactive"
|
|
163
159
|
isPlacementActive={ isPlacementActive }
|
|
164
160
|
onGestureStart={ handleGestureStart }
|
|
@@ -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
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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
|
-
|
|
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( '
|
|
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(
|
|
62
|
+
setupCropPanel();
|
|
71
63
|
|
|
72
64
|
const rotate = screen.getByText( 'Rotate' );
|
|
73
65
|
const aspectRatio = screen.getByLabelText( 'Aspect ratio' );
|
|
@@ -26,6 +26,25 @@ interface MediaEditorModalProps {
|
|
|
26
26
|
aspectRatioPresets?: AspectRatioPreset[];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
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.
|
|
34
|
+
*/
|
|
35
|
+
function ModalFooter() {
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
className="media-editor-modal__footer"
|
|
39
|
+
role="region"
|
|
40
|
+
aria-label={ __( 'Editor actions' ) }
|
|
41
|
+
>
|
|
42
|
+
<MediaEditor.HistoryActions />
|
|
43
|
+
<MediaEditor.SaveActions />
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
29
48
|
export function MediaEditorModal( {
|
|
30
49
|
fields = [],
|
|
31
50
|
aspectRatioPresets,
|
|
@@ -71,7 +90,6 @@ export function MediaEditorModal( {
|
|
|
71
90
|
id={ id }
|
|
72
91
|
fields={ fields }
|
|
73
92
|
aspectRatioPresets={ aspectRatioPresets }
|
|
74
|
-
showCloseButton
|
|
75
93
|
shouldCloseOnEsc
|
|
76
94
|
noticesClassName="media-editor-modal__snackbar"
|
|
77
95
|
noticesPortalElement={ portalElement }
|
|
@@ -107,9 +125,6 @@ export function MediaEditorModal( {
|
|
|
107
125
|
} }
|
|
108
126
|
renderFrame={ ( {
|
|
109
127
|
children,
|
|
110
|
-
headerActions,
|
|
111
|
-
footerActions,
|
|
112
|
-
footerLayout,
|
|
113
128
|
onRequestClose,
|
|
114
129
|
onKeyDown,
|
|
115
130
|
shouldCloseOnClickOutside,
|
|
@@ -126,16 +141,12 @@ export function MediaEditorModal( {
|
|
|
126
141
|
shouldCloseOnClickOutside={ shouldCloseOnClickOutside }
|
|
127
142
|
onKeyDown={ onKeyDown }
|
|
128
143
|
onRequestClose={ onRequestClose }
|
|
129
|
-
headerActions={
|
|
144
|
+
headerActions={
|
|
145
|
+
<MediaEditor.HeaderActions showCloseButton />
|
|
146
|
+
}
|
|
130
147
|
>
|
|
131
148
|
{ children }
|
|
132
|
-
<
|
|
133
|
-
className={ `media-editor-modal__footer is-${ footerLayout }` }
|
|
134
|
-
role="region"
|
|
135
|
-
aria-label={ __( 'Editor actions' ) }
|
|
136
|
-
>
|
|
137
|
-
{ footerActions }
|
|
138
|
-
</div>
|
|
149
|
+
<ModalFooter />
|
|
139
150
|
</Modal>
|
|
140
151
|
</ShortcutProvider>
|
|
141
152
|
) }
|
|
@@ -21,62 +21,21 @@
|
|
|
21
21
|
min-height: 0;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// Footer chrome
|
|
25
|
-
//
|
|
26
|
-
//
|
|
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
|
-
|
|
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 `FooterActions`).
|
|
50
|
-
.media-editor__footer-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
|
-
|
|
79
|
-
.
|
|
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`).
|
|
38
|
+
.media-editor__save-actions {
|
|
80
39
|
margin-left: auto;
|
|
81
40
|
}
|
|
82
41
|
}
|
|
@@ -85,9 +44,13 @@
|
|
|
85
44
|
// they read as live alongside the Reset/Cancel/Save actions. Disabled
|
|
86
45
|
// buttons (rendered with `aria-disabled` via `accessibleWhenDisabled`)
|
|
87
46
|
// keep the default muted icon colour.
|
|
47
|
+
// Scoped to the modal: the package ships one stylesheet, so an unscoped
|
|
48
|
+
// selector would also colour the history cluster in frames that place it in
|
|
49
|
+
// their own chrome (the wp-admin route puts it in the page header, where the
|
|
50
|
+
// neutral icon colour matches the header's other buttons).
|
|
88
51
|
// NOTE: overrides @wordpress/components Button internals (`.components-button`,
|
|
89
52
|
// `.has-icon`), scoped to our history-actions wrapper. Update if renamed.
|
|
90
|
-
.media-editor__history-actions .components-button.has-icon:not([aria-disabled="true"]) {
|
|
53
|
+
.media-editor-modal .media-editor__history-actions .components-button.has-icon:not([aria-disabled="true"]) {
|
|
91
54
|
color: var(--wp-admin-theme-color);
|
|
92
55
|
}
|
|
93
56
|
|
|
@@ -148,6 +148,11 @@ const DefaultComponent = () => {
|
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
export const Default: Story = {
|
|
151
|
+
parameters: {
|
|
152
|
+
// FIXME: Image credit text and its link fail color-contrast.
|
|
153
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
154
|
+
a11y: { test: 'todo' },
|
|
155
|
+
},
|
|
151
156
|
render: DefaultComponent,
|
|
152
157
|
};
|
|
153
158
|
|
|
@@ -511,6 +516,11 @@ const WithControlsComponent = () => {
|
|
|
511
516
|
};
|
|
512
517
|
|
|
513
518
|
export const WithControls: Story = {
|
|
519
|
+
parameters: {
|
|
520
|
+
// FIXME: The state dump scrolls once its content overflows, and is not keyboard-accessible (scrollable-region-focusable). Whether it overflows depends on the numbers rendered, so this appears intermittently.
|
|
521
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
522
|
+
a11y: { test: 'todo' },
|
|
523
|
+
},
|
|
514
524
|
render: WithControlsComponent,
|
|
515
525
|
};
|
|
516
526
|
|
|
@@ -1053,5 +1063,10 @@ aspect ratio: ${ ( sourceRegion.width / sourceRegion.height ).toFixed( 2 ) }
|
|
|
1053
1063
|
};
|
|
1054
1064
|
|
|
1055
1065
|
export const Debug: Story = {
|
|
1066
|
+
parameters: {
|
|
1067
|
+
// FIXME: Image credit text and its link fail color-contrast.
|
|
1068
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
1069
|
+
a11y: { test: 'todo' },
|
|
1070
|
+
},
|
|
1056
1071
|
render: DebugComponent,
|
|
1057
1072
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"extends": "../../tsconfig.base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"types": [ "gutenberg-env", "style-imports" ],
|
|
6
|
+
"checkJs": false
|
|
7
|
+
},
|
|
8
|
+
"references": [
|
|
9
|
+
{ "path": "../a11y/tsconfig.build.json" },
|
|
10
|
+
{ "path": "../admin-ui/tsconfig.build.json" },
|
|
11
|
+
{ "path": "../api-fetch/tsconfig.build.json" },
|
|
12
|
+
{ "path": "../components/tsconfig.build.json" },
|
|
13
|
+
{ "path": "../compose/tsconfig.build.json" },
|
|
14
|
+
{ "path": "../core-data/tsconfig.build.json" },
|
|
15
|
+
{ "path": "../data" },
|
|
16
|
+
{ "path": "../dataviews/tsconfig.build.json" },
|
|
17
|
+
{ "path": "../element/tsconfig.build.json" },
|
|
18
|
+
{ "path": "../i18n/tsconfig.build.json" },
|
|
19
|
+
{ "path": "../icons/tsconfig.build.json" },
|
|
20
|
+
{ "path": "../keyboard-shortcuts" },
|
|
21
|
+
{ "path": "../keycodes/tsconfig.build.json" },
|
|
22
|
+
{ "path": "../notices/tsconfig.build.json" },
|
|
23
|
+
{ "path": "../private-apis" },
|
|
24
|
+
{ "path": "../ui/tsconfig.build.json" }
|
|
25
|
+
]
|
|
26
|
+
}
|