@wordpress/core-commands 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/admin-navigation-commands.js +0 -40
- package/build/admin-navigation-commands.js.map +1 -1
- package/build/hooks.js +0 -4
- package/build/hooks.js.map +1 -1
- package/build/site-editor-navigation-commands.js +123 -73
- package/build/site-editor-navigation-commands.js.map +1 -1
- package/build-module/admin-navigation-commands.js +1 -41
- package/build-module/admin-navigation-commands.js.map +1 -1
- package/build-module/hooks.js +0 -3
- package/build-module/hooks.js.map +1 -1
- package/build-module/site-editor-navigation-commands.js +125 -75
- package/build-module/site-editor-navigation-commands.js.map +1 -1
- package/package.json +13 -13
- package/src/admin-navigation-commands.js +1 -42
- package/src/hooks.js +0 -7
- package/src/site-editor-navigation-commands.js +153 -92
|
@@ -6,7 +6,7 @@ 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
11
|
import { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';
|
|
12
12
|
import { useDebounce } from '@wordpress/compose';
|
|
@@ -14,7 +14,7 @@ import { useDebounce } from '@wordpress/compose';
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
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 {
|
|
@@ -152,8 +152,9 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
152
152
|
if (!isBlockBasedTheme && !templateType === 'wp_template_part') {
|
|
153
153
|
return [];
|
|
154
154
|
}
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
|
|
156
|
+
const result = [];
|
|
157
|
+
result.push(...orderedRecords.map(record => {
|
|
157
158
|
const extraArgs = isSiteEditor ? {
|
|
158
159
|
canvas: getQueryArg(window.location.href, 'canvas')
|
|
159
160
|
} : {};
|
|
@@ -180,7 +181,31 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
180
181
|
close();
|
|
181
182
|
}
|
|
182
183
|
};
|
|
183
|
-
});
|
|
184
|
+
}));
|
|
185
|
+
if (orderedRecords?.length > 0 && templateType === 'wp_template_part') {
|
|
186
|
+
result.push({
|
|
187
|
+
name: 'core/edit-site/open-template-parts',
|
|
188
|
+
label: __('Template parts'),
|
|
189
|
+
icon: symbolFilled,
|
|
190
|
+
callback: ({
|
|
191
|
+
close
|
|
192
|
+
}) => {
|
|
193
|
+
const args = {
|
|
194
|
+
path: '/patterns',
|
|
195
|
+
categoryType: 'wp_template_part',
|
|
196
|
+
categoryId: 'all-parts'
|
|
197
|
+
};
|
|
198
|
+
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
199
|
+
if (isSiteEditor) {
|
|
200
|
+
history.push(args);
|
|
201
|
+
} else {
|
|
202
|
+
document.location = targetUrl;
|
|
203
|
+
}
|
|
204
|
+
close();
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
184
209
|
}, [isBlockBasedTheme, orderedRecords, history]);
|
|
185
210
|
return {
|
|
186
211
|
commands,
|
|
@@ -194,91 +219,116 @@ const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerTemp
|
|
|
194
219
|
function useSiteEditorBasicNavigationCommands() {
|
|
195
220
|
const history = useHistory();
|
|
196
221
|
const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
|
|
197
|
-
const
|
|
222
|
+
const canCreateTemplate = useSelect(select => {
|
|
223
|
+
return select(coreStore).canUser('create', 'templates');
|
|
224
|
+
}, []);
|
|
198
225
|
const isBlockBasedTheme = useIsBlockBasedTheme();
|
|
199
226
|
const commands = useMemo(() => {
|
|
200
227
|
const result = [];
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
228
|
+
if (canCreateTemplate && isBlockBasedTheme) {
|
|
229
|
+
result.push({
|
|
230
|
+
name: 'core/edit-site/open-navigation',
|
|
231
|
+
label: __('Navigation'),
|
|
232
|
+
icon: navigation,
|
|
233
|
+
callback: ({
|
|
234
|
+
close
|
|
235
|
+
}) => {
|
|
236
|
+
const args = {
|
|
237
|
+
path: '/navigation'
|
|
238
|
+
};
|
|
239
|
+
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
240
|
+
if (isSiteEditor) {
|
|
241
|
+
history.push(args);
|
|
242
|
+
} else {
|
|
243
|
+
document.location = targetUrl;
|
|
244
|
+
}
|
|
245
|
+
close();
|
|
219
246
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
247
|
+
});
|
|
248
|
+
result.push({
|
|
249
|
+
name: 'core/edit-site/open-styles',
|
|
250
|
+
label: __('Styles'),
|
|
251
|
+
icon: styles,
|
|
252
|
+
callback: ({
|
|
253
|
+
close
|
|
254
|
+
}) => {
|
|
255
|
+
const args = {
|
|
256
|
+
path: '/wp_global_styles'
|
|
257
|
+
};
|
|
258
|
+
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
259
|
+
if (isSiteEditor) {
|
|
260
|
+
history.push(args);
|
|
261
|
+
} else {
|
|
262
|
+
document.location = targetUrl;
|
|
263
|
+
}
|
|
264
|
+
close();
|
|
238
265
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
266
|
+
});
|
|
267
|
+
result.push({
|
|
268
|
+
name: 'core/edit-site/open-pages',
|
|
269
|
+
label: __('Pages'),
|
|
270
|
+
icon: page,
|
|
271
|
+
callback: ({
|
|
272
|
+
close
|
|
273
|
+
}) => {
|
|
274
|
+
const args = {
|
|
275
|
+
path: '/page'
|
|
276
|
+
};
|
|
277
|
+
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
278
|
+
if (isSiteEditor) {
|
|
279
|
+
history.push(args);
|
|
280
|
+
} else {
|
|
281
|
+
document.location = targetUrl;
|
|
282
|
+
}
|
|
283
|
+
close();
|
|
257
284
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
285
|
+
});
|
|
286
|
+
result.push({
|
|
287
|
+
name: 'core/edit-site/open-templates',
|
|
288
|
+
label: __('Templates'),
|
|
289
|
+
icon: layout,
|
|
290
|
+
callback: ({
|
|
291
|
+
close
|
|
292
|
+
}) => {
|
|
293
|
+
const args = {
|
|
294
|
+
path: '/wp_template'
|
|
295
|
+
};
|
|
296
|
+
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
297
|
+
if (isSiteEditor) {
|
|
298
|
+
history.push(args);
|
|
299
|
+
} else {
|
|
300
|
+
document.location = targetUrl;
|
|
301
|
+
}
|
|
302
|
+
close();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
261
306
|
result.push({
|
|
262
|
-
name: 'core/edit-site/open-
|
|
263
|
-
label: __('
|
|
264
|
-
icon:
|
|
307
|
+
name: 'core/edit-site/open-patterns',
|
|
308
|
+
label: __('Patterns'),
|
|
309
|
+
icon: symbol,
|
|
265
310
|
callback: ({
|
|
266
311
|
close
|
|
267
312
|
}) => {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
313
|
+
if (canCreateTemplate) {
|
|
314
|
+
const args = {
|
|
315
|
+
path: '/patterns'
|
|
316
|
+
};
|
|
317
|
+
const targetUrl = addQueryArgs('site-editor.php', args);
|
|
318
|
+
if (isSiteEditor) {
|
|
319
|
+
history.push(args);
|
|
320
|
+
} else {
|
|
321
|
+
document.location = targetUrl;
|
|
322
|
+
}
|
|
323
|
+
close();
|
|
274
324
|
} else {
|
|
275
|
-
|
|
325
|
+
// If a user cannot access the site editor
|
|
326
|
+
document.location.href = 'edit.php?post_type=wp_block';
|
|
276
327
|
}
|
|
277
|
-
close();
|
|
278
328
|
}
|
|
279
329
|
});
|
|
280
330
|
return result;
|
|
281
|
-
}, [history, isSiteEditor,
|
|
331
|
+
}, [history, isSiteEditor, canCreateTemplate, isBlockBasedTheme]);
|
|
282
332
|
return {
|
|
283
333
|
commands,
|
|
284
334
|
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;A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,IAAI,CAAEZ,IAAK,CAAC;QACrB,CAAC,MAAM;UACNG,QAAQ,CAACC,QAAQ,GAAGF,SAAS;QAC9B;QACAH,KAAK,CAAC,CAAC;MACR;IACD,CAAE,CAAC;IAEH,OAAO6B,MAAM;EACd,CAAC,EAAE,CAAErD,OAAO,EAAE8B,YAAY,EAAEsB,qBAAqB,EAAEnD,iBAAiB,CAAG,CAAC;EAExE,OAAO;IACNW,QAAQ;IACRR,SAAS,EAAE;EACZ,CAAC;AACF;AAEA,OAAO,SAASkD,+BAA+BA,CAAA,EAAG;EACjD7F,gBAAgB,CAAE;IACjBuD,IAAI,EAAE,+BAA+B;IACrCuC,IAAI,EAAER;EACP,CAAE,CAAC;EACHtF,gBAAgB,CAAE;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","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,E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K,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": "0.27.0",
|
|
4
4
|
"description": "WordPress core reusable commands.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/block-editor": "^12.
|
|
31
|
-
"@wordpress/commands": "^0.
|
|
32
|
-
"@wordpress/compose": "^6.
|
|
33
|
-
"@wordpress/core-data": "^6.
|
|
34
|
-
"@wordpress/data": "^9.
|
|
35
|
-
"@wordpress/element": "^5.
|
|
36
|
-
"@wordpress/i18n": "^4.
|
|
37
|
-
"@wordpress/icons": "^9.
|
|
38
|
-
"@wordpress/private-apis": "^0.
|
|
39
|
-
"@wordpress/router": "^0.
|
|
40
|
-
"@wordpress/url": "^3.
|
|
30
|
+
"@wordpress/block-editor": "^12.26.0",
|
|
31
|
+
"@wordpress/commands": "^0.29.0",
|
|
32
|
+
"@wordpress/compose": "^6.35.0",
|
|
33
|
+
"@wordpress/core-data": "^6.35.0",
|
|
34
|
+
"@wordpress/data": "^9.28.0",
|
|
35
|
+
"@wordpress/element": "^5.35.0",
|
|
36
|
+
"@wordpress/i18n": "^4.58.0",
|
|
37
|
+
"@wordpress/icons": "^9.49.0",
|
|
38
|
+
"@wordpress/private-apis": "^0.40.0",
|
|
39
|
+
"@wordpress/router": "^0.27.0",
|
|
40
|
+
"@wordpress/url": "^3.59.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": "^18.0.0",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "42f38f287506a6b3ed8ccba839b18ad066821044"
|
|
50
50
|
}
|
|
@@ -3,26 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useCommand } from '@wordpress/commands';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { plus
|
|
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,
|