@wordpress/media-editor 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/build/components/media-editor/index.cjs +65 -79
  3. package/build/components/media-editor/index.cjs.map +3 -3
  4. package/build/components/media-editor-canvas/index.cjs +0 -2
  5. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  6. package/build/components/media-editor-modal/index.cjs +31 -15
  7. package/build/components/media-editor-modal/index.cjs.map +3 -3
  8. package/build-module/components/media-editor/index.mjs +67 -79
  9. package/build-module/components/media-editor/index.mjs.map +2 -2
  10. package/build-module/components/media-editor-canvas/index.mjs +0 -2
  11. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  12. package/build-module/components/media-editor-modal/index.mjs +31 -15
  13. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  14. package/build-style/style-rtl.css +4 -4
  15. package/build-style/style.css +4 -4
  16. package/build-types/components/media-editor/index.d.ts +46 -11
  17. package/build-types/components/media-editor/index.d.ts.map +1 -1
  18. package/build-types/components/media-editor-canvas/index.d.ts +1 -4
  19. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  20. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  21. package/global.d.ts +5 -0
  22. package/package.json +24 -22
  23. package/src/components/media-editor/index.tsx +152 -118
  24. package/src/components/media-editor/style.scss +6 -3
  25. package/src/components/media-editor-canvas/index.tsx +5 -9
  26. package/src/components/media-editor-modal/index.tsx +43 -12
  27. package/src/components/media-editor-modal/style.scss +8 -4
  28. package/src/image-editor/stories/rectangle-crop.story.tsx +15 -0
  29. package/tsconfig.build.json +26 -0
  30. package/tsconfig.build.tsbuildinfo +1 -0
  31. package/tsconfig.json +22 -15
  32. package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -8
  33. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
  34. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -10
  35. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
  36. package/tsconfig.tsbuildinfo +0 -1
@@ -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\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\tshowCloseButton\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\theaderActions,\n\t\t\t\tfooterActions,\n\t\t\t\tfooterLayout,\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={ headerActions }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ `media-editor-modal__footer is-${ footerLayout }` }\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ footerActions }\n\t\t\t\t\t\t</div>\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;A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BAClB,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,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;AAAA,cAEE;AAAA;AAAA,gBACF;AAAA,kBAAC;AAAA;AAAA,oBACA,WAAY,iCAAkC,YAAa;AAAA,oBAC3D,MAAK;AAAA,oBACL,cAAa,GAAI,gBAAiB;AAAA,oBAEhC;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UACD;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\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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MACA;AAAA,MACA,kBAAgB;AAAA,MAChB,kBAAiB;AAAA,MACjB,sBAAuB;AAAA,MACvB,SAAU;AAAA,MACV,SAAU,CAAE,EAAE,IAAI,SAAS,KAAK,SAAS,MAAO;AAC/C,YAAK,WAAW,UAAW;AAC1B,gBAAM,SAAiC;AAAA,YACtC,IAAI;AAAA,YACJ;AAAA,UACD;AACA,mBAAU,MAAO;AAAA,QAClB;AACA,oBAAY;AACZ,YAAK,YAAY,YAAY,SAAS,MAAM,UAAW;AAItD,8BAAqB,GAAI,eAAgB,GAAG;AAAA,YAC3C,MAAM;AAAA,YACN,SAAS;AAAA,cACR;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;",
6
6
  "names": []
7
7
  }
@@ -448,7 +448,7 @@
448
448
  }
449
449
  @media (min-width: 600px) {
450
450
  .media-editor .media-editor__sidebar {
451
- padding-right: 1px;
451
+ padding-inline: 8px;
452
452
  }
453
453
  }
454
454
  .media-editor .media-editor__sidebar-panel {
@@ -551,7 +551,7 @@
551
551
  flex-direction: row;
552
552
  align-items: center;
553
553
  }
554
- .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor__footer-actions {
554
+ .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor__save-actions {
555
555
  margin-right: auto;
556
556
  }
557
557
  .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-narrow {
@@ -568,11 +568,11 @@
568
568
  gap: 16px;
569
569
  }
570
570
  .media-editor-modal__footer-row .media-editor-image-controls,
571
- .media-editor-modal__footer-row .media-editor__footer-actions {
571
+ .media-editor-modal__footer-row .media-editor__save-actions {
572
572
  margin-right: auto;
573
573
  }
574
574
 
575
- .media-editor__history-actions .components-button.has-icon:not([aria-disabled=true]) {
575
+ .media-editor-modal .media-editor__history-actions .components-button.has-icon:not([aria-disabled=true]) {
576
576
  color: var(--wp-admin-theme-color);
577
577
  }
578
578
 
@@ -448,7 +448,7 @@
448
448
  }
449
449
  @media (min-width: 600px) {
450
450
  .media-editor .media-editor__sidebar {
451
- padding-left: 1px;
451
+ padding-inline: 8px;
452
452
  }
453
453
  }
454
454
  .media-editor .media-editor__sidebar-panel {
@@ -551,7 +551,7 @@
551
551
  flex-direction: row;
552
552
  align-items: center;
553
553
  }
554
- .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor__footer-actions {
554
+ .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-wide .media-editor__save-actions {
555
555
  margin-left: auto;
556
556
  }
557
557
  .media-editor-modal.components-modal__frame .media-editor-modal__footer.is-narrow {
@@ -568,11 +568,11 @@
568
568
  gap: 16px;
569
569
  }
570
570
  .media-editor-modal__footer-row .media-editor-image-controls,
571
- .media-editor-modal__footer-row .media-editor__footer-actions {
571
+ .media-editor-modal__footer-row .media-editor__save-actions {
572
572
  margin-left: auto;
573
573
  }
574
574
 
575
- .media-editor__history-actions .components-button.has-icon:not([aria-disabled=true]) {
575
+ .media-editor-modal .media-editor__history-actions .components-button.has-icon:not([aria-disabled=true]) {
576
576
  color: var(--wp-admin-theme-color);
577
577
  }
578
578
 
@@ -6,18 +6,14 @@ import { type MediaEditorSaveResult } from './use-save-media-editor';
6
6
  export type { MediaEditorSaveResult } from './use-save-media-editor';
7
7
  export interface MediaEditorFrameProps {
8
8
  children: ReactNode;
9
- headerActions: ReactNode;
10
- footerActions: ReactNode;
11
9
  /**
12
- * Footer layout selector. Frames apply this to the footer container
13
- * as a modifier class. Tracks the sidebar-collapse breakpoint (`medium`).
14
- *
15
- * - `wide` — sidebar is a column; footer is a single row of History |
16
- * Cancel/Save (transform controls live in the Crop panel).
17
- * - `narrow` — sidebar collapsed; transform controls sit above a
18
- * History | Cancel/Save row.
10
+ * Whether the media being edited is an image. The history and transform
11
+ * clusters render nothing for other media types, so a frame uses this to
12
+ * decide whether the container it would put them in is worth rendering at
13
+ * all.
19
14
  */
20
- footerLayout: 'wide' | 'narrow';
15
+ isImage: boolean;
16
+ layout: 'wide' | 'narrow';
21
17
  onRequestClose: () => void;
22
18
  onKeyDown: (event: ReactKeyboardEvent<HTMLElement>) => void;
23
19
  shouldCloseOnClickOutside: boolean;
@@ -34,9 +30,48 @@ export interface MediaEditorProps {
34
30
  renderFrame: (props: MediaEditorFrameProps) => JSX.Element;
35
31
  noticesClassName?: string;
36
32
  noticesPortalElement?: Element | null;
37
- showCloseButton?: boolean;
38
33
  shouldCloseOnEsc?: boolean;
34
+ /**
35
+ * The `@wordpress/interface` scope for the details sidebar and its pinned
36
+ * items. Frames should pass a distinct scope so that sidebar visibility —
37
+ * which is persisted per scope to user meta — is remembered separately for
38
+ * each surface. The modal is a transient surface where a collapsed sidebar
39
+ * is a reasonable choice; the full-screen route is one where the sidebar is
40
+ * the primary metadata surface and should open by default. Sharing a scope
41
+ * would let a choice made in one decide the other's starting state.
42
+ *
43
+ * @default 'media-editor'
44
+ */
45
+ scope?: string;
39
46
  }
47
+ export interface HeaderActionsProps {
48
+ /**
49
+ * Whether to include a Close button. Frames with a dismissal affordance of
50
+ * their own — a route's breadcrumbs, say — leave it out.
51
+ *
52
+ * @default false
53
+ */
54
+ showCloseButton?: boolean;
55
+ }
56
+ declare function HeaderActions({ showCloseButton }: HeaderActionsProps): import("react").JSX.Element;
57
+ declare function HistoryActions(): import("react").JSX.Element | null;
58
+ export interface SaveActionsProps {
59
+ /**
60
+ * Button height. Footers take the 40px default; frames placing these in a
61
+ * page header pass `compact` to match the header's other controls.
62
+ *
63
+ * @default 'default'
64
+ */
65
+ size?: 'default' | 'compact';
66
+ }
67
+ declare function SaveActions({ size }: SaveActionsProps): import("react").JSX.Element;
68
+ declare function ImageControls(): import("react").JSX.Element | null;
40
69
  export declare function MediaEditor(props: MediaEditorProps): import("react").JSX.Element;
70
+ export declare namespace MediaEditor {
71
+ export { HeaderActions };
72
+ export { HistoryActions };
73
+ export { SaveActions };
74
+ export { ImageControls };
75
+ }
41
76
  export default MediaEditor;
42
77
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/index.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOlD,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAStD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAGN,KAAK,qBAAqB,EAC1B,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAerE,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,SAAS,CAAC;IACzB,aAAa,EAAE,SAAS,CAAC;IACzB;;;;;;;;OAQ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AM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC7B;AAED,iBAAS,WAAW,CAAE,EAAE,IAAgB,EAAE,EAAE,gBAAgB,+BAkC3D;AAED,iBAAS,aAAa,uCAcrB;AA8WD,wBAAgB,WAAW,CAAE,KAAK,EAAE,gBAAgB,+BAMnD;yBANe,WAAW;;;;;;eAgBZ,WAAW"}
@@ -1,6 +1,4 @@
1
1
  export interface MediaEditorCanvasProps {
2
- /** Focus the crop area when the canvas mounts. */
3
- focusOnMount?: boolean;
4
2
  /** Whether external placement activity should reveal the grid. */
5
3
  isPlacementActive?: boolean;
6
4
  /** Fires when a canvas cropper gesture begins. */
@@ -17,10 +15,9 @@ export interface MediaEditorCanvasProps {
17
15
  * guards can render a spinner or fall through to `<MediaPreview>`.
18
16
  *
19
17
  * @param props
20
- * @param props.focusOnMount
21
18
  * @param props.isPlacementActive
22
19
  * @param props.onGestureStart
23
20
  * @param props.onGestureEnd
24
21
  */
25
- export default function MediaEditorCanvas({ focusOnMount, isPlacementActive, onGestureStart, onGestureEnd, }: MediaEditorCanvasProps): import("react").JSX.Element | null;
22
+ export default function MediaEditorCanvas({ isPlacementActive, onGestureStart, onGestureEnd, }: MediaEditorCanvasProps): import("react").JSX.Element | null;
26
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-canvas/index.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,sBAAsB;IACtC,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAE,EAC1C,YAAY,EACZ,iBAAyB,EACzB,cAAc,EACd,YAAY,GACZ,EAAE,sBAAsB,sCAkIxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-canvas/index.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,sBAAsB;IACtC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAE,EAC1C,iBAAyB,EACzB,cAAc,EACd,YAAY,GACZ,EAAE,sBAAsB,sCAkIxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-modal/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,UAAU,qBAAqB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAE,KAAK,CAAE,EAAE,CAAC;IAC1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAED,wBAAgB,gBAAgB,CAAE,EACjC,MAAW,EACX,kBAAkB,GAClB,EAAE,qBAAqB,sCAgHvB;eAEc,gBAAgB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-modal/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,UAAU,qBAAqB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAE,KAAK,CAAE,EAAE,CAAC;IAC1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAwCD,wBAAgB,gBAAgB,CAAE,EACjC,MAAW,EACX,kBAAkB,GAClB,EAAE,qBAAqB,sCAyGvB;eAEc,gBAAgB"}
package/global.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /*
2
+ * With typeRoots set in tsconfig, global types outside those directories,
3
+ * like the jest-dom matchers, must be referenced explicitly.
4
+ */
5
+ import '@testing-library/jest-dom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/media-editor",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Media editor components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -43,32 +43,34 @@
43
43
  "build-module/store/index.mjs"
44
44
  ],
45
45
  "dependencies": {
46
- "@wordpress/a11y": "^4.53.0",
47
- "@wordpress/api-fetch": "^7.53.0",
48
- "@wordpress/base-styles": "^12.1.0",
49
- "@wordpress/components": "^39.0.0",
50
- "@wordpress/compose": "^8.6.0",
51
- "@wordpress/core-data": "^7.53.0",
52
- "@wordpress/data": "^10.53.0",
53
- "@wordpress/dataviews": "^18.0.0",
54
- "@wordpress/date": "^5.53.0",
55
- "@wordpress/element": "^8.5.0",
56
- "@wordpress/i18n": "^6.26.0",
57
- "@wordpress/icons": "^15.4.0",
58
- "@wordpress/interface": "^9.38.0",
59
- "@wordpress/keyboard-shortcuts": "^5.53.0",
60
- "@wordpress/keycodes": "^4.53.0",
61
- "@wordpress/notices": "^5.53.0",
62
- "@wordpress/private-apis": "^1.53.0",
63
- "@wordpress/ui": "^0.20.0",
46
+ "@wordpress/a11y": "^4.54.0",
47
+ "@wordpress/api-fetch": "^7.54.0",
48
+ "@wordpress/base-styles": "^13.0.0",
49
+ "@wordpress/components": "^40.0.0",
50
+ "@wordpress/compose": "^8.7.0",
51
+ "@wordpress/core-data": "^7.54.0",
52
+ "@wordpress/data": "^10.54.0",
53
+ "@wordpress/dataviews": "^18.1.0",
54
+ "@wordpress/date": "^5.54.0",
55
+ "@wordpress/element": "^8.6.0",
56
+ "@wordpress/i18n": "^6.27.0",
57
+ "@wordpress/icons": "^15.5.0",
58
+ "@wordpress/interface": "^10.0.0",
59
+ "@wordpress/keyboard-shortcuts": "^5.54.0",
60
+ "@wordpress/keycodes": "^4.54.0",
61
+ "@wordpress/notices": "^5.54.0",
62
+ "@wordpress/private-apis": "^1.54.0",
63
+ "@wordpress/ui": "^0.21.0",
64
64
  "clsx": "^2.1.1",
65
65
  "gl-matrix": "^3.4.3"
66
66
  },
67
67
  "devDependencies": {
68
- "@storybook/react-vite": "^10.4.3",
68
+ "@storybook/react-vite": "^10.5.3",
69
69
  "@testing-library/dom": "^10.4.1",
70
+ "@testing-library/jest-dom": "^6.9.1",
70
71
  "@testing-library/react": "^16.3.2",
71
- "@testing-library/user-event": "^14.6.1"
72
+ "@testing-library/user-event": "^14.6.1",
73
+ "@types/jest": "^30.0.0"
72
74
  },
73
75
  "peerDependencies": {
74
76
  "@types/react": "^18 || ^19",
@@ -82,5 +84,5 @@
82
84
  "publishConfig": {
83
85
  "access": "public"
84
86
  },
85
- "gitHead": "989764d42ff93e33684aaf0b96a5b7f3d9bbff52"
87
+ "gitHead": "5ef24f60261976bb198ad035db24bf81c1fb92b4"
86
88
  }