@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 3.34 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/media/metadata-panel.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MediaEditorProvider, MediaForm } from '@wordpress/media-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport usePostFields from '../post-fields';\nimport PostCardPanel from '../post-card-panel';\nimport PostPanelSection from '../post-panel-section';\n\n/**\n * Media metadata panel for the editor sidebar.\n * Displays a form for editing media properties with PostCardPanel header.\n *\n * @param {Object} props - Component props.\n * @param {Function} props.onActionPerformed - Callback when an action is performed.\n * @return {Element} The MediaMetadataPanel component.\n */\nexport default function MediaMetadataPanel( { onActionPerformed } ) {\n\tconst { media, postType, postId } = useSelect( ( select ) => {\n\t\tconst _postType = select( editorStore ).getCurrentPostType();\n\t\tconst _postId = select( editorStore ).getCurrentPostId();\n\t\tconst currentPost = select( coreStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\t_postId,\n\t\t\t{\n\t\t\t\t_embed: 'author,wp:attached-to',\n\t\t\t}\n\t\t);\n\t\treturn {\n\t\t\tmedia: currentPost,\n\t\t\tpostType: _postType,\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst fields = usePostFields( { postType: 'attachment' } );\n\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\tfields,\n\t\t} ),\n\t\t[ fields ]\n\t);\n\n\tconst handleUpdate = ( updates ) => {\n\t\teditPost( updates );\n\t};\n\n\treturn (\n\t\t<PostPanelSection className=\"editor-media-metadata-panel\">\n\t\t\t<MediaEditorProvider\n\t\t\t\tvalue={ media }\n\t\t\t\tsettings={ settings }\n\t\t\t\tonChange={ handleUpdate }\n\t\t\t>\n\t\t\t\t<MediaForm\n\t\t\t\t\theader={\n\t\t\t\t\t\t<PostCardPanel\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tpostId={ postId }\n\t\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</MediaEditorProvider>\n\t\t</PostPanelSection>\n\t);\n}\n"],
"mappings": ";AAGA,SAAS,qBAAqB,iBAAiB;AAC/C,SAAS,WAAW,mBAAmB;AACvC,SAAS,eAAe;AACxB,SAAS,SAAS,iBAAiB;AAKnC,SAAS,SAAS,mBAAmB;AACrC,OAAO,mBAAmB;AAC1B,OAAO,mBAAmB;AAC1B,OAAO,sBAAsB;AAoDvB;AA1CS,SAAR,mBAAqC,EAAE,kBAAkB,GAAI;AACnE,QAAM,EAAE,OAAO,UAAU,OAAO,IAAI,UAAW,CAAE,WAAY;AAC5D,UAAM,YAAY,OAAQ,WAAY,EAAE,mBAAmB;AAC3D,UAAM,UAAU,OAAQ,WAAY,EAAE,iBAAiB;AACvD,UAAM,cAAc,OAAQ,SAAU,EAAE;AAAA,MACvC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACC,QAAQ;AAAA,MACT;AAAA,IACD;AACA,WAAO;AAAA,MACN,OAAO;AAAA,MACP,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,SAAS,IAAI,YAAa,WAAY;AAC9C,QAAM,SAAS,cAAe,EAAE,UAAU,aAAa,CAAE;AAEzD,QAAM,WAAW;AAAA,IAChB,OAAQ;AAAA,MACP;AAAA,IACD;AAAA,IACA,CAAE,MAAO;AAAA,EACV;AAEA,QAAM,eAAe,CAAE,YAAa;AACnC,aAAU,OAAQ;AAAA,EACnB;AAEA,SACC,oBAAC,oBAAiB,WAAU,+BAC3B;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ;AAAA,MACR;AAAA,MACA,UAAW;AAAA,MAEX;AAAA,QAAC;AAAA;AAAA,UACA,QACC;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA;AAAA,MAEF;AAAA;AAAA,EACD,GACD;AAEF;",
"names": []
}