@wordpress/media-editor 0.17.0 → 0.17.2-next.v.202609031004.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/build/components/media-editor/index.cjs +152 -133
  3. package/build/components/media-editor/index.cjs.map +3 -3
  4. package/build/components/media-editor-crop-panel/index.cjs +2 -3
  5. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  6. package/build/components/media-editor-modal/index.cjs +7 -21
  7. package/build/components/media-editor-modal/index.cjs.map +2 -2
  8. package/build-module/components/media-editor/index.mjs +154 -140
  9. package/build-module/components/media-editor/index.mjs.map +2 -2
  10. package/build-module/components/media-editor-crop-panel/index.mjs +2 -3
  11. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  12. package/build-module/components/media-editor-modal/index.mjs +9 -23
  13. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  14. package/build-style/style-rtl.css +66 -106
  15. package/build-style/style.css +66 -106
  16. package/build-types/components/media-editor/index.d.ts +7 -14
  17. package/build-types/components/media-editor/index.d.ts.map +1 -1
  18. package/build-types/components/media-editor-crop-panel/index.d.ts +4 -11
  19. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  20. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  21. package/package.json +21 -21
  22. package/src/components/media-editor/index.tsx +276 -200
  23. package/src/components/media-editor/style.scss +136 -134
  24. package/src/components/media-editor-crop-panel/index.tsx +4 -12
  25. package/src/components/media-editor-crop-panel/test/{index.tsx → index.jsdom.test.tsx} +2 -10
  26. package/src/components/media-editor-modal/index.tsx +9 -29
  27. package/src/components/media-editor-modal/style.scss +8 -49
  28. package/src/components/media-editor-modal/test/build-modifiers.test.ts +24 -14
  29. package/src/components/rotation-ruler/style.scss +1 -1
  30. package/src/image-editor/core/math/test/sanitize.ts +1 -0
  31. package/src/image-editor/core/test/camera.ts +2 -3
  32. package/src/image-editor/core/test/interaction-controller.ts +50 -40
  33. package/src/image-editor/core/test/preview-export-parity.ts +31 -23
  34. package/src/image-editor/core/test/render-camera-bridge.ts +1 -0
  35. package/src/image-editor/core/test/state.ts +1 -0
  36. package/src/image-editor/core/test/stencil-math.ts +1 -0
  37. package/src/image-editor/core/transforms/test/pipeline.ts +1 -0
  38. package/src/store/test/reducer.ts +9 -8
  39. package/tsconfig.build.json +1 -1
  40. package/tsconfig.build.tsbuildinfo +1 -1
  41. package/tsconfig.json +3 -3
  42. /package/src/components/media-editor/test/{use-crop-options.tsx → use-crop-options.jsdom.test.tsx} +0 -0
  43. /package/src/components/media-editor-image-controls/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  44. /package/src/components/media-editor-modal/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  45. /package/src/components/rotation-ruler/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  46. /package/src/image-editor/core/export/test/{canvas-renderer.ts → canvas-renderer.jsdom.test.ts} +0 -0
  47. /package/src/image-editor/react/components/stencils/test/{rectangle-stencil.tsx → rectangle-stencil.jsdom.test.tsx} +0 -0
  48. /package/src/image-editor/react/components/test/{cropper.tsx → cropper.jsdom.test.tsx} +0 -0
  49. /package/src/image-editor/react/hooks/test/{use-aria-announcer.ts → use-aria-announcer.jsdom.test.ts} +0 -0
  50. /package/src/image-editor/react/hooks/test/{use-cropper-reducer.ts → use-cropper-reducer.jsdom.test.ts} +0 -0
  51. /package/src/image-editor/react/hooks/test/{use-interaction.ts → use-interaction.jsdom.test.ts} +0 -0
  52. /package/src/image-editor/react/hooks/test/{use-transform-style.ts → use-transform-style.jsdom.test.ts} +0 -0
  53. /package/src/state/test/{use-media-editor-state.ts → use-media-editor-state.jsdom.test.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor/index.tsx"],
4
- "sourcesContent": ["import {\n\tButton,\n\tSpinner,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { Stack, Tabs } from '@wordpress/ui';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tcreateContext,\n\tcreatePortal,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close, drawerRight, keyboard, redo, undo } from '@wordpress/icons';\nimport {\n\tdisplayShortcut,\n\tisAppleOS,\n\tisKeyboardEvent,\n} from '@wordpress/keycodes';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport {\n\tComplementaryArea,\n\tInterfaceSkeleton,\n\tPinnedItems,\n\t// @ts-expect-error `@wordpress/interface` is not typed yet.\n} from '@wordpress/interface';\nimport type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\nimport { MediaEditorProvider } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\nimport MediaPreview from '../media-preview';\nimport MediaEditorCanvas from '../media-editor-canvas';\nimport MediaEditorFineRotation from '../media-editor-fine-rotation';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport MediaEditorCropPanel from '../media-editor-crop-panel';\nimport MediaForm from '../media-form';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { MediaEditorStateProvider, useMediaEditor } from '../../state';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorKeyboardShortcutsModal from '../media-editor-keyboard-shortcuts-modal';\nimport {\n\tMEDIA_EDITOR_NOTICES_CONTEXT,\n\tuseSaveMediaEditor,\n\ttype MediaEditorSaveResult,\n} from './use-save-media-editor';\nimport { useCropOptions } from './use-crop-options';\n\nexport type { MediaEditorSaveResult } from './use-save-media-editor';\n\n// Embed query for the attachment's author and parent post. Shared between\n// the `getEntityRecord` read and the matching `invalidateResolution` so the\n// two stay in lockstep.\nconst ATTACHMENT_EMBED_QUERY = { _embed: 'author,wp:attached-to' } as const;\n\nconst PLACEMENT_CONTROL_IDLE_MS = 300;\n\ninterface EditorTab {\n\tid: string;\n\ttitle: string;\n\tpanel: JSX.Element;\n}\n\nexport interface MediaEditorFrameProps {\n\tchildren: ReactNode;\n\t/**\n\t * Whether the media being edited is an image. The history and transform\n\t * clusters render nothing for other media types, so a frame uses this to\n\t * decide whether the container it would put them in is worth rendering at\n\t * all.\n\t */\n\tisImage: boolean;\n\tlayout: 'wide' | 'narrow';\n\tonRequestClose: () => void;\n\tonKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;\n\tshouldCloseOnClickOutside: boolean;\n\tisSaving: boolean;\n\thasChanges: boolean;\n\thasMedia: boolean;\n}\n\nexport interface MediaEditorProps {\n\tfields?: Field< Media >[];\n\tid: number;\n\taspectRatioPresets?: AspectRatioPreset[];\n\tonClose?: () => void;\n\tonSaved?: ( result: MediaEditorSaveResult ) => void;\n\trenderFrame: ( props: MediaEditorFrameProps ) => JSX.Element;\n\tnoticesClassName?: string;\n\tnoticesPortalElement?: Element | null;\n\tshouldCloseOnEsc?: boolean;\n\t/**\n\t * The `@wordpress/interface` scope for the details sidebar and its pinned\n\t * items. Frames should pass a distinct scope so that sidebar visibility —\n\t * which is persisted per scope to user meta — is remembered separately for\n\t * each surface. The modal is a transient surface where a collapsed sidebar\n\t * is a reasonable choice; the full-screen route is one where the sidebar is\n\t * the primary metadata surface and should open by default. Sharing a scope\n\t * would let a choice made in one decide the other's starting state.\n\t *\n\t * @default 'media-editor'\n\t */\n\tscope?: string;\n}\n\ninterface MediaEditorSidebarProps {\n\ttabs: EditorTab[];\n\tactiveTabId?: string;\n\tonTabChange: ( tabId: string ) => void;\n\tscope: string;\n}\n\nfunction MediaEditorSidebar( {\n\ttabs,\n\tactiveTabId,\n\tonTabChange,\n\tscope,\n}: MediaEditorSidebarProps ) {\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tscope={ scope }\n\t\t\tidentifier=\"media-editor/details\"\n\t\t\ttitle={ __( 'Details' ) }\n\t\t\ticon={ drawerRight }\n\t\t\tisActiveByDefault\n\t\t\tclassName=\"media-editor__sidebar\"\n\t\t\tpanelClassName=\"media-editor__sidebar-panel\"\n\t\t\theaderClassName=\"media-editor__sidebar-header\"\n\t\t\tcloseLabel={ __( 'Close media panel' ) }\n\t\t\t// Makes `Tabs.Root` the container, so the tab list passed as\n\t\t\t// `header` and the panels below share a subtree across the fill.\n\t\t\trender={\n\t\t\t\t<Tabs.Root\n\t\t\t\t\tvalue={ activeTabId }\n\t\t\t\t\tonValueChange={ ( value ) =>\n\t\t\t\t\t\tonTabChange( value as string )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t}\n\t\t\theader={\n\t\t\t\t<Tabs.List variant=\"minimal\">\n\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab key={ tab.id } value={ tab.id }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.List>\n\t\t\t}\n\t\t>\n\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t<Tabs.Panel key={ tab.id } value={ tab.id } tabIndex={ -1 }>\n\t\t\t\t\t{ tab.panel }\n\t\t\t\t</Tabs.Panel>\n\t\t\t) ) }\n\t\t</ComplementaryArea>\n\t);\n}\n\n/**\n * Everything the frame's action clusters need from the editor. Supplied by\n * context rather than by props so the clusters can be module-level components:\n * a component created during a render has a new identity on every pass, which\n * remounts its subtree and drops focus mid-interaction.\n */\ninterface MediaEditorFrameContextValue {\n\tisImage: boolean;\n\tisSaving: boolean;\n\thasMedia: boolean;\n\thasChanges: boolean;\n\tisUndoRedoDisabled: boolean;\n\tscope: string;\n\taspectRatioPresets?: AspectRatioPreset[];\n\tonCancel: () => void;\n\tonSave: () => void;\n\tonReset: () => void;\n}\n\nconst MediaEditorFrameContext =\n\tcreateContext< MediaEditorFrameContextValue | null >( null );\n\n/**\n * Hook to access the media editor's frame context.\n *\n * Must be used within a MediaEditor component.\n *\n * @return MediaEditorFrameContextValue the action clusters render from.\n */\nfunction useMediaEditorFrameContext(): MediaEditorFrameContextValue {\n\tconst context = useContext( MediaEditorFrameContext );\n\tif ( ! context ) {\n\t\tthrow new Error(\n\t\t\t'useMediaEditorFrameContext must be used within MediaEditor'\n\t\t);\n\t}\n\treturn context;\n}\n\nexport interface HeaderActionsProps {\n\t/**\n\t * Whether to include a Close button. Frames with a dismissal affordance of\n\t * their own — a route's breadcrumbs, say — leave it out.\n\t *\n\t * @default false\n\t */\n\tshowCloseButton?: boolean;\n}\n\nfunction HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {\n\tconst { isImage, isSaving, onCancel, scope } = useMediaEditorFrameContext();\n\tconst [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__header-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t{ isImage && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ keyboard }\n\t\t\t\t\tlabel={ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\tonClick={ () => setIsShortcutsModalOpen( true ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<PinnedItems.Slot scope={ scope } />\n\t\t\t{ showCloseButton && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isShortcutsModalOpen && (\n\t\t\t\t<MediaEditorKeyboardShortcutsModal\n\t\t\t\t\tonClose={ () => setIsShortcutsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction HistoryActions() {\n\tconst { isImage, isUndoRedoDisabled, onReset } =\n\t\tuseMediaEditorFrameContext();\n\tconst {\n\t\treset,\n\t\tisDirty,\n\t\thasUndo,\n\t\thasRedo,\n\t\tundo: undoCrop,\n\t\tredo: redoCrop,\n\t\tbeginGesture,\n\t\tendGesture,\n\t} = useMediaEditor();\n\t// Non-image media has no edit history. Checked after the hooks above so\n\t// the hook order stays stable across renders.\n\tif ( ! isImage ) {\n\t\treturn null;\n\t}\n\tconst handleUndo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tundoCrop();\n\t};\n\tconst handleRedo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tredoCrop();\n\t};\n\tconst handleReset = () => {\n\t\tbeginGesture();\n\t\treset();\n\t\tonReset();\n\t\tendGesture();\n\t};\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__history-actions\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleReset }\n\t\t\t>\n\t\t\t\t{ __( 'Reset' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ undo }\n\t\t\t\tlabel={ __( 'Undo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasUndo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleUndo }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ redo }\n\t\t\t\tlabel={ __( 'Redo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={\n\t\t\t\t\tisAppleOS()\n\t\t\t\t\t\t? displayShortcut.primaryShift( 'z' )\n\t\t\t\t\t\t: displayShortcut.primary( 'y' )\n\t\t\t\t}\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasRedo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleRedo }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n\nexport interface SaveActionsProps {\n\t/**\n\t * Button height. Footers take the 40px default; frames placing these in a\n\t * page header pass `compact` to match the header's other controls.\n\t *\n\t * @default 'default'\n\t */\n\tsize?: 'default' | 'compact';\n}\n\nfunction SaveActions( { size = 'default' }: SaveActionsProps ) {\n\tconst { isSaving, hasMedia, hasChanges, onCancel, onSave } =\n\t\tuseMediaEditorFrameContext();\n\tconst saveDisabled = isSaving || ! hasMedia || ! hasChanges;\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__save-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tonClick={ onCancel }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ onSave }\n\t\t\t\tisBusy={ isSaving }\n\t\t\t\tdisabled={ saveDisabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Save' ) }\n\t\t\t</Button>\n\t\t</Stack>\n\t);\n}\n\nfunction ImageControls() {\n\tconst { isImage, aspectRatioPresets } = useMediaEditorFrameContext();\n\t// Non-image media has nothing to transform. Placement is the frame's call:\n\t// render this only in the `narrow` layout, since above that breakpoint the\n\t// Crop panel holds these controls already.\n\tif ( ! isImage ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<MediaEditorImageControls\n\t\t\tshowAspectRatioControl\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t/>\n\t);\n}\n\nfunction MediaEditorContent( {\n\tfields = [],\n\tid,\n\taspectRatioPresets,\n\tonClose,\n\tonSaved,\n\trenderFrame,\n\tnoticesClassName = 'media-editor__snackbar',\n\tnoticesPortalElement,\n\tshouldCloseOnEsc = false,\n\tscope = 'media-editor',\n}: MediaEditorProps ) {\n\tconst cropper = useMediaEditor();\n\t// The sidebar is a side column from the `small` breakpoint up and collapses\n\t// to an overlay below it — mirroring InterfaceSkeleton's behaviour, shifted\n\t// from `medium` to `small` (see the matching CSS overrides in style.scss).\n\t// Track that single breakpoint: in \"panel mode\" (≥ small) the\n\t// rotate/flip/zoom controls live in the Crop panel; below it they have no\n\t// panel to live in and the frame places them instead. (The fine-rotation\n\t// ruler always sits under the canvas.)\n\tconst isPanelLayout = useViewportMatch( 'small' );\n\tconst layout: 'wide' | 'narrow' = isPanelLayout ? 'wide' : 'narrow';\n\n\tconst { media, hasEdits } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\thasEditsForEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\t// Trigger an _embed fetch so `_embedded.author` and\n\t\t\t// `_embedded['wp:attached-to']` land on the record for the Details\n\t\t\t// fields to read. `getEditedEntityRecord` doesn't formally accept a\n\t\t\t// query, so we can't embed via that selector directly.\n\t\t\tgetEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tid,\n\t\t\t\tATTACHMENT_EMBED_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tmedia: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) as Media,\n\t\t\t\thasEdits: hasEditsForEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id ]\n\t);\n\n\tconst hasChanges = cropper.isCropperDirty || hasEdits;\n\n\tconst { clearEntityRecordEdits, editEntityRecord, invalidateResolution } =\n\t\tuseDispatch( coreStore );\n\tconst { removeAllNotices } = useDispatch( noticesStore );\n\n\tconst [ isDiscardDialogOpen, setIsDiscardDialogOpen ] = useState( false );\n\tconst [ isPlacementActive, setIsPlacementActive ] = useState( false );\n\tconst [ isCanvasGestureActive, setIsCanvasGestureActive ] =\n\t\tuseState( false );\n\tconst placementControlTimerRef =\n\t\tuseRef< ReturnType< typeof setTimeout > >();\n\n\tconst signalPlacementControlInteraction = useCallback( () => {\n\t\tsetIsPlacementActive( true );\n\t\tclearTimeout( placementControlTimerRef.current );\n\t\tplacementControlTimerRef.current = setTimeout( () => {\n\t\t\tsetIsPlacementActive( false );\n\t\t}, PLACEMENT_CONTROL_IDLE_MS );\n\t}, [] );\n\tconst handleCanvasGestureStart = useCallback( () => {\n\t\tsetIsCanvasGestureActive( true );\n\t}, [] );\n\tconst handleCanvasGestureEnd = useCallback( () => {\n\t\tsetIsCanvasGestureActive( false );\n\t}, [] );\n\tconst isCropInteractionActive = isPlacementActive || isCanvasGestureActive;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( placementControlTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsPlacementActive( false );\n\t\tsetIsCanvasGestureActive( false );\n\t}, [ id ] );\n\n\t// Bust the cached `_embed` resolution each time the editor mounts (or the\n\t// id changes) so embedded data such as the attached post's title or the\n\t// author's name reflects any edits made elsewhere since the last open.\n\tuseEffect( () => {\n\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t'postType',\n\t\t\t'attachment',\n\t\t\tid,\n\t\t\tATTACHMENT_EMBED_QUERY,\n\t\t] );\n\t}, [ id, invalidateResolution ] );\n\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type ).type;\n\tconst isImage = !! media && mediaType === 'image';\n\tconst {\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tresetCropOptions,\n\t} = useCropOptions( {\n\t\taspectRatioPresets,\n\t} );\n\tconst { isSaving, save: saveMediaEditor } = useSaveMediaEditor( {\n\t\tcropper,\n\t\tid,\n\t\tisImage,\n\t\tmedia,\n\t\tonSaved,\n\t} );\n\n\tconst tabs = useMemo< EditorTab[] >( () => {\n\t\tconst detailsTab: EditorTab = {\n\t\t\tid: 'details',\n\t\t\ttitle: __( 'Details' ),\n\t\t\tpanel: (\n\t\t\t\t<Stack\n\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"lg\"\n\t\t\t\t>\n\t\t\t\t\t<MediaForm />\n\t\t\t\t</Stack>\n\t\t\t),\n\t\t};\n\t\tif ( ! isImage ) {\n\t\t\treturn [ detailsTab ];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'crop',\n\t\t\t\ttitle: __( 'Crop' ),\n\t\t\t\tpanel: (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\tgap=\"lg\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<MediaEditorCropPanel\n\t\t\t\t\t\t\taspectRatioValue={ aspectRatioValue }\n\t\t\t\t\t\t\tonAspectRatioChange={ setAspectRatioValue }\n\t\t\t\t\t\t\taspectRatioOptions={ aspectRatioOptions }\n\t\t\t\t\t\t\tshowTransformControls={ isPanelLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Stack>\n\t\t\t\t),\n\t\t\t},\n\t\t\tdetailsTab,\n\t\t];\n\t}, [\n\t\tisImage,\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tisPanelLayout,\n\t] );\n\n\t// Control the active tab from state here so the selection survives the\n\t// sidebar closing (which unmounts the `ComplementaryArea` Fill and its\n\t// tabs). Fall back to the first tab until one is picked, so images open on\n\t// Crop.\n\tconst [ selectedTabId, setSelectedTabId ] = useState< string >();\n\tconst activeTabId = selectedTabId ?? tabs[ 0 ]?.id;\n\n\tconst handleChange = ( updates: Partial< Media > ) => {\n\t\teditEntityRecord( 'postType', 'attachment', id, updates );\n\t};\n\n\tconst discardAndClose = () => {\n\t\tremoveAllNotices( 'snackbar', MEDIA_EDITOR_NOTICES_CONTEXT );\n\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\tonClose?.();\n\t};\n\n\tconst handleRequestClose = () => {\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( hasChanges ) {\n\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\treturn;\n\t\t}\n\t\tdiscardAndClose();\n\t};\n\n\tconst handleKeyDown = ( event: ReactKeyboardEvent< HTMLElement > ) => {\n\t\tconst isUndoShortcut = isKeyboardEvent.primary( event, 'z' );\n\t\tconst isRedoShortcut =\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' ) ||\n\t\t\t( ! isAppleOS() && isKeyboardEvent.primary( event, 'y' ) );\n\t\tif ( ( isUndoShortcut || isRedoShortcut ) && isImage ) {\n\t\t\tconst target = event.target as HTMLElement;\n\t\t\tconst isMetadataField =\n\t\t\t\t( target.tagName === 'INPUT' ||\n\t\t\t\t\ttarget.tagName === 'TEXTAREA' ||\n\t\t\t\t\ttarget.isContentEditable ) &&\n\t\t\t\t! target.closest( `[${ CROP_CONTROL_ATTR }]` );\n\t\t\tif ( ! isMetadataField ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( isCropInteractionActive ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( isRedoShortcut ) {\n\t\t\t\t\tcropper.redo();\n\t\t\t\t} else {\n\t\t\t\t\tcropper.undo();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( shouldCloseOnEsc ) {\n\t\t\tif ( event.code !== 'Escape' && event.key !== 'Escape' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( isSaving ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( hasChanges ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst snackbar = (\n\t\t<SnackbarNotices\n\t\t\tclassName={ noticesClassName }\n\t\t\tcontext={ MEDIA_EDITOR_NOTICES_CONTEXT }\n\t\t/>\n\t);\n\n\tconst ruler = isImage ? (\n\t\t<MediaEditorFineRotation\n\t\t\tonPlacementControlInteraction={ signalPlacementControlInteraction }\n\t\t/>\n\t) : null;\n\n\tconst children = (\n\t\t<MediaEditorProvider\n\t\t\tvalue={ media ?? undefined }\n\t\t\tonChange={ handleChange }\n\t\t\tsettings={ { fields } }\n\t\t>\n\t\t\t<div className=\"media-editor\">\n\t\t\t\t{ ! media ? (\n\t\t\t\t\t<div className=\"media-editor__loading\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MediaEditorSidebar\n\t\t\t\t\t\t\ttabs={ tabs }\n\t\t\t\t\t\t\tactiveTabId={ activeTabId }\n\t\t\t\t\t\t\tonTabChange={ setSelectedTabId }\n\t\t\t\t\t\t\tscope={ scope }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\tclassName=\"media-editor__skeleton\"\n\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\tbody: isImage\n\t\t\t\t\t\t\t\t\t? __( 'Image editor' )\n\t\t\t\t\t\t\t\t\t: __( 'Media preview' ),\n\t\t\t\t\t\t\t\tsidebar: __( 'Media details' ),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t<div className=\"media-editor__content\">\n\t\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas-area\">\n\t\t\t\t\t\t\t\t\t\t{ isImage ? (\n\t\t\t\t\t\t\t\t\t\t\t<MediaEditorCanvas\n\t\t\t\t\t\t\t\t\t\t\t\tisPlacementActive={\n\t\t\t\t\t\t\t\t\t\t\t\t\tisPlacementActive\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tonGestureStart={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureStart\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tonGestureEnd={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureEnd\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t<MediaPreview />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t{ isImage && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas-toolbar\">\n\t\t\t\t\t\t\t\t\t\t\t{ ruler }\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope={ scope } />\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isDiscardDialogOpen }\n\t\t\t\tconfirmButtonText={ __( 'Discard' ) }\n\t\t\t\tcancelButtonText={ __( 'Keep editing' ) }\n\t\t\t\tonCancel={ () => setIsDiscardDialogOpen( false ) }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\tsetIsDiscardDialogOpen( false );\n\t\t\t\t\tdiscardAndClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Are you sure you want to discard your unsaved changes?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t\t{ noticesPortalElement\n\t\t\t\t? createPortal( snackbar, noticesPortalElement )\n\t\t\t\t: snackbar }\n\t\t</MediaEditorProvider>\n\t);\n\n\t// Rebuilt each render, like the elements it replaces: consumers re-render\n\t// as they always did, but the cluster component types stay stable.\n\tconst contextValue: MediaEditorFrameContextValue = {\n\t\tisImage,\n\t\tisSaving,\n\t\thasMedia: !! media,\n\t\thasChanges,\n\t\tisUndoRedoDisabled: isCropInteractionActive,\n\t\tscope,\n\t\taspectRatioPresets,\n\t\tonCancel: handleRequestClose,\n\t\tonSave: saveMediaEditor,\n\t\tonReset: resetCropOptions,\n\t};\n\n\treturn (\n\t\t<MediaEditorFrameContext.Provider value={ contextValue }>\n\t\t\t{ renderFrame( {\n\t\t\t\tchildren,\n\t\t\t\tisImage,\n\t\t\t\tlayout,\n\t\t\t\tonRequestClose: handleRequestClose,\n\t\t\t\tonKeyDown: handleKeyDown,\n\t\t\t\tshouldCloseOnClickOutside: ! hasChanges && ! isSaving,\n\t\t\t\tisSaving,\n\t\t\t\thasChanges,\n\t\t\t\thasMedia: !! media,\n\t\t\t} ) }\n\t\t</MediaEditorFrameContext.Provider>\n\t);\n}\n\nexport function MediaEditor( props: MediaEditorProps ) {\n\treturn (\n\t\t<MediaEditorStateProvider key={ props.id }>\n\t\t\t<MediaEditorContent { ...props } />\n\t\t</MediaEditorStateProvider>\n\t);\n}\n\n// Attached to `MediaEditor` so frames import and arrange them, the way\n// `DataViewsPicker` exposes its own sub-components. They read what they need\n// from context, so a frame only chooses where they go and how they look.\nMediaEditor.HeaderActions = HeaderActions;\nMediaEditor.HistoryActions = HistoryActions;\nMediaEditor.SaveActions = SaveActions;\nMediaEditor.ImageControls = ImageControls;\n\nexport default MediaEditor;\n"],
5
- "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,SAAS,OAAO,YAAY;AAC5B,SAAS,wBAAwB;AACjC,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,OAAO,aAAa,UAAU,MAAM,YAAY;AACzD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,iBAAiB,SAAS,oBAAoB;AAEvD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAEP,SAAS,2BAA2B;AAEpC,OAAO,kBAAkB;AACzB,OAAO,uBAAuB;AAC9B,OAAO,6BAA6B;AACpC,OAAO,8BAA8B;AACrC,OAAO,0BAA0B;AACjC,OAAO,eAAe;AACtB,SAAS,gCAAgC;AACzC,SAAS,0BAA0B,sBAAsB;AAEzD,SAAS,yBAAyB;AAClC,OAAO,uCAAuC;AAC9C;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,sBAAsB;AAsF3B,SAsgBC,UAtgBD,KA+EF,YA/EE;AA/EJ,IAAM,yBAAyB,EAAE,QAAQ,wBAAwB;AAEjE,IAAM,4BAA4B;AAyDlC,SAAS,mBAAoB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA6B;AAC5B,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,YAAW;AAAA,MACX,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YACA,QAAS;AAAA,YACT,mBAAoB,GAAI,SAAU;AAAA,YAClC,kBAAmB,GAAI,cAAe;AAAA,YACtC,UAAW,MAAM,uBAAwB,KAAM;AAAA,YAC/C,WAAY,MAAM;AACjB,qCAAwB,KAAM;AAC9B,8BAAgB;AAAA,YACjB;AAAA,YAEE;AAAA,cACD;AAAA,YACD;AAAA;AAAA,QACD;AAAA,QACE,uBACC,aAAc,UAAU,oBAAqB,IAC7C;AAAA;AAAA;AAAA,EACJ;AAKD,QAAM,eAA6C;AAAA,IAClD;AAAA,IACA;AAAA,IACA,UAAU,CAAC,CAAE;AAAA,IACb;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,EACV;AAEA,SACC,oBAAC,wBAAwB,UAAxB,EAAiC,OAAQ,cACvC,sBAAa;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,2BAA2B,CAAE,cAAc,CAAE;AAAA,IAC7C;AAAA,IACA;AAAA,IACA,UAAU,CAAC,CAAE;AAAA,EACd,CAAE,GACH;AAEF;AAEO,SAAS,YAAa,OAA0B;AACtD,SACC,oBAAC,4BACA,8BAAC,sBAAqB,GAAG,OAAQ,KADF,MAAM,EAEtC;AAEF;AAKA,YAAY,gBAAgB;AAC5B,YAAY,iBAAiB;AAC7B,YAAY,cAAc;AAC1B,YAAY,gBAAgB;AAE5B,IAAO,uBAAQ;",
4
+ "sourcesContent": ["import clsx from 'clsx';\nimport {\n\tButton,\n\tSpinner,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { Stack, Tabs, VisuallyHidden } from '@wordpress/ui';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { NavigableRegion } from '@wordpress/admin-ui';\nimport {\n\tcreateContext,\n\tcreatePortal,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close, drawerRight, keyboard, redo, undo } from '@wordpress/icons';\nimport {\n\tdisplayShortcut,\n\tisAppleOS,\n\tisKeyboardEvent,\n} from '@wordpress/keycodes';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\nimport { MediaEditorProvider } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\nimport MediaPreview from '../media-preview';\nimport MediaEditorCanvas from '../media-editor-canvas';\nimport MediaEditorFineRotation from '../media-editor-fine-rotation';\nimport MediaEditorCropPanel from '../media-editor-crop-panel';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport MediaForm from '../media-form';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { MediaEditorStateProvider, useMediaEditor } from '../../state';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorKeyboardShortcutsModal from '../media-editor-keyboard-shortcuts-modal';\nimport {\n\tMEDIA_EDITOR_NOTICES_CONTEXT,\n\tuseSaveMediaEditor,\n\ttype MediaEditorSaveResult,\n} from './use-save-media-editor';\nimport { useCropOptions } from './use-crop-options';\n\nexport type { MediaEditorSaveResult } from './use-save-media-editor';\n\n// Embed query for the attachment's author and parent post. Shared between\n// the `getEntityRecord` read and the matching `invalidateResolution` so the\n// two stay in lockstep.\nconst ATTACHMENT_EMBED_QUERY = { _embed: 'author,wp:attached-to' } as const;\n\nconst PLACEMENT_CONTROL_IDLE_MS = 300;\n\n/**\n * Identifier for the details panel, and the panel the sidebar opens on before\n * the user picks another. The sidebar tracks which panel is open rather than\n * whether one is, so a further panel is a new id here and a new entry in the\n * tab list — not a change to the state's shape.\n */\nconst DETAILS_PANEL = 'details';\n\n/** Identifier for the crop panel. Images only; other media has nothing to crop. */\nconst CROP_PANEL = 'crop';\n\ninterface MediaEditorTab {\n\tid: string;\n\ttitle: string;\n\trender: () => JSX.Element;\n}\n\nexport interface MediaEditorFrameProps {\n\tchildren: ReactNode;\n\t/**\n\t * Whether the media being edited is an image. The history and transform\n\t * clusters render nothing for other media types, so a frame uses this to\n\t * decide whether the container it would put them in is worth rendering at\n\t * all.\n\t */\n\tisImage: boolean;\n\t/**\n\t * `narrow` below the `small` breakpoint, where the frame's header has no\n\t * room for the history cluster beside its other controls. A frame uses\n\t * this to place that cluster, not to decide whether it renders —\n\t * `HistoryActions` returns nothing on its own when the canvas is off\n\t * screen.\n\t */\n\tlayout: 'wide' | 'narrow';\n\tonRequestClose: () => void;\n\tonKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;\n\tshouldCloseOnClickOutside: boolean;\n\tisSaving: boolean;\n\thasChanges: boolean;\n\thasMedia: boolean;\n}\n\nexport interface MediaEditorProps {\n\tfields?: Field< Media >[];\n\tid: number;\n\taspectRatioPresets?: AspectRatioPreset[];\n\tonClose?: () => void;\n\tonSaved?: ( result: MediaEditorSaveResult ) => void;\n\trenderFrame: ( props: MediaEditorFrameProps ) => JSX.Element;\n\tnoticesClassName?: string;\n\tnoticesPortalElement?: Element | null;\n\tshouldCloseOnEsc?: boolean;\n}\n\ninterface MediaEditorSidebarProps {\n\ttabs: MediaEditorTab[];\n\t/** The open panel's id. Always one of `tabs`. */\n\tactiveTab: string;\n\tonSelectTab: ( tab: string ) => void;\n}\n\nfunction MediaEditorSidebar( {\n\ttabs,\n\tactiveTab,\n\tonSelectTab,\n}: MediaEditorSidebarProps ) {\n\treturn (\n\t\t<NavigableRegion\n\t\t\tclassName=\"media-editor__sidebar\"\n\t\t\tariaLabel={ __( 'Media settings' ) }\n\t\t>\n\t\t\t{ /* No visible heading and no close button: the strip below names\n\t\t\t the open panel and the header's pressed toggle dismisses it.\n\t\t\t The heading stays for screen readers, which read neither as\n\t\t\t this region's title. */ }\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Media settings' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Tabs.Root\n\t\t\t\tclassName=\"media-editor__tabs\"\n\t\t\t\tvalue={ activeTab }\n\t\t\t\tonValueChange={ onSelectTab }\n\t\t\t>\n\t\t\t\t{ /* `Tabs.List` sizes itself to its tabs (`width: fit-content`),\n\t\t\t\t so the rule under the strip is drawn by this wrapper\n\t\t\t\t instead, which spans the column. */ }\n\t\t\t\t<div className=\"media-editor__tablist\">\n\t\t\t\t\t<Tabs.List variant=\"minimal\">\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.Tab key={ tab.id } value={ tab.id }>\n\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs.List>\n\t\t\t\t</div>\n\t\t\t\t{ /* One `Tabs.Panel` per tab: the counts have to match or\n\t\t\t\t `Tabs.Root` throws in dev. Only the active one paints\n\t\t\t\t anything — the rest render nothing. */ }\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<Tabs.Panel\n\t\t\t\t\t\tkey={ tab.id }\n\t\t\t\t\t\tvalue={ tab.id }\n\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t\t\t{ tab.render() }\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</Tabs.Panel>\n\t\t\t\t) ) }\n\t\t\t</Tabs.Root>\n\t\t</NavigableRegion>\n\t);\n}\n\n/**\n * Everything the frame's action clusters need from the editor. Supplied by\n * context rather than by props so the clusters can be module-level components:\n * a component created during a render has a new identity on every pass, which\n * remounts its subtree and drops focus mid-interaction.\n */\ninterface MediaEditorFrameContextValue {\n\tisImage: boolean;\n\tisSaving: boolean;\n\thasMedia: boolean;\n\thasChanges: boolean;\n\tisUndoRedoDisabled: boolean;\n\taspectRatioPresets?: AspectRatioPreset[];\n\t/** `true` above `large`, where the panel docks beside the canvas. */\n\tisWide: boolean;\n\t/** The open panel's id, or `null` when none is. */\n\tactivePanel: string | null;\n\t/**\n\t * Opens the sidebar on the last-shown panel, or closes it when one is\n\t * already open.\n\t */\n\tonTogglePanel: () => void;\n\tonCancel: () => void;\n\tonSave: () => void;\n\tonReset: () => void;\n}\n\nconst MediaEditorFrameContext =\n\tcreateContext< MediaEditorFrameContextValue | null >( null );\n\n/**\n * Hook to access the media editor's frame context.\n *\n * Must be used within a MediaEditor component.\n *\n * @return MediaEditorFrameContextValue the action clusters render from.\n */\nfunction useMediaEditorFrameContext(): MediaEditorFrameContextValue {\n\tconst context = useContext( MediaEditorFrameContext );\n\tif ( ! context ) {\n\t\tthrow new Error(\n\t\t\t'useMediaEditorFrameContext must be used within MediaEditor'\n\t\t);\n\t}\n\treturn context;\n}\n\nexport interface HeaderActionsProps {\n\t/**\n\t * Whether to include a Close button. Frames with a dismissal affordance of\n\t * their own — a route's breadcrumbs, say — leave it out.\n\t *\n\t * @default false\n\t */\n\tshowCloseButton?: boolean;\n}\n\nfunction HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {\n\tconst { isImage, isSaving, onCancel, isWide, activePanel, onTogglePanel } =\n\t\tuseMediaEditorFrameContext();\n\tconst isPanelOpen = !! activePanel;\n\tconst [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__header-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t{ isImage && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ keyboard }\n\t\t\t\t\tlabel={ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\tonClick={ () => setIsShortcutsModalOpen( true ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ /* The sidebar holds more than one panel, so this opens and\n\t\t\t closes the sidebar rather than naming a panel: reopening\n\t\t\t returns to whichever tab was last showing, and the tab strip\n\t\t\t inside switches between them. */ }\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ drawerRight }\n\t\t\t\tlabel={ __( 'Media settings' ) }\n\t\t\t\tisPressed={ isPanelOpen }\n\t\t\t\t// Only a docked column really expands beside the canvas; below\n\t\t\t\t// that the panel replaces the view, which the pressed state\n\t\t\t\t// already describes.\n\t\t\t\taria-expanded={ isWide ? isPanelOpen : undefined }\n\t\t\t\tonClick={ onTogglePanel }\n\t\t\t/>\n\t\t\t{ showCloseButton && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isShortcutsModalOpen && (\n\t\t\t\t<MediaEditorKeyboardShortcutsModal\n\t\t\t\t\tonClose={ () => setIsShortcutsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction HistoryActions() {\n\tconst { isImage, isUndoRedoDisabled, onReset, isWide, activePanel } =\n\t\tuseMediaEditorFrameContext();\n\tconst {\n\t\treset,\n\t\tisDirty,\n\t\thasUndo,\n\t\thasRedo,\n\t\tundo: undoCrop,\n\t\tredo: redoCrop,\n\t\tbeginGesture,\n\t\tendGesture,\n\t} = useMediaEditor();\n\t// Reset, undo and redo act on the cropper, so they only appear where the\n\t// canvas does. Non-image media has no edit history at all; below the dock\n\t// breakpoint an open panel replaces the canvas, and leaving these behind\n\t// would put an enabled, destructive Reset next to metadata fields it does\n\t// not touch — clicking it would discard a crop the user cannot see.\n\t// (Metadata edits have no undo of their own; a history spanning both is a\n\t// larger change than hiding these.) Checked after the hooks above so the\n\t// hook order stays stable across renders.\n\tif ( ! isImage || ( ! isWide && !! activePanel ) ) {\n\t\treturn null;\n\t}\n\tconst handleUndo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tundoCrop();\n\t};\n\tconst handleRedo = () => {\n\t\tif ( isUndoRedoDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tredoCrop();\n\t};\n\tconst handleReset = () => {\n\t\tbeginGesture();\n\t\treset();\n\t\tonReset();\n\t\tendGesture();\n\t};\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__history-actions\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleReset }\n\t\t\t>\n\t\t\t\t{ __( 'Reset' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ undo }\n\t\t\t\tlabel={ __( 'Undo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasUndo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleUndo }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ redo }\n\t\t\t\tlabel={ __( 'Redo' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tshortcut={\n\t\t\t\t\tisAppleOS()\n\t\t\t\t\t\t? displayShortcut.primaryShift( 'z' )\n\t\t\t\t\t\t: displayShortcut.primary( 'y' )\n\t\t\t\t}\n\t\t\t\tdisabled={ isUndoRedoDisabled || ! hasRedo }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ handleRedo }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n\nexport interface SaveActionsProps {\n\t/**\n\t * Button height. Footers take the 40px default; frames placing these in a\n\t * page header pass `compact` to match the header's other controls.\n\t *\n\t * @default 'default'\n\t */\n\tsize?: 'default' | 'compact';\n}\n\nfunction SaveActions( { size = 'default' }: SaveActionsProps ) {\n\tconst { isSaving, hasMedia, hasChanges, onCancel, onSave } =\n\t\tuseMediaEditorFrameContext();\n\tconst saveDisabled = isSaving || ! hasMedia || ! hasChanges;\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"media-editor__save-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"sm\"\n\t\t>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tonClick={ onCancel }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ onSave }\n\t\t\t\tisBusy={ isSaving }\n\t\t\t\tdisabled={ saveDisabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Save' ) }\n\t\t\t</Button>\n\t\t</Stack>\n\t);\n}\n\nfunction MediaEditorContent( {\n\tfields = [],\n\tid,\n\taspectRatioPresets,\n\tonClose,\n\tonSaved,\n\trenderFrame,\n\tnoticesClassName = 'media-editor__snackbar',\n\tnoticesPortalElement,\n\tshouldCloseOnEsc = false,\n}: MediaEditorProps ) {\n\tconst cropper = useMediaEditor();\n\t// Width decides whether the settings panel docks beside the canvas or\n\t// takes the whole body. It docks from `small` (600px): the modal is the\n\t// viewport less a 16px margin either side, so a 320px panel and the\n\t// canvas column's 2 x 24px gutters still leave the canvas ~200px there\n\t// and ~380px by 782px. Tight, but a full-screen panel would have hidden\n\t// the image altogether — you could not crop and preview at once.\n\t//\n\t// The same line moves the transform controls: docked, the Crop panel\n\t// carries them; below it they fall back to a row under the canvas.\n\t//\n\t// The choice is not carried across openings: the modal is transient, and\n\t// re-opening with the panel hidden on a wide screen is how #81487 read to\n\t// people in the first place. Within one opening it does hold — see\n\t// `hasChosenPanelRef` below.\n\tconst isWide = useViewportMatch( 'small' );\n\t// `null` when nothing is open, otherwise the open panel's id.\n\tconst [ activePanel, setActivePanel ] = useState< string | null >(\n\t\tisWide ? DETAILS_PANEL : null\n\t);\n\t// Width picks the starting panel, but only until the user picks one. After\n\t// that their choice holds for the rest of the session: closing the panel\n\t// and then resizing — or crossing the breakpoint by rotating a tablet —\n\t// should not reopen something they just dismissed.\n\tconst hasChosenPanelRef = useRef( false );\n\t// The panel the toggle reopens, and the one width picks until the user\n\t// picks their own. Tracked separately from `hasChosenPanelRef` because\n\t// the two answer different questions: whether the panel should be open,\n\t// and which tab it should show.\n\tconst lastPanelRef = useRef( DETAILS_PANEL );\n\tconst hasChosenTabRef = useRef( false );\n\t// Switching tabs says nothing about whether the panel should be open, so\n\t// it leaves `hasChosenPanelRef` alone: picking Details on a wide screen\n\t// and then dragging the window narrow should still hand the canvas the\n\t// full width.\n\tconst selectPanel = useCallback( ( panel: string ) => {\n\t\thasChosenTabRef.current = true;\n\t\tlastPanelRef.current = panel;\n\t\tsetActivePanel( panel );\n\t}, [] );\n\tconst togglePanel = useCallback( () => {\n\t\thasChosenPanelRef.current = true;\n\t\tsetActivePanel( ( open ) => ( open ? null : lastPanelRef.current ) );\n\t}, [] );\n\t// Below `small` a frame's header cannot fit the history cluster alongside\n\t// its own controls, so it moves that cluster elsewhere. The same width\n\t// undocks the panel, so this is `isWide` rather than a second query.\n\tconst layout: 'wide' | 'narrow' = isWide ? 'wide' : 'narrow';\n\tconst { media, hasEdits } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\thasEditsForEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\t// Trigger an _embed fetch so `_embedded.author` and\n\t\t\t// `_embedded['wp:attached-to']` land on the record for the Details\n\t\t\t// fields to read. `getEditedEntityRecord` doesn't formally accept a\n\t\t\t// query, so we can't embed via that selector directly.\n\t\t\tgetEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tid,\n\t\t\t\tATTACHMENT_EMBED_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tmedia: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) as Media,\n\t\t\t\thasEdits: hasEditsForEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id ]\n\t);\n\n\tconst hasChanges = cropper.isCropperDirty || hasEdits;\n\n\tconst { clearEntityRecordEdits, editEntityRecord, invalidateResolution } =\n\t\tuseDispatch( coreStore );\n\tconst { removeAllNotices } = useDispatch( noticesStore );\n\n\tconst [ isDiscardDialogOpen, setIsDiscardDialogOpen ] = useState( false );\n\tconst [ isPlacementActive, setIsPlacementActive ] = useState( false );\n\tconst [ isCanvasGestureActive, setIsCanvasGestureActive ] =\n\t\tuseState( false );\n\tconst placementControlTimerRef =\n\t\tuseRef< ReturnType< typeof setTimeout > >();\n\n\tconst signalPlacementControlInteraction = useCallback( () => {\n\t\tsetIsPlacementActive( true );\n\t\tclearTimeout( placementControlTimerRef.current );\n\t\tplacementControlTimerRef.current = setTimeout( () => {\n\t\t\tsetIsPlacementActive( false );\n\t\t}, PLACEMENT_CONTROL_IDLE_MS );\n\t}, [] );\n\tconst handleCanvasGestureStart = useCallback( () => {\n\t\tsetIsCanvasGestureActive( true );\n\t}, [] );\n\tconst handleCanvasGestureEnd = useCallback( () => {\n\t\tsetIsCanvasGestureActive( false );\n\t}, [] );\n\tconst isCropInteractionActive = isPlacementActive || isCanvasGestureActive;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( placementControlTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsPlacementActive( false );\n\t\tsetIsCanvasGestureActive( false );\n\t}, [ id ] );\n\n\t// Bust the cached `_embed` resolution each time the editor mounts (or the\n\t// id changes) so embedded data such as the attached post's title or the\n\t// author's name reflects any edits made elsewhere since the last open.\n\tuseEffect( () => {\n\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t'postType',\n\t\t\t'attachment',\n\t\t\tid,\n\t\t\tATTACHMENT_EMBED_QUERY,\n\t\t] );\n\t}, [ id, invalidateResolution ] );\n\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type ).type;\n\tconst isImage = !! media && mediaType === 'image';\n\n\t// Until the user picks a panel, follow the breakpoint: dragging a window\n\t// narrow hands the canvas the full width instead of leaving a panel\n\t// wedged beside it.\n\t//\n\t// Docked, the panel opens on Crop: the canvas is still beside it and\n\t// cropping is what the editor is for. Below `small` an open panel covers\n\t// the canvas, and crop controls with no crop in sight are not worth\n\t// opening on, so Details leads there. Non-image media has no Crop tab at\n\t// all (see `tabs`), so it always gets Details. `isImage` comes from a\n\t// record that resolves after mount, which is why this runs in an effect\n\t// rather than seeding `useState`.\n\tuseEffect( () => {\n\t\tif ( hasChosenPanelRef.current && hasChosenTabRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst defaultPanel = isWide && isImage ? CROP_PANEL : DETAILS_PANEL;\n\t\tif ( ! hasChosenTabRef.current ) {\n\t\t\tlastPanelRef.current = defaultPanel;\n\t\t}\n\t\tif ( ! hasChosenPanelRef.current ) {\n\t\t\tsetActivePanel( isWide ? lastPanelRef.current : null );\n\t\t}\n\t}, [ isWide, isImage ] );\n\t// Only `resetCropOptions` is needed here, for the Reset button; the\n\t// aspect-ratio members are read by `MediaEditorImageControls` itself.\n\tconst {\n\t\taspectRatioValue,\n\t\tsetAspectRatioValue,\n\t\taspectRatioOptions,\n\t\tresetCropOptions,\n\t} = useCropOptions( { aspectRatioPresets } );\n\tconst { isSaving, save: saveMediaEditor } = useSaveMediaEditor( {\n\t\tcropper,\n\t\tid,\n\t\tisImage,\n\t\tmedia,\n\t\tonSaved,\n\t} );\n\n\tconst handleChange = ( updates: Partial< Media > ) => {\n\t\teditEntityRecord( 'postType', 'attachment', id, updates );\n\t};\n\n\tconst discardAndClose = () => {\n\t\tremoveAllNotices( 'snackbar', MEDIA_EDITOR_NOTICES_CONTEXT );\n\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\tonClose?.();\n\t};\n\n\tconst handleRequestClose = () => {\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( hasChanges ) {\n\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\treturn;\n\t\t}\n\t\tdiscardAndClose();\n\t};\n\n\tconst handleKeyDown = ( event: ReactKeyboardEvent< HTMLElement > ) => {\n\t\tconst isUndoShortcut = isKeyboardEvent.primary( event, 'z' );\n\t\tconst isRedoShortcut =\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' ) ||\n\t\t\t( ! isAppleOS() && isKeyboardEvent.primary( event, 'y' ) );\n\t\tif ( ( isUndoShortcut || isRedoShortcut ) && isImage ) {\n\t\t\tconst target = event.target as HTMLElement;\n\t\t\tconst isMetadataField =\n\t\t\t\t( target.tagName === 'INPUT' ||\n\t\t\t\t\ttarget.tagName === 'TEXTAREA' ||\n\t\t\t\t\ttarget.isContentEditable ) &&\n\t\t\t\t! target.closest( `[${ CROP_CONTROL_ATTR }]` );\n\t\t\tif ( ! isMetadataField ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( isCropInteractionActive ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( isRedoShortcut ) {\n\t\t\t\t\tcropper.redo();\n\t\t\t\t} else {\n\t\t\t\t\tcropper.undo();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( shouldCloseOnEsc ) {\n\t\t\tif ( event.code !== 'Escape' && event.key !== 'Escape' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( isSaving ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( hasChanges ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst snackbar = (\n\t\t<SnackbarNotices\n\t\t\tclassName={ noticesClassName }\n\t\t\tcontext={ MEDIA_EDITOR_NOTICES_CONTEXT }\n\t\t/>\n\t);\n\n\t// Below `small` the panel is full screen, so an open one replaces the\n\t// canvas and these never share the screen with the Crop panel's copies:\n\t// this row is what reaches rotate/flip/zoom while the panel is closed,\n\t// with aspect ratio joining them as a dropdown. From `small` up the Crop\n\t// panel docks beside the canvas and carries them instead.\n\tconst imageControls =\n\t\tisImage && ! isWide ? (\n\t\t\t<MediaEditorImageControls\n\t\t\t\tshowAspectRatioControl\n\t\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\t/>\n\t\t) : null;\n\n\t// Crop leads, since it is what the docked panel opens on. Non-image media\n\t// has nothing to crop and gets Details alone, which is why the sidebar\n\t// takes this list rather than deriving it.\n\tconst tabs: MediaEditorTab[] = [\n\t\t...( isImage\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: CROP_PANEL,\n\t\t\t\t\t\ttitle: __( 'Crop' ),\n\t\t\t\t\t\trender: () => (\n\t\t\t\t\t\t\t<MediaEditorCropPanel\n\t\t\t\t\t\t\t\taspectRatioValue={ aspectRatioValue }\n\t\t\t\t\t\t\t\tonAspectRatioChange={ setAspectRatioValue }\n\t\t\t\t\t\t\t\taspectRatioOptions={ aspectRatioOptions }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: [] ),\n\t\t{\n\t\t\tid: DETAILS_PANEL,\n\t\t\ttitle: __( 'Details' ),\n\t\t\trender: () => <MediaForm />,\n\t\t},\n\t];\n\n\tconst ruler = isImage ? (\n\t\t<MediaEditorFineRotation\n\t\t\tonPlacementControlInteraction={ signalPlacementControlInteraction }\n\t\t/>\n\t) : null;\n\n\tconst children = (\n\t\t<MediaEditorProvider\n\t\t\tvalue={ media ?? undefined }\n\t\t\tonChange={ handleChange }\n\t\t\tsettings={ { fields } }\n\t\t>\n\t\t\t<div className=\"media-editor\">\n\t\t\t\t{ ! media ? (\n\t\t\t\t\t<div className=\"media-editor__loading\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx( 'media-editor__body', {\n\t\t\t\t\t\t\t'has-panel-open': !! activePanel,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<NavigableRegion\n\t\t\t\t\t\t\tclassName=\"media-editor__content\"\n\t\t\t\t\t\t\tariaLabel={\n\t\t\t\t\t\t\t\tisImage\n\t\t\t\t\t\t\t\t\t? __( 'Image editor' )\n\t\t\t\t\t\t\t\t\t: __( 'Media preview' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"media-editor__canvas-area\">\n\t\t\t\t\t\t\t\t{ isImage ? (\n\t\t\t\t\t\t\t\t\t<MediaEditorCanvas\n\t\t\t\t\t\t\t\t\t\tisPlacementActive={ isPlacementActive }\n\t\t\t\t\t\t\t\t\t\tonGestureStart={\n\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureStart\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonGestureEnd={ handleCanvasGestureEnd }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<MediaPreview />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{ isImage && (\n\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas-toolbar\">\n\t\t\t\t\t\t\t\t\t{ ruler }\n\t\t\t\t\t\t\t\t\t{ imageControls }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</NavigableRegion>\n\t\t\t\t\t\t{ !! activePanel && (\n\t\t\t\t\t\t\t<MediaEditorSidebar\n\t\t\t\t\t\t\t\ttabs={ tabs }\n\t\t\t\t\t\t\t\t// Swapping the edited media can drop the Crop\n\t\t\t\t\t\t\t\t// tab out from under an open panel — saving a\n\t\t\t\t\t\t\t\t// crop moves the editor to a new id, which may\n\t\t\t\t\t\t\t\t// resolve as non-image. Fall back rather than\n\t\t\t\t\t\t\t\t// hand `Tabs.Root` a value no tab matches.\n\t\t\t\t\t\t\t\tactiveTab={\n\t\t\t\t\t\t\t\t\ttabs.some(\n\t\t\t\t\t\t\t\t\t\t( tab ) => tab.id === activePanel\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t? activePanel\n\t\t\t\t\t\t\t\t\t\t: DETAILS_PANEL\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelectTab={ selectPanel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isDiscardDialogOpen }\n\t\t\t\tconfirmButtonText={ __( 'Discard' ) }\n\t\t\t\tcancelButtonText={ __( 'Keep editing' ) }\n\t\t\t\tonCancel={ () => setIsDiscardDialogOpen( false ) }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\tsetIsDiscardDialogOpen( false );\n\t\t\t\t\tdiscardAndClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Are you sure you want to discard your unsaved changes?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t\t{ noticesPortalElement\n\t\t\t\t? createPortal( snackbar, noticesPortalElement )\n\t\t\t\t: snackbar }\n\t\t</MediaEditorProvider>\n\t);\n\n\t// Rebuilt each render, like the elements it replaces: consumers re-render\n\t// as they always did, but the cluster component types stay stable.\n\tconst contextValue: MediaEditorFrameContextValue = {\n\t\tisImage,\n\t\tisSaving,\n\t\thasMedia: !! media,\n\t\thasChanges,\n\t\tisUndoRedoDisabled: isCropInteractionActive,\n\t\taspectRatioPresets,\n\t\tisWide,\n\t\tactivePanel,\n\t\tonTogglePanel: togglePanel,\n\t\tonCancel: handleRequestClose,\n\t\tonSave: saveMediaEditor,\n\t\tonReset: resetCropOptions,\n\t};\n\n\treturn (\n\t\t<MediaEditorFrameContext.Provider value={ contextValue }>\n\t\t\t{ renderFrame( {\n\t\t\t\tchildren,\n\t\t\t\tisImage,\n\t\t\t\tlayout,\n\t\t\t\tonRequestClose: handleRequestClose,\n\t\t\t\tonKeyDown: handleKeyDown,\n\t\t\t\tshouldCloseOnClickOutside: ! hasChanges && ! isSaving,\n\t\t\t\tisSaving,\n\t\t\t\thasChanges,\n\t\t\t\thasMedia: !! media,\n\t\t\t} ) }\n\t\t</MediaEditorFrameContext.Provider>\n\t);\n}\n\nexport function MediaEditor( props: MediaEditorProps ) {\n\treturn (\n\t\t<MediaEditorStateProvider key={ props.id }>\n\t\t\t<MediaEditorContent { ...props } />\n\t\t</MediaEditorStateProvider>\n\t);\n}\n\n// Attached to `MediaEditor` so frames import and arrange them, the way\n// `DataViewsPicker` exposes its own sub-components. They read what they need\n// from context, so a frame only chooses where they go and how they look.\nMediaEditor.HeaderActions = HeaderActions;\nMediaEditor.HistoryActions = HistoryActions;\nMediaEditor.SaveActions = SaveActions;\n\nexport default MediaEditor;\n"],
5
+ "mappings": ";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AAC5B,YAAY,iBAAiB;AAC7B,YAAY,cAAc;AAE1B,IAAO,uBAAQ;",
6
6
  "names": []
7
7
  }
@@ -8,8 +8,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
8
8
  function MediaEditorCropPanel({
9
9
  aspectRatioValue,
10
10
  onAspectRatioChange,
11
- aspectRatioOptions,
12
- showTransformControls = false
11
+ aspectRatioOptions
13
12
  }) {
14
13
  return (
15
14
  // Tag the whole panel as a crop-control region so the modal's
@@ -23,7 +22,7 @@ function MediaEditorCropPanel({
23
22
  ...{ [CROP_CONTROL_ATTR]: true },
24
23
  children: [
25
24
  /* @__PURE__ */ jsx(VisuallyHidden, { render: /* @__PURE__ */ jsx("h2", {}), children: __("Crop options") }),
26
- showTransformControls && /* @__PURE__ */ jsx(MediaEditorImageControls, { withLabels: true }),
25
+ /* @__PURE__ */ jsx(MediaEditorImageControls, { withLabels: true }),
27
26
  /* @__PURE__ */ jsx(
28
27
  SelectControl,
29
28
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-crop-panel/index.tsx"],
4
- "sourcesContent": ["import { SelectControl } from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n\t/**\n\t * When `true`, render the rotate/flip/zoom image controls at the top of\n\t * the panel. Used on wide viewports where the footer no longer carries\n\t * them.\n\t */\n\tshowTransformControls?: boolean;\n}\n\n/**\n * Sidebar panel for crop controls. Renders the aspect-ratio selector, plus the\n * rotate/flip and zoom controls on wide viewports (these move to the footer\n * toolbar when the sidebar collapses).\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.aspectRatioOptions\n * @param props.showTransformControls\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\taspectRatioOptions,\n\tshowTransformControls = false,\n}: MediaEditorCropPanelProps ) {\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ showTransformControls && <MediaEditorImageControls withLabels /> }\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ onAspectRatioChange }\n\t\t\t\toptions={ aspectRatioOptions.map( ( preset ) => ( {\n\t\t\t\t\tlabel: preset.label,\n\t\t\t\t\tvalue: preset.value.toString(),\n\t\t\t\t} ) ) }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n"],
5
- "mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,OAAO,sBAAsB;AACtC,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,OAAO,8BAA8B;AA0CnC,SAK0B,KAL1B;AAVa,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AACzB,GAA+B;AAC9B;AAAA;AAAA;AAAA;AAAA,IAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,KAAI;AAAA,QACF,GAAG,EAAE,CAAE,iBAAkB,GAAG,KAAK;AAAA,QAEnC;AAAA,8BAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,cAAe,GACtB;AAAA,UACE,yBAAyB,oBAAC,4BAAyB,YAAU,MAAC;AAAA,UAChE;AAAA,YAAC;AAAA;AAAA,cACA,OAAQ,GAAI,cAAe;AAAA,cAC3B,OAAQ;AAAA,cACR,UAAW;AAAA,cACX,SAAU,mBAAmB,IAAK,CAAE,YAAc;AAAA,gBACjD,OAAO,OAAO;AAAA,gBACd,OAAO,OAAO,MAAM,SAAS;AAAA,cAC9B,EAAI;AAAA;AAAA,UACL;AAAA;AAAA;AAAA,IACD;AAAA;AAEF;",
4
+ "sourcesContent": ["import { SelectControl } from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n}\n\n/**\n * Sidebar panel for crop controls: rotate, flip and zoom above the\n * aspect-ratio selector. Rendered where the panel docks; below that the\n * transform controls sit under the canvas instead, placed by the editor.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.aspectRatioOptions\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\taspectRatioOptions,\n}: MediaEditorCropPanelProps ) {\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<MediaEditorImageControls withLabels />\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ onAspectRatioChange }\n\t\t\t\toptions={ aspectRatioOptions.map( ( preset ) => ( {\n\t\t\t\t\tlabel: preset.label,\n\t\t\t\t\tvalue: preset.value.toString(),\n\t\t\t\t} ) ) }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n"],
5
+ "mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,OAAO,sBAAsB;AACtC,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,OAAO,8BAA8B;AAkCnC,SAK0B,KAL1B;AATa,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AACD,GAA+B;AAC9B;AAAA;AAAA;AAAA;AAAA,IAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,KAAI;AAAA,QACF,GAAG,EAAE,CAAE,iBAAkB,GAAG,KAAK;AAAA,QAEnC;AAAA,8BAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,cAAe,GACtB;AAAA,UACA,oBAAC,4BAAyB,YAAU,MAAC;AAAA,UACrC;AAAA,YAAC;AAAA;AAAA,cACA,OAAQ,GAAI,cAAe;AAAA,cAC3B,OAAQ;AAAA,cACR,UAAW;AAAA,cACX,SAAU,mBAAmB,IAAK,CAAE,YAAc;AAAA,gBACjD,OAAO,OAAO;AAAA,gBACd,OAAO,OAAO,MAAM,SAAS;AAAA,cAC9B,EAAI;AAAA;AAAA,UACL;AAAA;AAAA;AAAA,IACD;AAAA;AAEF;",
6
6
  "names": []
7
7
  }
@@ -6,31 +6,18 @@ import { ShortcutProvider } from "@wordpress/keyboard-shortcuts";
6
6
  import { store as noticesStore } from "@wordpress/notices";
7
7
  import MediaEditor from "../media-editor/index.mjs";
8
8
  import { store as mediaEditorStore } from "../../store/index.mjs";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- function ModalFooter({ layout }) {
11
- return /* @__PURE__ */ jsx(
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ function ModalFooter() {
11
+ return /* @__PURE__ */ jsxs(
12
12
  "div",
13
13
  {
14
- className: `media-editor-modal__footer is-${layout}`,
14
+ className: "media-editor-modal__footer",
15
15
  role: "region",
16
16
  "aria-label": __("Editor actions"),
17
- children: layout === "wide" ? (
18
- // Sidebar is a column: the image controls live in the Crop
19
- // panel, so the footer is just History + Cancel/Save.
20
- /* @__PURE__ */ jsxs(Fragment, { children: [
21
- /* @__PURE__ */ jsx(MediaEditor.HistoryActions, {}),
22
- /* @__PURE__ */ jsx(MediaEditor.SaveActions, {})
23
- ] })
24
- ) : (
25
- // Sidebar collapsed: the image controls drop into the footer.
26
- /* @__PURE__ */ jsxs(Fragment, { children: [
27
- /* @__PURE__ */ jsx(MediaEditor.ImageControls, {}),
28
- /* @__PURE__ */ jsxs("div", { className: "media-editor-modal__footer-row", children: [
29
- /* @__PURE__ */ jsx(MediaEditor.HistoryActions, {}),
30
- /* @__PURE__ */ jsx(MediaEditor.SaveActions, {})
31
- ] })
32
- ] })
33
- )
17
+ children: [
18
+ /* @__PURE__ */ jsx(MediaEditor.HistoryActions, {}),
19
+ /* @__PURE__ */ jsx(MediaEditor.SaveActions, {})
20
+ ]
34
21
  }
35
22
  );
36
23
  }
@@ -98,7 +85,6 @@ function MediaEditorModal({
98
85
  },
99
86
  renderFrame: ({
100
87
  children,
101
- layout,
102
88
  onRequestClose,
103
89
  onKeyDown,
104
90
  shouldCloseOnClickOutside
@@ -120,7 +106,7 @@ function MediaEditorModal({
120
106
  headerActions: /* @__PURE__ */ jsx(MediaEditor.HeaderActions, { showCloseButton: true }),
121
107
  children: [
122
108
  children,
123
- /* @__PURE__ */ jsx(ModalFooter, { layout })
109
+ /* @__PURE__ */ jsx(ModalFooter, {})
124
110
  ]
125
111
  }
126
112
  )
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-modal/index.tsx"],
4
- "sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\ninterface ModalFooterProps {\n\tlayout: 'wide' | 'narrow';\n}\n\n/**\n * The modal's footer chrome. The fine-rotation ruler always lives under the\n * canvas (in `media-editor__content`), never here, so it stays constrained to\n * the canvas column at every viewport. One JSX tree per layout; DOM order\n * matches visual order.\n */\nfunction ModalFooter( { layout }: ModalFooterProps ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ `media-editor-modal__footer is-${ layout }` }\n\t\t\trole=\"region\"\n\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t>\n\t\t\t{ layout === 'wide' ? (\n\t\t\t\t// Sidebar is a column: the image controls live in the Crop\n\t\t\t\t// panel, so the footer is just History + Cancel/Save.\n\t\t\t\t<>\n\t\t\t\t\t<MediaEditor.HistoryActions />\n\t\t\t\t\t<MediaEditor.SaveActions />\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t// Sidebar collapsed: the image controls drop into the footer.\n\t\t\t\t<>\n\t\t\t\t\t<MediaEditor.ImageControls />\n\t\t\t\t\t<div className=\"media-editor-modal__footer-row\">\n\t\t\t\t\t\t<MediaEditor.HistoryActions />\n\t\t\t\t\t\t<MediaEditor.SaveActions />\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onClose } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate, getOnClose } =\n\t\t\tselect( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t\tonClose: getOnClose(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\tlayout,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={\n\t\t\t\t\t\t\t<MediaEditor.HeaderActions showCloseButton />\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<ModalFooter layout={ layout } />\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
5
- "mappings": ";AAAA,SAAS,aAAa;AACtB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,SAAS,oBAAoB;AAGtC,OAAO,iBAAiB;AAExB,SAAS,SAAS,wBAAwB;AAuCtC,mBACC,KADD;AAVJ,SAAS,YAAa,EAAE,OAAO,GAAsB;AACpD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,iCAAkC,MAAO;AAAA,MACrD,MAAK;AAAA,MACL,cAAa,GAAI,gBAAiB;AAAA,MAEhC,qBAAW;AAAA;AAAA;AAAA,QAGZ,iCACC;AAAA,8BAAC,YAAY,gBAAZ,EAA2B;AAAA,UAC5B,oBAAC,YAAY,aAAZ,EAAwB;AAAA,WAC1B;AAAA;AAAA;AAAA,QAGA,iCACC;AAAA,8BAAC,YAAY,eAAZ,EAA0B;AAAA,UAC3B,qBAAC,SAAI,WAAU,kCACd;AAAA,gCAAC,YAAY,gBAAZ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R;AAAA,gBACC,OAAO,GAAI,MAAO;AAAA,gBAClB,SAAS,MAAM;AACd,2BAAU;AAAA,oBACT,IAAI,SAAS;AAAA,oBACb,KAAK,SAAS;AAAA,kBACf,CAAE;AAAA,gBACH;AAAA,cACD;AAAA,YACD;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,MACA,aAAc,CAAE;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,MACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,WAAY;AAAA,UAEZ;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,OAAQ,GAAI,YAAa;AAAA,cACzB,MAAK;AAAA,cACL,eAAgB;AAAA,cAChB;AAAA,cACA;AAAA,cACA;AAAA,cACA,eACC,oBAAC,YAAY,eAAZ,EAA0B,iBAAe,MAAC;AAAA,cAG1C;AAAA;AAAA,gBACF,oBAAC,eAAY,QAAkB;AAAA;AAAA;AAAA,UAChC;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
4
+ "sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\n/**\n * The modal's footer chrome. The fine-rotation ruler and the image controls\n * both live under the canvas (in `media-editor__content`), never here, so the\n * footer has one layout at every width: History on the left, Cancel/Save on\n * the right.\n */\nfunction ModalFooter() {\n\treturn (\n\t\t<div\n\t\t\tclassName=\"media-editor-modal__footer\"\n\t\t\trole=\"region\"\n\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t>\n\t\t\t<MediaEditor.HistoryActions />\n\t\t\t<MediaEditor.SaveActions />\n\t\t</div>\n\t);\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onClose } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate, getOnClose } =\n\t\t\tselect( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t\tonClose: getOnClose(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={\n\t\t\t\t\t\t\t<MediaEditor.HeaderActions showCloseButton />\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<ModalFooter />\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
5
+ "mappings": ";AAAA,SAAS,aAAa;AACtB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,SAAS,oBAAoB;AAGtC,OAAO,iBAAiB;AAExB,SAAS,SAAS,wBAAwB;AA2BxC,SAKC,KALD;AAFF,SAAS,cAAc;AACtB,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,MAAK;AAAA,MACL,cAAa,GAAI,gBAAiB;AAAA,MAElC;AAAA,4BAAC,YAAY,gBAAZ,EAA2B;AAAA,QAC5B,oBAAC,YAAY,aAAZ,EAAwB;AAAA;AAAA;AAAA,EAC1B;AAEF;AAEO,SAAS,iBAAkB;AAAA,EACjC,SAAS,CAAC;AAAA,EACV;AACD,GAA2B;AAC1B,QAAM,EAAE,aAAa,IAAI,UAAU,QAAQ,IAAI,UAAW,CAAE,WAAY;AACvE,UAAM,EAAE,QAAQ,OAAO,aAAa,WAAW,IAC9C,OAAQ,gBAAiB;AAC1B,WAAO;AAAA,MACN,aAAa,OAAO;AAAA,MACpB,IAAI,MAAM;AAAA,MACV,UAAU,YAAY;AAAA,MACtB,SAAS,WAAW;AAAA,IACrB;AAAA,EACD,GAA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AA,cACL,eAAgB;AAAA,cAChB;AAAA,cACA;AAAA,cACA;AAAA,cACA,eACC,oBAAC,YAAY,eAAZ,EAA0B,iBAAe,MAAC;AAAA,cAG1C;AAAA;AAAA,gBACF,oBAAC,eAAY;AAAA;AAAA;AAAA,UACd;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
6
6
  "names": []
7
7
  }
@@ -65,8 +65,7 @@
65
65
  .media-editor-preview--image img {
66
66
  max-width: 100%;
67
67
  max-height: 100%;
68
- -o-object-fit: contain;
69
- object-fit: contain;
68
+ object-fit: contain;
70
69
  width: auto;
71
70
  height: auto;
72
71
  opacity: 0;
@@ -88,8 +87,7 @@
88
87
  .media-editor-preview--video video {
89
88
  max-width: 100%;
90
89
  max-height: 100%;
91
- -o-object-fit: contain;
92
- object-fit: contain;
90
+ object-fit: contain;
93
91
  width: auto;
94
92
  height: auto;
95
93
  }
@@ -135,7 +133,6 @@
135
133
  height: 100%;
136
134
  touch-action: none;
137
135
  -webkit-user-select: none;
138
- -moz-user-select: none;
139
136
  user-select: none;
140
137
  cursor: grab;
141
138
  }
@@ -236,9 +233,7 @@
236
233
  box-shadow: 0 0 0 1px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
237
234
  }
238
235
  .wp-media-editor-image-editor__handle {
239
- -webkit-appearance: none;
240
- -moz-appearance: none;
241
- appearance: none;
236
+ appearance: none;
242
237
  margin: 0;
243
238
  padding: 0;
244
239
  font: inherit;
@@ -381,41 +376,47 @@
381
376
  align-items: center;
382
377
  justify-content: center;
383
378
  }
384
- .media-editor .interface-interface-skeleton {
385
- position: relative;
386
- top: auto;
387
- left: auto;
388
- bottom: auto;
389
- right: auto;
390
- height: 100%;
391
- max-height: none;
392
- flex: 1;
393
- flex-direction: column;
394
- }
395
- .media-editor-modal .media-editor .interface-interface-skeleton.interface-interface-skeleton {
396
- top: auto;
397
- }
398
- .media-editor .interface-interface-skeleton__editor {
399
- min-width: 0;
379
+ .media-editor .media-editor__body {
380
+ container-type: inline-size;
381
+ container-name: media-editor-body;
382
+ display: flex;
400
383
  flex: 1;
384
+ min-height: 0;
401
385
  }
402
386
  .media-editor .media-editor__content {
403
387
  display: flex;
404
388
  flex: 1;
405
389
  flex-direction: column;
390
+ min-width: 0;
406
391
  min-height: 0;
407
- margin: 0 24px;
408
- border-radius: 8px;
409
- overflow: hidden;
392
+ margin: 24px 24px 8px 24px;
393
+ }
394
+ @media (min-width: 600px) {
395
+ .media-editor .media-editor__content {
396
+ margin: 0 24px;
397
+ }
398
+ }
399
+ @container media-editor-body (min-width: 864px) {
400
+ .media-editor .media-editor__content {
401
+ min-width: 520px;
402
+ }
410
403
  }
411
404
  .media-editor .media-editor__canvas-toolbar {
412
405
  display: flex;
413
- flex-shrink: 0;
406
+ flex: 0 0 auto;
407
+ flex-direction: column;
408
+ align-items: center;
409
+ gap: 12px;
410
+ }
411
+ .media-editor .media-editor__canvas-toolbar .media-editor-fine-rotation {
412
+ display: flex;
414
413
  justify-content: center;
414
+ align-self: stretch;
415
415
  background: #e0e0e0;
416
+ border-radius: 0 0 8px 8px;
416
417
  padding: 8px 16px;
417
418
  }
418
- .media-editor .media-editor__canvas-toolbar .media-editor-fine-rotation {
419
+ .media-editor .media-editor__canvas-toolbar .media-editor-fine-rotation .rotation-ruler {
419
420
  flex: 0 1 360px;
420
421
  min-width: 0;
421
422
  }
@@ -424,6 +425,7 @@
424
425
  align-items: center;
425
426
  justify-content: center;
426
427
  background: #e0e0e0;
428
+ border-radius: 8px;
427
429
  overflow: auto;
428
430
  flex: 1;
429
431
  min-height: 0;
@@ -435,73 +437,52 @@
435
437
  .media-editor .media-editor__canvas-area video {
436
438
  max-width: 100%;
437
439
  max-height: 100%;
438
- -o-object-fit: contain;
439
- object-fit: contain;
440
+ object-fit: contain;
440
441
  }
441
442
  .media-editor .media-editor__sidebar {
442
- box-sizing: border-box;
443
- }
444
- .media-editor .media-editor__sidebar *,
445
- .media-editor .media-editor__sidebar *::before,
446
- .media-editor .media-editor__sidebar *::after {
447
- box-sizing: inherit;
443
+ display: flex;
444
+ flex: 1;
445
+ flex-direction: column;
446
+ min-width: 0;
447
+ min-height: 0;
448
+ overflow: hidden;
448
449
  }
449
450
  @media (min-width: 600px) {
450
451
  .media-editor .media-editor__sidebar {
451
- padding-inline: 8px;
452
+ flex: none;
453
+ width: var(--wpds-dimension-surface-width-sm, 320px);
452
454
  }
453
455
  }
454
- .media-editor .media-editor__sidebar-panel {
455
- padding-bottom: 24px;
456
+ .media-editor .media-editor__tabs {
457
+ display: flex;
458
+ flex: 1;
459
+ flex-direction: column;
460
+ min-height: 0;
456
461
  }
457
- .media-editor .interface-interface-skeleton__sidebar {
458
- border-top: 0;
459
- box-shadow: none;
460
- outline: 1px solid transparent;
462
+ .media-editor .media-editor__tablist {
463
+ flex-shrink: 0;
464
+ margin-inline: 24px;
465
+ background: #fff;
466
+ border-bottom: 1px solid #ddd;
461
467
  }
462
468
  .media-editor .media-editor__panel {
463
- padding: 16px;
464
- }
465
- @media (min-width: 600px) {
466
- .media-editor .media-editor__panel {
467
- padding: 24px 0 0 24px;
468
- }
469
- }
470
- .media-editor .components-panel__header.media-editor__sidebar-header {
471
- padding-right: 0;
472
- padding-left: 8px;
473
- margin-left: 24px;
474
- margin-left: 0;
469
+ flex: 1;
470
+ min-height: 0;
471
+ overflow-y: auto;
472
+ padding-block: 24px;
473
+ padding-inline: 24px;
475
474
  }
476
- @media (min-width: 600px) {
477
- .media-editor .components-panel__header.media-editor__sidebar-header {
478
- margin-left: 24px;
479
- }
475
+ .media-editor .media-editor__content:has(.media-editor-fine-rotation) .media-editor__canvas-area {
476
+ border-end-start-radius: 0;
477
+ border-end-end-radius: 0;
480
478
  }
481
- .media-editor .components-panel__header.media-editor__sidebar-header .components-button.has-icon {
482
- padding: 0;
479
+ .media-editor .media-editor__body.has-panel-open .media-editor__content {
480
+ display: none;
483
481
  }
484
482
  @media (min-width: 600px) {
485
- .media-editor .components-panel__header.media-editor__sidebar-header .components-button.has-icon {
483
+ .media-editor .media-editor__body.has-panel-open .media-editor__content {
486
484
  display: flex;
487
- }
488
- }
489
- @media (min-width: 600px) and (max-width: 781px) {
490
- .media-editor .interface-interface-skeleton__sidebar:has(.interface-complementary-area__fill) {
491
- position: relative !important;
492
- }
493
- .media-editor .interface-complementary-area__fill,
494
- .media-editor .interface-complementary-area {
495
- width: 280px !important;
496
- }
497
- }
498
- @media (max-width: 599px) {
499
- .media-editor .interface-interface-skeleton__sidebar:has(.interface-complementary-area__fill) {
500
- width: 100%;
501
- }
502
- .media-editor .interface-complementary-area__fill,
503
- .media-editor .interface-complementary-area {
504
- width: 100% !important;
485
+ margin: 0 24px 0 0;
505
486
  }
506
487
  }
507
488
 
@@ -542,33 +523,13 @@
542
523
  .media-editor-modal.components-modal__frame .media-editor-modal__footer {
543
524
  flex-shrink: 0;
544
525
  display: flex;
545
- gap: 16px;
546
- padding: 16px 32px 24px;
547
- background: #fff;
548
- z-index: 1000001;
549
- }
550
- .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide {
551
526
  flex-direction: row;
552
527
  align-items: center;
553
- }
554
- .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor__save-actions {
555
- margin-right: auto;
556
- }
557
- .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-narrow {
558
- flex-direction: column;
559
- }
560
- .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-narrow > .media-editor-image-controls {
561
- align-self: center;
562
- }
563
-
564
- .media-editor-modal__footer-row {
565
- display: flex;
566
- flex-wrap: wrap;
567
- align-items: center;
568
528
  gap: 16px;
529
+ padding: 24px;
530
+ background: #fff;
569
531
  }
570
- .media-editor-modal__footer-row .media-editor-image-controls,
571
- .media-editor-modal__footer-row .media-editor__save-actions {
532
+ .media-editor-modal.components-modal__frame .media-editor-modal__footer .media-editor__save-actions {
572
533
  margin-right: auto;
573
534
  }
574
535
 
@@ -728,7 +689,6 @@
728
689
  color: #1e1e1e;
729
690
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
730
691
  -webkit-user-select: none;
731
- -moz-user-select: none;
732
692
  user-select: none;
733
693
  touch-action: none;
734
694
  cursor: ew-resize;
@@ -752,7 +712,7 @@
752
712
  margin: -1px;
753
713
  padding: 0;
754
714
  border: 0;
755
- clip: rect(0 0 0 0);
715
+ clip-path: inset(50%);
756
716
  overflow: hidden;
757
717
  white-space: nowrap;
758
718
  }