@wordpress/core-commands 0.27.0 → 1.0.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 +7 -1
- package/build/site-editor-navigation-commands.js +8 -20
- package/build/site-editor-navigation-commands.js.map +1 -1
- package/build-module/site-editor-navigation-commands.js +9 -21
- package/build-module/site-editor-navigation-commands.js.map +1 -1
- package/package.json +15 -14
- package/src/site-editor-navigation-commands.js +9 -40
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.0.0 (2024-05-31)
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Increase the minimum required Node.js version to v18.12.0 matching long-term support releases ([#31270](https://github.com/WordPress/gutenberg/pull/61930)). Learn more about [Node.js releases](https://nodejs.org/en/about/previous-releases).
|
|
10
|
+
|
|
5
11
|
## 0.27.0 (2024-05-16)
|
|
6
12
|
|
|
7
13
|
## 0.26.0 (2024-05-02)
|
|
@@ -54,4 +60,4 @@
|
|
|
54
60
|
|
|
55
61
|
## 0.2.0 (2023-05-10)
|
|
56
62
|
|
|
57
|
-
Initial release.
|
|
63
|
+
Initial release.
|
|
@@ -25,8 +25,7 @@ var _orderEntityRecordsBySearch = require("./utils/order-entity-records-by-searc
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
const {
|
|
28
|
-
useHistory
|
|
29
|
-
useLocation
|
|
28
|
+
useHistory
|
|
30
29
|
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
31
30
|
const icons = {
|
|
32
31
|
post: _icons.post,
|
|
@@ -94,9 +93,6 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
|
|
94
93
|
};
|
|
95
94
|
}
|
|
96
95
|
const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
|
|
97
|
-
const extraArgs = isSiteEditor ? {
|
|
98
|
-
canvas: (0, _url.getQueryArg)(window.location.href, 'canvas')
|
|
99
|
-
} : {};
|
|
100
96
|
return {
|
|
101
97
|
...command,
|
|
102
98
|
callback: ({
|
|
@@ -105,7 +101,7 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
|
|
105
101
|
const args = {
|
|
106
102
|
postType,
|
|
107
103
|
postId: record.id,
|
|
108
|
-
|
|
104
|
+
canvas: 'edit'
|
|
109
105
|
};
|
|
110
106
|
const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
|
|
111
107
|
if (isSiteEditor) {
|
|
@@ -127,9 +123,6 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
127
123
|
search
|
|
128
124
|
}) {
|
|
129
125
|
const history = useHistory();
|
|
130
|
-
const location = useLocation();
|
|
131
|
-
const isPatternsPage = location?.params?.path === '/patterns' || location?.params?.postType === 'wp_block';
|
|
132
|
-
const didAccessPatternsPage = !!location?.params?.didAccessPatternsPage;
|
|
133
126
|
const isBlockBasedTheme = (0, _hooks.useIsBlockBasedTheme)();
|
|
134
127
|
const {
|
|
135
128
|
records,
|
|
@@ -162,9 +155,6 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
162
155
|
const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
|
|
163
156
|
const result = [];
|
|
164
157
|
result.push(...orderedRecords.map(record => {
|
|
165
|
-
const extraArgs = isSiteEditor ? {
|
|
166
|
-
canvas: (0, _url.getQueryArg)(window.location.href, 'canvas')
|
|
167
|
-
} : {};
|
|
168
158
|
return {
|
|
169
159
|
name: templateType + '-' + record.id,
|
|
170
160
|
searchLabel: record.title?.rendered + ' ' + record.id,
|
|
@@ -176,8 +166,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
176
166
|
const args = {
|
|
177
167
|
postType: templateType,
|
|
178
168
|
postId: record.id,
|
|
179
|
-
|
|
180
|
-
...extraArgs
|
|
169
|
+
canvas: 'edit'
|
|
181
170
|
};
|
|
182
171
|
const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
|
|
183
172
|
if (isSiteEditor) {
|
|
@@ -198,8 +187,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
198
187
|
close
|
|
199
188
|
}) => {
|
|
200
189
|
const args = {
|
|
201
|
-
|
|
202
|
-
categoryType: 'wp_template_part',
|
|
190
|
+
postType: 'wp_template_part',
|
|
203
191
|
categoryId: 'all-parts'
|
|
204
192
|
};
|
|
205
193
|
const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
|
|
@@ -241,7 +229,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
241
229
|
close
|
|
242
230
|
}) => {
|
|
243
231
|
const args = {
|
|
244
|
-
|
|
232
|
+
postType: 'wp_navigation'
|
|
245
233
|
};
|
|
246
234
|
const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
|
|
247
235
|
if (isSiteEditor) {
|
|
@@ -279,7 +267,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
279
267
|
close
|
|
280
268
|
}) => {
|
|
281
269
|
const args = {
|
|
282
|
-
|
|
270
|
+
post_type: 'page'
|
|
283
271
|
};
|
|
284
272
|
const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
|
|
285
273
|
if (isSiteEditor) {
|
|
@@ -298,7 +286,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
298
286
|
close
|
|
299
287
|
}) => {
|
|
300
288
|
const args = {
|
|
301
|
-
|
|
289
|
+
postType: 'wp_template'
|
|
302
290
|
};
|
|
303
291
|
const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
|
|
304
292
|
if (isSiteEditor) {
|
|
@@ -319,7 +307,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
319
307
|
}) => {
|
|
320
308
|
if (canCreateTemplate) {
|
|
321
309
|
const args = {
|
|
322
|
-
|
|
310
|
+
postType: 'wp_block'
|
|
323
311
|
};
|
|
324
312
|
const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
|
|
325
313
|
if (isSiteEditor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_commands","require","_i18n","_element","_data","_coreData","_icons","_router","_url","_compose","_hooks","_lockUnlock","_orderEntityRecordsBySearch","useHistory","useLocation","unlock","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","useDebouncedValue","value","debouncedValue","setDebouncedValue","useState","debounced","useDebounce","useEffect","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","useIsBlockBasedTheme","delayedSearch","records","isLoading","useSelect","select","query","per_page","orderby","status","coreStore","getEntityRecords","hasFinishedResolution","commands","useMemo","map","record","command","name","id","searchLabel","title","rendered","label","__","icon","callback","close","args","action","targetUrl","addQueryArgs","document","location","isSiteEditor","getPath","window","href","includes","extraArgs","canvas","getQueryArg","postId","push","getNavigationCommandLoaderPerTemplate","templateType","isPatternsPage","params","path","didAccessPatternsPage","orderedRecords","orderEntityRecordsBySearch","slice","result","undefined","length","categoryType","categoryId","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","canCreateTemplate","canUser","navigation","styles","symbol","useSiteEditorNavigationCommands","useCommandLoader","hook","context"],"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"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} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useIsBlockBasedTheme } from './hooks';\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory, useLocation } = 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 = useIsBlockBasedTheme();\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? 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\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\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcanvas: getQueryArg(\n\t\t\t\t\t\t\t\twindow.location.href,\n\t\t\t\t\t\t\t\t'canvas'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\n\t\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\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ 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 location = useLocation();\n\n\t\tconst isPatternsPage =\n\t\t\tlocation?.params?.path === '/patterns' ||\n\t\t\tlocation?.params?.postType === 'wp_block';\n\t\tconst didAccessPatternsPage =\n\t\t\t!! location?.params?.didAccessPatternsPage;\n\n\t\tconst isBlockBasedTheme = useIsBlockBasedTheme();\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! isBlockBasedTheme &&\n\t\t\t\t! 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\tconst extraArgs = isSiteEditor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcanvas: getQueryArg(\n\t\t\t\t\t\t\t\t\twindow.location.href,\n\t\t\t\t\t\t\t\t\t'canvas'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {};\n\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\tconst args = {\n\t\t\t\t\t\t\t\tpostType: templateType,\n\t\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t\tdidAccessPatternsPage:\n\t\t\t\t\t\t\t\t\t! isBlockBasedTheme &&\n\t\t\t\t\t\t\t\t\t( isPatternsPage || didAccessPatternsPage )\n\t\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = targetUrl;\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: __( 'Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpath: '/patterns',\n\t\t\t\t\t\t\tcategoryType: 'wp_template_part',\n\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst canCreateTemplate = useSelect( ( select ) => {\n\t\treturn select( coreStore ).canUser( 'create', 'templates' );\n\t}, [] );\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\tlabel: __( 'Navigation' ),\n\t\t\t\ticon: navigation,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/navigation',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\tlabel: __( 'Styles' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-pages',\n\t\t\t\tlabel: __( 'Pages' ),\n\t\t\t\ticon: page,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/page',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\tlabel: __( 'Templates' ),\n\t\t\t\ticon: layout,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/wp_template',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\tlabel: __( 'Patterns' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/patterns',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t} else {\n\t\t\t\t\t// If a user cannot access the site editor\n\t\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t\t}\n\t\t\t},\n\t\t} );\n\n\t\treturn result;\n\t}, [ history, isSiteEditor, canCreateTemplate, isBlockBasedTheme ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AASA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,2BAAA,GAAAX,OAAA;AA1BA;AACA;AACA;;AAmBA;AACA;AACA;;AAKA,MAAM;EAAEY,UAAU;EAAEC;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAE/D,MAAMC,KAAK,GAAG;EACbC,IAAI,EAAJA,WAAI;EACJC,IAAI,EAAJA,WAAI;EACJC,WAAW,EAAEC,aAAM;EACnBC,gBAAgB,EAAEC;AACnB,CAAC;AAED,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAM,CAAEC,cAAc,EAAEC,iBAAiB,CAAE,GAAG,IAAAC,iBAAQ,EA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oC,YAAY,EAAE6B,iBAAiB,EAAEhE,iBAAiB,CAAG,CAAC;EAEpE,OAAO;IACNc,QAAQ;IACRV,SAAS,EAAE;EACZ,CAAC;AACF;AAEO,SAASiE,+BAA+BA,CAAA,EAAG;EACjD,IAAAC,0BAAgB,EAAE;IACjBnD,IAAI,EAAE,+BAA+B;IACrCoD,IAAI,EAAEZ;EACP,CAAE,CAAC;EACH,IAAAW,0BAAgB,EAAE;IACjBnD,IAAI,EAAE,+BAA+B;IACrCoD,IAAI,EAAEX;EACP,CAAE,CAAC;EACH,IAAAU,0BAAgB,EAAE;IACjBnD,IAAI,EAAE,mCAAmC;IACzCoD,IAAI,EAAEV;EACP,CAAE,CAAC;EACH,IAAAS,0BAAgB,EAAE;IACjBnD,IAAI,EAAE,wCAAwC;IAC9CoD,IAAI,EAAET;EACP,CAAE,CAAC;EACH,IAAAQ,0BAAgB,EAAE;IACjBnD,IAAI,EAAE,iCAAiC;IACvCoD,IAAI,EAAER,oCAAoC;IAC1CS,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_commands","require","_i18n","_element","_data","_coreData","_icons","_router","_url","_compose","_hooks","_lockUnlock","_orderEntityRecordsBySearch","useHistory","unlock","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","useDebouncedValue","value","debouncedValue","setDebouncedValue","useState","debounced","useDebounce","useEffect","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","useIsBlockBasedTheme","delayedSearch","records","isLoading","useSelect","select","query","per_page","orderby","status","coreStore","getEntityRecords","hasFinishedResolution","commands","useMemo","map","record","command","name","id","searchLabel","title","rendered","label","__","icon","callback","close","args","action","targetUrl","addQueryArgs","document","location","isSiteEditor","getPath","window","href","includes","postId","canvas","push","getNavigationCommandLoaderPerTemplate","templateType","orderedRecords","orderEntityRecordsBySearch","slice","result","length","categoryId","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","canCreateTemplate","canUser","navigation","styles","path","post_type","symbol","useSiteEditorNavigationCommands","useCommandLoader","hook","context"],"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"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} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useIsBlockBasedTheme } from './hooks';\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 = useIsBlockBasedTheme();\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? 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\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\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ 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 = useIsBlockBasedTheme();\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! isBlockBasedTheme &&\n\t\t\t\t! 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\tconst args = {\n\t\t\t\t\t\t\t\tpostType: templateType,\n\t\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = targetUrl;\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: __( 'Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst canCreateTemplate = useSelect( ( select ) => {\n\t\treturn select( coreStore ).canUser( 'create', 'templates' );\n\t}, [] );\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\tlabel: __( 'Navigation' ),\n\t\t\t\ticon: navigation,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_navigation',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\tlabel: __( 'Styles' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-pages',\n\t\t\t\tlabel: __( 'Pages' ),\n\t\t\t\ticon: page,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpost_type: 'page',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\tlabel: __( 'Templates' ),\n\t\t\t\ticon: layout,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\tlabel: __( 'Patterns' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_block',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t} else {\n\t\t\t\t\t// If a user cannot access the site editor\n\t\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t\t}\n\t\t\t},\n\t\t} );\n\n\t\treturn result;\n\t}, [ history, isSiteEditor, canCreateTemplate, isBlockBasedTheme ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AASA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,2BAAA,GAAAX,OAAA;AA1BA;AACA;AACA;;AAmBA;AACA;AACA;;AAKA,MAAM;EAAEY;AAAW,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAElD,MAAMC,KAAK,GAAG;EACbC,IAAI,EAAJA,WAAI;EACJC,IAAI,EAAJA,WAAI;EACJC,WAAW,EAAEC,aAAM;EACnBC,gBAAgB,EAAEC;AACnB,CAAC;AAED,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAM,CAAEC,cAAc,EAAEC,iBAAiB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,EAAG,CAAC;EAC5D,MAAMC,SAAS,GAAG,IAAAC,oBAAW,EAAEH,iBAAiB,EAAE,GAAI,CAAC;EAEvD,IAAAI,kBAAS,EAAE,MAAM;IAChBF,SAAS,CAAEJ,KAAM,CAAC;IAClB,OAAO,MAAMI,SAAS,CAACG,MAAM,CAAC,CAAC;EAChC,CAAC,EAAE,CAAEH,SAAS,EAAEJ,KAAK,CAAG,CAAC;EAEzB,OAAOC,cAAc;AACtB;AAEA,MAA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,CAAEb,IAAK,CAAC;UACrB,CAAC,MAAM;YACNI,QAAQ,CAACC,QAAQ,GAAGH,SAAS;UAC9B;UACAH,KAAK,CAAC,CAAC;QACR,CAAC,MAAM;UACN;UACAK,QAAQ,CAACC,QAAQ,CAACI,IAAI,GAAG,6BAA6B;QACvD;MACD;IACD,CAAE,CAAC;IAEH,OAAOU,MAAM;EACd,CAAC,EAAE,CAAEjD,OAAO,EAAEoC,YAAY,EAAEqB,iBAAiB,EAAExD,iBAAiB,CAAG,CAAC;EAEpE,OAAO;IACNc,QAAQ;IACRV,SAAS,EAAE;EACZ,CAAC;AACF;AAEO,SAAS2D,+BAA+BA,CAAA,EAAG;EACjD,IAAAC,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,+BAA+B;IACrC8C,IAAI,EAAEd;EACP,CAAE,CAAC;EACH,IAAAa,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,+BAA+B;IACrC8C,IAAI,EAAEb;EACP,CAAE,CAAC;EACH,IAAAY,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,mCAAmC;IACzC8C,IAAI,EAAEZ;EACP,CAAE,CAAC;EACH,IAAAW,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,wCAAwC;IAC9C8C,IAAI,EAAEX;EACP,CAAE,CAAC;EACH,IAAAU,0BAAgB,EAAE;IACjB7C,IAAI,EAAE,iCAAiC;IACvC8C,IAAI,EAAEV,oCAAoC;IAC1CW,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
8
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
9
|
import { post, page, layout, symbol, symbolFilled, styles, navigation } from '@wordpress/icons';
|
|
10
10
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
11
|
-
import {
|
|
11
|
+
import { addQueryArgs, getPath } from '@wordpress/url';
|
|
12
12
|
import { useDebounce } from '@wordpress/compose';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -18,8 +18,7 @@ import { useIsBlockBasedTheme } from './hooks';
|
|
|
18
18
|
import { unlock } from './lock-unlock';
|
|
19
19
|
import { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';
|
|
20
20
|
const {
|
|
21
|
-
useHistory
|
|
22
|
-
useLocation
|
|
21
|
+
useHistory
|
|
23
22
|
} = unlock(routerPrivateApis);
|
|
24
23
|
const icons = {
|
|
25
24
|
post,
|
|
@@ -87,9 +86,6 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
|
|
87
86
|
};
|
|
88
87
|
}
|
|
89
88
|
const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
|
|
90
|
-
const extraArgs = isSiteEditor ? {
|
|
91
|
-
canvas: getQueryArg(window.location.href, 'canvas')
|
|
92
|
-
} : {};
|
|
93
89
|
return {
|
|
94
90
|
...command,
|
|
95
91
|
callback: ({
|
|
@@ -98,7 +94,7 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
|
|
98
94
|
const args = {
|
|
99
95
|
postType,
|
|
100
96
|
postId: record.id,
|
|
101
|
-
|
|
97
|
+
canvas: 'edit'
|
|
102
98
|
};
|
|
103
99
|
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
104
100
|
if (isSiteEditor) {
|
|
@@ -120,9 +116,6 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
120
116
|
search
|
|
121
117
|
}) {
|
|
122
118
|
const history = useHistory();
|
|
123
|
-
const location = useLocation();
|
|
124
|
-
const isPatternsPage = location?.params?.path === '/patterns' || location?.params?.postType === 'wp_block';
|
|
125
|
-
const didAccessPatternsPage = !!location?.params?.didAccessPatternsPage;
|
|
126
119
|
const isBlockBasedTheme = useIsBlockBasedTheme();
|
|
127
120
|
const {
|
|
128
121
|
records,
|
|
@@ -155,9 +148,6 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
155
148
|
const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
|
|
156
149
|
const result = [];
|
|
157
150
|
result.push(...orderedRecords.map(record => {
|
|
158
|
-
const extraArgs = isSiteEditor ? {
|
|
159
|
-
canvas: getQueryArg(window.location.href, 'canvas')
|
|
160
|
-
} : {};
|
|
161
151
|
return {
|
|
162
152
|
name: templateType + '-' + record.id,
|
|
163
153
|
searchLabel: record.title?.rendered + ' ' + record.id,
|
|
@@ -169,8 +159,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
169
159
|
const args = {
|
|
170
160
|
postType: templateType,
|
|
171
161
|
postId: record.id,
|
|
172
|
-
|
|
173
|
-
...extraArgs
|
|
162
|
+
canvas: 'edit'
|
|
174
163
|
};
|
|
175
164
|
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
176
165
|
if (isSiteEditor) {
|
|
@@ -191,8 +180,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
191
180
|
close
|
|
192
181
|
}) => {
|
|
193
182
|
const args = {
|
|
194
|
-
|
|
195
|
-
categoryType: 'wp_template_part',
|
|
183
|
+
postType: 'wp_template_part',
|
|
196
184
|
categoryId: 'all-parts'
|
|
197
185
|
};
|
|
198
186
|
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
@@ -234,7 +222,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
234
222
|
close
|
|
235
223
|
}) => {
|
|
236
224
|
const args = {
|
|
237
|
-
|
|
225
|
+
postType: 'wp_navigation'
|
|
238
226
|
};
|
|
239
227
|
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
240
228
|
if (isSiteEditor) {
|
|
@@ -272,7 +260,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
272
260
|
close
|
|
273
261
|
}) => {
|
|
274
262
|
const args = {
|
|
275
|
-
|
|
263
|
+
post_type: 'page'
|
|
276
264
|
};
|
|
277
265
|
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
278
266
|
if (isSiteEditor) {
|
|
@@ -291,7 +279,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
291
279
|
close
|
|
292
280
|
}) => {
|
|
293
281
|
const args = {
|
|
294
|
-
|
|
282
|
+
postType: 'wp_template'
|
|
295
283
|
};
|
|
296
284
|
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
297
285
|
if (isSiteEditor) {
|
|
@@ -312,7 +300,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
312
300
|
}) => {
|
|
313
301
|
if (canCreateTemplate) {
|
|
314
302
|
const args = {
|
|
315
|
-
|
|
303
|
+
postType: 'wp_block'
|
|
316
304
|
};
|
|
317
305
|
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
318
306
|
if (isSiteEditor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCommandLoader","__","useMemo","useEffect","useState","useSelect","store","coreStore","post","page","layout","symbol","symbolFilled","styles","navigation","privateApis","routerPrivateApis","getQueryArg","addQueryArgs","getPath","useDebounce","useIsBlockBasedTheme","unlock","orderEntityRecordsBySearch","useHistory","useLocation","icons","wp_template","wp_template_part","useDebouncedValue","value","debouncedValue","setDebouncedValue","debounced","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","delayedSearch","records","isLoading","select","query","per_page","orderby","status","getEntityRecords","hasFinishedResolution","commands","map","record","command","name","id","searchLabel","title","rendered","label","icon","callback","close","args","action","targetUrl","document","location","isSiteEditor","window","href","includes","extraArgs","canvas","postId","push","getNavigationCommandLoaderPerTemplate","templateType","isPatternsPage","params","path","didAccessPatternsPage","orderedRecords","slice","result","undefined","length","categoryType","categoryId","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","canCreateTemplate","canUser","useSiteEditorNavigationCommands","hook","context"],"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"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} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useIsBlockBasedTheme } from './hooks';\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory, useLocation } = 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 = useIsBlockBasedTheme();\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? 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\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\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcanvas: getQueryArg(\n\t\t\t\t\t\t\t\twindow.location.href,\n\t\t\t\t\t\t\t\t'canvas'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\n\t\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\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ 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 location = useLocation();\n\n\t\tconst isPatternsPage =\n\t\t\tlocation?.params?.path === '/patterns' ||\n\t\t\tlocation?.params?.postType === 'wp_block';\n\t\tconst didAccessPatternsPage =\n\t\t\t!! location?.params?.didAccessPatternsPage;\n\n\t\tconst isBlockBasedTheme = useIsBlockBasedTheme();\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! isBlockBasedTheme &&\n\t\t\t\t! 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\tconst extraArgs = isSiteEditor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcanvas: getQueryArg(\n\t\t\t\t\t\t\t\t\twindow.location.href,\n\t\t\t\t\t\t\t\t\t'canvas'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {};\n\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\tconst args = {\n\t\t\t\t\t\t\t\tpostType: templateType,\n\t\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t\tdidAccessPatternsPage:\n\t\t\t\t\t\t\t\t\t! isBlockBasedTheme &&\n\t\t\t\t\t\t\t\t\t( isPatternsPage || didAccessPatternsPage )\n\t\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = targetUrl;\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: __( 'Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpath: '/patterns',\n\t\t\t\t\t\t\tcategoryType: 'wp_template_part',\n\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst canCreateTemplate = useSelect( ( select ) => {\n\t\treturn select( coreStore ).canUser( 'create', 'templates' );\n\t}, [] );\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\tlabel: __( 'Navigation' ),\n\t\t\t\ticon: navigation,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/navigation',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\tlabel: __( 'Styles' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-pages',\n\t\t\t\tlabel: __( 'Pages' ),\n\t\t\t\ticon: page,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/page',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\tlabel: __( 'Templates' ),\n\t\t\t\ticon: layout,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/wp_template',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\tlabel: __( 'Patterns' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/patterns',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t} else {\n\t\t\t\t\t// If a user cannot access the site editor\n\t\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t\t}\n\t\t\t},\n\t\t} );\n\n\t\treturn result;\n\t}, [ history, isSiteEditor, canCreateTemplate, isBlockBasedTheme ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACjE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,IAAI,EACJC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,YAAY,EACZC,MAAM,EACNC,UAAU,QACJ,kBAAkB;AACzB,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,WAAW,EAAEC,YAAY,EAAEC,OAAO,QAAQ,gBAAgB;AACnE,SAASC,WAAW,QAAQ,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AAEZ,IAAK,CAAC;UACrB,CAAC,MAAM;YACNG,QAAQ,CAACC,QAAQ,GAAGF,SAAS;UAC9B;UACAH,KAAK,CAAC,CAAC;QACR,CAAC,MAAM;UACN;UACAI,QAAQ,CAACC,QAAQ,CAACG,IAAI,GAAG,6BAA6B;QACvD;MACD;IACD,CAAE,CAAC;IAEH,OAAOc,MAAM;EACd,CAAC,EAAE,CAAE9C,OAAO,EAAE8B,YAAY,EAAE0B,iBAAiB,EAAEvD,iBAAiB,CAAG,CAAC;EAEpE,OAAO;IACNW,QAAQ;IACRR,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,OAAO,SAASsD,+BAA+BA,CAAA,EAAG;EACjDjG,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,+BAA+B;IACrC2C,IAAI,EAAER;EACP,CAAE,CAAC;EACH1F,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,+BAA+B;IACrC2C,IAAI,EAAEP;EACP,CAAE,CAAC;EACH3F,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,mCAAmC;IACzC2C,IAAI,EAAEN;EACP,CAAE,CAAC;EACH5F,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,wCAAwC;IAC9C2C,IAAI,EAAEL;EACP,CAAE,CAAC;EACH7F,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,iCAAiC;IACvC2C,IAAI,EAAEJ,oCAAoC;IAC1CK,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useCommandLoader","__","useMemo","useEffect","useState","useSelect","store","coreStore","post","page","layout","symbol","symbolFilled","styles","navigation","privateApis","routerPrivateApis","addQueryArgs","getPath","useDebounce","useIsBlockBasedTheme","unlock","orderEntityRecordsBySearch","useHistory","icons","wp_template","wp_template_part","useDebouncedValue","value","debouncedValue","setDebouncedValue","debounced","cancel","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","isBlockBasedTheme","delayedSearch","records","isLoading","select","query","per_page","orderby","status","getEntityRecords","hasFinishedResolution","commands","map","record","command","name","id","searchLabel","title","rendered","label","icon","callback","close","args","action","targetUrl","document","location","isSiteEditor","window","href","includes","postId","canvas","push","getNavigationCommandLoaderPerTemplate","templateType","orderedRecords","slice","result","length","categoryId","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","canCreateTemplate","canUser","path","post_type","useSiteEditorNavigationCommands","hook","context"],"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"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} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useIsBlockBasedTheme } from './hooks';\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 = useIsBlockBasedTheme();\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? 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\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\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ 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 = useIsBlockBasedTheme();\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! isBlockBasedTheme &&\n\t\t\t\t! 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\tconst args = {\n\t\t\t\t\t\t\t\tpostType: templateType,\n\t\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = targetUrl;\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: __( 'Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\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}, [ isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerTemplate( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst canCreateTemplate = useSelect( ( select ) => {\n\t\treturn select( coreStore ).canUser( 'create', 'templates' );\n\t}, [] );\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\tlabel: __( 'Navigation' ),\n\t\t\t\ticon: navigation,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_navigation',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\tlabel: __( 'Styles' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-pages',\n\t\t\t\tlabel: __( 'Pages' ),\n\t\t\t\ticon: page,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpost_type: 'page',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tresult.push( {\n\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\tlabel: __( 'Templates' ),\n\t\t\t\ticon: layout,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\tlabel: __( 'Patterns' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tpostType: 'wp_block',\n\t\t\t\t\t};\n\t\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t}\n\t\t\t\t\tclose();\n\t\t\t\t} else {\n\t\t\t\t\t// If a user cannot access the site editor\n\t\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t\t}\n\t\t\t},\n\t\t} );\n\n\t\treturn result;\n\t}, [ history, isSiteEditor, canCreateTemplate, isBlockBasedTheme ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACjE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,IAAI,EACJC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,YAAY,EACZC,MAAM,EACNC,UAAU,QACJ,kBAAkB;AACzB,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,YAAY,EAAEC,OAAO,QAAQ,gBAAgB;AACtD,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,0BAA0B,QAAQ,wCAAwC;AAEnF,MAAM;EAAEC;AAAW,CAAC,GAAGF,MAAM,CAAEL,iBAAkB,CAAC;AAElD,MAAMQ,KAAK,GAAG;EACbhB,IAAI;EACJC,IAAI;EACJgB,WAAW,EAAEf,MAAM;EACnBgB,gBAAgB,EAAEd;AACnB,CAAC;AAED,SAASe,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAM,CAAEC,cAAc,EAAEC,iBAAiB,CAAE,GAAG1B,QAAQ,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B,QAAQ,EAAE;UACX,CAAC;UACD,MAAM8B,SAAS,GAAG/C,YAAY,CAAE,iBAAiB,EAAE6C,IAAK,CAAC;UACzD,IAAKK,YAAY,EAAG;YACnB9B,OAAO,CAACoC,IAAI,CAAEX,IAAK,CAAC;UACrB,CAAC,MAAM;YACNG,QAAQ,CAACC,QAAQ,GAAGF,SAAS;UAC9B;UACAH,KAAK,CAAC,CAAC;QACR,CAAC,MAAM;UACN;UACAI,QAAQ,CAACC,QAAQ,CAACG,IAAI,GAAG,6BAA6B;QACvD;MACD;IACD,CAAE,CAAC;IAEH,OAAOS,MAAM;EACd,CAAC,EAAE,CAAEzC,OAAO,EAAE8B,YAAY,EAAEmB,iBAAiB,EAAEhD,iBAAiB,CAAG,CAAC;EAEpE,OAAO;IACNW,QAAQ;IACRR,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,OAAO,SAASiD,+BAA+BA,CAAA,EAAG;EACjD1F,gBAAgB,CAAE;IACjBqD,IAAI,EAAE,+BAA+B;IACrCsC,IAAI,EAAEV;EACP,CAAE,CAAC;EACHjF,gBAAgB,CAAE;IACjBqD,IAAI,EAAE,+BAA+B;IACrCsC,IAAI,EAAET;EACP,CAAE,CAAC;EACHlF,gBAAgB,CAAE;IACjBqD,IAAI,EAAE,mCAAmC;IACzCsC,IAAI,EAAER;EACP,CAAE,CAAC;EACHnF,gBAAgB,CAAE;IACjBqD,IAAI,EAAE,wCAAwC;IAC9CsC,IAAI,EAAEP;EACP,CAAE,CAAC;EACHpF,gBAAgB,CAAE;IACjBqD,IAAI,EAAE,iCAAiC;IACvCsC,IAAI,EAAEN,oCAAoC;IAC1CO,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/core-commands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "WordPress core reusable commands.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=12"
|
|
22
|
+
"node": ">=18.12.0",
|
|
23
|
+
"npm": ">=8.19.2"
|
|
23
24
|
},
|
|
24
25
|
"main": "build/index.js",
|
|
25
26
|
"module": "build-module/index.js",
|
|
@@ -27,17 +28,17 @@
|
|
|
27
28
|
"sideEffects": false,
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/block-editor": "^
|
|
31
|
-
"@wordpress/commands": "^0.
|
|
32
|
-
"@wordpress/compose": "^
|
|
33
|
-
"@wordpress/core-data": "^
|
|
34
|
-
"@wordpress/data": "^
|
|
35
|
-
"@wordpress/element": "^
|
|
36
|
-
"@wordpress/i18n": "^
|
|
37
|
-
"@wordpress/icons": "^
|
|
38
|
-
"@wordpress/private-apis": "^0.
|
|
39
|
-
"@wordpress/router": "^0.
|
|
40
|
-
"@wordpress/url": "^
|
|
31
|
+
"@wordpress/block-editor": "^13.0.0",
|
|
32
|
+
"@wordpress/commands": "^1.0.0",
|
|
33
|
+
"@wordpress/compose": "^7.0.0",
|
|
34
|
+
"@wordpress/core-data": "^7.0.0",
|
|
35
|
+
"@wordpress/data": "^10.0.0",
|
|
36
|
+
"@wordpress/element": "^6.0.0",
|
|
37
|
+
"@wordpress/i18n": "^5.0.0",
|
|
38
|
+
"@wordpress/icons": "^10.0.0",
|
|
39
|
+
"@wordpress/private-apis": "^1.0.0",
|
|
40
|
+
"@wordpress/router": "^1.0.0",
|
|
41
|
+
"@wordpress/url": "^4.0.0"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"react": "^18.0.0",
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2f30cddff15723ac7017fd009fc5913b7b419400"
|
|
50
51
|
}
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
navigation,
|
|
17
17
|
} from '@wordpress/icons';
|
|
18
18
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
19
|
-
import {
|
|
19
|
+
import { addQueryArgs, getPath } from '@wordpress/url';
|
|
20
20
|
import { useDebounce } from '@wordpress/compose';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -26,7 +26,7 @@ import { useIsBlockBasedTheme } from './hooks';
|
|
|
26
26
|
import { unlock } from './lock-unlock';
|
|
27
27
|
import { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';
|
|
28
28
|
|
|
29
|
-
const { useHistory
|
|
29
|
+
const { useHistory } = unlock( routerPrivateApis );
|
|
30
30
|
|
|
31
31
|
const icons = {
|
|
32
32
|
post,
|
|
@@ -119,14 +119,6 @@ const getNavigationCommandLoaderPerPostType = ( postType ) =>
|
|
|
119
119
|
const isSiteEditor = getPath( window.location.href )?.includes(
|
|
120
120
|
'site-editor.php'
|
|
121
121
|
);
|
|
122
|
-
const extraArgs = isSiteEditor
|
|
123
|
-
? {
|
|
124
|
-
canvas: getQueryArg(
|
|
125
|
-
window.location.href,
|
|
126
|
-
'canvas'
|
|
127
|
-
),
|
|
128
|
-
}
|
|
129
|
-
: {};
|
|
130
122
|
|
|
131
123
|
return {
|
|
132
124
|
...command,
|
|
@@ -134,7 +126,7 @@ const getNavigationCommandLoaderPerPostType = ( postType ) =>
|
|
|
134
126
|
const args = {
|
|
135
127
|
postType,
|
|
136
128
|
postId: record.id,
|
|
137
|
-
|
|
129
|
+
canvas: 'edit',
|
|
138
130
|
};
|
|
139
131
|
const targetUrl = addQueryArgs(
|
|
140
132
|
'site-editor.php',
|
|
@@ -160,14 +152,6 @@ const getNavigationCommandLoaderPerPostType = ( postType ) =>
|
|
|
160
152
|
const getNavigationCommandLoaderPerTemplate = ( templateType ) =>
|
|
161
153
|
function useNavigationCommandLoader( { search } ) {
|
|
162
154
|
const history = useHistory();
|
|
163
|
-
const location = useLocation();
|
|
164
|
-
|
|
165
|
-
const isPatternsPage =
|
|
166
|
-
location?.params?.path === '/patterns' ||
|
|
167
|
-
location?.params?.postType === 'wp_block';
|
|
168
|
-
const didAccessPatternsPage =
|
|
169
|
-
!! location?.params?.didAccessPatternsPage;
|
|
170
|
-
|
|
171
155
|
const isBlockBasedTheme = useIsBlockBasedTheme();
|
|
172
156
|
const { records, isLoading } = useSelect( ( select ) => {
|
|
173
157
|
const { getEntityRecords } = select( coreStore );
|
|
@@ -203,15 +187,6 @@ const getNavigationCommandLoaderPerTemplate = ( templateType ) =>
|
|
|
203
187
|
const result = [];
|
|
204
188
|
result.push(
|
|
205
189
|
...orderedRecords.map( ( record ) => {
|
|
206
|
-
const extraArgs = isSiteEditor
|
|
207
|
-
? {
|
|
208
|
-
canvas: getQueryArg(
|
|
209
|
-
window.location.href,
|
|
210
|
-
'canvas'
|
|
211
|
-
),
|
|
212
|
-
}
|
|
213
|
-
: {};
|
|
214
|
-
|
|
215
190
|
return {
|
|
216
191
|
name: templateType + '-' + record.id,
|
|
217
192
|
searchLabel: record.title?.rendered + ' ' + record.id,
|
|
@@ -223,12 +198,7 @@ const getNavigationCommandLoaderPerTemplate = ( templateType ) =>
|
|
|
223
198
|
const args = {
|
|
224
199
|
postType: templateType,
|
|
225
200
|
postId: record.id,
|
|
226
|
-
|
|
227
|
-
! isBlockBasedTheme &&
|
|
228
|
-
( isPatternsPage || didAccessPatternsPage )
|
|
229
|
-
? 1
|
|
230
|
-
: undefined,
|
|
231
|
-
...extraArgs,
|
|
201
|
+
canvas: 'edit',
|
|
232
202
|
};
|
|
233
203
|
const targetUrl = addQueryArgs(
|
|
234
204
|
'site-editor.php',
|
|
@@ -255,8 +225,7 @@ const getNavigationCommandLoaderPerTemplate = ( templateType ) =>
|
|
|
255
225
|
icon: symbolFilled,
|
|
256
226
|
callback: ( { close } ) => {
|
|
257
227
|
const args = {
|
|
258
|
-
|
|
259
|
-
categoryType: 'wp_template_part',
|
|
228
|
+
postType: 'wp_template_part',
|
|
260
229
|
categoryId: 'all-parts',
|
|
261
230
|
};
|
|
262
231
|
const targetUrl = addQueryArgs(
|
|
@@ -309,7 +278,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
309
278
|
icon: navigation,
|
|
310
279
|
callback: ( { close } ) => {
|
|
311
280
|
const args = {
|
|
312
|
-
|
|
281
|
+
postType: 'wp_navigation',
|
|
313
282
|
};
|
|
314
283
|
const targetUrl = addQueryArgs( 'site-editor.php', args );
|
|
315
284
|
if ( isSiteEditor ) {
|
|
@@ -345,7 +314,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
345
314
|
icon: page,
|
|
346
315
|
callback: ( { close } ) => {
|
|
347
316
|
const args = {
|
|
348
|
-
|
|
317
|
+
post_type: 'page',
|
|
349
318
|
};
|
|
350
319
|
const targetUrl = addQueryArgs( 'site-editor.php', args );
|
|
351
320
|
if ( isSiteEditor ) {
|
|
@@ -363,7 +332,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
363
332
|
icon: layout,
|
|
364
333
|
callback: ( { close } ) => {
|
|
365
334
|
const args = {
|
|
366
|
-
|
|
335
|
+
postType: 'wp_template',
|
|
367
336
|
};
|
|
368
337
|
const targetUrl = addQueryArgs( 'site-editor.php', args );
|
|
369
338
|
if ( isSiteEditor ) {
|
|
@@ -383,7 +352,7 @@ function useSiteEditorBasicNavigationCommands() {
|
|
|
383
352
|
callback: ( { close } ) => {
|
|
384
353
|
if ( canCreateTemplate ) {
|
|
385
354
|
const args = {
|
|
386
|
-
|
|
355
|
+
postType: 'wp_block',
|
|
387
356
|
};
|
|
388
357
|
const targetUrl = addQueryArgs( 'site-editor.php', args );
|
|
389
358
|
if ( isSiteEditor ) {
|