@wordpress/core-commands 1.29.0 → 1.29.1-next.f34ab90e9.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/build/admin-navigation-commands.js +44 -2
- package/build/admin-navigation-commands.js.map +1 -1
- package/build/index.js +0 -3
- package/build/index.js.map +1 -1
- package/build-module/admin-navigation-commands.js +44 -2
- package/build-module/admin-navigation-commands.js.map +1 -1
- package/build-module/index.js +0 -3
- package/build-module/index.js.map +1 -1
- package/package.json +15 -15
- package/src/admin-navigation-commands.js +56 -0
- package/src/index.js +0 -3
|
@@ -64,7 +64,8 @@ const getAddNewPageCommand = () => function useAddNewPageCommand() {
|
|
|
64
64
|
name: 'core/add-new-page',
|
|
65
65
|
label: (0, _i18n.__)('Add Page'),
|
|
66
66
|
icon: _icons.plus,
|
|
67
|
-
callback: addNewPage
|
|
67
|
+
callback: addNewPage,
|
|
68
|
+
keywords: [(0, _i18n.__)('page'), (0, _i18n.__)('new'), (0, _i18n.__)('add'), (0, _i18n.__)('create')]
|
|
68
69
|
}];
|
|
69
70
|
}, [createPageEntity, isSiteEditor, isBlockBasedTheme]);
|
|
70
71
|
return {
|
|
@@ -72,6 +73,42 @@ const getAddNewPageCommand = () => function useAddNewPageCommand() {
|
|
|
72
73
|
commands
|
|
73
74
|
};
|
|
74
75
|
};
|
|
76
|
+
const getAdminBasicNavigationCommands = () => function useAdminBasicNavigationCommands() {
|
|
77
|
+
const {
|
|
78
|
+
isBlockBasedTheme,
|
|
79
|
+
canCreateTemplate
|
|
80
|
+
} = (0, _data.useSelect)(select => {
|
|
81
|
+
return {
|
|
82
|
+
isBlockBasedTheme: select(_coreData.store).getCurrentTheme()?.is_block_theme,
|
|
83
|
+
canCreateTemplate: select(_coreData.store).canUser('create', {
|
|
84
|
+
kind: 'postType',
|
|
85
|
+
name: 'wp_template'
|
|
86
|
+
})
|
|
87
|
+
};
|
|
88
|
+
}, []);
|
|
89
|
+
const commands = (0, _element.useMemo)(() => {
|
|
90
|
+
if (canCreateTemplate && isBlockBasedTheme) {
|
|
91
|
+
const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
|
|
92
|
+
if (!isSiteEditor) {
|
|
93
|
+
return [{
|
|
94
|
+
name: 'core/go-to-site-editor',
|
|
95
|
+
label: (0, _i18n.__)('Open Site Editor'),
|
|
96
|
+
callback: ({
|
|
97
|
+
close
|
|
98
|
+
}) => {
|
|
99
|
+
close();
|
|
100
|
+
document.location = 'site-editor.php';
|
|
101
|
+
}
|
|
102
|
+
}];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return [];
|
|
106
|
+
}, [canCreateTemplate, isBlockBasedTheme]);
|
|
107
|
+
return {
|
|
108
|
+
commands,
|
|
109
|
+
isLoading: false
|
|
110
|
+
};
|
|
111
|
+
};
|
|
75
112
|
function useAdminNavigationCommands() {
|
|
76
113
|
(0, _commands.useCommand)({
|
|
77
114
|
name: 'core/add-new-post',
|
|
@@ -79,11 +116,16 @@ function useAdminNavigationCommands() {
|
|
|
79
116
|
icon: _icons.plus,
|
|
80
117
|
callback: () => {
|
|
81
118
|
document.location.assign('post-new.php');
|
|
82
|
-
}
|
|
119
|
+
},
|
|
120
|
+
keywords: [(0, _i18n.__)('post'), (0, _i18n.__)('new'), (0, _i18n.__)('add'), (0, _i18n.__)('create')]
|
|
83
121
|
});
|
|
84
122
|
(0, _commands.useCommandLoader)({
|
|
85
123
|
name: 'core/add-new-page',
|
|
86
124
|
hook: getAddNewPageCommand()
|
|
87
125
|
});
|
|
126
|
+
(0, _commands.useCommandLoader)({
|
|
127
|
+
name: 'core/admin-navigation',
|
|
128
|
+
hook: getAdminBasicNavigationCommands()
|
|
129
|
+
});
|
|
88
130
|
}
|
|
89
131
|
//# sourceMappingURL=admin-navigation-commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_commands","require","_i18n","_icons","_url","_coreData","_data","_element","_notices","_router","_lockUnlock","useHistory","unlock","routerPrivateApis","getAddNewPageCommand","useAddNewPageCommand","isSiteEditor","getPath","window","location","href","includes","history","isBlockBasedTheme","useSelect","select","coreStore","getCurrentTheme","is_block_theme","saveEntityRecord","useDispatch","createErrorNotice","noticesStore","createPageEntity","useCallback","close","page","status","throwOnError","id","navigate","error","errorMessage","message","code","__","type","commands","useMemo","addNewPage","document","name","label","icon","plus","callback","isLoading","useAdminNavigationCommands","useCommand","assign","useCommandLoader","hook"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand, useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { getPath } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst getAddNewPageCommand = () =>\n\tfunction useAddNewPageCommand() {\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst history = useHistory();\n\t\tconst isBlockBasedTheme = useSelect( ( select ) => {\n\t\t\treturn select( coreStore ).getCurrentTheme()?.is_block_theme;\n\t\t}, [] );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\t\tconst createPageEntity = useCallback(\n\t\t\tasync ( { close } ) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await saveEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif ( page?.id ) {\n\t\t\t\t\t\thistory.navigate( `/page/${ page.id }?canvas=edit` );\n\t\t\t\t\t}\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while creating the item.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t} );\n\t\t\t\t} finally {\n\t\t\t\t\tclose();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ createErrorNotice, history, saveEntityRecord ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\tconst addNewPage =\n\t\t\t\tisSiteEditor && isBlockBasedTheme\n\t\t\t\t\t? createPageEntity\n\t\t\t\t\t: () =>\n\t\t\t\t\t\t\t( document.location.href =\n\t\t\t\t\t\t\t\t'post-new.php?post_type=page' );\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/add-new-page',\n\t\t\t\t\tlabel: __( 'Add Page' ),\n\t\t\t\t\ticon: plus,\n\t\t\t\t\tcallback: addNewPage,\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ createPageEntity, isSiteEditor, isBlockBasedTheme ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add Post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.assign( 'post-new.php' );\n\t\t},\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/add-new-page',\n\t\thook: getAddNewPageCommand(),\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,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AAO,CAACkB,QAAQ,CAAE,SAAUJ,IAAI,CAACG,EAAE,cAAgB,CAAC;MACrD;IACD,CAAC,CAAC,OAAQE,KAAK,EAAG;MACjB,MAAMC,YAAY,GACjBD,KAAK,CAACE,OAAO,IAAIF,KAAK,CAACG,IAAI,KAAK,eAAe,GAC5CH,KAAK,CAACE,OAAO,GACb,IAAAE,QAAE,EACF,4CACA,CAAC;MAELd,iBAAiB,CAAEW,YAAY,EAAE;QAChCI,IAAI,EAAE;MACP,CAAE,CAAC;IACJ,CAAC,SAAS;MACTX,KAAK,CAAC,CAAC;IACR;EACD,CAAC,EACD,CAAEJ,iBAAiB,EAAET,OAAO,EAAEO,gBAAgB,CAC/C,CAAC;EAED,MAAMkB,QAAQ,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC/B,MAAMC,UAAU,GACfjC,YAAY,IAAIO,iBAAiB,GAC9BU,gBAAgB,GAChB,MACEiB,QAAQ,CAAC/B,QAAQ,CAACC,IAAI,GACvB,6BAA+B;IACpC,OAAO,CACN;MACC+B,IAAI,EAAE,mBAAmB;MACzBC,KAAK,EAAE,IAAAP,QAAE,EAAE,UAAW,CAAC;MACvBQ,IAAI,EAAEC,WAAI;MACVC,QAAQ,EAAEN;
|
|
1
|
+
{"version":3,"names":["_commands","require","_i18n","_icons","_url","_coreData","_data","_element","_notices","_router","_lockUnlock","useHistory","unlock","routerPrivateApis","getAddNewPageCommand","useAddNewPageCommand","isSiteEditor","getPath","window","location","href","includes","history","isBlockBasedTheme","useSelect","select","coreStore","getCurrentTheme","is_block_theme","saveEntityRecord","useDispatch","createErrorNotice","noticesStore","createPageEntity","useCallback","close","page","status","throwOnError","id","navigate","error","errorMessage","message","code","__","type","commands","useMemo","addNewPage","document","name","label","icon","plus","callback","keywords","isLoading","getAdminBasicNavigationCommands","useAdminBasicNavigationCommands","canCreateTemplate","canUser","kind","useAdminNavigationCommands","useCommand","assign","useCommandLoader","hook"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand, useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { getPath } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst getAddNewPageCommand = () =>\n\tfunction useAddNewPageCommand() {\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst history = useHistory();\n\t\tconst isBlockBasedTheme = useSelect( ( select ) => {\n\t\t\treturn select( coreStore ).getCurrentTheme()?.is_block_theme;\n\t\t}, [] );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\t\tconst createPageEntity = useCallback(\n\t\t\tasync ( { close } ) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await saveEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif ( page?.id ) {\n\t\t\t\t\t\thistory.navigate( `/page/${ page.id }?canvas=edit` );\n\t\t\t\t\t}\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while creating the item.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t} );\n\t\t\t\t} finally {\n\t\t\t\t\tclose();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ createErrorNotice, history, saveEntityRecord ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\tconst addNewPage =\n\t\t\t\tisSiteEditor && isBlockBasedTheme\n\t\t\t\t\t? createPageEntity\n\t\t\t\t\t: () =>\n\t\t\t\t\t\t\t( document.location.href =\n\t\t\t\t\t\t\t\t'post-new.php?post_type=page' );\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/add-new-page',\n\t\t\t\t\tlabel: __( 'Add Page' ),\n\t\t\t\t\ticon: plus,\n\t\t\t\t\tcallback: addNewPage,\n\t\t\t\t\tkeywords: [\n\t\t\t\t\t\t__( 'page' ),\n\t\t\t\t\t\t__( 'new' ),\n\t\t\t\t\t\t__( 'add' ),\n\t\t\t\t\t\t__( 'create' ),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ createPageEntity, isSiteEditor, isBlockBasedTheme ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nconst getAdminBasicNavigationCommands = () =>\n\tfunction useAdminBasicNavigationCommands() {\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\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\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\tif ( ! isSiteEditor ) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'core/go-to-site-editor',\n\t\t\t\t\t\t\tlabel: __( 'Open Site Editor' ),\n\t\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t\tdocument.location = 'site-editor.php';\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\n\t\t\treturn [];\n\t\t}, [ canCreateTemplate, isBlockBasedTheme ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add Post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.assign( 'post-new.php' );\n\t\t},\n\t\tkeywords: [ __( 'post' ), __( 'new' ), __( 'add' ), __( 'create' ) ],\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/add-new-page',\n\t\thook: getAddNewPageCommand(),\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/admin-navigation',\n\t\thook: getAdminBasicNavigationCommands(),\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAKA,IAAAS,WAAA,GAAAT,OAAA;AAhBA;AACA;AACA;;AAWA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EAAE,uBAAuB;IAC7BgB,IAAI,EAAET,+BAA+B,CAAC;EACvC,CAAE,CAAC;AACJ","ignoreList":[]}
|
package/build/index.js
CHANGED
|
@@ -44,9 +44,6 @@ function CommandPalette() {
|
|
|
44
44
|
* Initializes the Command Palette.
|
|
45
45
|
*/
|
|
46
46
|
function initializeCommandPalette() {
|
|
47
|
-
if (!globalThis.IS_GUTENBERG_PLUGIN) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
47
|
const root = document.createElement('div');
|
|
51
48
|
document.body.appendChild(root);
|
|
52
49
|
(0, _element.createRoot)(root).render(/*#__PURE__*/(0, _jsxRuntime.jsx)(_element.StrictMode, {
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_router","_commands","_adminNavigationCommands","_siteEditorNavigationCommands","_lockUnlock","_jsxRuntime","_privateApis","RouterProvider","unlock","routerPrivateApis","CommandPalette","useAdminNavigationCommands","useSiteEditorNavigationCommands","jsx","pathArg","children","CommandMenu","initializeCommandPalette","
|
|
1
|
+
{"version":3,"names":["_element","require","_router","_commands","_adminNavigationCommands","_siteEditorNavigationCommands","_lockUnlock","_jsxRuntime","_privateApis","RouterProvider","unlock","routerPrivateApis","CommandPalette","useAdminNavigationCommands","useSiteEditorNavigationCommands","jsx","pathArg","children","CommandMenu","initializeCommandPalette","root","document","createElement","body","appendChild","createRoot","render","StrictMode"],"sources":["@wordpress/core-commands/src/index.js"],"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() {\n\tuseAdminNavigationCommands();\n\tuseSiteEditorNavigationCommands();\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 */\nexport function initializeCommandPalette() {\n\tconst root = document.createElement( 'div' );\n\tdocument.body.appendChild( root );\n\tcreateRoot( root ).render(\n\t\t<StrictMode>\n\t\t\t<CommandPalette />\n\t\t</StrictMode>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,wBAAA,GAAAH,OAAA;AACA,IAAAI,6BAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAAuC,IAAAM,WAAA,GAAAN,OAAA;AACvC,IAAAO,YAAA,GAAAP,OAAA;AAbA;AACA;AACA;;AAKA;AACA;AACA;;AAMA,MAAM;EAAEQ;AAAe,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;;AAEtD;AACA,SAASC,cAAcA,CAAA,EAAG;EACzB,IAAAC,mDAA0B,EAAC,CAAC;EAC5B,IAAAC,6DAA+B,EAAC,CAAC;EACjC,oBACC,IAAAP,WAAA,CAAAQ,GAAA,EAACN,cAAc;IAACO,OAAO,EAAC,GAAG;IAAAC,QAAA,eAC1B,IAAAV,WAAA,CAAAQ,GAAA,EAACZ,SAAA,CAAAe,WAAW,IAAE;EAAC,CACA,CAAC;AAEnB;;AAEA;AACA;AACA;AACO,SAASC,wBAAwBA,CAAA,EAAG;EAC1C,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAE,KAAM,CAAC;EAC5CD,QAAQ,CAACE,IAAI,CAACC,WAAW,CAAEJ,IAAK,CAAC;EACjC,IAAAK,mBAAU,EAAEL,IAAK,CAAC,CAACM,MAAM,cACxB,IAAAnB,WAAA,CAAAQ,GAAA,EAACf,QAAA,CAAA2B,UAAU;IAAAV,QAAA,eACV,IAAAV,WAAA,CAAAQ,GAAA,EAACH,cAAc,IAAE;EAAC,CACP,CACb,CAAC;AACF","ignoreList":[]}
|
|
@@ -57,7 +57,8 @@ const getAddNewPageCommand = () => function useAddNewPageCommand() {
|
|
|
57
57
|
name: 'core/add-new-page',
|
|
58
58
|
label: __('Add Page'),
|
|
59
59
|
icon: plus,
|
|
60
|
-
callback: addNewPage
|
|
60
|
+
callback: addNewPage,
|
|
61
|
+
keywords: [__('page'), __('new'), __('add'), __('create')]
|
|
61
62
|
}];
|
|
62
63
|
}, [createPageEntity, isSiteEditor, isBlockBasedTheme]);
|
|
63
64
|
return {
|
|
@@ -65,6 +66,42 @@ const getAddNewPageCommand = () => function useAddNewPageCommand() {
|
|
|
65
66
|
commands
|
|
66
67
|
};
|
|
67
68
|
};
|
|
69
|
+
const getAdminBasicNavigationCommands = () => function useAdminBasicNavigationCommands() {
|
|
70
|
+
const {
|
|
71
|
+
isBlockBasedTheme,
|
|
72
|
+
canCreateTemplate
|
|
73
|
+
} = useSelect(select => {
|
|
74
|
+
return {
|
|
75
|
+
isBlockBasedTheme: select(coreStore).getCurrentTheme()?.is_block_theme,
|
|
76
|
+
canCreateTemplate: select(coreStore).canUser('create', {
|
|
77
|
+
kind: 'postType',
|
|
78
|
+
name: 'wp_template'
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
const commands = useMemo(() => {
|
|
83
|
+
if (canCreateTemplate && isBlockBasedTheme) {
|
|
84
|
+
const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
|
|
85
|
+
if (!isSiteEditor) {
|
|
86
|
+
return [{
|
|
87
|
+
name: 'core/go-to-site-editor',
|
|
88
|
+
label: __('Open Site Editor'),
|
|
89
|
+
callback: ({
|
|
90
|
+
close
|
|
91
|
+
}) => {
|
|
92
|
+
close();
|
|
93
|
+
document.location = 'site-editor.php';
|
|
94
|
+
}
|
|
95
|
+
}];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [];
|
|
99
|
+
}, [canCreateTemplate, isBlockBasedTheme]);
|
|
100
|
+
return {
|
|
101
|
+
commands,
|
|
102
|
+
isLoading: false
|
|
103
|
+
};
|
|
104
|
+
};
|
|
68
105
|
export function useAdminNavigationCommands() {
|
|
69
106
|
useCommand({
|
|
70
107
|
name: 'core/add-new-post',
|
|
@@ -72,11 +109,16 @@ export function useAdminNavigationCommands() {
|
|
|
72
109
|
icon: plus,
|
|
73
110
|
callback: () => {
|
|
74
111
|
document.location.assign('post-new.php');
|
|
75
|
-
}
|
|
112
|
+
},
|
|
113
|
+
keywords: [__('post'), __('new'), __('add'), __('create')]
|
|
76
114
|
});
|
|
77
115
|
useCommandLoader({
|
|
78
116
|
name: 'core/add-new-page',
|
|
79
117
|
hook: getAddNewPageCommand()
|
|
80
118
|
});
|
|
119
|
+
useCommandLoader({
|
|
120
|
+
name: 'core/admin-navigation',
|
|
121
|
+
hook: getAdminBasicNavigationCommands()
|
|
122
|
+
});
|
|
81
123
|
}
|
|
82
124
|
//# sourceMappingURL=admin-navigation-commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCommand","useCommandLoader","__","plus","getPath","store","coreStore","useSelect","useDispatch","useCallback","useMemo","noticesStore","privateApis","routerPrivateApis","unlock","useHistory","getAddNewPageCommand","useAddNewPageCommand","isSiteEditor","window","location","href","includes","history","isBlockBasedTheme","select","getCurrentTheme","is_block_theme","saveEntityRecord","createErrorNotice","createPageEntity","close","page","status","throwOnError","id","navigate","error","errorMessage","message","code","type","commands","addNewPage","document","name","label","icon","callback","isLoading","useAdminNavigationCommands","assign","hook"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand, useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { getPath } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst getAddNewPageCommand = () =>\n\tfunction useAddNewPageCommand() {\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst history = useHistory();\n\t\tconst isBlockBasedTheme = useSelect( ( select ) => {\n\t\t\treturn select( coreStore ).getCurrentTheme()?.is_block_theme;\n\t\t}, [] );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\t\tconst createPageEntity = useCallback(\n\t\t\tasync ( { close } ) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await saveEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif ( page?.id ) {\n\t\t\t\t\t\thistory.navigate( `/page/${ page.id }?canvas=edit` );\n\t\t\t\t\t}\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while creating the item.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t} );\n\t\t\t\t} finally {\n\t\t\t\t\tclose();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ createErrorNotice, history, saveEntityRecord ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\tconst addNewPage =\n\t\t\t\tisSiteEditor && isBlockBasedTheme\n\t\t\t\t\t? createPageEntity\n\t\t\t\t\t: () =>\n\t\t\t\t\t\t\t( document.location.href =\n\t\t\t\t\t\t\t\t'post-new.php?post_type=page' );\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/add-new-page',\n\t\t\t\t\tlabel: __( 'Add Page' ),\n\t\t\t\t\ticon: plus,\n\t\t\t\t\tcallback: addNewPage,\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ createPageEntity, isSiteEditor, isBlockBasedTheme ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add Post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.assign( 'post-new.php' );\n\t\t},\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/add-new-page',\n\t\thook: getAddNewPageCommand(),\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,gBAAgB,QAAQ,qBAAqB;AAClE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASL,KAAK,IAAIM,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,eAAe;AAEtC,MA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AAEF,iBAAiB,EAAEN,OAAO,EAAEK,gBAAgB,CAC/C,CAAC;EAED,MAAMc,QAAQ,GAAGhC,OAAO,CAAE,MAAM;IAC/B,MAAMiC,UAAU,GACfzB,YAAY,IAAIM,iBAAiB,GAC9BM,gBAAgB,GAChB,MACEc,QAAQ,CAACxB,QAAQ,CAACC,IAAI,GACvB,6BAA+B;IACpC,OAAO,CACN;MACCwB,IAAI,EAAE,mBAAmB;MACzBC,KAAK,EAAE5C,EAAE,CAAE,UAAW,CAAC;MACvB6C,IAAI,EAAE5C,IAAI;MACV6C,QAAQ,EAAEL;
|
|
1
|
+
{"version":3,"names":["useCommand","useCommandLoader","__","plus","getPath","store","coreStore","useSelect","useDispatch","useCallback","useMemo","noticesStore","privateApis","routerPrivateApis","unlock","useHistory","getAddNewPageCommand","useAddNewPageCommand","isSiteEditor","window","location","href","includes","history","isBlockBasedTheme","select","getCurrentTheme","is_block_theme","saveEntityRecord","createErrorNotice","createPageEntity","close","page","status","throwOnError","id","navigate","error","errorMessage","message","code","type","commands","addNewPage","document","name","label","icon","callback","keywords","isLoading","getAdminBasicNavigationCommands","useAdminBasicNavigationCommands","canCreateTemplate","canUser","kind","useAdminNavigationCommands","assign","hook"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand, useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { getPath } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst getAddNewPageCommand = () =>\n\tfunction useAddNewPageCommand() {\n\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t'site-editor.php'\n\t\t);\n\t\tconst history = useHistory();\n\t\tconst isBlockBasedTheme = useSelect( ( select ) => {\n\t\t\treturn select( coreStore ).getCurrentTheme()?.is_block_theme;\n\t\t}, [] );\n\t\tconst { saveEntityRecord } = useDispatch( coreStore );\n\t\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\t\tconst createPageEntity = useCallback(\n\t\t\tasync ( { close } ) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await saveEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif ( page?.id ) {\n\t\t\t\t\t\thistory.navigate( `/page/${ page.id }?canvas=edit` );\n\t\t\t\t\t}\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while creating the item.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t} );\n\t\t\t\t} finally {\n\t\t\t\t\tclose();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ createErrorNotice, history, saveEntityRecord ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\tconst addNewPage =\n\t\t\t\tisSiteEditor && isBlockBasedTheme\n\t\t\t\t\t? createPageEntity\n\t\t\t\t\t: () =>\n\t\t\t\t\t\t\t( document.location.href =\n\t\t\t\t\t\t\t\t'post-new.php?post_type=page' );\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/add-new-page',\n\t\t\t\t\tlabel: __( 'Add Page' ),\n\t\t\t\t\ticon: plus,\n\t\t\t\t\tcallback: addNewPage,\n\t\t\t\t\tkeywords: [\n\t\t\t\t\t\t__( 'page' ),\n\t\t\t\t\t\t__( 'new' ),\n\t\t\t\t\t\t__( 'add' ),\n\t\t\t\t\t\t__( 'create' ),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t];\n\t\t}, [ createPageEntity, isSiteEditor, isBlockBasedTheme ] );\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nconst getAdminBasicNavigationCommands = () =>\n\tfunction useAdminBasicNavigationCommands() {\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\n\t\tconst commands = useMemo( () => {\n\t\t\tif ( canCreateTemplate && isBlockBasedTheme ) {\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\tif ( ! isSiteEditor ) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'core/go-to-site-editor',\n\t\t\t\t\t\t\tlabel: __( 'Open Site Editor' ),\n\t\t\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t\tdocument.location = 'site-editor.php';\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\n\t\t\treturn [];\n\t\t}, [ canCreateTemplate, isBlockBasedTheme ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading: false,\n\t\t};\n\t};\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add Post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.assign( 'post-new.php' );\n\t\t},\n\t\tkeywords: [ __( 'post' ), __( 'new' ), __( 'add' ), __( 'create' ) ],\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/add-new-page',\n\t\thook: getAddNewPageCommand(),\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/admin-navigation',\n\t\thook: getAdminBasicNavigationCommands(),\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,gBAAgB,QAAQ,qBAAqB;AAClE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASL,KAAK,IAAIM,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,eAAe;AAEtC,MAAM;EAAEC;AAAW,CAAC,GAAGD,MAAM,CAAED,iBAAkB,CAAC;AAElD,MAAMG,oBAAoB,GAAGA,CAAA,KAC5B,SAASC,oBAAoBA,CAAA,EAAG;EAC/B,MAAMC,YAAY,GAAGd,OAAO,CAAEe,MAAM,CAACC,QAAQ,CAACC,IAAK,CAAC,EAAEC,QAAQ,CAC7D,iBACD,CAAC;EACD,MAAMC,OAAO,GAAGR,UAAU,CAAC,CAAC;EAC5B,MAAMS,iBAAiB,GAAGjB,SAAS,CAAIk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AAiB;UACtC;QACD,CAAC,CACD;MACF;IACD;IAEA,OAAO,EAAE;EACV,CAAC,EAAE,CAAEiC,iBAAiB,EAAE7B,iBAAiB,CAAG,CAAC;EAE7C,OAAO;IACNkB,QAAQ;IACRQ,SAAS,EAAE;EACZ,CAAC;AACF,CAAC;AAEF,OAAO,SAASM,0BAA0BA,CAAA,EAAG;EAC5CxD,UAAU,CAAE;IACX6C,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAE5C,EAAE,CAAE,UAAW,CAAC;IACvB6C,IAAI,EAAE5C,IAAI;IACV6C,QAAQ,EAAEA,CAAA,KAAM;MACfJ,QAAQ,CAACxB,QAAQ,CAACqC,MAAM,CAAE,cAAe,CAAC;IAC3C,CAAC;IACDR,QAAQ,EAAE,CAAE/C,EAAE,CAAE,MAAO,CAAC,EAAEA,EAAE,CAAE,KAAM,CAAC,EAAEA,EAAE,CAAE,KAAM,CAAC,EAAEA,EAAE,CAAE,QAAS,CAAC;EACnE,CAAE,CAAC;EAEHD,gBAAgB,CAAE;IACjB4C,IAAI,EAAE,mBAAmB;IACzBa,IAAI,EAAE1C,oBAAoB,CAAC;EAC5B,CAAE,CAAC;EAEHf,gBAAgB,CAAE;IACjB4C,IAAI,EAAE,uBAAuB;IAC7Ba,IAAI,EAAEP,+BAA+B,CAAC;EACvC,CAAE,CAAC;AACJ","ignoreList":[]}
|
package/build-module/index.js
CHANGED
|
@@ -31,9 +31,6 @@ function CommandPalette() {
|
|
|
31
31
|
* Initializes the Command Palette.
|
|
32
32
|
*/
|
|
33
33
|
export function initializeCommandPalette() {
|
|
34
|
-
if (!globalThis.IS_GUTENBERG_PLUGIN) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
34
|
const root = document.createElement('div');
|
|
38
35
|
document.body.appendChild(root);
|
|
39
36
|
createRoot(root).render(/*#__PURE__*/_jsx(StrictMode, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createRoot","StrictMode","privateApis","routerPrivateApis","CommandMenu","useAdminNavigationCommands","useSiteEditorNavigationCommands","unlock","jsx","_jsx","RouterProvider","CommandPalette","pathArg","children","initializeCommandPalette","
|
|
1
|
+
{"version":3,"names":["createRoot","StrictMode","privateApis","routerPrivateApis","CommandMenu","useAdminNavigationCommands","useSiteEditorNavigationCommands","unlock","jsx","_jsx","RouterProvider","CommandPalette","pathArg","children","initializeCommandPalette","root","document","createElement","body","appendChild","render"],"sources":["@wordpress/core-commands/src/index.js"],"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() {\n\tuseAdminNavigationCommands();\n\tuseSiteEditorNavigationCommands();\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 */\nexport function initializeCommandPalette() {\n\tconst root = document.createElement( 'div' );\n\tdocument.body.appendChild( root );\n\tcreateRoot( root ).render(\n\t\t<StrictMode>\n\t\t\t<CommandPalette />\n\t\t</StrictMode>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;AAC3D,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,WAAW,QAAQ,qBAAqB;;AAEjD;AACA;AACA;AACA,SAASC,0BAA0B,QAAQ,6BAA6B;AACxE,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,MAAM,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AACvC,SAASP,WAAW,QAAQ,gBAAgB;AAE5C,MAAM;EAAEQ;AAAe,CAAC,GAAGH,MAAM,CAAEJ,iBAAkB,CAAC;;AAEtD;AACA,SAASQ,cAAcA,CAAA,EAAG;EACzBN,0BAA0B,CAAC,CAAC;EAC5BC,+BAA+B,CAAC,CAAC;EACjC,oBACCG,IAAA,CAACC,cAAc;IAACE,OAAO,EAAC,GAAG;IAAAC,QAAA,eAC1BJ,IAAA,CAACL,WAAW,IAAE;EAAC,CACA,CAAC;AAEnB;;AAEA;AACA;AACA;AACA,OAAO,SAASU,wBAAwBA,CAAA,EAAG;EAC1C,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAE,KAAM,CAAC;EAC5CD,QAAQ,CAACE,IAAI,CAACC,WAAW,CAAEJ,IAAK,CAAC;EACjCf,UAAU,CAAEe,IAAK,CAAC,CAACK,MAAM,cACxBX,IAAA,CAACR,UAAU;IAAAY,QAAA,eACVJ,IAAA,CAACE,cAAc,IAAE;EAAC,CACP,CACb,CAAC;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/core-commands",
|
|
3
|
-
"version": "1.29.0",
|
|
3
|
+
"version": "1.29.1-next.f34ab90e9.0",
|
|
4
4
|
"description": "WordPress core reusable commands.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "7.25.7",
|
|
32
|
-
"@wordpress/block-editor": "^15.2.0",
|
|
33
|
-
"@wordpress/commands": "^1.29.0",
|
|
34
|
-
"@wordpress/compose": "^7.29.0",
|
|
35
|
-
"@wordpress/core-data": "^7.29.0",
|
|
36
|
-
"@wordpress/data": "^10.29.0",
|
|
37
|
-
"@wordpress/element": "^6.29.0",
|
|
38
|
-
"@wordpress/html-entities": "^4.29.0",
|
|
39
|
-
"@wordpress/i18n": "^6.2.0",
|
|
40
|
-
"@wordpress/icons": "^10.29.0",
|
|
41
|
-
"@wordpress/notices": "^5.29.0",
|
|
42
|
-
"@wordpress/private-apis": "^1.29.0",
|
|
43
|
-
"@wordpress/router": "^1.29.0",
|
|
44
|
-
"@wordpress/url": "^4.29.0"
|
|
32
|
+
"@wordpress/block-editor": "^15.2.1-next.f34ab90e9.0",
|
|
33
|
+
"@wordpress/commands": "^1.29.1-next.f34ab90e9.0",
|
|
34
|
+
"@wordpress/compose": "^7.29.1-next.f34ab90e9.0",
|
|
35
|
+
"@wordpress/core-data": "^7.29.1-next.f34ab90e9.0",
|
|
36
|
+
"@wordpress/data": "^10.29.1-next.f34ab90e9.0",
|
|
37
|
+
"@wordpress/element": "^6.29.1-next.f34ab90e9.0",
|
|
38
|
+
"@wordpress/html-entities": "^4.29.1-next.f34ab90e9.0",
|
|
39
|
+
"@wordpress/i18n": "^6.2.1-next.f34ab90e9.0",
|
|
40
|
+
"@wordpress/icons": "^10.29.1-next.f34ab90e9.0",
|
|
41
|
+
"@wordpress/notices": "^5.29.1-next.f34ab90e9.0",
|
|
42
|
+
"@wordpress/private-apis": "^1.29.1-next.f34ab90e9.0",
|
|
43
|
+
"@wordpress/router": "^1.29.1-next.f34ab90e9.0",
|
|
44
|
+
"@wordpress/url": "^4.29.1-next.f34ab90e9.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "91f58004986ec6faf118825f925ac7873d171986"
|
|
54
54
|
}
|
|
@@ -77,6 +77,12 @@ const getAddNewPageCommand = () =>
|
|
|
77
77
|
label: __( 'Add Page' ),
|
|
78
78
|
icon: plus,
|
|
79
79
|
callback: addNewPage,
|
|
80
|
+
keywords: [
|
|
81
|
+
__( 'page' ),
|
|
82
|
+
__( 'new' ),
|
|
83
|
+
__( 'add' ),
|
|
84
|
+
__( 'create' ),
|
|
85
|
+
],
|
|
80
86
|
},
|
|
81
87
|
];
|
|
82
88
|
}, [ createPageEntity, isSiteEditor, isBlockBasedTheme ] );
|
|
@@ -87,6 +93,50 @@ const getAddNewPageCommand = () =>
|
|
|
87
93
|
};
|
|
88
94
|
};
|
|
89
95
|
|
|
96
|
+
const getAdminBasicNavigationCommands = () =>
|
|
97
|
+
function useAdminBasicNavigationCommands() {
|
|
98
|
+
const { isBlockBasedTheme, canCreateTemplate } = useSelect(
|
|
99
|
+
( select ) => {
|
|
100
|
+
return {
|
|
101
|
+
isBlockBasedTheme:
|
|
102
|
+
select( coreStore ).getCurrentTheme()?.is_block_theme,
|
|
103
|
+
canCreateTemplate: select( coreStore ).canUser( 'create', {
|
|
104
|
+
kind: 'postType',
|
|
105
|
+
name: 'wp_template',
|
|
106
|
+
} ),
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
[]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const commands = useMemo( () => {
|
|
113
|
+
if ( canCreateTemplate && isBlockBasedTheme ) {
|
|
114
|
+
const isSiteEditor = getPath( window.location.href )?.includes(
|
|
115
|
+
'site-editor.php'
|
|
116
|
+
);
|
|
117
|
+
if ( ! isSiteEditor ) {
|
|
118
|
+
return [
|
|
119
|
+
{
|
|
120
|
+
name: 'core/go-to-site-editor',
|
|
121
|
+
label: __( 'Open Site Editor' ),
|
|
122
|
+
callback: ( { close } ) => {
|
|
123
|
+
close();
|
|
124
|
+
document.location = 'site-editor.php';
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return [];
|
|
132
|
+
}, [ canCreateTemplate, isBlockBasedTheme ] );
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
commands,
|
|
136
|
+
isLoading: false,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
90
140
|
export function useAdminNavigationCommands() {
|
|
91
141
|
useCommand( {
|
|
92
142
|
name: 'core/add-new-post',
|
|
@@ -95,10 +145,16 @@ export function useAdminNavigationCommands() {
|
|
|
95
145
|
callback: () => {
|
|
96
146
|
document.location.assign( 'post-new.php' );
|
|
97
147
|
},
|
|
148
|
+
keywords: [ __( 'post' ), __( 'new' ), __( 'add' ), __( 'create' ) ],
|
|
98
149
|
} );
|
|
99
150
|
|
|
100
151
|
useCommandLoader( {
|
|
101
152
|
name: 'core/add-new-page',
|
|
102
153
|
hook: getAddNewPageCommand(),
|
|
103
154
|
} );
|
|
155
|
+
|
|
156
|
+
useCommandLoader( {
|
|
157
|
+
name: 'core/admin-navigation',
|
|
158
|
+
hook: getAdminBasicNavigationCommands(),
|
|
159
|
+
} );
|
|
104
160
|
}
|
package/src/index.js
CHANGED
|
@@ -30,9 +30,6 @@ function CommandPalette() {
|
|
|
30
30
|
* Initializes the Command Palette.
|
|
31
31
|
*/
|
|
32
32
|
export function initializeCommandPalette() {
|
|
33
|
-
if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
33
|
const root = document.createElement( 'div' );
|
|
37
34
|
document.body.appendChild( root );
|
|
38
35
|
createRoot( root ).render(
|