@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.
Files changed (44) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/build/components/media-editor/index.cjs +188 -183
  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-crop-panel/index.cjs +2 -3
  7. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  8. package/build/components/media-editor-modal/index.cjs +16 -14
  9. package/build/components/media-editor-modal/index.cjs.map +3 -3
  10. package/build-module/components/media-editor/index.mjs +192 -190
  11. package/build-module/components/media-editor/index.mjs.map +2 -2
  12. package/build-module/components/media-editor-canvas/index.mjs +0 -2
  13. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  14. package/build-module/components/media-editor-crop-panel/index.mjs +2 -3
  15. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  16. package/build-module/components/media-editor-modal/index.mjs +16 -14
  17. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  18. package/build-style/style-rtl.css +62 -95
  19. package/build-style/style.css +62 -95
  20. package/build-types/components/media-editor/index.d.ts +39 -11
  21. package/build-types/components/media-editor/index.d.ts.map +1 -1
  22. package/build-types/components/media-editor-canvas/index.d.ts +1 -4
  23. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  24. package/build-types/components/media-editor-crop-panel/index.d.ts +4 -11
  25. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  26. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  27. package/global.d.ts +5 -0
  28. package/package.json +23 -22
  29. package/src/components/media-editor/index.tsx +381 -271
  30. package/src/components/media-editor/style.scss +136 -131
  31. package/src/components/media-editor-canvas/index.tsx +5 -9
  32. package/src/components/media-editor-crop-panel/index.tsx +4 -12
  33. package/src/components/media-editor-crop-panel/test/index.tsx +2 -10
  34. package/src/components/media-editor-modal/index.tsx +23 -12
  35. package/src/components/media-editor-modal/style.scss +14 -51
  36. package/src/image-editor/stories/rectangle-crop.story.tsx +15 -0
  37. package/tsconfig.build.json +26 -0
  38. package/tsconfig.build.tsbuildinfo +1 -0
  39. package/tsconfig.json +23 -16
  40. package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -8
  41. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
  42. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -10
  43. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
  44. package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md CHANGED
@@ -2,8 +2,32 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 0.16.0 (2026-08-12)
5
+ ## 0.17.1-next.0 (2026-08-28)
6
+
7
+ ### Internal
8
+
9
+ - Remove unused dependency `@wordpress/date` ([#82103](https://github.com/WordPress/gutenberg/pull/82103)).
10
+ - Remove tsconfig project references to packages that are not dependencies ([#82106](https://github.com/WordPress/gutenberg/pull/82106)).
11
+
12
+ ## 0.17.0 (2026-08-26)
13
+
14
+ ### Enhancements
15
+
16
+ - `MediaEditor`: replace `ComplementaryArea` and `InterfaceSkeleton` with a layout the media editor owns, and widen the settings panel so its controls and fields are not so cramped ([#81840](https://github.com/WordPress/gutenberg/pull/81840)).
17
+ - `MediaEditor.ImageControls` is removed, and `renderFrame` drops `hasCanvas`. Both were added in the same unreleased cycle: the transform controls belong to the Crop panel, and `HistoryActions` already renders nothing when a panel covers the canvas, so a frame gating on it repeated that check from the outside. The `scope` prop is removed too: it named an `@wordpress/interface` scope that persisted the panel's open state, which went with `ComplementaryArea` ([#81840](https://github.com/WordPress/gutenberg/pull/81840)).
18
+ - Expose the header, history (reset/undo/redo), save (cancel/save) and image control clusters as `MediaEditor` sub-components, so each frame imports and arranges them to suit its own chrome. `renderFrame` now passes data only: `footerActions` is gone, `footerLayout` is now `layout`, and `isImage` is new. `showCloseButton` moves from `MediaEditor` to `MediaEditor.HeaderActions` ([#81563](https://github.com/WordPress/gutenberg/pull/81563)).
6
19
 
20
+ ### Bug Fixes
21
+
22
+ - `MediaEditor`: make the Details fields reachable below the `small` breakpoint. `ComplementaryArea` closed the sidebar on small viewports and offered no way to re-open it, so the fields could not be edited on a phone at all ([#81840](https://github.com/WordPress/gutenberg/pull/81840)).
23
+ - Keep the Details sidebar from clipping focus outlines, with balanced horizontal padding ([#81703](https://github.com/WordPress/gutenberg/pull/81703)).
24
+ - Keep initial focus on the modal dialog frame instead of moving it to the crop area once the image loads ([#81541](https://github.com/WordPress/gutenberg/pull/81541)).
25
+
26
+ ### Internal
27
+
28
+ - Split tsconfig into a build project and a default dev project so dev files are type checked without publishing their declarations. ([#81514](https://github.com/WordPress/gutenberg/pull/81514))
29
+
30
+ ## 0.16.0 (2026-08-12)
7
31
 
8
32
  ## 0.15.0 (2026-07-29)
9
33
 
@@ -34,23 +34,24 @@ __export(media_editor_exports, {
34
34
  default: () => media_editor_default
35
35
  });
36
36
  module.exports = __toCommonJS(media_editor_exports);
37
+ var import_clsx = __toESM(require("clsx"));
37
38
  var import_components = require("@wordpress/components");
38
39
  var import_ui = require("@wordpress/ui");
39
40
  var import_compose = require("@wordpress/compose");
40
41
  var import_data = require("@wordpress/data");
41
42
  var import_core_data = require("@wordpress/core-data");
43
+ var import_admin_ui = require("@wordpress/admin-ui");
42
44
  var import_element = require("@wordpress/element");
43
45
  var import_i18n = require("@wordpress/i18n");
44
46
  var import_icons = require("@wordpress/icons");
45
47
  var import_keycodes = require("@wordpress/keycodes");
46
48
  var import_notices = require("@wordpress/notices");
47
- var import_interface = require("@wordpress/interface");
48
49
  var import_media_editor_provider = require("../media-editor-provider/index.cjs");
49
50
  var import_media_preview = __toESM(require("../media-preview/index.cjs"));
50
51
  var import_media_editor_canvas = __toESM(require("../media-editor-canvas/index.cjs"));
51
52
  var import_media_editor_fine_rotation = __toESM(require("../media-editor-fine-rotation/index.cjs"));
52
- var import_media_editor_image_controls = __toESM(require("../media-editor-image-controls/index.cjs"));
53
53
  var import_media_editor_crop_panel = __toESM(require("../media-editor-crop-panel/index.cjs"));
54
+ var import_media_editor_image_controls = __toESM(require("../media-editor-image-controls/index.cjs"));
54
55
  var import_media_form = __toESM(require("../media-form/index.cjs"));
55
56
  var import_utils = require("../../utils/index.cjs");
56
57
  var import_state = require("../../state/index.cjs");
@@ -61,41 +62,58 @@ var import_use_crop_options = require("./use-crop-options.cjs");
61
62
  var import_jsx_runtime = require("react/jsx-runtime");
62
63
  var ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
63
64
  var PLACEMENT_CONTROL_IDLE_MS = 300;
65
+ var DETAILS_PANEL = "details";
66
+ var CROP_PANEL = "crop";
64
67
  function MediaEditorSidebar({
65
68
  tabs,
66
- activeTabId,
67
- onTabChange
69
+ activeTab,
70
+ onSelectTab
68
71
  }) {
69
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
- import_interface.ComplementaryArea,
72
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
73
+ import_admin_ui.NavigableRegion,
71
74
  {
72
- scope: "media-editor",
73
- identifier: "media-editor/details",
74
- title: (0, import_i18n.__)("Details"),
75
- icon: import_icons.drawerRight,
76
- isActiveByDefault: true,
77
75
  className: "media-editor__sidebar",
78
- panelClassName: "media-editor__sidebar-panel",
79
- headerClassName: "media-editor__sidebar-header",
80
- closeLabel: (0, import_i18n.__)("Close media panel"),
81
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
82
- import_ui.Tabs.Root,
83
- {
84
- value: activeTabId,
85
- onValueChange: (value) => onTabChange(value)
86
- }
87
- ),
88
- header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.List, { variant: "minimal", children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.Tab, { value: tab.id, children: tab.title }, tab.id)) }),
89
- children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.Panel, { value: tab.id, tabIndex: -1, children: tab.panel }, tab.id))
76
+ ariaLabel: (0, import_i18n.__)("Media settings"),
77
+ children: [
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {}), children: (0, import_i18n.__)("Media settings") }),
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
80
+ import_ui.Tabs.Root,
81
+ {
82
+ className: "media-editor__tabs",
83
+ value: activeTab,
84
+ onValueChange: onSelectTab,
85
+ children: [
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__tablist", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.List, { variant: "minimal", children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.Tab, { value: tab.id, children: tab.title }, tab.id)) }) }),
87
+ tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
+ import_ui.Tabs.Panel,
89
+ {
90
+ value: tab.id,
91
+ tabIndex: -1,
92
+ className: "media-editor__panel",
93
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Stack, { direction: "column", gap: "lg", children: tab.render() })
94
+ },
95
+ tab.id
96
+ ))
97
+ ]
98
+ }
99
+ )
100
+ ]
90
101
  }
91
102
  );
92
103
  }
93
- function HeaderActions({
94
- isSaving,
95
- isImage,
96
- showCloseButton = false,
97
- onCancel
98
- }) {
104
+ var MediaEditorFrameContext = (0, import_element.createContext)(null);
105
+ function useMediaEditorFrameContext() {
106
+ const context = (0, import_element.useContext)(MediaEditorFrameContext);
107
+ if (!context) {
108
+ throw new Error(
109
+ "useMediaEditorFrameContext must be used within MediaEditor"
110
+ );
111
+ }
112
+ return context;
113
+ }
114
+ function HeaderActions({ showCloseButton = false }) {
115
+ const { isImage, isSaving, onCancel, isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
116
+ const isPanelOpen = !!activePanel;
99
117
  const [isShortcutsModalOpen, setIsShortcutsModalOpen] = (0, import_element.useState)(false);
100
118
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
101
119
  import_ui.Stack,
@@ -114,7 +132,17 @@ function HeaderActions({
114
132
  onClick: () => setIsShortcutsModalOpen(true)
115
133
  }
116
134
  ),
117
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.PinnedItems.Slot, { scope: "media-editor" }),
135
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
136
+ import_components.Button,
137
+ {
138
+ size: "compact",
139
+ icon: import_icons.drawerRight,
140
+ label: (0, import_i18n.__)("Media settings"),
141
+ isPressed: isPanelOpen,
142
+ "aria-expanded": isWide ? isPanelOpen : void 0,
143
+ onClick: onTogglePanel
144
+ }
145
+ ),
118
146
  showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
119
147
  import_components.Button,
120
148
  {
@@ -136,10 +164,8 @@ function HeaderActions({
136
164
  }
137
165
  );
138
166
  }
139
- function HistoryActions({
140
- isUndoRedoDisabled = false,
141
- onReset
142
- }) {
167
+ function HistoryActions() {
168
+ const { isImage, isUndoRedoDisabled, onReset, isWide, activePanel } = useMediaEditorFrameContext();
143
169
  const {
144
170
  reset,
145
171
  isDirty,
@@ -150,6 +176,9 @@ function HistoryActions({
150
176
  beginGesture,
151
177
  endGesture
152
178
  } = (0, import_state.useMediaEditor)();
179
+ if (!isImage || !isWide && !!activePanel) {
180
+ return null;
181
+ }
153
182
  const handleUndo = () => {
154
183
  if (isUndoRedoDisabled) {
155
184
  return;
@@ -216,18 +245,13 @@ function HistoryActions({
216
245
  }
217
246
  );
218
247
  }
219
- function FooterActions({
220
- isSaving,
221
- hasMedia,
222
- hasChanges,
223
- onCancel,
224
- onSave
225
- }) {
248
+ function SaveActions({ size = "default" }) {
249
+ const { isSaving, hasMedia, hasChanges, onCancel, onSave } = useMediaEditorFrameContext();
226
250
  const saveDisabled = isSaving || !hasMedia || !hasChanges;
227
251
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
228
252
  import_ui.Stack,
229
253
  {
230
- className: "media-editor__footer-actions",
254
+ className: "media-editor__save-actions",
231
255
  justify: "flex-end",
232
256
  align: "center",
233
257
  gap: "sm",
@@ -236,6 +260,7 @@ function FooterActions({
236
260
  import_components.Button,
237
261
  {
238
262
  __next40pxDefaultSize: true,
263
+ size,
239
264
  variant: "tertiary",
240
265
  onClick: onCancel,
241
266
  disabled: isSaving,
@@ -247,6 +272,7 @@ function FooterActions({
247
272
  import_components.Button,
248
273
  {
249
274
  __next40pxDefaultSize: true,
275
+ size,
250
276
  variant: "primary",
251
277
  onClick: onSave,
252
278
  isBusy: isSaving,
@@ -268,12 +294,26 @@ function MediaEditorContent({
268
294
  renderFrame,
269
295
  noticesClassName = "media-editor__snackbar",
270
296
  noticesPortalElement,
271
- showCloseButton = false,
272
297
  shouldCloseOnEsc = false
273
298
  }) {
274
299
  const cropper = (0, import_state.useMediaEditor)();
275
- const isPanelLayout = (0, import_compose.useViewportMatch)("small");
276
- const footerLayout = isPanelLayout ? "wide" : "narrow";
300
+ const isWide = (0, import_compose.useViewportMatch)("small");
301
+ const [activePanel, setActivePanel] = (0, import_element.useState)(
302
+ isWide ? DETAILS_PANEL : null
303
+ );
304
+ const hasChosenPanelRef = (0, import_element.useRef)(false);
305
+ const lastPanelRef = (0, import_element.useRef)(DETAILS_PANEL);
306
+ const hasChosenTabRef = (0, import_element.useRef)(false);
307
+ const selectPanel = (0, import_element.useCallback)((panel) => {
308
+ hasChosenTabRef.current = true;
309
+ lastPanelRef.current = panel;
310
+ setActivePanel(panel);
311
+ }, []);
312
+ const togglePanel = (0, import_element.useCallback)(() => {
313
+ hasChosenPanelRef.current = true;
314
+ setActivePanel((open) => open ? null : lastPanelRef.current);
315
+ }, []);
316
+ const layout = isWide ? "wide" : "narrow";
277
317
  const { media, hasEdits } = (0, import_data.useSelect)(
278
318
  (select) => {
279
319
  const {
@@ -342,14 +382,24 @@ function MediaEditorContent({
342
382
  }, [id, invalidateResolution]);
343
383
  const mediaType = (0, import_utils.getMediaTypeFromMimeType)(media?.mime_type).type;
344
384
  const isImage = !!media && mediaType === "image";
385
+ (0, import_element.useEffect)(() => {
386
+ if (hasChosenPanelRef.current && hasChosenTabRef.current) {
387
+ return;
388
+ }
389
+ const defaultPanel = isWide && isImage ? CROP_PANEL : DETAILS_PANEL;
390
+ if (!hasChosenTabRef.current) {
391
+ lastPanelRef.current = defaultPanel;
392
+ }
393
+ if (!hasChosenPanelRef.current) {
394
+ setActivePanel(isWide ? lastPanelRef.current : null);
395
+ }
396
+ }, [isWide, isImage]);
345
397
  const {
346
398
  aspectRatioValue,
347
399
  setAspectRatioValue,
348
400
  aspectRatioOptions,
349
401
  resetCropOptions
350
- } = (0, import_use_crop_options.useCropOptions)({
351
- aspectRatioPresets
352
- });
402
+ } = (0, import_use_crop_options.useCropOptions)({ aspectRatioPresets });
353
403
  const { isSaving, save: saveMediaEditor } = (0, import_use_save_media_editor.useSaveMediaEditor)({
354
404
  cropper,
355
405
  id,
@@ -357,56 +407,6 @@ function MediaEditorContent({
357
407
  media,
358
408
  onSaved
359
409
  });
360
- const tabs = (0, import_element.useMemo)(() => {
361
- const detailsTab = {
362
- id: "details",
363
- title: (0, import_i18n.__)("Details"),
364
- panel: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
365
- import_ui.Stack,
366
- {
367
- className: "media-editor__panel",
368
- direction: "column",
369
- gap: "lg",
370
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_form.default, {})
371
- }
372
- )
373
- };
374
- if (!isImage) {
375
- return [detailsTab];
376
- }
377
- return [
378
- {
379
- id: "crop",
380
- title: (0, import_i18n.__)("Crop"),
381
- panel: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
382
- import_ui.Stack,
383
- {
384
- className: "media-editor__panel",
385
- direction: "column",
386
- gap: "lg",
387
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
388
- import_media_editor_crop_panel.default,
389
- {
390
- aspectRatioValue,
391
- onAspectRatioChange: setAspectRatioValue,
392
- aspectRatioOptions,
393
- showTransformControls: isPanelLayout
394
- }
395
- )
396
- }
397
- )
398
- },
399
- detailsTab
400
- ];
401
- }, [
402
- isImage,
403
- aspectRatioValue,
404
- setAspectRatioValue,
405
- aspectRatioOptions,
406
- isPanelLayout
407
- ]);
408
- const [selectedTabId, setSelectedTabId] = (0, import_element.useState)();
409
- const activeTabId = selectedTabId ?? tabs[0]?.id;
410
410
  const handleChange = (updates) => {
411
411
  editEntityRecord("postType", "attachment", id, updates);
412
412
  };
@@ -464,6 +464,34 @@ function MediaEditorContent({
464
464
  context: import_use_save_media_editor.MEDIA_EDITOR_NOTICES_CONTEXT
465
465
  }
466
466
  );
467
+ const imageControls = isImage && !isWide ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
468
+ import_media_editor_image_controls.default,
469
+ {
470
+ showAspectRatioControl: true,
471
+ aspectRatioPresets
472
+ }
473
+ ) : null;
474
+ const tabs = [
475
+ ...isImage ? [
476
+ {
477
+ id: CROP_PANEL,
478
+ title: (0, import_i18n.__)("Crop"),
479
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
480
+ import_media_editor_crop_panel.default,
481
+ {
482
+ aspectRatioValue,
483
+ onAspectRatioChange: setAspectRatioValue,
484
+ aspectRatioOptions
485
+ }
486
+ )
487
+ }
488
+ ] : [],
489
+ {
490
+ id: DETAILS_PANEL,
491
+ title: (0, import_i18n.__)("Details"),
492
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_form.default, {})
493
+ }
494
+ ];
467
495
  const ruler = isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
468
496
  import_media_editor_fine_rotation.default,
469
497
  {
@@ -477,39 +505,47 @@ function MediaEditorContent({
477
505
  onChange: handleChange,
478
506
  settings: { fields },
479
507
  children: [
480
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor", children: !media ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__loading", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
481
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
482
- MediaEditorSidebar,
483
- {
484
- tabs,
485
- activeTabId,
486
- onTabChange: setSelectedTabId
487
- }
488
- ),
489
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
490
- import_interface.InterfaceSkeleton,
491
- {
492
- className: "media-editor__skeleton",
493
- labels: {
494
- body: isImage ? (0, import_i18n.__)("Image editor") : (0, import_i18n.__)("Media preview"),
495
- sidebar: (0, import_i18n.__)("Media details")
496
- },
497
- content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor__content", children: [
498
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-area", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
499
- import_media_editor_canvas.default,
500
- {
501
- focusOnMount: true,
502
- isPlacementActive,
503
- onGestureStart: handleCanvasGestureStart,
504
- onGestureEnd: handleCanvasGestureEnd
505
- }
506
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_preview.default, {}) }),
507
- isImage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-toolbar", children: ruler })
508
- ] }),
509
- sidebar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.ComplementaryArea.Slot, { scope: "media-editor" })
510
- }
511
- )
512
- ] }) }),
508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor", children: !media ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__loading", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
509
+ "div",
510
+ {
511
+ className: (0, import_clsx.default)("media-editor__body", {
512
+ "has-panel-open": !!activePanel
513
+ }),
514
+ children: [
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
516
+ import_admin_ui.NavigableRegion,
517
+ {
518
+ className: "media-editor__content",
519
+ ariaLabel: isImage ? (0, import_i18n.__)("Image editor") : (0, import_i18n.__)("Media preview"),
520
+ children: [
521
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-area", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
522
+ import_media_editor_canvas.default,
523
+ {
524
+ isPlacementActive,
525
+ onGestureStart: handleCanvasGestureStart,
526
+ onGestureEnd: handleCanvasGestureEnd
527
+ }
528
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_preview.default, {}) }),
529
+ isImage && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor__canvas-toolbar", children: [
530
+ ruler,
531
+ imageControls
532
+ ] })
533
+ ]
534
+ }
535
+ ),
536
+ !!activePanel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
537
+ MediaEditorSidebar,
538
+ {
539
+ tabs,
540
+ activeTab: tabs.some(
541
+ (tab) => tab.id === activePanel
542
+ ) ? activePanel : DETAILS_PANEL,
543
+ onSelectTab: selectPanel
544
+ }
545
+ )
546
+ ]
547
+ }
548
+ ) }),
513
549
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
514
550
  import_components.__experimentalConfirmDialog,
515
551
  {
@@ -530,69 +566,38 @@ function MediaEditorContent({
530
566
  ]
531
567
  }
532
568
  );
533
- const history = isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
534
- HistoryActions,
535
- {
536
- isUndoRedoDisabled: isCropInteractionActive,
537
- onReset: resetCropOptions
538
- }
539
- ) : null;
540
- const imageControls = isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
541
- import_media_editor_image_controls.default,
542
- {
543
- showAspectRatioControl: true,
544
- aspectRatioPresets
545
- }
546
- ) : null;
547
- const actions = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
548
- FooterActions,
549
- {
550
- isSaving,
551
- hasMedia: !!media,
552
- hasChanges,
553
- onCancel: handleRequestClose,
554
- onSave: saveMediaEditor
555
- }
556
- );
557
- let footerActions;
558
- if (footerLayout === "wide") {
559
- footerActions = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
560
- history,
561
- actions
562
- ] });
563
- } else {
564
- footerActions = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
565
- imageControls,
566
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-modal__footer-row", children: [
567
- history,
568
- actions
569
- ] })
570
- ] });
571
- }
572
- return renderFrame({
569
+ const contextValue = {
570
+ isImage,
571
+ isSaving,
572
+ hasMedia: !!media,
573
+ hasChanges,
574
+ isUndoRedoDisabled: isCropInteractionActive,
575
+ aspectRatioPresets,
576
+ isWide,
577
+ activePanel,
578
+ onTogglePanel: togglePanel,
579
+ onCancel: handleRequestClose,
580
+ onSave: saveMediaEditor,
581
+ onReset: resetCropOptions
582
+ };
583
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaEditorFrameContext.Provider, { value: contextValue, children: renderFrame({
573
584
  children,
574
- headerActions: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
575
- HeaderActions,
576
- {
577
- isSaving,
578
- isImage,
579
- showCloseButton,
580
- onCancel: handleRequestClose
581
- }
582
- ),
583
- footerActions,
584
- footerLayout,
585
+ isImage,
586
+ layout,
585
587
  onRequestClose: handleRequestClose,
586
588
  onKeyDown: handleKeyDown,
587
589
  shouldCloseOnClickOutside: !hasChanges && !isSaving,
588
590
  isSaving,
589
591
  hasChanges,
590
592
  hasMedia: !!media
591
- });
593
+ }) });
592
594
  }
593
595
  function MediaEditor(props) {
594
596
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_state.MediaEditorStateProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaEditorContent, { ...props }) }, props.id);
595
597
  }
598
+ MediaEditor.HeaderActions = HeaderActions;
599
+ MediaEditor.HistoryActions = HistoryActions;
600
+ MediaEditor.SaveActions = SaveActions;
596
601
  var media_editor_default = MediaEditor;
597
602
  // Annotate the CommonJS export names for ESM import in node:
598
603
  0 && (module.exports = {