@wordpress/core-commands 1.32.1-next.ff1cebbba.0 → 1.33.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 +2 -0
- package/build/site-editor-navigation-commands.js +1 -6
- package/build/site-editor-navigation-commands.js.map +2 -2
- package/build-module/site-editor-navigation-commands.js +1 -6
- package/build-module/site-editor-navigation-commands.js.map +2 -2
- package/package.json +15 -15
- package/src/site-editor-navigation-commands.js +1 -6
package/CHANGELOG.md
CHANGED
|
@@ -37,7 +37,6 @@ const icons = {
|
|
|
37
37
|
post: import_icons.post,
|
|
38
38
|
page: import_icons.page,
|
|
39
39
|
wp_template: import_icons.layout,
|
|
40
|
-
wp_registered_template: import_icons.layout,
|
|
41
40
|
wp_template_part: import_icons.symbolFilled
|
|
42
41
|
};
|
|
43
42
|
function useDebouncedValue(value) {
|
|
@@ -154,7 +153,7 @@ const getNavigationCommandLoaderPerTemplate = (templateType) => function useNavi
|
|
|
154
153
|
(select) => {
|
|
155
154
|
return {
|
|
156
155
|
isBlockBasedTheme: select(import_core_data.store).getCurrentTheme()?.is_block_theme,
|
|
157
|
-
canCreateTemplate: select(import_core_data.store).canUser("
|
|
156
|
+
canCreateTemplate: select(import_core_data.store).canUser("create", {
|
|
158
157
|
kind: "postType",
|
|
159
158
|
name: templateType
|
|
160
159
|
})
|
|
@@ -411,10 +410,6 @@ function useSiteEditorNavigationCommands() {
|
|
|
411
410
|
name: "core/edit-site/navigate-templates",
|
|
412
411
|
hook: getNavigationCommandLoaderPerTemplate("wp_template")
|
|
413
412
|
});
|
|
414
|
-
(0, import_commands.useCommandLoader)({
|
|
415
|
-
name: "core/edit-site/navigate-templates",
|
|
416
|
-
hook: getNavigationCommandLoaderPerTemplate("wp_registered_template")
|
|
417
|
-
});
|
|
418
413
|
(0, import_commands.useCommandLoader)({
|
|
419
414
|
name: "core/edit-site/navigate-template-parts",
|
|
420
415
|
hook: getNavigationCommandLoaderPerTemplate("wp_template_part")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/site-editor-navigation-commands.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_registered_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'read', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\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\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\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\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\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\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\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}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_registered_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAiC;AACjC,kBAAmB;AACnB,qBAA6C;AAC7C,kBAA0B;AAC1B,uBAAmC;AACnC,mBASO;AACP,oBAAiD;AACjD,iBAAsC;AACtC,qBAA4B;AAC5B,2BAA+B;AAK/B,yBAAuB;AACvB,4CAA2C;AAE3C,MAAM,EAAE,WAAW,QAAI,2BAAQ,cAAAA,WAAkB;AAEjD,MAAM,QAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\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\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\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\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\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\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\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}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAiC;AACjC,kBAAmB;AACnB,qBAA6C;AAC7C,kBAA0B;AAC1B,uBAAmC;AACnC,mBASO;AACP,oBAAiD;AACjD,iBAAsC;AACtC,qBAA4B;AAC5B,2BAA+B;AAK/B,yBAAuB;AACvB,4CAA2C;AAE3C,MAAM,EAAE,WAAW,QAAI,2BAAQ,cAAAA,WAAkB;AAEjD,MAAM,QAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,kBAAkB;AACnB;AAEA,SAAS,kBAAmB,OAAQ;AACnC,QAAM,CAAE,gBAAgB,iBAAkB,QAAI,yBAAU,EAAG;AAC3D,QAAM,gBAAY,4BAAa,mBAAmB,GAAI;AAEtD,gCAAW,MAAM;AAChB,cAAW,KAAM;AACjB,WAAO,MAAM,UAAU,OAAO;AAAA,EAC/B,GAAG,CAAE,WAAW,KAAM,CAAE;AAExB,SAAO;AACR;AAEA,MAAM,wCAAwC,CAAE,aAC/C,SAAS,2BAA4B,EAAE,OAAO,GAAI;AACjD,QAAM,UAAU,WAAW;AAC3B,QAAM,EAAE,mBAAmB,kBAAkB,QAAI;AAAA,IAChD,CAAE,WAAY;AACb,aAAO;AAAA,QACN,mBACC,OAAQ,iBAAAC,KAAU,EAAE,gBAAgB,GAAG;AAAA,QACxC,mBAAmB,OAAQ,iBAAAA,KAAU,EAAE,QAAS,UAAU;AAAA,UACzD,MAAM;AAAA,UACN,MAAM;AAAA,QACP,CAAE;AAAA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AAM,sCAAuC,MAAO;AAAA,EACrD,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,aAAc;AAAA,EAC5D,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,kBAAmB;AAAA,EACjE,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,qCAAqC;AAAA,IAC3C,SAAS;AAAA,EACV,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,+BAA+B;AAAA,EACtC,CAAE;AACH;",
|
|
6
6
|
"names": ["routerPrivateApis", "coreStore"]
|
|
7
7
|
}
|
|
@@ -24,7 +24,6 @@ const icons = {
|
|
|
24
24
|
post,
|
|
25
25
|
page,
|
|
26
26
|
wp_template: layout,
|
|
27
|
-
wp_registered_template: layout,
|
|
28
27
|
wp_template_part: symbolFilled
|
|
29
28
|
};
|
|
30
29
|
function useDebouncedValue(value) {
|
|
@@ -141,7 +140,7 @@ const getNavigationCommandLoaderPerTemplate = (templateType) => function useNavi
|
|
|
141
140
|
(select) => {
|
|
142
141
|
return {
|
|
143
142
|
isBlockBasedTheme: select(coreStore).getCurrentTheme()?.is_block_theme,
|
|
144
|
-
canCreateTemplate: select(coreStore).canUser("
|
|
143
|
+
canCreateTemplate: select(coreStore).canUser("create", {
|
|
145
144
|
kind: "postType",
|
|
146
145
|
name: templateType
|
|
147
146
|
})
|
|
@@ -398,10 +397,6 @@ function useSiteEditorNavigationCommands() {
|
|
|
398
397
|
name: "core/edit-site/navigate-templates",
|
|
399
398
|
hook: getNavigationCommandLoaderPerTemplate("wp_template")
|
|
400
399
|
});
|
|
401
|
-
useCommandLoader({
|
|
402
|
-
name: "core/edit-site/navigate-templates",
|
|
403
|
-
hook: getNavigationCommandLoaderPerTemplate("wp_registered_template")
|
|
404
|
-
});
|
|
405
400
|
useCommandLoader({
|
|
406
401
|
name: "core/edit-site/navigate-template-parts",
|
|
407
402
|
hook: getNavigationCommandLoaderPerTemplate("wp_template_part")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/site-editor-navigation-commands.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_registered_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'read', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\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\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\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\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\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\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\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}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_registered_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t} );\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,wBAAwB;AACjC,SAAS,UAAU;AACnB,SAAS,SAAS,WAAW,gBAAgB;AAC7C,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,eAAe,yBAAyB;AACjD,SAAS,cAAc,eAAe;AACtC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAK/B,SAAS,cAAc;AACvB,SAAS,kCAAkC;AAE3C,MAAM,EAAE,WAAW,IAAI,OAAQ,iBAAkB;AAEjD,MAAM,QAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tclose();\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\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\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\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\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\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\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\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\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}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t} );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,wBAAwB;AACjC,SAAS,UAAU;AACnB,SAAS,SAAS,WAAW,gBAAgB;AAC7C,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,eAAe,yBAAyB;AACjD,SAAS,cAAc,eAAe;AACtC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAK/B,SAAS,cAAc;AACvB,SAAS,kCAAkC;AAE3C,MAAM,EAAE,WAAW,IAAI,OAAQ,iBAAkB;AAEjD,MAAM,QAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,kBAAkB;AACnB;AAEA,SAAS,kBAAmB,OAAQ;AACnC,QAAM,CAAE,gBAAgB,iBAAkB,IAAI,SAAU,EAAG;AAC3D,QAAM,YAAY,YAAa,mBAAmB,GAAI;AAEtD,YAAW,MAAM;AAChB,cAAW,KAAM;AACjB,WAAO,MAAM,UAAU,OAAO;AAAA,EAC/B,GAAG,CAAE,WAAW,KAAM,CAAE;AAExB,SAAO;AACR;AAEA,MAAM,wCAAwC,CAAE,aAC/C,SAAS,2BAA4B,EAAE,OAAO,GAAI;AACjD,QAAM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CAAkC;AACjD,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,MAAO;AAAA,EACrD,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,MAAO;AAAA,EACrD,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,aAAc;AAAA,EAC5D,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,kBAAmB;AAAA,EACjE,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,qCAAqC;AAAA,IAC3C,SAAS;AAAA,EACV,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,+BAA+B;AAAA,EACtC,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/core-commands",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "WordPress core reusable commands.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"wpScript": true,
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@wordpress/block-editor": "^15.
|
|
39
|
-
"@wordpress/commands": "^1.
|
|
40
|
-
"@wordpress/compose": "^7.
|
|
41
|
-
"@wordpress/core-data": "^7.
|
|
42
|
-
"@wordpress/data": "^10.
|
|
43
|
-
"@wordpress/element": "^6.
|
|
44
|
-
"@wordpress/html-entities": "^4.
|
|
45
|
-
"@wordpress/i18n": "^6.
|
|
46
|
-
"@wordpress/icons": "^11.0.
|
|
47
|
-
"@wordpress/notices": "^5.
|
|
48
|
-
"@wordpress/private-apis": "^1.
|
|
49
|
-
"@wordpress/router": "^1.
|
|
50
|
-
"@wordpress/url": "^4.
|
|
38
|
+
"@wordpress/block-editor": "^15.6.0",
|
|
39
|
+
"@wordpress/commands": "^1.33.0",
|
|
40
|
+
"@wordpress/compose": "^7.33.0",
|
|
41
|
+
"@wordpress/core-data": "^7.33.0",
|
|
42
|
+
"@wordpress/data": "^10.33.0",
|
|
43
|
+
"@wordpress/element": "^6.33.0",
|
|
44
|
+
"@wordpress/html-entities": "^4.33.0",
|
|
45
|
+
"@wordpress/i18n": "^6.6.0",
|
|
46
|
+
"@wordpress/icons": "^11.0.0",
|
|
47
|
+
"@wordpress/notices": "^5.33.0",
|
|
48
|
+
"@wordpress/private-apis": "^1.33.0",
|
|
49
|
+
"@wordpress/router": "^1.33.0",
|
|
50
|
+
"@wordpress/url": "^4.33.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "^18.0.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "2bbe0d34ab65458468758c48826296d7a753428b"
|
|
60
60
|
}
|
|
@@ -33,7 +33,6 @@ const icons = {
|
|
|
33
33
|
post,
|
|
34
34
|
page,
|
|
35
35
|
wp_template: layout,
|
|
36
|
-
wp_registered_template: layout,
|
|
37
36
|
wp_template_part: symbolFilled,
|
|
38
37
|
};
|
|
39
38
|
|
|
@@ -171,7 +170,7 @@ const getNavigationCommandLoaderPerTemplate = ( templateType ) =>
|
|
|
171
170
|
return {
|
|
172
171
|
isBlockBasedTheme:
|
|
173
172
|
select( coreStore ).getCurrentTheme()?.is_block_theme,
|
|
174
|
-
canCreateTemplate: select( coreStore ).canUser( '
|
|
173
|
+
canCreateTemplate: select( coreStore ).canUser( 'create', {
|
|
175
174
|
kind: 'postType',
|
|
176
175
|
name: templateType,
|
|
177
176
|
} ),
|
|
@@ -470,10 +469,6 @@ export function useSiteEditorNavigationCommands() {
|
|
|
470
469
|
name: 'core/edit-site/navigate-templates',
|
|
471
470
|
hook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),
|
|
472
471
|
} );
|
|
473
|
-
useCommandLoader( {
|
|
474
|
-
name: 'core/edit-site/navigate-templates',
|
|
475
|
-
hook: getNavigationCommandLoaderPerTemplate( 'wp_registered_template' ),
|
|
476
|
-
} );
|
|
477
472
|
useCommandLoader( {
|
|
478
473
|
name: 'core/edit-site/navigate-template-parts',
|
|
479
474
|
hook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),
|