@wordpress/editor 14.19.3 → 14.21.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.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/build/components/commands/index.js +1 -1
- package/build/components/commands/index.js.map +1 -1
- package/build/components/plugin-pre-publish-panel/index.js +1 -1
- package/build/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build/components/post-actions/actions.js +10 -8
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +19 -3
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +16 -6
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-status/index.js +5 -1
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-sticky/index.js +1 -1
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-template/block-theme.js +1 -3
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +1 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/create-new-template.js +1 -4
- package/build/components/post-template/create-new-template.js.map +1 -1
- package/build/components/post-template/hooks.js +6 -5
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +2 -3
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-visibility/index.js +39 -109
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js +2 -2
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/post-visibility/utils.js +14 -15
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build/components/preview-dropdown/index.js +2 -4
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/commands/index.js +1 -1
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.js +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +10 -8
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +19 -3
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +16 -6
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-status/index.js +5 -1
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-sticky/index.js +1 -1
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +1 -3
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +1 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/create-new-template.js +1 -4
- package/build-module/components/post-template/create-new-template.js.map +1 -1
- package/build-module/components/post-template/hooks.js +6 -5
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +2 -3
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-visibility/index.js +41 -111
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js +3 -3
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/post-visibility/utils.js +13 -14
- package/build-module/components/post-visibility/utils.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +2 -4
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-style/style-rtl.css +6 -137
- package/build-style/style.css +6 -137
- package/build-types/components/plugin-pre-publish-panel/index.d.ts +1 -1
- package/build-types/components/post-actions/actions.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template.d.ts +1 -3
- package/build-types/components/post-template/create-new-template.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/post-visibility/index.d.ts.map +1 -1
- package/build-types/components/post-visibility/label.d.ts.map +1 -1
- package/build-types/components/post-visibility/utils.d.ts +5 -20
- package/build-types/components/post-visibility/utils.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/autocompleters/style.scss +2 -3
- package/src/components/commands/index.js +1 -1
- package/src/components/plugin-pre-publish-panel/index.js +1 -1
- package/src/components/post-actions/actions.js +13 -8
- package/src/components/post-publish-panel/maybe-category-panel.js +20 -5
- package/src/components/post-publish-panel/maybe-tags-panel.js +39 -22
- package/src/components/post-status/index.js +7 -2
- package/src/components/post-sticky/index.js +1 -1
- package/src/components/post-template/block-theme.js +1 -3
- package/src/components/post-template/create-new-template-modal.js +1 -0
- package/src/components/post-template/create-new-template.js +1 -2
- package/src/components/post-template/hooks.js +12 -8
- package/src/components/post-template/style.scss +4 -0
- package/src/components/post-template/swap-template-button.js +6 -4
- package/src/components/post-visibility/index.js +41 -118
- package/src/components/post-visibility/label.js +7 -4
- package/src/components/post-visibility/utils.js +11 -8
- package/src/components/preview-dropdown/index.js +6 -3
- package/src/style.scss +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/components/post-visibility/style.scss +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","CheckboxControl","Dropdown","__experimentalVStack","VStack","TextControl","RadioControl","__","sprintf","useDispatch","useSelect","useState","useMemo","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useInstanceId","drafts","published","scheduled","pending","notAllowed","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","PostPanelRow","PostSticky","PrivatePostSchedule","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","postStatusesInfo","label","icon","draft","private","future","publish","STATUS_OPTIONS","value","description","DESIGN_POST_TYPES","PostStatus","status","date","password","postId","postType","canEdit","select","_getCurrentPost$_link","getEditedPostAttribute","getCurrentPostId","getCurrentPostType","getCurrentPost","_links","showPassword","setShowPassword","passwordInputId","editEntityRecord","popoverAnchor","setPopoverAnchor","popoverProps","anchor","headerTitle","placement","offset","shift","includes","updatePost","newStatus","newPassword","newDate","handleTogglePassword","handleStatus","Date","ref","children","className","contentClassName","focusOnMount","renderToggle","onToggle","isOpen","variant","size","onClick","renderContent","onClose","title","spacing","hideLabelFromVision","options","onChange","selected","showPopoverHeaderActions","isCompact","as","__nextHasNoMarginBottom","help","checked","placeholder","type","id","__next40pxDefaultSize","maxLength"],"sources":["@wordpress/editor/src/components/post-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\tDropdown,\n\t__experimentalVStack as VStack,\n\tTextControl,\n\tRadioControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport PostSticky from '../post-sticky';\nimport { PrivatePostSchedule } from '../post-schedule';\nimport { store as editorStore } from '../../store';\n\nconst postStatusesInfo = {\n\t'auto-draft': { label: __( 'Draft' ), icon: drafts },\n\tdraft: { label: __( 'Draft' ), icon: drafts },\n\tpending: { label: __( 'Pending' ), icon: pending },\n\tprivate: { label: __( 'Private' ), icon: notAllowed },\n\tfuture: { label: __( 'Scheduled' ), icon: scheduled },\n\tpublish: { label: __( 'Published' ), icon: published },\n};\n\nexport const STATUS_OPTIONS = [\n\t{\n\t\tlabel: __( 'Draft' ),\n\t\tvalue: 'draft',\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tlabel: __( 'Pending' ),\n\t\tvalue: 'pending',\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tlabel: __( 'Private' ),\n\t\tvalue: 'private',\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tlabel: __( 'Scheduled' ),\n\t\tvalue: 'future',\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tlabel: __( 'Published' ),\n\t\tvalue: 'publish',\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n];\n\nconst DESIGN_POST_TYPES = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n];\n\nexport default function PostStatus() {\n\tconst { status, date, password, postId, postType, canEdit } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPost,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tdate: getEditedPostAttribute( 'date' ),\n\t\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tcanEdit:\n\t\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ showPassword, setShowPassword ] = useState( !! password );\n\tconst passwordInputId = useInstanceId(\n\t\tPostStatus,\n\t\t'editor-change-status__password-input'\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Status & visibility' ),\n\t\t\theaderTitle: __( 'Status & visibility' ),\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( DESIGN_POST_TYPES.includes( postType ) ) {\n\t\treturn null;\n\t}\n\n\tconst updatePost = ( {\n\t\tstatus: newStatus = status,\n\t\tpassword: newPassword = password,\n\t\tdate: newDate = date,\n\t} ) => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tstatus: newStatus,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\tconst handleTogglePassword = ( value ) => {\n\t\tsetShowPassword( value );\n\t\tif ( ! value ) {\n\t\t\tupdatePost( { password: '' } );\n\t\t}\n\t};\n\n\tconst handleStatus = ( value ) => {\n\t\tlet newDate = date;\n\t\tlet newPassword = password;\n\t\tif ( status === 'future' && new Date( date ) > new Date() ) {\n\t\t\tnewDate = null;\n\t\t}\n\t\tif ( value === 'private' && password ) {\n\t\t\tnewPassword = '';\n\t\t}\n\t\tupdatePost( {\n\t\t\tstatus: value,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Status' ) } ref={ setPopoverAnchor }>\n\t\t\t{ canEdit ? (\n\t\t\t\t<Dropdown\n\t\t\t\t\tclassName=\"editor-post-status\"\n\t\t\t\t\tcontentClassName=\"editor-change-status__content\"\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"editor-post-status__toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\ticon={ postStatusesInfo[ status ]?.icon }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post status.\n\t\t\t\t\t\t\t\t__( 'Change status: %s' ),\n\t\t\t\t\t\t\t\tpostStatusesInfo[ status ]?.label\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\t\ttitle={ __( 'Status & visibility' ) }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<form>\n\t\t\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__options\"\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Status' ) }\n\t\t\t\t\t\t\t\t\t\toptions={ STATUS_OPTIONS }\n\t\t\t\t\t\t\t\t\t\tonChange={ handleStatus }\n\t\t\t\t\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\t\t\t\t\tstatus === 'auto-draft'\n\t\t\t\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t\t\t\t: status\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ status === 'future' && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__publish-date-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<PrivatePostSchedule\n\t\t\t\t\t\t\t\t\t\t\t\tshowPopoverHeaderActions={\n\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\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\tisCompact\n\t\t\t\t\t\t\t\t\t\t\t/>\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\t{ status !== 'private' && (\n\t\t\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\t\t\tas=\"fieldset\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__password-fieldset\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Password protected'\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\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Only visible to those who know the password'\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\tchecked={ showPassword }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleTogglePassword\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\t{ showPassword && (\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__password-input\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdatePost( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpassword: value,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Use a secure password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid={ passwordInputId }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</>\n\t\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","CheckboxControl","Dropdown","__experimentalVStack","VStack","TextControl","RadioControl","__","sprintf","useDispatch","useSelect","useState","useMemo","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useInstanceId","drafts","published","scheduled","pending","notAllowed","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","PostPanelRow","PostSticky","PrivatePostSchedule","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","postStatusesInfo","label","icon","draft","private","future","publish","STATUS_OPTIONS","value","description","DESIGN_POST_TYPES","PostStatus","status","date","password","postId","postType","canEdit","select","_getCurrentPost$_link","getEditedPostAttribute","getCurrentPostId","getCurrentPostType","getCurrentPost","_links","showPassword","setShowPassword","passwordInputId","editEntityRecord","popoverAnchor","setPopoverAnchor","popoverProps","anchor","headerTitle","placement","offset","shift","includes","updatePost","newStatus","newPassword","newDate","handleTogglePassword","handleStatus","Date","ref","children","className","contentClassName","focusOnMount","renderToggle","onToggle","isOpen","variant","size","onClick","renderContent","onClose","title","onSubmit","event","preventDefault","spacing","hideLabelFromVision","options","onChange","selected","showPopoverHeaderActions","isCompact","as","__nextHasNoMarginBottom","help","checked","placeholder","type","id","__next40pxDefaultSize","maxLength"],"sources":["@wordpress/editor/src/components/post-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\tDropdown,\n\t__experimentalVStack as VStack,\n\tTextControl,\n\tRadioControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport PostSticky from '../post-sticky';\nimport { PrivatePostSchedule } from '../post-schedule';\nimport { store as editorStore } from '../../store';\n\nconst postStatusesInfo = {\n\t'auto-draft': { label: __( 'Draft' ), icon: drafts },\n\tdraft: { label: __( 'Draft' ), icon: drafts },\n\tpending: { label: __( 'Pending' ), icon: pending },\n\tprivate: { label: __( 'Private' ), icon: notAllowed },\n\tfuture: { label: __( 'Scheduled' ), icon: scheduled },\n\tpublish: { label: __( 'Published' ), icon: published },\n};\n\nexport const STATUS_OPTIONS = [\n\t{\n\t\tlabel: __( 'Draft' ),\n\t\tvalue: 'draft',\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tlabel: __( 'Pending' ),\n\t\tvalue: 'pending',\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tlabel: __( 'Private' ),\n\t\tvalue: 'private',\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tlabel: __( 'Scheduled' ),\n\t\tvalue: 'future',\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tlabel: __( 'Published' ),\n\t\tvalue: 'publish',\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n];\n\nconst DESIGN_POST_TYPES = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n];\n\nexport default function PostStatus() {\n\tconst { status, date, password, postId, postType, canEdit } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPost,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tdate: getEditedPostAttribute( 'date' ),\n\t\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tcanEdit:\n\t\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ showPassword, setShowPassword ] = useState( !! password );\n\tconst passwordInputId = useInstanceId(\n\t\tPostStatus,\n\t\t'editor-change-status__password-input'\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Status & visibility' ),\n\t\t\theaderTitle: __( 'Status & visibility' ),\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( DESIGN_POST_TYPES.includes( postType ) ) {\n\t\treturn null;\n\t}\n\n\tconst updatePost = ( {\n\t\tstatus: newStatus = status,\n\t\tpassword: newPassword = password,\n\t\tdate: newDate = date,\n\t} ) => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tstatus: newStatus,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\tconst handleTogglePassword = ( value ) => {\n\t\tsetShowPassword( value );\n\t\tif ( ! value ) {\n\t\t\tupdatePost( { password: '' } );\n\t\t}\n\t};\n\n\tconst handleStatus = ( value ) => {\n\t\tlet newDate = date;\n\t\tlet newPassword = password;\n\t\tif ( status === 'future' && new Date( date ) > new Date() ) {\n\t\t\tnewDate = null;\n\t\t}\n\t\tif ( value === 'private' && password ) {\n\t\t\tnewPassword = '';\n\t\t}\n\t\tupdatePost( {\n\t\t\tstatus: value,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Status' ) } ref={ setPopoverAnchor }>\n\t\t\t{ canEdit ? (\n\t\t\t\t<Dropdown\n\t\t\t\t\tclassName=\"editor-post-status\"\n\t\t\t\t\tcontentClassName=\"editor-change-status__content\"\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"editor-post-status__toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\ticon={ postStatusesInfo[ status ]?.icon }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post status.\n\t\t\t\t\t\t\t\t__( 'Change status: %s' ),\n\t\t\t\t\t\t\t\tpostStatusesInfo[ status ]?.label\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\t\ttitle={ __( 'Status & visibility' ) }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<form\n\t\t\t\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__options\"\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Status' ) }\n\t\t\t\t\t\t\t\t\t\toptions={ STATUS_OPTIONS }\n\t\t\t\t\t\t\t\t\t\tonChange={ handleStatus }\n\t\t\t\t\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\t\t\t\t\tstatus === 'auto-draft'\n\t\t\t\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t\t\t\t: status\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ status === 'future' && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__publish-date-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<PrivatePostSchedule\n\t\t\t\t\t\t\t\t\t\t\t\tshowPopoverHeaderActions={\n\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\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\tisCompact\n\t\t\t\t\t\t\t\t\t\t\t/>\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\t{ status !== 'private' && (\n\t\t\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\t\t\tas=\"fieldset\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__password-fieldset\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Password protected'\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\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Only visible to those who know the password.'\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\tchecked={ showPassword }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleTogglePassword\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\t{ showPassword && (\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__password-input\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdatePost( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpassword: value,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Use a secure password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid={ passwordInputId }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</form>\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\t\t<div className=\"editor-post-status is-read-only\">\n\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,eAAe,EACfC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,EACXC,YAAY,QACN,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SACCC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,UAAU,QACJ,kBAAkB;;AAEzB;AACA;AACA;AACA,SACCC,kBAAkB,EAClBC,uBAAuB,EACvBC,iBAAiB,EACjBC,oBAAoB,QACd,uBAAuB;AAC9B,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SAASC,mBAAmB,QAAQ,kBAAkB;AACt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U;kBAClB2D,WAAW,EAAGvG,EAAE,CACf,uBACD,CAAG;kBACHwG,IAAI,EAAC,MAAM;kBACXC,EAAE,EAAGhD,eAAiB;kBACtBiD,qBAAqB;kBACrBN,uBAAuB;kBACvBO,SAAS,EAAG;gBAAK,CACjB;cAAC,CACE,CACL;YAAA,CACM,CACR,eACDlF,IAAA,CAACJ,UAAU,IAAE,CAAC;UAAA,CACP;QAAC,CACJ,CAAC;MAAA,CACN;IACA,CACH,CAAC,gBAEFI,IAAA;MAAKoD,SAAS,EAAC,iCAAiC;MAAAD,QAAA,EAC7C9C,gBAAgB,CAAEY,MAAM,CAAE,EAAEX;IAAK,CAC/B;EACL,CACY,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -29,7 +29,7 @@ export default function PostSticky() {
|
|
|
29
29
|
children: /*#__PURE__*/_jsx(CheckboxControl, {
|
|
30
30
|
className: "editor-post-sticky__checkbox-control",
|
|
31
31
|
label: __('Sticky'),
|
|
32
|
-
help: __('Pin this post to the top of the blog'),
|
|
32
|
+
help: __('Pin this post to the top of the blog.'),
|
|
33
33
|
checked: postSticky,
|
|
34
34
|
onChange: () => editPost({
|
|
35
35
|
sticky: !postSticky
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","CheckboxControl","useDispatch","useSelect","PostStickyCheck","store","editorStore","jsx","_jsx","PostSticky","postSticky","select","_select$getEditedPost","getEditedPostAttribute","editPost","children","className","label","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,SAAS;AACrC,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,eAAe,SAASC,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEL,WAAY,CAAC,CAACO,sBAAsB,CAAE,QAAS,CAAC,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEE;EAAS,CAAC,GAAGZ,WAAW,CAAEI,WAAY,CAAC;EAE/C,oBACCE,IAAA,CAACJ,eAAe;IAAAW,QAAA,eACfP,IAAA,CAACP,eAAe;MACfe,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAGjB,EAAE,CAAE,QAAS,CAAG;MACxBkB,IAAI,EAAGlB,EAAE,CAAE,
|
|
1
|
+
{"version":3,"names":["__","CheckboxControl","useDispatch","useSelect","PostStickyCheck","store","editorStore","jsx","_jsx","PostSticky","postSticky","select","_select$getEditedPost","getEditedPostAttribute","editPost","children","className","label","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog.' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,SAAS;AACrC,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,eAAe,SAASC,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEL,WAAY,CAAC,CAACO,sBAAsB,CAAE,QAAS,CAAC,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEE;EAAS,CAAC,GAAGZ,WAAW,CAAEI,WAAY,CAAC;EAE/C,oBACCE,IAAA,CAACJ,eAAe;IAAAW,QAAA,eACfP,IAAA,CAACP,eAAe;MACfe,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAGjB,EAAE,CAAE,QAAS,CAAG;MACxBkB,IAAI,EAAGlB,EAAE,CAAE,uCAAwC,CAAG;MACtDmB,OAAO,EAAGT,UAAY;MACtBU,QAAQ,EAAGA,CAAA,KAAMN,QAAQ,CAAE;QAAEO,MAAM,EAAE,CAAEX;MAAW,CAAE,CAAG;MACvDY,uBAAuB;IAAA,CACvB;EAAC,CACc,CAAC;AAEpB","ignoreList":[]}
|
|
@@ -125,9 +125,7 @@ export default function BlockThemeControl({
|
|
|
125
125
|
onClick: onClose
|
|
126
126
|
}), /*#__PURE__*/_jsx(ResetDefaultTemplate, {
|
|
127
127
|
onClick: onClose
|
|
128
|
-
}), canCreateTemplate && /*#__PURE__*/_jsx(CreateNewTemplate, {
|
|
129
|
-
onClick: onClose
|
|
130
|
-
})]
|
|
128
|
+
}), canCreateTemplate && /*#__PURE__*/_jsx(CreateNewTemplate, {})]
|
|
131
129
|
}), /*#__PURE__*/_jsx(MenuGroup, {
|
|
132
130
|
children: /*#__PURE__*/_jsx(MenuItem, {
|
|
133
131
|
icon: !isTemplateHidden ? check : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","useState","useMemo","__","useEntityRecord","store","coreStore","check","noticesStore","preferencesStore","PostPanelRow","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","select","getRenderingMode","_getEditorSettings","editorSettings","hasOwnProperty","get","getPreference","editedRecord","template","hasResolved","createSuccessNotice","setRenderingMode","setDefaultRenderingMode","canCreateTemplate","canUser","kind","name","popoverAnchor","setPopoverAnchor","popoverProps","anchor","className","placement","offset","shift","notificationAction","label","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","ref","children","focusOnMount","toggleProps","size","variant","tooltipPosition","text","title","icon","onClose","postId","postType","isSelected","role","newRenderingMode"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode, setDefaultRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tclassName: 'editor-post-template__dropdown',\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t\tvariant: 'tertiary',\n\t\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Template options' ) }\n\t\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\t\ticon={ null }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\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{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tconst newRenderingMode = isTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only';\n\t\t\t\t\t\t\t\t\tsetRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tsetDefaultRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAC1E,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASF,KAAK,IAAIG,YAAY,QAAQ,oBAAoB;AAC1D,SAASH,KAAK,IAAII,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,mBAAmB;;AAE5C;AACA;AACA;AACA,SAASL,KAAK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B,CAAC;YAC5C,CAAG;YAAAd,QAAA,EAED3D,EAAE,CAAE,eAAgB;UAAC,CACd;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACF,CAAC;AAEjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","useState","useMemo","__","useEntityRecord","store","coreStore","check","noticesStore","preferencesStore","PostPanelRow","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","select","getRenderingMode","_getEditorSettings","editorSettings","hasOwnProperty","get","getPreference","editedRecord","template","hasResolved","createSuccessNotice","setRenderingMode","setDefaultRenderingMode","canCreateTemplate","canUser","kind","name","popoverAnchor","setPopoverAnchor","popoverProps","anchor","className","placement","offset","shift","notificationAction","label","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","ref","children","focusOnMount","toggleProps","size","variant","tooltipPosition","text","title","icon","onClose","postId","postType","isSelected","role","newRenderingMode"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode, setDefaultRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tclassName: 'editor-post-template__dropdown',\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t\tvariant: 'tertiary',\n\t\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Template options' ) }\n\t\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\t\ticon={ null }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\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{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t{ canCreateTemplate && <CreateNewTemplate /> }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tconst newRenderingMode = isTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only';\n\t\t\t\t\t\t\t\t\tsetRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tsetDefaultRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sB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jCmD,IAAI,EAAC,kBAAkB;YACvBpB,OAAO,EAAGA,CAAA,KAAM;cACf,MAAMqB,gBAAgB,GAAGpD,gBAAgB,GACtC,iBAAiB,GACjB,WAAW;cACde,gBAAgB,CAAEqC,gBAAiB,CAAC;cACpCpC,uBAAuB,CAAEoC,gBAAiB,CAAC;YAC5C,CAAG;YAAAd,QAAA,EAED3D,EAAE,CAAE,eAAgB;UAAC,CACd;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACF,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -80,6 +80,7 @@ export default function CreateNewTemplateModal({
|
|
|
80
80
|
onRequestClose: cancel,
|
|
81
81
|
focusOnMount: "firstContentElement",
|
|
82
82
|
size: "small",
|
|
83
|
+
overlayClassName: "editor-post-template__create-template-modal",
|
|
83
84
|
children: /*#__PURE__*/_jsx("form", {
|
|
84
85
|
className: "editor-post-template__create-form",
|
|
85
86
|
onSubmit: submit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","unlock","store","editorStore","jsx","_jsx","jsxs","_jsxs","DEFAULT_TITLE","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","select","getEditorSettings","getCurrentTemplateId","getTemplateId","createTemplate","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","newTemplate","slug","content","postId","id","postType","onRequestClose","focusOnMount","size","children","className","onSubmit","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","justify","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,WAAW,QAAQ,mBAAmB;AAC1D,SACCC,KAAK,EACLC,WAAW,EACXC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEnD,MAAMC,aAAa,GAAGT,EAAE,CAAE,iBAAkB,CAAC;AAE7C,eAAe,SAASU,sBAAsBA,CAAE;EAAEC;AAAQ,CA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EACD,CACCpC,WAAW,CACV,YAAY,EACZ;MACCqC,MAAM,EAAE;QAAEC,OAAO,EAAE;MAAK;IACzB,CAAC,EACD,CAAEtC,WAAW,CAAE,iBAAkB,CAAC,CACnC,CAAC,EACDA,WAAW,CAAE,mBAAmB,EAAE;MACjCqC,MAAM,EAAE;QAAEC,OAAO,EAAE;MAAK;IACzB,CAAE,CAAC,CAEL,CAAC,CACA,CAAC;IAEJ,MAAMC,WAAW,GAAG,MAAMb,cAAc,CAAE;MACzCc,IAAI,EAAE/B,YAAY,CAAEkB,KAAK,IAAIV,aAAc,CAAC;MAC5CwB,OAAO,EAAEN,kBAAkB;MAC3BR,KAAK,EAAEA,KAAK,IAAIV;IACjB,CAAE,CAAC;IAEHa,SAAS,CAAE,KAAM,CAAC;IAClBT,wBAAwB,CAAE;MACzBqB,MAAM,EAAEH,WAAW,CAACI,EAAE;MACtBC,QAAQ,EAAE;IACX,CAAE,CAAC;IACHb,MAAM,CAAC,CAAC;EACT,CAAC;EAED,oBACCjB,IAAA,CAACb,KAAK;IACL0B,KAAK,EAAGnB,EAAE,CAAE,wBAAyB,CAAG;IACxCqC,cAAc,EAAGd,MAAQ;IACzBe,YAAY,EAAC,qBAAqB;IAClCC,IAAI,EAAC,OAAO;IAAAC,QAAA,
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","unlock","store","editorStore","jsx","_jsx","jsxs","_jsxs","DEFAULT_TITLE","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","select","getEditorSettings","getCurrentTemplateId","getTemplateId","createTemplate","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","newTemplate","slug","content","postId","id","postType","onRequestClose","focusOnMount","size","overlayClassName","children","className","onSubmit","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","justify","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t\toverlayClassName=\"editor-post-template__create-template-modal\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,WAAW,QAAQ,mBAAmB;AAC1D,SACCC,KAAK,EACLC,WAAW,EACXC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,SAASC,MAAM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W;UACXmD,qBAAqB;UACrBC,uBAAuB;UACvBC,KAAK,EAAG/C,EAAE,CAAE,MAAO,CAAG;UACtBgD,KAAK,EAAG7B,KAAO;UACf8B,QAAQ,EAAG7B,QAAU;UACrB8B,WAAW,EAAGzC,aAAe;UAC7B0C,QAAQ,EAAG9B,MAAQ;UACnB+B,IAAI,EAAGpD,EAAE;UACR;UACA,iHACD;QAAG,CACH,CAAC,eACFQ,KAAA,CAACX,MAAM;UAACwD,OAAO,EAAC,OAAO;UAAAZ,QAAA,gBACtBnC,IAAA,CAACX,MAAM;YACNkD,qBAAqB;YACrBS,OAAO,EAAC,UAAU;YAClBC,OAAO,EAAGhC,MAAQ;YAAAkB,QAAA,EAEhBzC,EAAE,CAAE,QAAS;UAAC,CACT,CAAC,eAETM,IAAA,CAACX,MAAM;YACNkD,qBAAqB;YACrBS,OAAO,EAAC,SAAS;YACjBE,IAAI,EAAC,QAAQ;YACbnC,MAAM,EAAGA,MAAQ;YACjB,iBAAgBA,MAAQ;YAAAoB,QAAA,EAEtBzC,EAAE,CAAE,QAAS;UAAC,CACT,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
|
|
@@ -13,9 +13,7 @@ import { useState } from '@wordpress/element';
|
|
|
13
13
|
import CreateNewTemplateModal from './create-new-template-modal';
|
|
14
14
|
import { useAllowSwitchingTemplates } from './hooks';
|
|
15
15
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
export default function CreateNewTemplate({
|
|
17
|
-
onClick
|
|
18
|
-
}) {
|
|
16
|
+
export default function CreateNewTemplate() {
|
|
19
17
|
const {
|
|
20
18
|
canCreateTemplates
|
|
21
19
|
} = useSelect(select => {
|
|
@@ -45,7 +43,6 @@ export default function CreateNewTemplate({
|
|
|
45
43
|
}), isCreateModalOpen && /*#__PURE__*/_jsx(CreateNewTemplateModal, {
|
|
46
44
|
onClose: () => {
|
|
47
45
|
setIsCreateModalOpen(false);
|
|
48
|
-
onClick();
|
|
49
46
|
}
|
|
50
47
|
})]
|
|
51
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MenuItem","__","useSelect","store","coreStore","useState","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CreateNewTemplate","
|
|
1
|
+
{"version":3,"names":["MenuItem","__","useSelect","store","coreStore","useState","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CreateNewTemplate","canCreateTemplates","select","canUser","kind","name","isCreateModalOpen","setIsCreateModalOpen","allowSwitchingTemplate","children","onClick","onClose"],"sources":["@wordpress/editor/src/components/post-template/create-new-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nexport default function CreateNewTemplate() {\n\tconst { canCreateTemplates } = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\treturn {\n\t\t\tcanCreateTemplates: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! canCreateTemplates || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsCreateModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t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A,CAAA,KAAM;QACfH,oBAAoB,CAAE,IAAK,CAAC;MAC7B,CAAG;MAAAE,QAAA,EAEDtB,EAAE,CAAE,qBAAsB;IAAC,CACpB,CAAC,EAETmB,iBAAiB,iBAClBX,IAAA,CAACH,sBAAsB;MACtBmB,OAAO,EAAGA,CAAA,KAAM;QACfJ,oBAAoB,CAAE,KAAM,CAAC;MAC9B;IAAG,CACH,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
@@ -36,16 +36,17 @@ export function useAllowSwitchingTemplates() {
|
|
|
36
36
|
kind: 'root',
|
|
37
37
|
name: 'site'
|
|
38
38
|
}) ? getEntityRecord('root', 'site') : undefined;
|
|
39
|
-
const templates = getEntityRecords('postType', 'wp_template', {
|
|
40
|
-
per_page: -1
|
|
41
|
-
});
|
|
42
39
|
const isPostsPage = +postId === siteSettings?.page_for_posts;
|
|
40
|
+
const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front;
|
|
43
41
|
// If current page is set front page or posts page, we also need
|
|
44
42
|
// to check if the current theme has a template for it. If not
|
|
45
|
-
const
|
|
43
|
+
const templates = isFrontPage ? getEntityRecords('postType', 'wp_template', {
|
|
44
|
+
per_page: -1
|
|
45
|
+
}) : [];
|
|
46
|
+
const hasFrontPage = isFrontPage && !!templates?.some(({
|
|
46
47
|
slug
|
|
47
48
|
}) => slug === 'front-page');
|
|
48
|
-
return !isPostsPage && !
|
|
49
|
+
return !isPostsPage && !hasFrontPage;
|
|
49
50
|
}, [postId, postType]);
|
|
50
51
|
}
|
|
51
52
|
function useTemplates(postType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useMemo","store","coreStore","editorStore","useEditedPostContext","select","getCurrentPostId","getCurrentPostType","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","siteSettings","kind","name","undefined","
|
|
1
|
+
{"version":3,"names":["useSelect","useMemo","store","coreStore","editorStore","useEditedPostContext","select","getCurrentPostId","getCurrentPostType","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","siteSettings","kind","name","undefined","isPostsPage","page_for_posts","isFrontPage","page_on_front","templates","per_page","hasFrontPage","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } 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';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && +postId === siteSettings?.page_on_front;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst templates = isFrontPage\n\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t } )\n\t\t\t\t: [];\n\t\t\tconst hasFrontPage =\n\t\t\t\tisFrontPage &&\n\t\t\t\t!! templates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! hasFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAA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AAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOhB,SAAS,EAAEmB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACR,IAAI,KAAKY,cAAe,CAAC,EACvEZ,IAAI;AACR","ignoreList":[]}
|
|
@@ -27,9 +27,6 @@ export default function SwapTemplateButton({
|
|
|
27
27
|
const {
|
|
28
28
|
editEntityRecord
|
|
29
29
|
} = useDispatch(coreStore);
|
|
30
|
-
if (!availableTemplates?.length) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
30
|
const onTemplateSelect = async template => {
|
|
34
31
|
editEntityRecord('postType', postType, postId, {
|
|
35
32
|
template: template.name
|
|
@@ -41,6 +38,8 @@ export default function SwapTemplateButton({
|
|
|
41
38
|
};
|
|
42
39
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
43
40
|
children: [/*#__PURE__*/_jsx(MenuItem, {
|
|
41
|
+
disabled: !availableTemplates?.length,
|
|
42
|
+
accessibleWhenDisabled: true,
|
|
44
43
|
onClick: () => setShowModal(true),
|
|
45
44
|
children: __('Change template')
|
|
46
45
|
}), showModal && /*#__PURE__*/_jsx(Modal, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useState","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","__","useDispatch","store","coreStore","parse","useAvailableTemplates","useEditedPostContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SwapTemplateButton","onClick","showModal","setShowModal","postType","postId","availableTemplates","editEntityRecord","
|
|
1
|
+
{"version":3,"names":["useMemo","useState","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","__","useDispatch","store","coreStore","parse","useAvailableTemplates","useEditedPostContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SwapTemplateButton","onClick","showModal","setShowModal","postType","postId","availableTemplates","editEntityRecord","onTemplateSelect","template","name","undoIgnore","children","disabled","length","accessibleWhenDisabled","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","map","slug","blocks","content","raw","rendered","id","label","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,+BAA+B,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC9F,SAASC,QAAQ,EAAEC,KAAK,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,KAAK,QAAQ,mBAAmB;;AAEzC;AACA;AACA;AACA,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtE,eAAe,SAASC,kBAAkBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACzD,MAAM,CAAEC,SAAS,EAAEC,YAAY,CAAE,GAAGtB,QAAQ,CAAE,KAAM,CAAC;EACrD,MAAM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,CAAEY,QAAS,CAAC;EAC5D,MAAMmB,mBAAmB,GAAG3C,OAAO,CAClC,MACC0B,kBAAkB,CAACkB,GAAG,CAAIf,QAAQ,KAAQ;IACzCC,IAAI,EAAED,QAAQ,CAACgB,IAAI;IACnBC,MAAM,EAAEnC,KAAK,CAAEkB,QAAQ,CAACkB,OAAO,CAACC,GAAI,CAAC;IACrCZ,KAAK,EAAElC,cAAc,CAAE2B,QAAQ,CAACO,KAAK,CAACa,QAAS,CAAC;IAChDC,EAAE,EAAErB,QAAQ,CAACqB;EACd,CAAC,CAAG,CAAC,EACN,CAAExB,kBAAkB,CACrB,CAAC;EACD,oBACCX,IAAA,CAACX,iBAAiB;IACjB+C,KAAK,EAAG5C,EAAE,CAAE,WAAY,CAAG;IAC3B6C,aAAa,EAAGT,mBAAqB;IACrCU,cAAc,EAAGX;EAAU,CAC3B,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useState } from '@wordpress/element';
|
|
6
|
-
import {
|
|
6
|
+
import { TextControl, RadioControl, __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
7
|
import { useInstanceId } from '@wordpress/compose';
|
|
8
8
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
9
|
import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
|
|
@@ -11,7 +11,7 @@ import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { VISIBILITY_OPTIONS } from './utils';
|
|
15
15
|
import { store as editorStore } from '../../store';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -36,43 +36,30 @@ export default function PostVisibility({
|
|
|
36
36
|
password: select(editorStore).getEditedPostAttribute('password')
|
|
37
37
|
}));
|
|
38
38
|
const {
|
|
39
|
-
editPost
|
|
40
|
-
savePost
|
|
39
|
+
editPost
|
|
41
40
|
} = useDispatch(editorStore);
|
|
42
41
|
const [hasPassword, setHasPassword] = useState(!!password);
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
function updateVisibility(value) {
|
|
43
|
+
const nextValues = {
|
|
44
|
+
public: {
|
|
45
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
46
|
+
password: ''
|
|
47
|
+
},
|
|
48
|
+
private: {
|
|
49
|
+
status: 'private',
|
|
50
|
+
password: ''
|
|
51
|
+
},
|
|
52
|
+
password: {
|
|
53
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
54
|
+
password: password || ''
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
editPost(nextValues[value]);
|
|
58
|
+
setHasPassword(value === 'password');
|
|
59
|
+
}
|
|
60
|
+
const updatePassword = value => {
|
|
45
61
|
editPost({
|
|
46
|
-
|
|
47
|
-
password: ''
|
|
48
|
-
});
|
|
49
|
-
setHasPassword(false);
|
|
50
|
-
};
|
|
51
|
-
const setPrivate = () => {
|
|
52
|
-
setShowPrivateConfirmDialog(true);
|
|
53
|
-
};
|
|
54
|
-
const confirmPrivate = () => {
|
|
55
|
-
editPost({
|
|
56
|
-
status: 'private',
|
|
57
|
-
password: ''
|
|
58
|
-
});
|
|
59
|
-
setHasPassword(false);
|
|
60
|
-
setShowPrivateConfirmDialog(false);
|
|
61
|
-
savePost();
|
|
62
|
-
};
|
|
63
|
-
const handleDialogCancel = () => {
|
|
64
|
-
setShowPrivateConfirmDialog(false);
|
|
65
|
-
};
|
|
66
|
-
const setPasswordProtected = () => {
|
|
67
|
-
editPost({
|
|
68
|
-
status: visibility === 'private' ? 'draft' : status,
|
|
69
|
-
password: password || ''
|
|
70
|
-
});
|
|
71
|
-
setHasPassword(true);
|
|
72
|
-
};
|
|
73
|
-
const updatePassword = event => {
|
|
74
|
-
editPost({
|
|
75
|
-
password: event.target.value
|
|
62
|
+
password: value
|
|
76
63
|
});
|
|
77
64
|
};
|
|
78
65
|
return /*#__PURE__*/_jsxs("div", {
|
|
@@ -81,82 +68,25 @@ export default function PostVisibility({
|
|
|
81
68
|
title: __('Visibility'),
|
|
82
69
|
help: __('Control how this post is viewed.'),
|
|
83
70
|
onClose: onClose
|
|
84
|
-
}), /*#__PURE__*/_jsxs(
|
|
85
|
-
|
|
86
|
-
children: [/*#__PURE__*/_jsx(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
onChange: setPrivate
|
|
103
|
-
}), /*#__PURE__*/_jsx(PostVisibilityChoice, {
|
|
104
|
-
instanceId: instanceId,
|
|
105
|
-
value: "password",
|
|
106
|
-
label: visibilityOptions.password.label,
|
|
107
|
-
info: visibilityOptions.password.info,
|
|
108
|
-
checked: hasPassword,
|
|
109
|
-
onChange: setPasswordProtected
|
|
110
|
-
}), hasPassword && /*#__PURE__*/_jsxs("div", {
|
|
111
|
-
className: "editor-post-visibility__password",
|
|
112
|
-
children: [/*#__PURE__*/_jsx(VisuallyHidden, {
|
|
113
|
-
as: "label",
|
|
114
|
-
htmlFor: `editor-post-visibility__password-input-${instanceId}`,
|
|
115
|
-
children: __('Create password')
|
|
116
|
-
}), /*#__PURE__*/_jsx("input", {
|
|
117
|
-
className: "editor-post-visibility__password-input",
|
|
118
|
-
id: `editor-post-visibility__password-input-${instanceId}`,
|
|
119
|
-
type: "text",
|
|
120
|
-
onChange: updatePassword,
|
|
121
|
-
value: password,
|
|
122
|
-
placeholder: __('Use a secure password')
|
|
123
|
-
})]
|
|
71
|
+
}), /*#__PURE__*/_jsxs(VStack, {
|
|
72
|
+
spacing: 4,
|
|
73
|
+
children: [/*#__PURE__*/_jsx(RadioControl, {
|
|
74
|
+
label: __('Visibility'),
|
|
75
|
+
hideLabelFromVision: true,
|
|
76
|
+
options: VISIBILITY_OPTIONS,
|
|
77
|
+
selected: hasPassword ? 'password' : visibility,
|
|
78
|
+
onChange: updateVisibility
|
|
79
|
+
}), hasPassword && /*#__PURE__*/_jsx(TextControl, {
|
|
80
|
+
label: __('Password'),
|
|
81
|
+
onChange: updatePassword,
|
|
82
|
+
value: password,
|
|
83
|
+
placeholder: __('Use a secure password'),
|
|
84
|
+
type: "text",
|
|
85
|
+
id: `editor-post-visibility__password-input-${instanceId}`,
|
|
86
|
+
__next40pxDefaultSize: true,
|
|
87
|
+
__nextHasNoMarginBottom: true,
|
|
88
|
+
maxLength: 255
|
|
124
89
|
})]
|
|
125
|
-
}), /*#__PURE__*/_jsx(ConfirmDialog, {
|
|
126
|
-
isOpen: showPrivateConfirmDialog,
|
|
127
|
-
onConfirm: confirmPrivate,
|
|
128
|
-
onCancel: handleDialogCancel,
|
|
129
|
-
confirmButtonText: __('Publish'),
|
|
130
|
-
size: "medium",
|
|
131
|
-
children: __('Would you like to privately publish this post now?')
|
|
132
|
-
})]
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
function PostVisibilityChoice({
|
|
136
|
-
instanceId,
|
|
137
|
-
value,
|
|
138
|
-
label,
|
|
139
|
-
info,
|
|
140
|
-
...props
|
|
141
|
-
}) {
|
|
142
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
143
|
-
className: "editor-post-visibility__choice",
|
|
144
|
-
children: [/*#__PURE__*/_jsx("input", {
|
|
145
|
-
type: "radio",
|
|
146
|
-
name: `editor-post-visibility__setting-${instanceId}`,
|
|
147
|
-
value: value,
|
|
148
|
-
id: `editor-post-${value}-${instanceId}`,
|
|
149
|
-
"aria-describedby": `editor-post-${value}-${instanceId}-description`,
|
|
150
|
-
className: "editor-post-visibility__radio",
|
|
151
|
-
...props
|
|
152
|
-
}), /*#__PURE__*/_jsx("label", {
|
|
153
|
-
htmlFor: `editor-post-${value}-${instanceId}`,
|
|
154
|
-
className: "editor-post-visibility__label",
|
|
155
|
-
children: label
|
|
156
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
157
|
-
id: `editor-post-${value}-${instanceId}-description`,
|
|
158
|
-
className: "editor-post-visibility__info",
|
|
159
|
-
children: info
|
|
160
90
|
})]
|
|
161
91
|
});
|
|
162
92
|
}
|