@wordpress/core-commands 0.26.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.
@@ -6,20 +6,19 @@ import { __ } from '@wordpress/i18n';
6
6
  import { useMemo, useEffect, useState } from '@wordpress/element';
7
7
  import { useSelect } from '@wordpress/data';
8
8
  import { store as coreStore } from '@wordpress/core-data';
9
- import { post, page, layout, symbolFilled, styles, navigation } from '@wordpress/icons';
9
+ import { post, page, layout, symbol, symbolFilled, styles, navigation } from '@wordpress/icons';
10
10
  import { privateApis as routerPrivateApis } from '@wordpress/router';
11
- import { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';
11
+ import { addQueryArgs, getPath } from '@wordpress/url';
12
12
  import { useDebounce } from '@wordpress/compose';
13
13
 
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';
17
+ 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
- ...extraArgs
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,
@@ -152,11 +145,9 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
152
145
  if (!isBlockBasedTheme && !templateType === 'wp_template_part') {
153
146
  return [];
154
147
  }
155
- return orderedRecords.map(record => {
156
- const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
157
- const extraArgs = isSiteEditor ? {
158
- canvas: getQueryArg(window.location.href, 'canvas')
159
- } : {};
148
+ const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
149
+ const result = [];
150
+ result.push(...orderedRecords.map(record => {
160
151
  return {
161
152
  name: templateType + '-' + record.id,
162
153
  searchLabel: record.title?.rendered + ' ' + record.id,
@@ -168,8 +159,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
168
159
  const args = {
169
160
  postType: templateType,
170
161
  postId: record.id,
171
- didAccessPatternsPage: !isBlockBasedTheme && (isPatternsPage || didAccessPatternsPage) ? 1 : undefined,
172
- ...extraArgs
162
+ canvas: 'edit'
173
163
  };
174
164
  const targetUrl = addQueryArgs('site-editor.php', args);
175
165
  if (isSiteEditor) {
@@ -180,7 +170,30 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
180
170
  close();
181
171
  }
182
172
  };
183
- });
173
+ }));
174
+ if (orderedRecords?.length > 0 && templateType === 'wp_template_part') {
175
+ result.push({
176
+ name: 'core/edit-site/open-template-parts',
177
+ label: __('Template parts'),
178
+ icon: symbolFilled,
179
+ callback: ({
180
+ close
181
+ }) => {
182
+ const args = {
183
+ postType: 'wp_template_part',
184
+ categoryId: 'all-parts'
185
+ };
186
+ const targetUrl = addQueryArgs('site-editor.php', args);
187
+ if (isSiteEditor) {
188
+ history.push(args);
189
+ } else {
190
+ document.location = targetUrl;
191
+ }
192
+ close();
193
+ }
194
+ });
195
+ }
196
+ return result;
184
197
  }, [isBlockBasedTheme, orderedRecords, history]);
185
198
  return {
186
199
  commands,
@@ -194,91 +207,116 @@ const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerTemp
194
207
  function useSiteEditorBasicNavigationCommands() {
195
208
  const history = useHistory();
196
209
  const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
197
- const isTemplatesAccessible = useIsTemplatesAccessible();
210
+ const canCreateTemplate = useSelect(select => {
211
+ return select(coreStore).canUser('create', 'templates');
212
+ }, []);
198
213
  const isBlockBasedTheme = useIsBlockBasedTheme();
199
214
  const commands = useMemo(() => {
200
215
  const result = [];
201
- if (!isTemplatesAccessible || !isBlockBasedTheme) {
202
- return result;
203
- }
204
- result.push({
205
- name: 'core/edit-site/open-navigation',
206
- label: __('Navigation'),
207
- icon: navigation,
208
- callback: ({
209
- close
210
- }) => {
211
- const args = {
212
- path: '/navigation'
213
- };
214
- const targetUrl = addQueryArgs('site-editor.php', args);
215
- if (isSiteEditor) {
216
- history.push(args);
217
- } else {
218
- document.location = targetUrl;
216
+ if (canCreateTemplate && isBlockBasedTheme) {
217
+ result.push({
218
+ name: 'core/edit-site/open-navigation',
219
+ label: __('Navigation'),
220
+ icon: navigation,
221
+ callback: ({
222
+ close
223
+ }) => {
224
+ const args = {
225
+ postType: 'wp_navigation'
226
+ };
227
+ const targetUrl = addQueryArgs('site-editor.php', args);
228
+ if (isSiteEditor) {
229
+ history.push(args);
230
+ } else {
231
+ document.location = targetUrl;
232
+ }
233
+ close();
219
234
  }
220
- close();
221
- }
222
- });
223
- result.push({
224
- name: 'core/edit-site/open-styles',
225
- label: __('Styles'),
226
- icon: styles,
227
- callback: ({
228
- close
229
- }) => {
230
- const args = {
231
- path: '/wp_global_styles'
232
- };
233
- const targetUrl = addQueryArgs('site-editor.php', args);
234
- if (isSiteEditor) {
235
- history.push(args);
236
- } else {
237
- document.location = targetUrl;
235
+ });
236
+ result.push({
237
+ name: 'core/edit-site/open-styles',
238
+ label: __('Styles'),
239
+ icon: styles,
240
+ callback: ({
241
+ close
242
+ }) => {
243
+ const args = {
244
+ path: '/wp_global_styles'
245
+ };
246
+ const targetUrl = addQueryArgs('site-editor.php', args);
247
+ if (isSiteEditor) {
248
+ history.push(args);
249
+ } else {
250
+ document.location = targetUrl;
251
+ }
252
+ close();
238
253
  }
239
- close();
240
- }
241
- });
242
- result.push({
243
- name: 'core/edit-site/open-pages',
244
- label: __('Pages'),
245
- icon: page,
246
- callback: ({
247
- close
248
- }) => {
249
- const args = {
250
- path: '/page'
251
- };
252
- const targetUrl = addQueryArgs('site-editor.php', args);
253
- if (isSiteEditor) {
254
- history.push(args);
255
- } else {
256
- document.location = targetUrl;
254
+ });
255
+ result.push({
256
+ name: 'core/edit-site/open-pages',
257
+ label: __('Pages'),
258
+ icon: page,
259
+ callback: ({
260
+ close
261
+ }) => {
262
+ const args = {
263
+ post_type: 'page'
264
+ };
265
+ const targetUrl = addQueryArgs('site-editor.php', args);
266
+ if (isSiteEditor) {
267
+ history.push(args);
268
+ } else {
269
+ document.location = targetUrl;
270
+ }
271
+ close();
257
272
  }
258
- close();
259
- }
260
- });
273
+ });
274
+ result.push({
275
+ name: 'core/edit-site/open-templates',
276
+ label: __('Templates'),
277
+ icon: layout,
278
+ callback: ({
279
+ close
280
+ }) => {
281
+ const args = {
282
+ postType: 'wp_template'
283
+ };
284
+ const targetUrl = addQueryArgs('site-editor.php', args);
285
+ if (isSiteEditor) {
286
+ history.push(args);
287
+ } else {
288
+ document.location = targetUrl;
289
+ }
290
+ close();
291
+ }
292
+ });
293
+ }
261
294
  result.push({
262
- name: 'core/edit-site/open-templates',
263
- label: __('Templates'),
264
- icon: layout,
295
+ name: 'core/edit-site/open-patterns',
296
+ label: __('Patterns'),
297
+ icon: symbol,
265
298
  callback: ({
266
299
  close
267
300
  }) => {
268
- const args = {
269
- path: '/wp_template'
270
- };
271
- const targetUrl = addQueryArgs('site-editor.php', args);
272
- if (isSiteEditor) {
273
- history.push(args);
301
+ if (canCreateTemplate) {
302
+ const args = {
303
+ postType: 'wp_block'
304
+ };
305
+ const targetUrl = addQueryArgs('site-editor.php', args);
306
+ if (isSiteEditor) {
307
+ history.push(args);
308
+ } else {
309
+ document.location = targetUrl;
310
+ }
311
+ close();
274
312
  } else {
275
- document.location = targetUrl;
313
+ // If a user cannot access the site editor
314
+ document.location.href = 'edit.php?post_type=wp_block';
276
315
  }
277
- close();
278
316
  }
279
317
  });
280
318
  return result;
281
- }, [history, isSiteEditor, isTemplatesAccessible, isBlockBasedTheme]);
319
+ }, [history, isSiteEditor, canCreateTemplate, isBlockBasedTheme]);
282
320
  return {
283
321
  commands,
284
322
  isLoading: false
@@ -1 +1 @@
1
- {"version":3,"names":["useCommandLoader","__","useMemo","useEffect","useState","useSelect","store","coreStore","post","page","layout","symbolFilled","styles","navigation","privateApis","routerPrivateApis","getQueryArg","addQueryArgs","getPath","useDebounce","useIsTemplatesAccessible","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","undefined","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","isTemplatesAccessible","result","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\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 { useIsTemplatesAccessible, 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\treturn orderedRecords.map( ( record ) => {\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? { canvas: getQueryArg( window.location.href, 'canvas' ) }\n\t\t\t\t\t: {};\n\n\t\t\t\treturn {\n\t\t\t\t\tname: templateType + '-' + 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[ templateType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType: templateType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\tdidAccessPatternsPage:\n\t\t\t\t\t\t\t\t! isBlockBasedTheme &&\n\t\t\t\t\t\t\t\t( isPatternsPage || didAccessPatternsPage )\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: undefined,\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}, [ 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 isTemplatesAccessible = useIsTemplatesAccessible();\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( ! isTemplatesAccessible || ! isBlockBasedTheme ) {\n\t\t\treturn result;\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\tlabel: __( 'Navigation' ),\n\t\t\ticon: navigation,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/navigation',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-styles',\n\t\t\tlabel: __( 'Styles' ),\n\t\t\ticon: styles,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-pages',\n\t\t\tlabel: __( 'Pages' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/page',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-templates',\n\t\t\tlabel: __( 'Templates' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_template',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\treturn result;\n\t}, [ history, isSiteEditor, isTemplatesAccessible, 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,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,oBAAoB;;AAEhD;AACA;AACA;AACA,SAASC,wBAAwB,EAAEC,oBAAoB,QAAQ,SAAS;AACxE,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,0BAA0B,QAAQ,wCAAwC;AAEnF,MAAM;EAAEC,UAAU;EAAEC;AAAY,CAAC,GAAGH,MAAM,CAAEP,iBAAkB,CAAC;AAE/D,MAAMW,KAAK,GAAG;EACblB,IAAI;EACJC,IAAI;EACJkB,WAAW,EAAEjB,MAAM;EACnBkB,gBAAgB,EAAEjB;AACnB,CAAC;AAED,SAASkB,iBAAiBA,CAAEC,KAAK,E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E;IACjBuD,IAAI,EAAE,+BAA+B;IACrCuC,IAAI,EAAEP;EACP,CAAE,CAAC;EACHvF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,mCAAmC;IACzCuC,IAAI,EAAEN;EACP,CAAE,CAAC;EACHxF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,wCAAwC;IAC9CuC,IAAI,EAAEL;EACP,CAAE,CAAC;EACHzF,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,iCAAiC;IACvCuC,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,i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AO,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.26.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": "^12.25.0",
31
- "@wordpress/commands": "^0.28.0",
32
- "@wordpress/compose": "^6.34.0",
33
- "@wordpress/core-data": "^6.34.0",
34
- "@wordpress/data": "^9.27.0",
35
- "@wordpress/element": "^5.34.0",
36
- "@wordpress/i18n": "^4.57.0",
37
- "@wordpress/icons": "^9.48.0",
38
- "@wordpress/private-apis": "^0.39.0",
39
- "@wordpress/router": "^0.26.0",
40
- "@wordpress/url": "^3.58.0"
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": "581d8a5580dba8f600b7268d51eb554771ae482c"
50
+ "gitHead": "2f30cddff15723ac7017fd009fc5913b7b419400"
50
51
  }
@@ -3,26 +3,9 @@
3
3
  */
4
4
  import { useCommand } from '@wordpress/commands';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { plus, symbol } from '@wordpress/icons';
7
- import { addQueryArgs, getPath } from '@wordpress/url';
8
- import { privateApis as routerPrivateApis } from '@wordpress/router';
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import { useIsTemplatesAccessible } from './hooks';
14
- import { unlock } from './lock-unlock';
15
-
16
- const { useHistory } = unlock( routerPrivateApis );
6
+ import { plus } from '@wordpress/icons';
17
7
 
18
8
  export function useAdminNavigationCommands() {
19
- const history = useHistory();
20
- const isTemplatesAccessible = useIsTemplatesAccessible();
21
-
22
- const isSiteEditor = getPath( window.location.href )?.includes(
23
- 'site-editor.php'
24
- );
25
-
26
9
  useCommand( {
27
10
  name: 'core/add-new-post',
28
11
  label: __( 'Add new post' ),
@@ -39,28 +22,4 @@ export function useAdminNavigationCommands() {
39
22
  document.location.href = 'post-new.php?post_type=page';
40
23
  },
41
24
  } );
42
- useCommand( {
43
- name: 'core/manage-reusable-blocks',
44
- label: __( 'Patterns' ),
45
- icon: symbol,
46
- callback: ( { close } ) => {
47
- // The site editor and templates both check whether the user
48
- // can read templates. We can leverage that here and this
49
- // command links to the classic dashboard manage patterns page
50
- // if the user can't access it.
51
- if ( isTemplatesAccessible ) {
52
- const args = {
53
- path: '/patterns',
54
- };
55
- if ( isSiteEditor ) {
56
- history.push( args );
57
- } else {
58
- document.location = addQueryArgs( 'site-editor.php', args );
59
- }
60
- close();
61
- } else {
62
- document.location.href = 'edit.php?post_type=wp_block';
63
- }
64
- },
65
- } );
66
25
  }
package/src/hooks.js CHANGED
@@ -4,13 +4,6 @@
4
4
  import { store as coreStore } from '@wordpress/core-data';
5
5
  import { useSelect } from '@wordpress/data';
6
6
 
7
- export function useIsTemplatesAccessible() {
8
- return useSelect(
9
- ( select ) => select( coreStore ).canUser( 'read', 'templates' ),
10
- []
11
- );
12
- }
13
-
14
7
  export function useIsBlockBasedTheme() {
15
8
  return useSelect(
16
9
  ( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,