@wordpress/media-editor 0.23.0 → 0.24.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 (87) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/components/media-editor/index.cjs +157 -107
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-save-media-editor.cjs +18 -8
  5. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  6. package/build/components/media-editor-canvas/index.cjs +9 -7
  7. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  8. package/build/components/media-editor-crop-panel/index.cjs +9 -7
  9. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  10. package/build/components/media-editor-fine-rotation/index.cjs +9 -7
  11. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  12. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +32 -33
  13. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  14. package/build/components/media-editor-modal/index.cjs +10 -7
  15. package/build/components/media-editor-modal/index.cjs.map +1 -1
  16. package/build/components/media-editor-panel/error-boundary.cjs +68 -0
  17. package/build/components/media-editor-panel/error-boundary.cjs.map +1 -0
  18. package/build/components/media-editor-panel/index.cjs +158 -0
  19. package/build/components/media-editor-panel/index.cjs.map +1 -0
  20. package/build/components/media-preview/index.cjs +143 -36
  21. package/build/components/media-preview/index.cjs.map +1 -1
  22. package/build/components/rotation-ruler/index.cjs +9 -7
  23. package/build/components/rotation-ruler/index.cjs.map +1 -1
  24. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -1
  25. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -1
  26. package/build/index.cjs +10 -8
  27. package/build/private-apis.cjs.map +1 -1
  28. package/build/state/aspect-ratio-presets.cjs +2 -2
  29. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  30. package/build/state/composite-reducer.cjs +9 -7
  31. package/build/state/composite-reducer.cjs.map +1 -1
  32. package/build/state/use-media-editor-state.cjs.map +1 -1
  33. package/build/store/index.cjs +11 -9
  34. package/build/store/index.cjs.map +1 -1
  35. package/build/utils/get-media-type.cjs +8 -0
  36. package/build/utils/get-media-type.cjs.map +1 -1
  37. package/build/utils/index.cjs +6 -0
  38. package/build-module/components/media-editor/index.mjs +142 -95
  39. package/build-module/components/media-editor/index.mjs.map +1 -1
  40. package/build-module/components/media-editor/use-save-media-editor.mjs +9 -1
  41. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  42. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +32 -33
  43. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  44. package/build-module/components/media-editor-modal/index.mjs +1 -0
  45. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  46. package/build-module/components/media-editor-panel/error-boundary.mjs +63 -0
  47. package/build-module/components/media-editor-panel/error-boundary.mjs.map +1 -0
  48. package/build-module/components/media-editor-panel/index.mjs +123 -0
  49. package/build-module/components/media-editor-panel/index.mjs.map +1 -0
  50. package/build-module/components/media-preview/index.mjs +123 -40
  51. package/build-module/components/media-preview/index.mjs.map +1 -1
  52. package/build-module/state/aspect-ratio-presets.mjs +2 -2
  53. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  54. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  55. package/build-module/utils/get-media-type.mjs +8 -1
  56. package/build-module/utils/get-media-type.mjs.map +1 -1
  57. package/build-module/utils/index.mjs +1 -1
  58. package/build-style/style-rtl.css +18 -30
  59. package/build-style/style.css +18 -30
  60. package/build-types/components/media-editor/index.d.ts +8 -0
  61. package/build-types/components/media-editor/index.d.ts.map +1 -1
  62. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  63. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  64. package/build-types/components/media-editor-panel/error-boundary.d.ts +23 -0
  65. package/build-types/components/media-editor-panel/error-boundary.d.ts.map +1 -0
  66. package/build-types/components/media-editor-panel/index.d.ts +46 -0
  67. package/build-types/components/media-editor-panel/index.d.ts.map +1 -0
  68. package/build-types/components/media-preview/index.d.ts.map +1 -1
  69. package/build-types/state/use-media-editor-state.d.ts +7 -2
  70. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  71. package/build-types/utils/get-media-type.d.ts +3 -1
  72. package/build-types/utils/get-media-type.d.ts.map +1 -1
  73. package/build-types/utils/index.d.ts +1 -1
  74. package/build-types/utils/index.d.ts.map +1 -1
  75. package/package.json +26 -22
  76. package/src/components/media-editor/index.tsx +209 -114
  77. package/src/components/media-editor/style.scss +21 -1
  78. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +55 -63
  79. package/src/components/media-editor-modal/index.tsx +3 -0
  80. package/src/components/media-editor-panel/error-boundary.tsx +88 -0
  81. package/src/components/media-editor-panel/index.tsx +211 -0
  82. package/src/components/media-preview/index.tsx +195 -36
  83. package/src/components/media-preview/style.scss +11 -32
  84. package/src/state/README.md +3 -1
  85. package/src/state/use-media-editor-state.ts +7 -2
  86. package/src/utils/get-media-type.ts +9 -1
  87. package/src/utils/index.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -2,12 +2,28 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.24.0 (2026-12-02)
6
+
7
+ ### Enhancements
8
+
9
+ - `MediaEditor` builds its sidebar tabs from mounted `MediaEditorPanel` components and mounts plugins registered with `registerPlugin` in the `media-editor` scope inside the editor's session provider. Core's Crop and Details are two such panels. A panel's content renders in the panel's own React tree, a panel that throws keeps the failure inside its tab, and common mistakes warn in development ([#84664](https://github.com/WordPress/gutenberg/pull/84664)).
10
+
11
+ ### Bug Fixes
12
+
13
+ - `MediaEditor`: Ignore keyboard shortcuts and Escape-to-close handling during IME composition ([#87354](https://github.com/WordPress/gutenberg/pull/87354)).
14
+ - Expose readable text for shortcut keycaps, including arrow groups and the Plus and Minus zoom keys ([#85490](https://github.com/WordPress/gutenberg/pull/85490)).
15
+
16
+ ### Internal
17
+
18
+ - Add `@wordpress/plugins`, `@wordpress/react-inert-value` and `@wordpress/warning` as dependencies ([#84664](https://github.com/WordPress/gutenberg/pull/84664)).
19
+
5
20
  ## 0.23.0 (2026-11-18)
6
21
 
7
22
  ### Enhancements
8
23
 
9
24
  - `MediaEditor.MoreMenu` takes `actions` and `item` props, and lists the actions eligible for the item, such as "Permanently delete". It now also shows for media other than images when it has actions ([#86349](https://github.com/WordPress/gutenberg/pull/86349)).
10
25
  - Show the shape of each aspect ratio in the aspect ratio dropdown of the crop panel and in the aspect ratio menu used on narrow screens ([#86348](https://github.com/WordPress/gutenberg/pull/86348)).
26
+ - `MediaPreview` shows media without a preview, such as a zip file, with its filename, file type and size, and Download and Copy URL buttons. Its empty and error states also use `EmptyState` from `@wordpress/ui` ([#86490](https://github.com/WordPress/gutenberg/pull/86490)).
11
27
 
12
28
  ### Bug Fixes
13
29
 
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -25,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
27
  enumerable: true
26
28
  }) : target, mod));
27
29
  let clsx = require("clsx");
28
- clsx = __toESM(clsx);
29
30
  let _wordpress_components = require("@wordpress/components");
30
31
  let _wordpress_ui = require("@wordpress/ui");
32
+ let _wordpress_plugins = require("@wordpress/plugins");
31
33
  let _wordpress_compose = require("@wordpress/compose");
32
34
  let _wordpress_data = require("@wordpress/data");
33
35
  let _wordpress_core_data = require("@wordpress/core-data");
@@ -37,39 +39,45 @@ let _wordpress_i18n = require("@wordpress/i18n");
37
39
  let _wordpress_icons = require("@wordpress/icons");
38
40
  let _wordpress_keycodes = require("@wordpress/keycodes");
39
41
  let _wordpress_notices = require("@wordpress/notices");
42
+ let _wordpress_react_inert_value = require("@wordpress/react-inert-value");
40
43
  let ___media_editor_provider_index_tsx = require("../media-editor-provider/index.cjs");
41
44
  let ___media_preview_index_tsx = require("../media-preview/index.cjs");
42
- ___media_preview_index_tsx = __toESM(___media_preview_index_tsx);
43
45
  let ___media_editor_canvas_index_tsx = require("../media-editor-canvas/index.cjs");
44
- ___media_editor_canvas_index_tsx = __toESM(___media_editor_canvas_index_tsx);
45
46
  let ___media_editor_fine_rotation_index_tsx = require("../media-editor-fine-rotation/index.cjs");
46
- ___media_editor_fine_rotation_index_tsx = __toESM(___media_editor_fine_rotation_index_tsx);
47
47
  let ___media_editor_crop_panel_index_tsx = require("../media-editor-crop-panel/index.cjs");
48
- ___media_editor_crop_panel_index_tsx = __toESM(___media_editor_crop_panel_index_tsx);
49
48
  let ___media_editor_image_controls_index_tsx = require("../media-editor-image-controls/index.cjs");
50
- ___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
51
49
  let ___media_form_index_tsx = require("../media-form/index.cjs");
52
- ___media_form_index_tsx = __toESM(___media_form_index_tsx);
50
+ let ___media_editor_panel_index_tsx = require("../media-editor-panel/index.cjs");
53
51
  let ______utils_index_ts = require("../../utils/index.cjs");
54
52
  let ______state_index_ts = require("../../state/index.cjs");
55
53
  let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
56
54
  let ___media_editor_keyboard_shortcuts_modal_index_tsx = require("../media-editor-keyboard-shortcuts-modal/index.cjs");
57
- ___media_editor_keyboard_shortcuts_modal_index_tsx = __toESM(___media_editor_keyboard_shortcuts_modal_index_tsx);
58
55
  let __use_save_media_editor_ts = require("./use-save-media-editor.cjs");
59
56
  let __use_crop_options_ts = require("./use-crop-options.cjs");
60
57
  let react_jsx_runtime = require("react/jsx-runtime");
58
+ clsx = __toESM(clsx);
59
+ ___media_preview_index_tsx = __toESM(___media_preview_index_tsx);
60
+ ___media_editor_canvas_index_tsx = __toESM(___media_editor_canvas_index_tsx);
61
+ ___media_editor_fine_rotation_index_tsx = __toESM(___media_editor_fine_rotation_index_tsx);
62
+ ___media_editor_crop_panel_index_tsx = __toESM(___media_editor_crop_panel_index_tsx);
63
+ ___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
64
+ ___media_form_index_tsx = __toESM(___media_form_index_tsx);
65
+ ___media_editor_panel_index_tsx = __toESM(___media_editor_panel_index_tsx);
66
+ ___media_editor_keyboard_shortcuts_modal_index_tsx = __toESM(___media_editor_keyboard_shortcuts_modal_index_tsx);
61
67
  // packages/media-editor/src/components/media-editor/index.tsx
62
68
  const ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
63
69
  const PLACEMENT_CONTROL_IDLE_MS = 300;
64
70
  /**
65
- * Identifier for the details panel, and the panel the sidebar opens on before
66
- * the user picks another. The sidebar tracks which panel is open rather than
67
- * whether one is, so a further panel is a new id here and a new entry in the
68
- * tab list — not a change to the state's shape.
71
+ * The Details panel's id. Every media type has this panel, so the sidebar
72
+ * shows it when the requested panel doesn't exist.
73
+ *
74
+ * The sidebar stores the open panel's id, so adding a panel only needs a new
75
+ * id and a new tab.
69
76
  */
70
- const DETAILS_PANEL = "details";
77
+ const DETAILS_PANEL = "core/details";
71
78
  /** Identifier for the crop panel. Images only; other media has nothing to crop. */
72
- const CROP_PANEL = "crop";
79
+ const CROP_PANEL = "core/crop";
80
+ const CROP_MEDIA_TYPES = ["image"];
73
81
  const SIDEBAR_ANIMATION_DURATION = .3;
74
82
  const sidebarVariants = {
75
83
  open: { width: "auto" },
@@ -103,6 +111,7 @@ function MediaEditorSidebar({ tabs, activeTab, onSelectTab, disabled = false })
103
111
  value: tab.id,
104
112
  tabIndex: -1,
105
113
  className: "media-editor__panel",
114
+ inert: (0, _wordpress_react_inert_value.inertValue)(disabled),
106
115
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Stack, {
107
116
  direction: "column",
108
117
  gap: "lg",
@@ -125,6 +134,16 @@ function useMediaEditorFrameContext() {
125
134
  if (!context) throw new Error("useMediaEditorFrameContext must be used within MediaEditor");
126
135
  return context;
127
136
  }
137
+ function CropPanelContent({ disabled }) {
138
+ const { aspectRatioPresets } = useMediaEditorFrameContext();
139
+ const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, __use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
140
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_crop_panel_index_tsx.default, {
141
+ aspectRatioValue,
142
+ onAspectRatioChange: setAspectRatioValue,
143
+ aspectRatioOptions,
144
+ disabled
145
+ });
146
+ }
128
147
  function PanelToggle() {
129
148
  const { isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
130
149
  const isPanelOpen = !!activePanel;
@@ -187,7 +206,11 @@ function MoreMenu({ actions = [], item }) {
187
206
  }
188
207
  action.callback(items, { registry });
189
208
  },
190
- children: "RenderModal" in action ? (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._x)("%s…", "menu item requiring further input"), label) : label
209
+ children: "RenderModal" in action ? (0, _wordpress_i18n.sprintf)(
210
+ /** translators: %s: Action label. Use the ellipsis and spacing appropriate for your language. */
211
+ (0, _wordpress_i18n._x)("%s…", "menu item requiring further input"),
212
+ label
213
+ ) : label
191
214
  }, action.id);
192
215
  }) })] })
193
216
  }),
@@ -318,7 +341,7 @@ function SaveActions({ size = "default" }) {
318
341
  })]
319
342
  });
320
343
  }
321
- function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, onEditOriginal, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false }) {
344
+ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, onEditOriginal, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false, defaultPanel = DETAILS_PANEL }) {
322
345
  const session = (0, ______state_index_ts.useMediaEditor)();
323
346
  const isWide = (0, _wordpress_compose.useViewportMatch)("small");
324
347
  const sidebarTransition = {
@@ -336,7 +359,17 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
336
359
  const layout = isWide ? "wide" : "narrow";
337
360
  const sourceMedia = (0, _wordpress_data.useSelect)((select) => select(_wordpress_core_data.store).getEntityRecord("postType", "attachment", id), [id]);
338
361
  const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = (0, _wordpress_data.useDispatch)(_wordpress_core_data.store);
339
- const { removeAllNotices } = (0, _wordpress_data.useDispatch)(_wordpress_notices.store);
362
+ const { createErrorNotice, removeAllNotices } = (0, _wordpress_data.useDispatch)(_wordpress_notices.store);
363
+ const handlePluginError = (0, _wordpress_element.useCallback)((name) => {
364
+ createErrorNotice((0, _wordpress_i18n.sprintf)(
365
+ /** translators: %s: plugin name */
366
+ (0, _wordpress_i18n.__)("The \"%s\" plugin has encountered an error and cannot be rendered."),
367
+ name
368
+ ), {
369
+ type: "snackbar",
370
+ context: __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT
371
+ });
372
+ }, [createErrorNotice]);
340
373
  const [isDiscardDialogOpen, setIsDiscardDialogOpen] = (0, _wordpress_element.useState)(false);
341
374
  const [isPlacementActive, setIsPlacementActive] = (0, _wordpress_element.useState)(false);
342
375
  const [isCanvasGestureActive, setIsCanvasGestureActive] = (0, _wordpress_element.useState)(false);
@@ -410,7 +443,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
410
443
  const hasChanges = session.hasOutputEdits || hasEdits || isSourceReplaced;
411
444
  const mediaType = (0, ______utils_index_ts.getMediaTypeFromMimeType)(media?.mime_type).type;
412
445
  const isImage = !!media && mediaType === "image";
413
- const currentTab = chosenTab ?? (isWide && isImage ? CROP_PANEL : DETAILS_PANEL);
446
+ const currentTab = chosenTab ?? (isWide ? defaultPanel : DETAILS_PANEL);
414
447
  let activePanel = chosenPanel;
415
448
  if (activePanel === void 0) activePanel = isWide ? currentTab : null;
416
449
  const selectPanel = (0, _wordpress_element.useCallback)((panel) => {
@@ -420,7 +453,6 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
420
453
  const togglePanel = (0, _wordpress_element.useCallback)(() => {
421
454
  setChosenPanel(activePanel ? null : currentTab);
422
455
  }, [activePanel, currentTab]);
423
- const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, __use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
424
456
  const { isSaving, save: saveMediaEditor } = (0, __use_save_media_editor_ts.useSaveMediaEditor)({
425
457
  session,
426
458
  id,
@@ -447,7 +479,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
447
479
  }
448
480
  discardAndClose();
449
481
  };
450
- const handleKeyDown = (event) => {
482
+ const handleKeyDown = (0, _wordpress_keycodes.withIgnoreIMEEvents)((event) => {
451
483
  const isUndoShortcut = _wordpress_keycodes.isKeyboardEvent.primary(event, "z");
452
484
  const isRedoShortcut = _wordpress_keycodes.isKeyboardEvent.primaryShift(event, "z") || !(0, _wordpress_keycodes.isAppleOS)() && _wordpress_keycodes.isKeyboardEvent.primary(event, "y");
453
485
  if ((isUndoShortcut || isRedoShortcut) && isImage) {
@@ -470,7 +502,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
470
502
  setIsDiscardDialogOpen(true);
471
503
  }
472
504
  }
473
- };
505
+ });
474
506
  const snackbar = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_notices.SnackbarNotices, {
475
507
  className: noticesClassName,
476
508
  context: __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT
@@ -480,91 +512,78 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
480
512
  aspectRatioPresets,
481
513
  disabled: isSaving
482
514
  }) : null;
483
- const tabs = [...isImage ? [{
484
- id: CROP_PANEL,
485
- title: (0, _wordpress_i18n.__)("Crop"),
486
- render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_crop_panel_index_tsx.default, {
487
- aspectRatioValue,
488
- onAspectRatioChange: setAspectRatioValue,
489
- aspectRatioOptions,
490
- disabled: isSaving
515
+ const { panels, contextValue: panelsContextValue } = (0, ___media_editor_panel_index_tsx.useMediaEditorPanels)();
516
+ const availableTabs = panels.filter((panel) => !panel.mediaTypes || panel.mediaTypes.includes(mediaType)).map((panel) => ({
517
+ id: panel.name,
518
+ title: panel.title,
519
+ render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Slot, {
520
+ bubblesVirtually: true,
521
+ name: (0, ___media_editor_panel_index_tsx.getPanelSlotName)(panel.name),
522
+ fillProps: { disabled: isSaving }
491
523
  })
492
- }] : [], {
493
- id: DETAILS_PANEL,
494
- title: (0, _wordpress_i18n.__)("Details"),
495
- render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_form_index_tsx.default, {})
496
- }];
524
+ }));
525
+ const defaultTab = availableTabs.find((tab) => tab.id === defaultPanel);
526
+ const tabs = defaultTab ? [defaultTab, ...availableTabs.filter((tab) => tab !== defaultTab)] : availableTabs;
497
527
  const ruler = isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_fine_rotation_index_tsx.default, {
498
528
  onPlacementControlInteraction: signalPlacementControlInteraction,
499
529
  disabled: isSaving
500
530
  }) : null;
501
- const children = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(___media_editor_provider_index_tsx.MediaEditorProvider, {
502
- value: media ?? void 0,
503
- onChange: handleChange,
504
- settings: {
505
- fields: isSaving ? fields.map((field) => ({
506
- ...field,
507
- isDisabled: true
508
- })) : fields,
509
- form
510
- },
511
- children: [
512
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
513
- className: "media-editor",
514
- children: !media ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
515
- className: "media-editor__loading",
516
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
517
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
518
- className: (0, clsx.default)("media-editor__body", { "has-panel-open": !!activePanel }),
519
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_admin_ui.NavigableRegion, {
520
- className: "media-editor__content",
521
- ariaLabel: isImage ? (0, _wordpress_i18n.__)("Image editor") : (0, _wordpress_i18n.__)("Media preview"),
522
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
523
- className: "media-editor__canvas-area",
524
- children: isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_canvas_index_tsx.default, {
525
- isPlacementActive,
526
- onGestureStart: handleCanvasGestureStart,
527
- onGestureEnd: handleCanvasGestureEnd,
528
- disabled: isSaving
529
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_preview_index_tsx.default, {})
530
- }), isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
531
- className: "media-editor__canvas-toolbar",
532
- children: [ruler, imageControls]
533
- })]
534
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableAnimatePresence, {
535
- initial: false,
536
- custom: sidebarTransition,
537
- children: !!activePanel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableMotion.div, {
538
- className: "media-editor__sidebar-container",
539
- variants: sidebarVariants,
540
- initial: "closed",
541
- animate: "open",
542
- exit: "closed",
543
- transition: sidebarTransition,
544
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorSidebar, {
545
- tabs,
546
- activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
547
- onSelectTab: selectPanel,
548
- disabled: isSaving
549
- })
550
- })
531
+ const children = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
532
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
533
+ className: "media-editor",
534
+ children: !media ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
535
+ className: "media-editor__loading",
536
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
537
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
538
+ className: (0, clsx.default)("media-editor__body", { "has-panel-open": !!activePanel }),
539
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_admin_ui.NavigableRegion, {
540
+ className: "media-editor__content",
541
+ ariaLabel: isImage ? (0, _wordpress_i18n.__)("Image editor") : (0, _wordpress_i18n.__)("Media preview"),
542
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
543
+ className: "media-editor__canvas-area",
544
+ children: isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_canvas_index_tsx.default, {
545
+ isPlacementActive,
546
+ onGestureStart: handleCanvasGestureStart,
547
+ onGestureEnd: handleCanvasGestureEnd,
548
+ disabled: isSaving
549
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_preview_index_tsx.default, {})
550
+ }), isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
551
+ className: "media-editor__canvas-toolbar",
552
+ children: [ruler, imageControls]
551
553
  })]
552
- })
553
- }),
554
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalConfirmDialog, {
555
- isOpen: isDiscardDialogOpen,
556
- confirmButtonText: (0, _wordpress_i18n.__)("Discard"),
557
- cancelButtonText: (0, _wordpress_i18n.__)("Keep editing"),
558
- onCancel: () => setIsDiscardDialogOpen(false),
559
- onConfirm: () => {
560
- setIsDiscardDialogOpen(false);
561
- discardAndClose();
562
- },
563
- children: (0, _wordpress_i18n.__)("Are you sure you want to discard your unsaved changes?")
564
- }),
565
- noticesPortalElement ? (0, _wordpress_element.createPortal)(snackbar, noticesPortalElement) : snackbar
566
- ]
567
- });
554
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableAnimatePresence, {
555
+ initial: false,
556
+ custom: sidebarTransition,
557
+ children: !!activePanel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableMotion.div, {
558
+ className: "media-editor__sidebar-container",
559
+ variants: sidebarVariants,
560
+ initial: "closed",
561
+ animate: "open",
562
+ exit: "closed",
563
+ transition: sidebarTransition,
564
+ children: tabs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorSidebar, {
565
+ tabs,
566
+ activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
567
+ onSelectTab: selectPanel,
568
+ disabled: isSaving
569
+ })
570
+ })
571
+ })]
572
+ })
573
+ }),
574
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalConfirmDialog, {
575
+ isOpen: isDiscardDialogOpen,
576
+ confirmButtonText: (0, _wordpress_i18n.__)("Discard"),
577
+ cancelButtonText: (0, _wordpress_i18n.__)("Keep editing"),
578
+ onCancel: () => setIsDiscardDialogOpen(false),
579
+ onConfirm: () => {
580
+ setIsDiscardDialogOpen(false);
581
+ discardAndClose();
582
+ },
583
+ children: (0, _wordpress_i18n.__)("Are you sure you want to discard your unsaved changes?")
584
+ }),
585
+ noticesPortalElement ? (0, _wordpress_element.createPortal)(snackbar, noticesPortalElement) : snackbar
586
+ ] });
568
587
  const contextValue = {
569
588
  isImage,
570
589
  isSaving,
@@ -585,7 +604,38 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
585
604
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorFrameContext.Provider, {
586
605
  value: contextValue,
587
606
  children: renderFrame({
588
- children,
607
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_provider_index_tsx.MediaEditorProvider, {
608
+ value: media ?? void 0,
609
+ onChange: handleChange,
610
+ settings: {
611
+ fields: isSaving ? fields.map((field) => ({
612
+ ...field,
613
+ isDisabled: true
614
+ })) : fields,
615
+ form
616
+ },
617
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.SlotFillProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(___media_editor_panel_index_tsx.MediaEditorPanelsProvider, {
618
+ value: panelsContextValue,
619
+ children: [
620
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_panel_index_tsx.default, {
621
+ name: CROP_PANEL,
622
+ title: (0, _wordpress_i18n.__)("Crop"),
623
+ mediaTypes: CROP_MEDIA_TYPES,
624
+ children: ({ disabled }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CropPanelContent, { disabled })
625
+ }),
626
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_panel_index_tsx.default, {
627
+ name: DETAILS_PANEL,
628
+ title: (0, _wordpress_i18n.__)("Details"),
629
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_form_index_tsx.default, {})
630
+ }),
631
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_plugins.PluginArea, {
632
+ scope: ___media_editor_panel_index_tsx.MEDIA_EDITOR_PLUGIN_SCOPE,
633
+ onError: handlePluginError
634
+ }),
635
+ children
636
+ ]
637
+ }) })
638
+ }),
589
639
  isImage,
590
640
  layout,
591
641
  onRequestClose: handleRequestClose,