@wordpress/core-commands 1.33.1 → 1.33.3
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/build/index.js +2 -2
- package/build/index.js.map +2 -2
- package/build/site-editor-navigation-commands.js +13 -19
- package/build/site-editor-navigation-commands.js.map +2 -2
- package/build-module/index.js +2 -2
- package/build-module/index.js.map +2 -2
- package/build-module/site-editor-navigation-commands.js +13 -19
- package/build-module/site-editor-navigation-commands.js.map +2 -2
- package/package.json +4 -4
- package/src/index.js +3 -2
- package/src/site-editor-navigation-commands.js +7 -17
package/build/index.js
CHANGED
|
@@ -31,9 +31,9 @@ var import_lock_unlock = require("./lock-unlock");
|
|
|
31
31
|
var import_private_apis = require("./private-apis");
|
|
32
32
|
const { RouterProvider } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
33
33
|
function CommandPalette({ settings }) {
|
|
34
|
-
const { menu_commands: menuCommands } = settings;
|
|
34
|
+
const { menu_commands: menuCommands, is_network_admin: isNetworkAdmin } = settings;
|
|
35
35
|
(0, import_admin_navigation_commands.useAdminNavigationCommands)(menuCommands);
|
|
36
|
-
(0, import_site_editor_navigation_commands.useSiteEditorNavigationCommands)();
|
|
36
|
+
(0, import_site_editor_navigation_commands.useSiteEditorNavigationCommands)(isNetworkAdmin);
|
|
37
37
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouterProvider, { pathArg: "p", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_commands.CommandMenu, {}) });
|
|
38
38
|
}
|
|
39
39
|
function initializeCommandPalette(settings) {
|
package/build/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { unlock } from './lock-unlock';\nexport { privateApis } from './private-apis';\n\nconst { RouterProvider } = unlock( routerPrivateApis );\n\n// Register core commands and render the Command Palette.\nfunction CommandPalette( { settings } ) {\n\tconst { menu_commands: menuCommands }
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { unlock } from './lock-unlock';\nexport { privateApis } from './private-apis';\n\nconst { RouterProvider } = unlock( routerPrivateApis );\n\n// Register core commands and render the Command Palette.\nfunction CommandPalette( { settings } ) {\n\tconst { menu_commands: menuCommands, is_network_admin: isNetworkAdmin } =\n\t\tsettings;\n\tuseAdminNavigationCommands( menuCommands );\n\tuseSiteEditorNavigationCommands( isNetworkAdmin );\n\treturn (\n\t\t<RouterProvider pathArg=\"p\">\n\t\t\t<CommandMenu />\n\t\t</RouterProvider>\n\t);\n}\n\n/**\n * Initializes the Command Palette.\n *\n * @param {Object} settings Command palette settings.\n */\nexport function initializeCommandPalette( settings ) {\n\tconst root = document.createElement( 'div' );\n\tdocument.body.appendChild( root );\n\tcreateRoot( root ).render(\n\t\t<StrictMode>\n\t\t\t<CommandPalette settings={ settings } />\n\t\t</StrictMode>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBG;AAtBH,qBAAuC;AACvC,oBAAiD;AACjD,sBAA4B;AAK5B,uCAA2C;AAC3C,6CAAgD;AAChD,yBAAuB;AACvB,0BAA4B;AAE5B,MAAM,EAAE,eAAe,QAAI,2BAAQ,cAAAA,WAAkB;AAGrD,SAAS,eAAgB,EAAE,SAAS,GAAI;AACvC,QAAM,EAAE,eAAe,cAAc,kBAAkB,eAAe,IACrE;AACD,mEAA4B,YAAa;AACzC,8EAAiC,cAAe;AAChD,SACC,4CAAC,kBAAe,SAAQ,KACvB,sDAAC,+BAAY,GACd;AAEF;AAOO,SAAS,yBAA0B,UAAW;AACpD,QAAM,OAAO,SAAS,cAAe,KAAM;AAC3C,WAAS,KAAK,YAAa,IAAK;AAChC,iCAAY,IAAK,EAAE;AAAA,IAClB,4CAAC,6BACA,sDAAC,kBAAe,UAAsB,GACvC;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["routerPrivateApis"]
|
|
7
7
|
}
|
|
@@ -97,9 +97,6 @@ const getNavigationCommandLoaderPerPostType = (postType) => function useNavigati
|
|
|
97
97
|
[delayedSearch]
|
|
98
98
|
);
|
|
99
99
|
const commands = (0, import_element.useMemo)(() => {
|
|
100
|
-
if (window.location.pathname.startsWith("/wp-admin/network/")) {
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
100
|
return (records ?? []).map((record) => {
|
|
104
101
|
const command = {
|
|
105
102
|
name: postType + "-" + record.id,
|
|
@@ -179,9 +176,6 @@ const getNavigationCommandLoaderPerTemplate = (templateType) => function useNavi
|
|
|
179
176
|
return (0, import_order_entity_records_by_search.orderEntityRecordsBySearch)(records, search).slice(0, 10);
|
|
180
177
|
}, [records, search]);
|
|
181
178
|
const commands = (0, import_element.useMemo)(() => {
|
|
182
|
-
if (window.location.pathname.startsWith("/wp-admin/network/")) {
|
|
183
|
-
return [];
|
|
184
|
-
}
|
|
185
179
|
if (!canCreateTemplate || !isBlockBasedTheme && !templateType === "wp_template_part") {
|
|
186
180
|
return [];
|
|
187
181
|
}
|
|
@@ -265,9 +259,6 @@ const getSiteEditorBasicNavigationCommands = () => function useSiteEditorBasicNa
|
|
|
265
259
|
};
|
|
266
260
|
}, []);
|
|
267
261
|
const commands = (0, import_element.useMemo)(() => {
|
|
268
|
-
if (window.location.pathname.startsWith("/wp-admin/network/")) {
|
|
269
|
-
return [];
|
|
270
|
-
}
|
|
271
262
|
const result = [];
|
|
272
263
|
if (canCreateTemplate && isBlockBasedTheme) {
|
|
273
264
|
result.push({
|
|
@@ -376,9 +367,6 @@ const getGlobalStylesOpenCssCommands = () => function useGlobalStylesOpenCssComm
|
|
|
376
367
|
};
|
|
377
368
|
}, []);
|
|
378
369
|
const commands = (0, import_element.useMemo)(() => {
|
|
379
|
-
if (window.location.pathname.includes("/wp-admin/network/")) {
|
|
380
|
-
return [];
|
|
381
|
-
}
|
|
382
370
|
if (!canEditCSS) {
|
|
383
371
|
return [];
|
|
384
372
|
}
|
|
@@ -409,31 +397,37 @@ const getGlobalStylesOpenCssCommands = () => function useGlobalStylesOpenCssComm
|
|
|
409
397
|
commands
|
|
410
398
|
};
|
|
411
399
|
};
|
|
412
|
-
function useSiteEditorNavigationCommands() {
|
|
400
|
+
function useSiteEditorNavigationCommands(isNetworkAdmin) {
|
|
413
401
|
(0, import_commands.useCommandLoader)({
|
|
414
402
|
name: "core/edit-site/navigate-pages",
|
|
415
|
-
hook: getNavigationCommandLoaderPerPostType("page")
|
|
403
|
+
hook: getNavigationCommandLoaderPerPostType("page"),
|
|
404
|
+
disabled: isNetworkAdmin
|
|
416
405
|
});
|
|
417
406
|
(0, import_commands.useCommandLoader)({
|
|
418
407
|
name: "core/edit-site/navigate-posts",
|
|
419
|
-
hook: getNavigationCommandLoaderPerPostType("post")
|
|
408
|
+
hook: getNavigationCommandLoaderPerPostType("post"),
|
|
409
|
+
disabled: isNetworkAdmin
|
|
420
410
|
});
|
|
421
411
|
(0, import_commands.useCommandLoader)({
|
|
422
412
|
name: "core/edit-site/navigate-templates",
|
|
423
|
-
hook: getNavigationCommandLoaderPerTemplate("wp_template")
|
|
413
|
+
hook: getNavigationCommandLoaderPerTemplate("wp_template"),
|
|
414
|
+
disabled: isNetworkAdmin
|
|
424
415
|
});
|
|
425
416
|
(0, import_commands.useCommandLoader)({
|
|
426
417
|
name: "core/edit-site/navigate-template-parts",
|
|
427
|
-
hook: getNavigationCommandLoaderPerTemplate("wp_template_part")
|
|
418
|
+
hook: getNavigationCommandLoaderPerTemplate("wp_template_part"),
|
|
419
|
+
disabled: isNetworkAdmin
|
|
428
420
|
});
|
|
429
421
|
(0, import_commands.useCommandLoader)({
|
|
430
422
|
name: "core/edit-site/basic-navigation",
|
|
431
423
|
hook: getSiteEditorBasicNavigationCommands(),
|
|
432
|
-
context: "site-editor"
|
|
424
|
+
context: "site-editor",
|
|
425
|
+
disabled: isNetworkAdmin
|
|
433
426
|
});
|
|
434
427
|
(0, import_commands.useCommandLoader)({
|
|
435
428
|
name: "core/edit-site/global-styles-css",
|
|
436
|
-
hook: getGlobalStylesOpenCssCommands()
|
|
429
|
+
hook: getGlobalStylesOpenCssCommands(),
|
|
430
|
+
disabled: isNetworkAdmin
|
|
437
431
|
});
|
|
438
432
|
}
|
|
439
433
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/site-editor-navigation-commands.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.includes( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAiC;AACjC,kBAAmB;AACnB,qBAA6C;AAC7C,kBAA0B;AAC1B,uBAAmC;AACnC,mBASO;AACP,oBAAiD;AACjD,iBAAsC;AACtC,qBAA4B;AAC5B,2BAA+B;AAK/B,yBAAuB;AACvB,4CAA2C;AAE3C,MAAM,EAAE,WAA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AAU,EAAE;AAAA,UAChC;AAAA,UACA,CAAE,YAAY,UAAU,KAAM;AAAA,QAC/B;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,aAAc;AAAA,EACjB;AAEA,QAAM,eAAW,wBAAS,MAAM;AAC/B,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands( isNetworkAdmin ) {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAiC;AACjC,kBAAmB;AACnB,qBAA6C;AAC7C,kBAA0B;AAC1B,uBAAmC;AACnC,mBASO;AACP,oBAAiD;AACjD,iBAAsC;AACtC,qBAA4B;AAC5B,2BAA+B;AAK/B,yBAAuB;AACvB,4CAA2C;AAE3C,MAAM,EAAE,WAAW,QAAI,2BAAQ,cAAAA,WAAkB;AAEjD,MAAM,QAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,kBAAkB;AACnB;AAEA,SAAS,kBAAmB,OAAQ;AACnC,QAAM,CAAE,gBAAgB,iBAAkB,QAAI,yBAAU,EAAG;AAC3D,QAAM,gBAAY,4BAAa,mBAAmB,GAAI;AAEtD,gCAAW,MAAM;AAChB,cAAW,KAAM;AACjB,WAAO,MAAM,UAAU,OAAO;AAAA,EAC/B,GAAG,CAAE,WAAW,KAAM,CAAE;AAExB,SAAO;AACR;AAEA,MAAM,wCAAwC,CAAE,aAC/C,SAAS,2BAA4B,EAAE,OAAO,GAAI;AACjD,QAAM,UAAU,WAAW;AAC3B,QAAM,EAAE,mBAAmB,kBAAkB,QAAI;AAAA,IAChD,CAAE,WAAY;AACb,aAAO;AAAA,QACN,mBACC,OAAQ,iBAAAC,KAAU,EAAE,gBAAgB,GAAG;AAAA,QACxC,mBAAmB,OAAQ,iBAAAA,KAAU,EAAE,QAAS,UAAU;AAAA,UACzD,MAAM;AAAA,UACN,MAAM;AAAA,QACP,CAAE;AAAA,MACH;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AACA,QAAM,gBAAgB,kBAAmB,MAAO;AAChD,QAAM,EAAE,SA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IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,aAAc;AAAA,IAC3D,UAAU;AAAA,EACX,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,sCAAuC,kBAAmB;AAAA,IAChE,UAAU;AAAA,EACX,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,qCAAqC;AAAA,IAC3C,SAAS;AAAA,IACT,UAAU;AAAA,EACX,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,+BAA+B;AAAA,IACrC,UAAU;AAAA,EACX,CAAE;AACH;",
|
|
6
6
|
"names": ["routerPrivateApis", "coreStore"]
|
|
7
7
|
}
|
package/build-module/index.js
CHANGED
|
@@ -8,9 +8,9 @@ import { unlock } from "./lock-unlock";
|
|
|
8
8
|
import { privateApis } from "./private-apis";
|
|
9
9
|
const { RouterProvider } = unlock(routerPrivateApis);
|
|
10
10
|
function CommandPalette({ settings }) {
|
|
11
|
-
const { menu_commands: menuCommands } = settings;
|
|
11
|
+
const { menu_commands: menuCommands, is_network_admin: isNetworkAdmin } = settings;
|
|
12
12
|
useAdminNavigationCommands(menuCommands);
|
|
13
|
-
useSiteEditorNavigationCommands();
|
|
13
|
+
useSiteEditorNavigationCommands(isNetworkAdmin);
|
|
14
14
|
return /* @__PURE__ */ jsx(RouterProvider, { pathArg: "p", children: /* @__PURE__ */ jsx(CommandMenu, {}) });
|
|
15
15
|
}
|
|
16
16
|
function initializeCommandPalette(settings) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { unlock } from './lock-unlock';\nexport { privateApis } from './private-apis';\n\nconst { RouterProvider } = unlock( routerPrivateApis );\n\n// Register core commands and render the Command Palette.\nfunction CommandPalette( { settings } ) {\n\tconst { menu_commands: menuCommands }
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { unlock } from './lock-unlock';\nexport { privateApis } from './private-apis';\n\nconst { RouterProvider } = unlock( routerPrivateApis );\n\n// Register core commands and render the Command Palette.\nfunction CommandPalette( { settings } ) {\n\tconst { menu_commands: menuCommands, is_network_admin: isNetworkAdmin } =\n\t\tsettings;\n\tuseAdminNavigationCommands( menuCommands );\n\tuseSiteEditorNavigationCommands( isNetworkAdmin );\n\treturn (\n\t\t<RouterProvider pathArg=\"p\">\n\t\t\t<CommandMenu />\n\t\t</RouterProvider>\n\t);\n}\n\n/**\n * Initializes the Command Palette.\n *\n * @param {Object} settings Command palette settings.\n */\nexport function initializeCommandPalette( settings ) {\n\tconst root = document.createElement( 'div' );\n\tdocument.body.appendChild( root );\n\tcreateRoot( root ).render(\n\t\t<StrictMode>\n\t\t\t<CommandPalette settings={ settings } />\n\t\t</StrictMode>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAyBG;AAtBH,SAAS,YAAY,kBAAkB;AACvC,SAAS,eAAe,yBAAyB;AACjD,SAAS,mBAAmB;AAK5B,SAAS,kCAAkC;AAC3C,SAAS,uCAAuC;AAChD,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAE5B,MAAM,EAAE,eAAe,IAAI,OAAQ,iBAAkB;AAGrD,SAAS,eAAgB,EAAE,SAAS,GAAI;AACvC,QAAM,EAAE,eAAe,cAAc,kBAAkB,eAAe,IACrE;AACD,6BAA4B,YAAa;AACzC,kCAAiC,cAAe;AAChD,SACC,oBAAC,kBAAe,SAAQ,KACvB,8BAAC,eAAY,GACd;AAEF;AAOO,SAAS,yBAA0B,UAAW;AACpD,QAAM,OAAO,SAAS,cAAe,KAAM;AAC3C,WAAS,KAAK,YAAa,IAAK;AAChC,aAAY,IAAK,EAAE;AAAA,IAClB,oBAAC,cACA,8BAAC,kBAAe,UAAsB,GACvC;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -84,9 +84,6 @@ const getNavigationCommandLoaderPerPostType = (postType) => function useNavigati
|
|
|
84
84
|
[delayedSearch]
|
|
85
85
|
);
|
|
86
86
|
const commands = useMemo(() => {
|
|
87
|
-
if (window.location.pathname.startsWith("/wp-admin/network/")) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
87
|
return (records ?? []).map((record) => {
|
|
91
88
|
const command = {
|
|
92
89
|
name: postType + "-" + record.id,
|
|
@@ -166,9 +163,6 @@ const getNavigationCommandLoaderPerTemplate = (templateType) => function useNavi
|
|
|
166
163
|
return orderEntityRecordsBySearch(records, search).slice(0, 10);
|
|
167
164
|
}, [records, search]);
|
|
168
165
|
const commands = useMemo(() => {
|
|
169
|
-
if (window.location.pathname.startsWith("/wp-admin/network/")) {
|
|
170
|
-
return [];
|
|
171
|
-
}
|
|
172
166
|
if (!canCreateTemplate || !isBlockBasedTheme && !templateType === "wp_template_part") {
|
|
173
167
|
return [];
|
|
174
168
|
}
|
|
@@ -252,9 +246,6 @@ const getSiteEditorBasicNavigationCommands = () => function useSiteEditorBasicNa
|
|
|
252
246
|
};
|
|
253
247
|
}, []);
|
|
254
248
|
const commands = useMemo(() => {
|
|
255
|
-
if (window.location.pathname.startsWith("/wp-admin/network/")) {
|
|
256
|
-
return [];
|
|
257
|
-
}
|
|
258
249
|
const result = [];
|
|
259
250
|
if (canCreateTemplate && isBlockBasedTheme) {
|
|
260
251
|
result.push({
|
|
@@ -363,9 +354,6 @@ const getGlobalStylesOpenCssCommands = () => function useGlobalStylesOpenCssComm
|
|
|
363
354
|
};
|
|
364
355
|
}, []);
|
|
365
356
|
const commands = useMemo(() => {
|
|
366
|
-
if (window.location.pathname.includes("/wp-admin/network/")) {
|
|
367
|
-
return [];
|
|
368
|
-
}
|
|
369
357
|
if (!canEditCSS) {
|
|
370
358
|
return [];
|
|
371
359
|
}
|
|
@@ -396,31 +384,37 @@ const getGlobalStylesOpenCssCommands = () => function useGlobalStylesOpenCssComm
|
|
|
396
384
|
commands
|
|
397
385
|
};
|
|
398
386
|
};
|
|
399
|
-
function useSiteEditorNavigationCommands() {
|
|
387
|
+
function useSiteEditorNavigationCommands(isNetworkAdmin) {
|
|
400
388
|
useCommandLoader({
|
|
401
389
|
name: "core/edit-site/navigate-pages",
|
|
402
|
-
hook: getNavigationCommandLoaderPerPostType("page")
|
|
390
|
+
hook: getNavigationCommandLoaderPerPostType("page"),
|
|
391
|
+
disabled: isNetworkAdmin
|
|
403
392
|
});
|
|
404
393
|
useCommandLoader({
|
|
405
394
|
name: "core/edit-site/navigate-posts",
|
|
406
|
-
hook: getNavigationCommandLoaderPerPostType("post")
|
|
395
|
+
hook: getNavigationCommandLoaderPerPostType("post"),
|
|
396
|
+
disabled: isNetworkAdmin
|
|
407
397
|
});
|
|
408
398
|
useCommandLoader({
|
|
409
399
|
name: "core/edit-site/navigate-templates",
|
|
410
|
-
hook: getNavigationCommandLoaderPerTemplate("wp_template")
|
|
400
|
+
hook: getNavigationCommandLoaderPerTemplate("wp_template"),
|
|
401
|
+
disabled: isNetworkAdmin
|
|
411
402
|
});
|
|
412
403
|
useCommandLoader({
|
|
413
404
|
name: "core/edit-site/navigate-template-parts",
|
|
414
|
-
hook: getNavigationCommandLoaderPerTemplate("wp_template_part")
|
|
405
|
+
hook: getNavigationCommandLoaderPerTemplate("wp_template_part"),
|
|
406
|
+
disabled: isNetworkAdmin
|
|
415
407
|
});
|
|
416
408
|
useCommandLoader({
|
|
417
409
|
name: "core/edit-site/basic-navigation",
|
|
418
410
|
hook: getSiteEditorBasicNavigationCommands(),
|
|
419
|
-
context: "site-editor"
|
|
411
|
+
context: "site-editor",
|
|
412
|
+
disabled: isNetworkAdmin
|
|
420
413
|
});
|
|
421
414
|
useCommandLoader({
|
|
422
415
|
name: "core/edit-site/global-styles-css",
|
|
423
|
-
hook: getGlobalStylesOpenCssCommands()
|
|
416
|
+
hook: getGlobalStylesOpenCssCommands(),
|
|
417
|
+
disabled: isNetworkAdmin
|
|
424
418
|
});
|
|
425
419
|
}
|
|
426
420
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/site-editor-navigation-commands.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( window.location.pathname.includes( '/wp-admin/network/' ) ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t} );\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,wBAAwB;AACjC,SAAS,UAAU;AACnB,SAAS,SAAS,WAAW,gBAAgB;AAC7C,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,eAAe,yBAAyB;AACjD,SAAS,cAAc,eAAe;AACtC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAK/B,SAAS,cAAc;AACvB,SAAS,kCAAkC;AAE3C,MAAM,EAAE,WAAW,IAAI,OAAQ,iBAAkB;AAEjD,MAAM,QAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,kBAAkB;AACnB;AAEA,SAAS,kBAAmB,OAAQ;AACnC,QAAM,CAAE,gBAAgB,iBAAkB,IAAI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oader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tbrush,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nfunction useDebouncedValue( value ) {\n\tconst [ debouncedValue, setDebouncedValue ] = useState( '' );\n\tconst debounced = useDebounce( setDebouncedValue, 250 );\n\n\tuseEffect( () => {\n\t\tdebounced( value );\n\t\treturn () => debounced.cancel();\n\t}, [ debounced, value ] );\n\n\treturn debouncedValue;\n}\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst delayedSearch = useDebouncedValue( search );\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! delayedSearch ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst query = {\n\t\t\t\t\tsearch: delayedSearch,\n\t\t\t\t\tper_page: 10,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\tstatus: [\n\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t'future',\n\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t'private',\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\trecords: select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tquery\n\t\t\t\t\t),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ delayedSearch ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).map( ( record ) => {\n\t\t\t\tconst command = {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? decodeEntities( record.title?.rendered )\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t};\n\n\t\t\t\tif (\n\t\t\t\t\t! canCreateTemplate ||\n\t\t\t\t\tpostType === 'post' ||\n\t\t\t\t\t( postType === 'page' && ! isBlockBasedTheme )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...command,\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\t\tpost: record.id,\n\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst targetUrl = addQueryArgs( 'post.php', args );\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...command,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/${ postType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: `/${ postType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ canCreateTemplate, records, isBlockBasedTheme, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getNavigationCommandLoaderPerTemplate = ( templateType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst { isBlockBasedTheme, canCreateTemplate } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: templateType,\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = { per_page: -1 };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', templateType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', templateType, query ]\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif (\n\t\t\t\t! canCreateTemplate ||\n\t\t\t\t( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t'site-editor.php'\n\t\t\t);\n\t\t\tconst result = [];\n\t\t\tresult.push(\n\t\t\t\t...orderedRecords.map( ( record ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: templateType + '-' + record.id,\n\t\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\t\ticon: icons[ templateType ],\n\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t`/${ templateType }/${ record.id }?canvas=edit`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: `/${ templateType }/${ record.id }`,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\torderedRecords?.length > 0 &&\n\t\t\t\ttemplateType === 'wp_template_part'\n\t\t\t) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\t\t\tlabel: __( 'Go to: Template parts' ),\n\t\t\t\t\ticon: symbolFilled,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t'/pattern?postType=wp_template_part&categoryId=all-parts'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\t\t\tcategoryId: 'all-parts',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn result;\n\t\t}, [ canCreateTemplate, isBlockBasedTheme, orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst getSiteEditorBasicNavigationCommands = () =>\n\tfunction useSiteEditorBasicNavigationCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } =\n\t\t\tuseSelect( ( select ) => {\n\t\t\t\treturn {\n\t\t\t\t\tisBlockBasedTheme:\n\t\t\t\t\t\tselect( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t\t\t\tcanCreateTemplate: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t\t} ),\n\t\t\t\t\tcanCreatePatterns: select( coreStore ).canUser( 'create', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t} ),\n\t\t\t\t};\n\t\t\t}, [] );\n\t\tconst commands = useMemo( () => {\n\t\t\tconst result = [];\n\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\n\t\t\t\t// Go to Styles command\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-styles',\n\t\t\t\t\tlabel: __( 'Go to: Styles' ),\n\t\t\t\t\ticon: styles,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\t\t\tlabel: __( 'Go to: Navigation' ),\n\t\t\t\t\ticon: navigation,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/navigation' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/navigation',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-templates',\n\t\t\t\t\tlabel: __( 'Go to: Templates' ),\n\t\t\t\t\ticon: layout,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/template' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/template',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( canCreatePatterns ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\t\t\tlabel: __( 'Go to: Patterns' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tif ( canCreateTemplate ) {\n\t\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\t\thistory.navigate( '/pattern' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If a user cannot access the site editor.\n\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t'edit.php?post_type=wp_block';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}, [\n\t\t\thistory,\n\t\t\tisSiteEditor,\n\t\t\tcanCreateTemplate,\n\t\t\tcanCreatePatterns,\n\t\t\tisBlockBasedTheme,\n\t\t] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nconst getGlobalStylesOpenCssCommands = () =>\n\tfunction useGlobalStylesOpenCssCommands() {\n\t\tconst history = useHistory();\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t\t};\n\t\t}, [] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( ! canEditCSS ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/open-styles-css',\n\t\t\t\t\tlabel: __( 'Open custom CSS' ),\n\t\t\t\t\ticon: brush,\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tclose();\n\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.navigate( '/styles?section=/css' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = addQueryArgs(\n\t\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tp: '/styles',\n\t\t\t\t\t\t\t\t\tsection: '/css',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ history, canEditCSS, isSiteEditor ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useSiteEditorNavigationCommands( isNetworkAdmin ) {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: getNavigationCommandLoaderPerPostType( 'page' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: getNavigationCommandLoaderPerPostType( 'post' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: getSiteEditorBasicNavigationCommands(),\n\t\tcontext: 'site-editor',\n\t\tdisabled: isNetworkAdmin,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/global-styles-css',\n\t\thook: getGlobalStylesOpenCssCommands(),\n\t\tdisabled: isNetworkAdmin,\n\t} );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,wBAAwB;AACjC,SAAS,UAAU;AACnB,SAA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AA,IAC3C,SAAS;AAAA,IACT,UAAU;AAAA,EACX,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,+BAA+B;AAAA,IACrC,UAAU;AAAA,EACX,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/core-commands",
|
|
3
|
-
"version": "1.33.
|
|
3
|
+
"version": "1.33.3",
|
|
4
4
|
"description": "WordPress core reusable commands.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"wpScript": true,
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@wordpress/block-editor": "^15.6.
|
|
38
|
+
"@wordpress/block-editor": "^15.6.3",
|
|
39
39
|
"@wordpress/commands": "^1.33.1",
|
|
40
40
|
"@wordpress/compose": "^7.33.1",
|
|
41
|
-
"@wordpress/core-data": "^7.33.
|
|
41
|
+
"@wordpress/core-data": "^7.33.3",
|
|
42
42
|
"@wordpress/data": "^10.33.1",
|
|
43
43
|
"@wordpress/element": "^6.33.1",
|
|
44
44
|
"@wordpress/html-entities": "^4.33.1",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "b54bd3285e50e409580bdfa2c47bc81f0000a0c9"
|
|
60
60
|
}
|
package/src/index.js
CHANGED
|
@@ -17,9 +17,10 @@ const { RouterProvider } = unlock( routerPrivateApis );
|
|
|
17
17
|
|
|
18
18
|
// Register core commands and render the Command Palette.
|
|
19
19
|
function CommandPalette( { settings } ) {
|
|
20
|
-
const { menu_commands: menuCommands } =
|
|
20
|
+
const { menu_commands: menuCommands, is_network_admin: isNetworkAdmin } =
|
|
21
|
+
settings;
|
|
21
22
|
useAdminNavigationCommands( menuCommands );
|
|
22
|
-
useSiteEditorNavigationCommands();
|
|
23
|
+
useSiteEditorNavigationCommands( isNetworkAdmin );
|
|
23
24
|
return (
|
|
24
25
|
<RouterProvider pathArg="p">
|
|
25
26
|
<CommandMenu />
|
|
@@ -101,10 +101,6 @@ const getNavigationCommandLoaderPerPostType = ( postType ) =>
|
|
|
101
101
|
);
|
|
102
102
|
|
|
103
103
|
const commands = useMemo( () => {
|
|
104
|
-
if ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
104
|
return ( records ?? [] ).map( ( record ) => {
|
|
109
105
|
const command = {
|
|
110
106
|
name: postType + '-' + record.id,
|
|
@@ -204,10 +200,6 @@ const getNavigationCommandLoaderPerTemplate = ( templateType ) =>
|
|
|
204
200
|
}, [ records, search ] );
|
|
205
201
|
|
|
206
202
|
const commands = useMemo( () => {
|
|
207
|
-
if ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {
|
|
208
|
-
return [];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
203
|
if (
|
|
212
204
|
! canCreateTemplate ||
|
|
213
205
|
( ! isBlockBasedTheme && ! templateType === 'wp_template_part' )
|
|
@@ -305,10 +297,6 @@ const getSiteEditorBasicNavigationCommands = () =>
|
|
|
305
297
|
};
|
|
306
298
|
}, [] );
|
|
307
299
|
const commands = useMemo( () => {
|
|
308
|
-
if ( window.location.pathname.startsWith( '/wp-admin/network/' ) ) {
|
|
309
|
-
return [];
|
|
310
|
-
}
|
|
311
|
-
|
|
312
300
|
const result = [];
|
|
313
301
|
|
|
314
302
|
if ( canCreateTemplate && isBlockBasedTheme ) {
|
|
@@ -434,10 +422,6 @@ const getGlobalStylesOpenCssCommands = () =>
|
|
|
434
422
|
}, [] );
|
|
435
423
|
|
|
436
424
|
const commands = useMemo( () => {
|
|
437
|
-
if ( window.location.pathname.includes( '/wp-admin/network/' ) ) {
|
|
438
|
-
return [];
|
|
439
|
-
}
|
|
440
|
-
|
|
441
425
|
if ( ! canEditCSS ) {
|
|
442
426
|
return [];
|
|
443
427
|
}
|
|
@@ -472,30 +456,36 @@ const getGlobalStylesOpenCssCommands = () =>
|
|
|
472
456
|
};
|
|
473
457
|
};
|
|
474
458
|
|
|
475
|
-
export function useSiteEditorNavigationCommands() {
|
|
459
|
+
export function useSiteEditorNavigationCommands( isNetworkAdmin ) {
|
|
476
460
|
useCommandLoader( {
|
|
477
461
|
name: 'core/edit-site/navigate-pages',
|
|
478
462
|
hook: getNavigationCommandLoaderPerPostType( 'page' ),
|
|
463
|
+
disabled: isNetworkAdmin,
|
|
479
464
|
} );
|
|
480
465
|
useCommandLoader( {
|
|
481
466
|
name: 'core/edit-site/navigate-posts',
|
|
482
467
|
hook: getNavigationCommandLoaderPerPostType( 'post' ),
|
|
468
|
+
disabled: isNetworkAdmin,
|
|
483
469
|
} );
|
|
484
470
|
useCommandLoader( {
|
|
485
471
|
name: 'core/edit-site/navigate-templates',
|
|
486
472
|
hook: getNavigationCommandLoaderPerTemplate( 'wp_template' ),
|
|
473
|
+
disabled: isNetworkAdmin,
|
|
487
474
|
} );
|
|
488
475
|
useCommandLoader( {
|
|
489
476
|
name: 'core/edit-site/navigate-template-parts',
|
|
490
477
|
hook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ),
|
|
478
|
+
disabled: isNetworkAdmin,
|
|
491
479
|
} );
|
|
492
480
|
useCommandLoader( {
|
|
493
481
|
name: 'core/edit-site/basic-navigation',
|
|
494
482
|
hook: getSiteEditorBasicNavigationCommands(),
|
|
495
483
|
context: 'site-editor',
|
|
484
|
+
disabled: isNetworkAdmin,
|
|
496
485
|
} );
|
|
497
486
|
useCommandLoader( {
|
|
498
487
|
name: 'core/edit-site/global-styles-css',
|
|
499
488
|
hook: getGlobalStylesOpenCssCommands(),
|
|
489
|
+
disabled: isNetworkAdmin,
|
|
500
490
|
} );
|
|
501
491
|
}
|