@wordpress/media-editor 0.16.0 → 0.17.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 (36) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/build/components/media-editor/index.cjs +65 -79
  3. package/build/components/media-editor/index.cjs.map +3 -3
  4. package/build/components/media-editor-canvas/index.cjs +0 -2
  5. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  6. package/build/components/media-editor-modal/index.cjs +31 -15
  7. package/build/components/media-editor-modal/index.cjs.map +3 -3
  8. package/build-module/components/media-editor/index.mjs +67 -79
  9. package/build-module/components/media-editor/index.mjs.map +2 -2
  10. package/build-module/components/media-editor-canvas/index.mjs +0 -2
  11. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  12. package/build-module/components/media-editor-modal/index.mjs +31 -15
  13. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  14. package/build-style/style-rtl.css +4 -4
  15. package/build-style/style.css +4 -4
  16. package/build-types/components/media-editor/index.d.ts +46 -11
  17. package/build-types/components/media-editor/index.d.ts.map +1 -1
  18. package/build-types/components/media-editor-canvas/index.d.ts +1 -4
  19. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  20. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  21. package/global.d.ts +5 -0
  22. package/package.json +24 -22
  23. package/src/components/media-editor/index.tsx +152 -118
  24. package/src/components/media-editor/style.scss +6 -3
  25. package/src/components/media-editor-canvas/index.tsx +5 -9
  26. package/src/components/media-editor-modal/index.tsx +43 -12
  27. package/src/components/media-editor-modal/style.scss +8 -4
  28. package/src/image-editor/stories/rectangle-crop.story.tsx +15 -0
  29. package/tsconfig.build.json +26 -0
  30. package/tsconfig.build.tsbuildinfo +1 -0
  31. package/tsconfig.json +22 -15
  32. package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -8
  33. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
  34. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -10
  35. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
  36. package/tsconfig.tsbuildinfo +0 -1
@@ -8,8 +8,10 @@ import { useViewportMatch } from '@wordpress/compose';
8
8
  import { useDispatch, useSelect } from '@wordpress/data';
9
9
  import { store as coreStore } from '@wordpress/core-data';
10
10
  import {
11
+ createContext,
11
12
  createPortal,
12
13
  useCallback,
14
+ useContext,
13
15
  useEffect,
14
16
  useMemo,
15
17
  useRef,
@@ -68,18 +70,14 @@ interface EditorTab {
68
70
 
69
71
  export interface MediaEditorFrameProps {
70
72
  children: ReactNode;
71
- headerActions: ReactNode;
72
- footerActions: ReactNode;
73
73
  /**
74
- * Footer layout selector. Frames apply this to the footer container
75
- * as a modifier class. Tracks the sidebar-collapse breakpoint (`medium`).
76
- *
77
- * - `wide` — sidebar is a column; footer is a single row of History |
78
- * Cancel/Save (transform controls live in the Crop panel).
79
- * - `narrow` — sidebar collapsed; transform controls sit above a
80
- * History | Cancel/Save row.
74
+ * Whether the media being edited is an image. The history and transform
75
+ * clusters render nothing for other media types, so a frame uses this to
76
+ * decide whether the container it would put them in is worth rendering at
77
+ * all.
81
78
  */
82
- footerLayout: 'wide' | 'narrow';
79
+ isImage: boolean;
80
+ layout: 'wide' | 'narrow';
83
81
  onRequestClose: () => void;
84
82
  onKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;
85
83
  shouldCloseOnClickOutside: boolean;
@@ -97,24 +95,37 @@ export interface MediaEditorProps {
97
95
  renderFrame: ( props: MediaEditorFrameProps ) => JSX.Element;
98
96
  noticesClassName?: string;
99
97
  noticesPortalElement?: Element | null;
100
- showCloseButton?: boolean;
101
98
  shouldCloseOnEsc?: boolean;
99
+ /**
100
+ * The `@wordpress/interface` scope for the details sidebar and its pinned
101
+ * items. Frames should pass a distinct scope so that sidebar visibility —
102
+ * which is persisted per scope to user meta — is remembered separately for
103
+ * each surface. The modal is a transient surface where a collapsed sidebar
104
+ * is a reasonable choice; the full-screen route is one where the sidebar is
105
+ * the primary metadata surface and should open by default. Sharing a scope
106
+ * would let a choice made in one decide the other's starting state.
107
+ *
108
+ * @default 'media-editor'
109
+ */
110
+ scope?: string;
102
111
  }
103
112
 
104
113
  interface MediaEditorSidebarProps {
105
114
  tabs: EditorTab[];
106
115
  activeTabId?: string;
107
116
  onTabChange: ( tabId: string ) => void;
117
+ scope: string;
108
118
  }
109
119
 
110
120
  function MediaEditorSidebar( {
111
121
  tabs,
112
122
  activeTabId,
113
123
  onTabChange,
124
+ scope,
114
125
  }: MediaEditorSidebarProps ) {
115
126
  return (
116
127
  <ComplementaryArea
117
- scope="media-editor"
128
+ scope={ scope }
118
129
  identifier="media-editor/details"
119
130
  title={ __( 'Details' ) }
120
131
  icon={ drawerRight }
@@ -152,19 +163,57 @@ function MediaEditorSidebar( {
152
163
  );
153
164
  }
154
165
 
155
- interface HeaderActionsProps {
156
- isSaving: boolean;
166
+ /**
167
+ * Everything the frame's action clusters need from the editor. Supplied by
168
+ * context rather than by props so the clusters can be module-level components:
169
+ * a component created during a render has a new identity on every pass, which
170
+ * remounts its subtree and drops focus mid-interaction.
171
+ */
172
+ interface MediaEditorFrameContextValue {
157
173
  isImage: boolean;
158
- showCloseButton?: boolean;
174
+ isSaving: boolean;
175
+ hasMedia: boolean;
176
+ hasChanges: boolean;
177
+ isUndoRedoDisabled: boolean;
178
+ scope: string;
179
+ aspectRatioPresets?: AspectRatioPreset[];
159
180
  onCancel: () => void;
181
+ onSave: () => void;
182
+ onReset: () => void;
183
+ }
184
+
185
+ const MediaEditorFrameContext =
186
+ createContext< MediaEditorFrameContextValue | null >( null );
187
+
188
+ /**
189
+ * Hook to access the media editor's frame context.
190
+ *
191
+ * Must be used within a MediaEditor component.
192
+ *
193
+ * @return MediaEditorFrameContextValue the action clusters render from.
194
+ */
195
+ function useMediaEditorFrameContext(): MediaEditorFrameContextValue {
196
+ const context = useContext( MediaEditorFrameContext );
197
+ if ( ! context ) {
198
+ throw new Error(
199
+ 'useMediaEditorFrameContext must be used within MediaEditor'
200
+ );
201
+ }
202
+ return context;
160
203
  }
161
204
 
162
- function HeaderActions( {
163
- isSaving,
164
- isImage,
165
- showCloseButton = false,
166
- onCancel,
167
- }: HeaderActionsProps ) {
205
+ export interface HeaderActionsProps {
206
+ /**
207
+ * Whether to include a Close button. Frames with a dismissal affordance of
208
+ * their own — a route's breadcrumbs, say — leave it out.
209
+ *
210
+ * @default false
211
+ */
212
+ showCloseButton?: boolean;
213
+ }
214
+
215
+ function HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {
216
+ const { isImage, isSaving, onCancel, scope } = useMediaEditorFrameContext();
168
217
  const [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );
169
218
  return (
170
219
  <Stack
@@ -181,7 +230,7 @@ function HeaderActions( {
181
230
  onClick={ () => setIsShortcutsModalOpen( true ) }
182
231
  />
183
232
  ) }
184
- <PinnedItems.Slot scope="media-editor" />
233
+ <PinnedItems.Slot scope={ scope } />
185
234
  { showCloseButton && (
186
235
  <Button
187
236
  size="compact"
@@ -201,15 +250,9 @@ function HeaderActions( {
201
250
  );
202
251
  }
203
252
 
204
- interface HistoryActionsProps {
205
- isUndoRedoDisabled?: boolean;
206
- onReset: () => void;
207
- }
208
-
209
- function HistoryActions( {
210
- isUndoRedoDisabled = false,
211
- onReset,
212
- }: HistoryActionsProps ) {
253
+ function HistoryActions() {
254
+ const { isImage, isUndoRedoDisabled, onReset } =
255
+ useMediaEditorFrameContext();
213
256
  const {
214
257
  reset,
215
258
  isDirty,
@@ -220,6 +263,11 @@ function HistoryActions( {
220
263
  beginGesture,
221
264
  endGesture,
222
265
  } = useMediaEditor();
266
+ // Non-image media has no edit history. Checked after the hooks above so
267
+ // the hook order stays stable across renders.
268
+ if ( ! isImage ) {
269
+ return null;
270
+ }
223
271
  const handleUndo = () => {
224
272
  if ( isUndoRedoDisabled ) {
225
273
  return;
@@ -281,31 +329,30 @@ function HistoryActions( {
281
329
  );
282
330
  }
283
331
 
284
- interface FooterActionsProps {
285
- isSaving: boolean;
286
- hasMedia: boolean;
287
- hasChanges: boolean;
288
- onCancel: () => void;
289
- onSave: () => void;
332
+ export interface SaveActionsProps {
333
+ /**
334
+ * Button height. Footers take the 40px default; frames placing these in a
335
+ * page header pass `compact` to match the header's other controls.
336
+ *
337
+ * @default 'default'
338
+ */
339
+ size?: 'default' | 'compact';
290
340
  }
291
341
 
292
- function FooterActions( {
293
- isSaving,
294
- hasMedia,
295
- hasChanges,
296
- onCancel,
297
- onSave,
298
- }: FooterActionsProps ) {
342
+ function SaveActions( { size = 'default' }: SaveActionsProps ) {
343
+ const { isSaving, hasMedia, hasChanges, onCancel, onSave } =
344
+ useMediaEditorFrameContext();
299
345
  const saveDisabled = isSaving || ! hasMedia || ! hasChanges;
300
346
  return (
301
347
  <Stack
302
- className="media-editor__footer-actions"
348
+ className="media-editor__save-actions"
303
349
  justify="flex-end"
304
350
  align="center"
305
351
  gap="sm"
306
352
  >
307
353
  <Button
308
354
  __next40pxDefaultSize
355
+ size={ size }
309
356
  variant="tertiary"
310
357
  onClick={ onCancel }
311
358
  disabled={ isSaving }
@@ -315,6 +362,7 @@ function FooterActions( {
315
362
  </Button>
316
363
  <Button
317
364
  __next40pxDefaultSize
365
+ size={ size }
318
366
  variant="primary"
319
367
  onClick={ onSave }
320
368
  isBusy={ isSaving }
@@ -327,6 +375,22 @@ function FooterActions( {
327
375
  );
328
376
  }
329
377
 
378
+ function ImageControls() {
379
+ const { isImage, aspectRatioPresets } = useMediaEditorFrameContext();
380
+ // Non-image media has nothing to transform. Placement is the frame's call:
381
+ // render this only in the `narrow` layout, since above that breakpoint the
382
+ // Crop panel holds these controls already.
383
+ if ( ! isImage ) {
384
+ return null;
385
+ }
386
+ return (
387
+ <MediaEditorImageControls
388
+ showAspectRatioControl
389
+ aspectRatioPresets={ aspectRatioPresets }
390
+ />
391
+ );
392
+ }
393
+
330
394
  function MediaEditorContent( {
331
395
  fields = [],
332
396
  id,
@@ -336,19 +400,19 @@ function MediaEditorContent( {
336
400
  renderFrame,
337
401
  noticesClassName = 'media-editor__snackbar',
338
402
  noticesPortalElement,
339
- showCloseButton = false,
340
403
  shouldCloseOnEsc = false,
404
+ scope = 'media-editor',
341
405
  }: MediaEditorProps ) {
342
406
  const cropper = useMediaEditor();
343
407
  // The sidebar is a side column from the `small` breakpoint up and collapses
344
408
  // to an overlay below it — mirroring InterfaceSkeleton's behaviour, shifted
345
409
  // from `medium` to `small` (see the matching CSS overrides in style.scss).
346
410
  // Track that single breakpoint: in "panel mode" (≥ small) the
347
- // rotate/flip/zoom controls live in the Crop panel and the footer is just
348
- // History + Cancel/Save; below it the controls drop into the footer. (The
349
- // fine-rotation ruler always sits under the canvas.)
411
+ // rotate/flip/zoom controls live in the Crop panel; below it they have no
412
+ // panel to live in and the frame places them instead. (The fine-rotation
413
+ // ruler always sits under the canvas.)
350
414
  const isPanelLayout = useViewportMatch( 'small' );
351
- const footerLayout: 'wide' | 'narrow' = isPanelLayout ? 'wide' : 'narrow';
415
+ const layout: 'wide' | 'narrow' = isPanelLayout ? 'wide' : 'narrow';
352
416
 
353
417
  const { media, hasEdits } = useSelect(
354
418
  ( select ) => {
@@ -596,6 +660,7 @@ function MediaEditorContent( {
596
660
  tabs={ tabs }
597
661
  activeTabId={ activeTabId }
598
662
  onTabChange={ setSelectedTabId }
663
+ scope={ scope }
599
664
  />
600
665
  <InterfaceSkeleton
601
666
  className="media-editor__skeleton"
@@ -610,7 +675,6 @@ function MediaEditorContent( {
610
675
  <div className="media-editor__canvas-area">
611
676
  { isImage ? (
612
677
  <MediaEditorCanvas
613
- focusOnMount
614
678
  isPlacementActive={
615
679
  isPlacementActive
616
680
  }
@@ -633,7 +697,7 @@ function MediaEditorContent( {
633
697
  </div>
634
698
  }
635
699
  sidebar={
636
- <ComplementaryArea.Slot scope="media-editor" />
700
+ <ComplementaryArea.Slot scope={ scope } />
637
701
  }
638
702
  />
639
703
  </>
@@ -659,74 +723,36 @@ function MediaEditorContent( {
659
723
  </MediaEditorProvider>
660
724
  );
661
725
 
662
- const history = isImage ? (
663
- <HistoryActions
664
- isUndoRedoDisabled={ isCropInteractionActive }
665
- onReset={ resetCropOptions }
666
- />
667
- ) : null;
668
- const imageControls = isImage ? (
669
- <MediaEditorImageControls
670
- showAspectRatioControl
671
- aspectRatioPresets={ aspectRatioPresets }
672
- />
673
- ) : null;
674
- const actions = (
675
- <FooterActions
676
- isSaving={ isSaving }
677
- hasMedia={ !! media }
678
- hasChanges={ hasChanges }
679
- onCancel={ handleRequestClose }
680
- onSave={ saveMediaEditor }
681
- />
682
- );
683
-
684
- // The fine-rotation ruler always lives under the canvas (in
685
- // `media-editor__content`), never the footer, so it stays constrained to
686
- // the canvas column at every viewport. One JSX tree per layout; DOM order
687
- // matches visual order.
688
- let footerActions: ReactNode;
689
- if ( footerLayout === 'wide' ) {
690
- // Sidebar is a column: image controls live in the Crop panel, so
691
- // the footer is just History + Cancel/Save.
692
- footerActions = (
693
- <>
694
- { history }
695
- { actions }
696
- </>
697
- );
698
- } else {
699
- // Sidebar collapsed: the image controls drop into the footer.
700
- footerActions = (
701
- <>
702
- { imageControls }
703
- <div className="media-editor-modal__footer-row">
704
- { history }
705
- { actions }
706
- </div>
707
- </>
708
- );
709
- }
710
-
711
- return renderFrame( {
712
- children,
713
- headerActions: (
714
- <HeaderActions
715
- isSaving={ isSaving }
716
- isImage={ isImage }
717
- showCloseButton={ showCloseButton }
718
- onCancel={ handleRequestClose }
719
- />
720
- ),
721
- footerActions,
722
- footerLayout,
723
- onRequestClose: handleRequestClose,
724
- onKeyDown: handleKeyDown,
725
- shouldCloseOnClickOutside: ! hasChanges && ! isSaving,
726
+ // Rebuilt each render, like the elements it replaces: consumers re-render
727
+ // as they always did, but the cluster component types stay stable.
728
+ const contextValue: MediaEditorFrameContextValue = {
729
+ isImage,
726
730
  isSaving,
727
- hasChanges,
728
731
  hasMedia: !! media,
729
- } );
732
+ hasChanges,
733
+ isUndoRedoDisabled: isCropInteractionActive,
734
+ scope,
735
+ aspectRatioPresets,
736
+ onCancel: handleRequestClose,
737
+ onSave: saveMediaEditor,
738
+ onReset: resetCropOptions,
739
+ };
740
+
741
+ return (
742
+ <MediaEditorFrameContext.Provider value={ contextValue }>
743
+ { renderFrame( {
744
+ children,
745
+ isImage,
746
+ layout,
747
+ onRequestClose: handleRequestClose,
748
+ onKeyDown: handleKeyDown,
749
+ shouldCloseOnClickOutside: ! hasChanges && ! isSaving,
750
+ isSaving,
751
+ hasChanges,
752
+ hasMedia: !! media,
753
+ } ) }
754
+ </MediaEditorFrameContext.Provider>
755
+ );
730
756
  }
731
757
 
732
758
  export function MediaEditor( props: MediaEditorProps ) {
@@ -737,4 +763,12 @@ export function MediaEditor( props: MediaEditorProps ) {
737
763
  );
738
764
  }
739
765
 
766
+ // Attached to `MediaEditor` so frames import and arrange them, the way
767
+ // `DataViewsPicker` exposes its own sub-components. They read what they need
768
+ // from context, so a frame only chooses where they go and how they look.
769
+ MediaEditor.HeaderActions = HeaderActions;
770
+ MediaEditor.HistoryActions = HistoryActions;
771
+ MediaEditor.SaveActions = SaveActions;
772
+ MediaEditor.ImageControls = ImageControls;
773
+
740
774
  export default MediaEditor;
@@ -102,10 +102,13 @@
102
102
  .media-editor__sidebar {
103
103
  @include reset;
104
104
 
105
- // Small left gutter so the tabs and panel content (and the zoom
106
- // slider's thumb at its minimum) sit off the sidebar edge.
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.
107
110
  @include break-small() {
108
- padding-left: 1px;
111
+ padding-inline: $grid-unit-10;
109
112
  }
110
113
  }
111
114
 
@@ -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), and focus is
147
- * withheld by gating `focusOnMount` on the loaded state — the
148
- * cropper's focus effect keys off that prop, so focus lands on the
149
- * crop area only once it's visible.
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 }
@@ -26,6 +26,44 @@ interface MediaEditorModalProps {
26
26
  aspectRatioPresets?: AspectRatioPreset[];
27
27
  }
28
28
 
29
+ interface ModalFooterProps {
30
+ layout: 'wide' | 'narrow';
31
+ }
32
+
33
+ /**
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.
38
+ */
39
+ function ModalFooter( { layout }: ModalFooterProps ) {
40
+ return (
41
+ <div
42
+ className={ `media-editor-modal__footer is-${ layout }` }
43
+ role="region"
44
+ aria-label={ __( 'Editor actions' ) }
45
+ >
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
+ ) }
63
+ </div>
64
+ );
65
+ }
66
+
29
67
  export function MediaEditorModal( {
30
68
  fields = [],
31
69
  aspectRatioPresets,
@@ -71,7 +109,6 @@ export function MediaEditorModal( {
71
109
  id={ id }
72
110
  fields={ fields }
73
111
  aspectRatioPresets={ aspectRatioPresets }
74
- showCloseButton
75
112
  shouldCloseOnEsc
76
113
  noticesClassName="media-editor-modal__snackbar"
77
114
  noticesPortalElement={ portalElement }
@@ -107,9 +144,7 @@ export function MediaEditorModal( {
107
144
  } }
108
145
  renderFrame={ ( {
109
146
  children,
110
- headerActions,
111
- footerActions,
112
- footerLayout,
147
+ layout,
113
148
  onRequestClose,
114
149
  onKeyDown,
115
150
  shouldCloseOnClickOutside,
@@ -126,16 +161,12 @@ export function MediaEditorModal( {
126
161
  shouldCloseOnClickOutside={ shouldCloseOnClickOutside }
127
162
  onKeyDown={ onKeyDown }
128
163
  onRequestClose={ onRequestClose }
129
- headerActions={ headerActions }
164
+ headerActions={
165
+ <MediaEditor.HeaderActions showCloseButton />
166
+ }
130
167
  >
131
168
  { children }
132
- <div
133
- className={ `media-editor-modal__footer is-${ footerLayout }` }
134
- role="region"
135
- aria-label={ __( 'Editor actions' ) }
136
- >
137
- { footerActions }
138
- </div>
169
+ <ModalFooter layout={ layout } />
139
170
  </Modal>
140
171
  </ShortcutProvider>
141
172
  ) }
@@ -46,8 +46,8 @@
46
46
  // Panel mode: the footer holds only History (left) and
47
47
  // Cancel/Save (right). `margin-left: auto` pins the actions to the
48
48
  // right edge whether or not History renders (e.g. non-image
49
- // attachments show only `FooterActions`).
50
- .media-editor__footer-actions {
49
+ // attachments show only `SaveActions`).
50
+ .media-editor__save-actions {
51
51
  margin-left: auto;
52
52
  }
53
53
  }
@@ -76,7 +76,7 @@
76
76
  gap: $grid-unit-20;
77
77
 
78
78
  .media-editor-image-controls,
79
- .media-editor__footer-actions {
79
+ .media-editor__save-actions {
80
80
  margin-left: auto;
81
81
  }
82
82
  }
@@ -85,9 +85,13 @@
85
85
  // they read as live alongside the Reset/Cancel/Save actions. Disabled
86
86
  // buttons (rendered with `aria-disabled` via `accessibleWhenDisabled`)
87
87
  // keep the default muted icon colour.
88
+ // Scoped to the modal: the package ships one stylesheet, so an unscoped
89
+ // selector would also colour the history cluster in frames that place it in
90
+ // their own chrome (the wp-admin route puts it in the page header, where the
91
+ // neutral icon colour matches the header's other buttons).
88
92
  // NOTE: overrides @wordpress/components Button internals (`.components-button`,
89
93
  // `.has-icon`), scoped to our history-actions wrapper. Update if renamed.
90
- .media-editor__history-actions .components-button.has-icon:not([aria-disabled="true"]) {
94
+ .media-editor-modal .media-editor__history-actions .components-button.has-icon:not([aria-disabled="true"]) {
91
95
  color: var(--wp-admin-theme-color);
92
96
  }
93
97
 
@@ -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": "../api-fetch/tsconfig.build.json" },
11
+ { "path": "../components/tsconfig.build.json" },
12
+ { "path": "../compose/tsconfig.build.json" },
13
+ { "path": "../core-data/tsconfig.build.json" },
14
+ { "path": "../data" },
15
+ { "path": "../dataviews/tsconfig.build.json" },
16
+ { "path": "../date" },
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
+ }