@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 1.86 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/post-template/reset-default-template.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAllowSwitchingTemplates,\n\tuseCurrentTemplateSlug,\n\tuseEditedPostContext,\n} from './hooks';\n\nexport default function ResetDefaultTemplate( { onClick } ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst { postType, postId } = useEditedPostContext();\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! currentTemplateSlug || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ template: '' },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Use default template' ) }\n\t\t</MenuItem>\n\t);\n}\n"],
"mappings": ";AAGA,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,iBAAiB;AAKnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAYL;AAVa,SAAR,qBAAuC,EAAE,QAAQ,GAAI;AAC3D,QAAM,sBAAsB,uBAAuB;AACnD,QAAM,yBAAyB,2BAA2B;AAC1D,QAAM,EAAE,UAAU,OAAO,IAAI,qBAAqB;AAClD,QAAM,EAAE,iBAAiB,IAAI,YAAa,SAAU;AAEpD,MAAK,CAAE,uBAAuB,CAAE,wBAAyB;AACxD,WAAO;AAAA,EACR;AACA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM;AACf;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA,EAAE,UAAU,GAAG;AAAA,UACf,EAAE,YAAY,KAAK;AAAA,QACpB;AACA,gBAAQ;AAAA,MACT;AAAA,MAEE,aAAI,sBAAuB;AAAA;AAAA,EAC9B;AAEF;",
"names": []
}