@wordpress/commands 1.39.1-next.v.202602111440.0 → 1.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +16 -0
- package/build/components/command-menu.cjs +80 -39
- package/build/components/command-menu.cjs.map +2 -2
- package/build/hooks/use-command-loader.cjs +3 -1
- package/build/hooks/use-command-loader.cjs.map +2 -2
- package/build/hooks/use-command.cjs +3 -0
- package/build/hooks/use-command.cjs.map +2 -2
- package/build/store/actions.cjs +18 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/reducer.cjs +2 -0
- package/build/store/reducer.cjs.map +2 -2
- package/build-module/components/command-menu.mjs +82 -40
- package/build-module/components/command-menu.mjs.map +2 -2
- package/build-module/hooks/use-command-loader.mjs +3 -1
- package/build-module/hooks/use-command-loader.mjs.map +2 -2
- package/build-module/hooks/use-command.mjs +3 -0
- package/build-module/hooks/use-command.mjs.map +2 -2
- package/build-module/store/actions.mjs +18 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/reducer.mjs +2 -0
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-style/style-rtl.css +27 -2
- package/build-style/style.css +27 -2
- package/package.json +11 -10
- package/src/components/command-menu.js +115 -29
- package/src/components/style.scss +34 -2
- package/src/hooks/use-command-loader.js +3 -0
- package/src/hooks/use-command.js +6 -0
- package/src/store/actions.js +44 -8
- package/src/store/reducer.js +2 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ There are two ways to register commands: static or dynamic. Both methods receive
|
|
|
10
10
|
- `label`: A human-readable label
|
|
11
11
|
- `icon`: An SVG icon
|
|
12
12
|
- `callback`: A callback function that is called when the command is selected
|
|
13
|
+
- `category`: (Optional) The category of the command. See [Command categories](#command-categories) below
|
|
13
14
|
- `context`: (Optional) The context of the command
|
|
14
15
|
- `keywords`: (Optional) An array of keywords for search matching
|
|
15
16
|
|
|
@@ -37,6 +38,17 @@ As the usage of the Command Palette expands, more contexts will be added.
|
|
|
37
38
|
|
|
38
39
|
Attaching a command or command loader to a given context is as simple as adding the `context` property (with the right context value from the available contexts above) to the `useCommand` or `useCommandLoader` calls.
|
|
39
40
|
|
|
41
|
+
## Command categories
|
|
42
|
+
|
|
43
|
+
Each command can be assigned a `category` that describes what kind of action it performs. Categories are used by the Command Palette to visually differentiate commands. The following categories are available:
|
|
44
|
+
|
|
45
|
+
- `command`: Executes code or toggles a command (e.g., Add block, duplicating a block).
|
|
46
|
+
- `view`: Navigates to an area in the admin or opens a panel (e.g., "Go to: Templates").
|
|
47
|
+
- `edit`: Navigates to edit a document (e.g., editing a template, editing a page).
|
|
48
|
+
- `action`: A generic fallback for commands that don't fit the other categories. This is also the default when an invalid category is provided.
|
|
49
|
+
|
|
50
|
+
If no `category` is specified, the command will have `action` set. If an invalid value is provided, a warning is emitted in development mode and the category defaults to `action`.
|
|
51
|
+
|
|
40
52
|
## WordPress Data API
|
|
41
53
|
|
|
42
54
|
The Command Palette also offers a number of [selectors and actions](https://developer.wordpress.org/block-editor/reference-guides/data/data-core-commands/) to manipulate its state, which include:
|
|
@@ -104,6 +116,7 @@ useCommand( {
|
|
|
104
116
|
name: 'myplugin/my-command-name',
|
|
105
117
|
label: __( 'Add new post' ),
|
|
106
118
|
icon: plus,
|
|
119
|
+
category: 'command',
|
|
107
120
|
callback: ( { close } ) => {
|
|
108
121
|
document.location.href = 'post-new.php';
|
|
109
122
|
close();
|
|
@@ -160,6 +173,7 @@ function usePageSearchCommandLoader( { search } ) {
|
|
|
160
173
|
? record.title?.rendered
|
|
161
174
|
: __( '(no title)' ),
|
|
162
175
|
icon: page,
|
|
176
|
+
category: 'edit',
|
|
163
177
|
callback: ( { close } ) => {
|
|
164
178
|
const args = {
|
|
165
179
|
p: '/page',
|
|
@@ -203,6 +217,7 @@ useCommands( [
|
|
|
203
217
|
name: 'myplugin/add-post',
|
|
204
218
|
label: __( 'Add new post' ),
|
|
205
219
|
icon: plus,
|
|
220
|
+
category: 'command',
|
|
206
221
|
callback: ( { close } ) => {
|
|
207
222
|
document.location.href = 'post-new.php';
|
|
208
223
|
close();
|
|
@@ -212,6 +227,7 @@ useCommands( [
|
|
|
212
227
|
name: 'myplugin/edit-posts',
|
|
213
228
|
label: __( 'Edit posts' ),
|
|
214
229
|
icon: pencil,
|
|
230
|
+
category: 'view',
|
|
215
231
|
callback: ( { close } ) => {
|
|
216
232
|
document.location.href = 'edit.php';
|
|
217
233
|
close();
|
|
@@ -31,7 +31,8 @@ var command_menu_exports = {};
|
|
|
31
31
|
__export(command_menu_exports, {
|
|
32
32
|
CommandMenu: () => CommandMenu,
|
|
33
33
|
CommandMenuGroup: () => CommandMenuGroup,
|
|
34
|
-
CommandMenuLoaderWrapper: () => CommandMenuLoaderWrapper
|
|
34
|
+
CommandMenuLoaderWrapper: () => CommandMenuLoaderWrapper,
|
|
35
|
+
isValidIcon: () => isValidIcon
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(command_menu_exports);
|
|
37
38
|
var import_cmdk = require("cmdk");
|
|
@@ -47,7 +48,27 @@ var import_lock_unlock = require("../lock-unlock.cjs");
|
|
|
47
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
49
|
var { withIgnoreIMEEvents } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
49
50
|
var inputLabel = (0, import_i18n.__)("Search commands and settings");
|
|
50
|
-
|
|
51
|
+
var CATEGORY_ICONS = {
|
|
52
|
+
view: import_icons.arrowRight
|
|
53
|
+
};
|
|
54
|
+
var CATEGORY_LABELS = {
|
|
55
|
+
command: (0, import_i18n.__)("Command"),
|
|
56
|
+
view: (0, import_i18n.__)("View"),
|
|
57
|
+
edit: (0, import_i18n.__)("Edit"),
|
|
58
|
+
action: (0, import_i18n.__)("Action"),
|
|
59
|
+
workflow: (0, import_i18n.__)("Workflow")
|
|
60
|
+
};
|
|
61
|
+
function isValidIcon(icon) {
|
|
62
|
+
return !!icon && (typeof icon === "string" || (0, import_element.isValidElement)(icon) || typeof icon === "function" || icon instanceof import_element.Component);
|
|
63
|
+
}
|
|
64
|
+
function CommandMenuLoader({
|
|
65
|
+
name,
|
|
66
|
+
search,
|
|
67
|
+
hook,
|
|
68
|
+
setLoader,
|
|
69
|
+
close,
|
|
70
|
+
category
|
|
71
|
+
}) {
|
|
51
72
|
const { isLoading, commands = [] } = hook({ search }) ?? {};
|
|
52
73
|
(0, import_element.useEffect)(() => {
|
|
53
74
|
setLoader(name, isLoading);
|
|
@@ -55,37 +76,53 @@ function CommandMenuLoader({ name, search, hook, setLoader, close }) {
|
|
|
55
76
|
if (!commands.length) {
|
|
56
77
|
return null;
|
|
57
78
|
}
|
|
58
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: commands.map((command) =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: commands.map((command) => {
|
|
80
|
+
const commandCategory = command.category ?? category;
|
|
81
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
+
import_cmdk.Command.Item,
|
|
83
|
+
{
|
|
84
|
+
value: command.searchLabel ?? command.label,
|
|
85
|
+
keywords: command.keywords,
|
|
86
|
+
onSelect: () => command.callback({ close }),
|
|
87
|
+
id: command.name,
|
|
88
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
89
|
+
import_components.__experimentalHStack,
|
|
90
|
+
{
|
|
91
|
+
alignment: "left",
|
|
92
|
+
className: (0, import_clsx.default)("commands-command-menu__item", {
|
|
93
|
+
"has-icon": CATEGORY_ICONS[commandCategory] || command.icon
|
|
94
|
+
}),
|
|
95
|
+
children: [
|
|
96
|
+
CATEGORY_ICONS[commandCategory] && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
+
import_icons.Icon,
|
|
98
|
+
{
|
|
99
|
+
icon: CATEGORY_ICONS[commandCategory]
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
!CATEGORY_ICONS[commandCategory] && isValidIcon(command.icon) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Icon, { icon: command.icon }),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "commands-command-menu__item-label", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
|
+
import_components.TextHighlight,
|
|
105
|
+
{
|
|
106
|
+
text: command.label,
|
|
107
|
+
highlight: search
|
|
108
|
+
}
|
|
109
|
+
) }),
|
|
110
|
+
CATEGORY_LABELS[commandCategory] && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "commands-command-menu__item-category", children: CATEGORY_LABELS[commandCategory] })
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
},
|
|
115
|
+
command.name
|
|
116
|
+
);
|
|
117
|
+
}) });
|
|
87
118
|
}
|
|
88
|
-
function CommandMenuLoaderWrapper({
|
|
119
|
+
function CommandMenuLoaderWrapper({
|
|
120
|
+
hook,
|
|
121
|
+
search,
|
|
122
|
+
setLoader,
|
|
123
|
+
close,
|
|
124
|
+
category
|
|
125
|
+
}) {
|
|
89
126
|
const currentLoaderRef = (0, import_element.useRef)(hook);
|
|
90
127
|
const [key, setKey] = (0, import_element.useState)(0);
|
|
91
128
|
(0, import_element.useEffect)(() => {
|
|
@@ -100,7 +137,8 @@ function CommandMenuLoaderWrapper({ hook, search, setLoader, close }) {
|
|
|
100
137
|
hook: currentLoaderRef.current,
|
|
101
138
|
search,
|
|
102
139
|
setLoader,
|
|
103
|
-
close
|
|
140
|
+
close,
|
|
141
|
+
category
|
|
104
142
|
},
|
|
105
143
|
key
|
|
106
144
|
);
|
|
@@ -132,17 +170,18 @@ function CommandMenuGroup({ isContextual, search, setLoader, close }) {
|
|
|
132
170
|
{
|
|
133
171
|
alignment: "left",
|
|
134
172
|
className: (0, import_clsx.default)("commands-command-menu__item", {
|
|
135
|
-
"has-icon": command.icon
|
|
173
|
+
"has-icon": CATEGORY_ICONS[command.category] || command.icon
|
|
136
174
|
}),
|
|
137
175
|
children: [
|
|
138
|
-
command.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Icon, { icon: command.icon }),
|
|
176
|
+
CATEGORY_ICONS[command.category] ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Icon, { icon: CATEGORY_ICONS[command.category] }) : command.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Icon, { icon: command.icon }),
|
|
139
177
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
140
178
|
import_components.TextHighlight,
|
|
141
179
|
{
|
|
142
180
|
text: command.label,
|
|
143
181
|
highlight: search
|
|
144
182
|
}
|
|
145
|
-
) })
|
|
183
|
+
) }),
|
|
184
|
+
CATEGORY_LABELS[command.category] && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "commands-command-menu__item-category", children: CATEGORY_LABELS[command.category] })
|
|
146
185
|
]
|
|
147
186
|
}
|
|
148
187
|
)
|
|
@@ -155,7 +194,8 @@ function CommandMenuGroup({ isContextual, search, setLoader, close }) {
|
|
|
155
194
|
hook: loader.hook,
|
|
156
195
|
search,
|
|
157
196
|
setLoader,
|
|
158
|
-
close
|
|
197
|
+
close,
|
|
198
|
+
category: loader.category
|
|
159
199
|
},
|
|
160
200
|
loader.name
|
|
161
201
|
))
|
|
@@ -208,7 +248,7 @@ function CommandMenu() {
|
|
|
208
248
|
}, [registerShortcut]);
|
|
209
249
|
(0, import_keyboard_shortcuts.useShortcut)(
|
|
210
250
|
"core/commands",
|
|
211
|
-
/** @type {
|
|
251
|
+
/** @type {React.KeyboardEventHandler} */
|
|
212
252
|
withIgnoreIMEEvents((event) => {
|
|
213
253
|
if (event.defaultPrevented) {
|
|
214
254
|
return;
|
|
@@ -293,6 +333,7 @@ function CommandMenu() {
|
|
|
293
333
|
0 && (module.exports = {
|
|
294
334
|
CommandMenu,
|
|
295
335
|
CommandMenuGroup,
|
|
296
|
-
CommandMenuLoaderWrapper
|
|
336
|
+
CommandMenuLoaderWrapper,
|
|
337
|
+
isValidIcon
|
|
297
338
|
});
|
|
298
339
|
//# sourceMappingURL=command-menu.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/command-menu.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { Command, useCommandState } from 'cmdk';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon, search as inputIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst { withIgnoreIMEEvents } = unlock( componentsPrivateApis );\n\nconst inputLabel = __( 'Search commands and settings' );\n\nfunction CommandMenuLoader( { name, search, hook, setLoader, close } ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tkeywords={ command.keywords }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( { hook, search, setLoader, close } ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoaderRef = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoaderRef.current !== hook ) {\n\t\t\tcurrentLoaderRef.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoaderRef.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tkeywords={ command.keywords }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon': command.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ command.icon && <Icon icon={ command.icon } /> }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { isOpen, search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = useMemo( () => {\n\t\tconst item = document.querySelector(\n\t\t\t`[cmdk-item=\"\"][data-value=\"${ _value }\"]`\n\t\t);\n\t\treturn item?.getAttribute( 'id' );\n\t}, [ _value ] );\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\treturn (\n\t\t<Command.Input\n\t\t\tref={ commandMenuInput }\n\t\t\tvalue={ search }\n\t\t\tonValueChange={ setSearch }\n\t\t\tplaceholder={ inputLabel }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t/>\n\t);\n}\n\n/**\n * @ignore\n */\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t/** @type {import('react').KeyboardEventHandler} */\n\t\twithIgnoreIMEEvents( ( event ) => {\n\t\t\t// Bails to avoid obscuring the effect of the preceding handler(s).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t} ),\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__header-search-icon\"\n\t\t\t\t\t\t\ticon={ inputIcon }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommandInput\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetSearch={ setSearch }\n\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List label={ __( 'Command suggestions' ) }>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAyC;AACzC,kBAAiB;AAKjB,kBAAuC;AACvC,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { Command, useCommandState } from 'cmdk';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tisValidElement,\n\tComponent,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tModal,\n\tTextHighlight,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport {\n\tstore as keyboardShortcutsStore,\n\tuseShortcut,\n} from '@wordpress/keyboard-shortcuts';\nimport { Icon, search as inputIcon, arrowRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst { withIgnoreIMEEvents } = unlock( componentsPrivateApis );\n\nconst inputLabel = __( 'Search commands and settings' );\n\n/**\n * Icons enforced per command category.\n * Categories listed here will always use the specified icon,\n * ignoring whatever icon the command itself provides.\n */\nconst CATEGORY_ICONS = {\n\tview: arrowRight,\n};\n\n/**\n * Translatable labels for command categories.\n */\nconst CATEGORY_LABELS = {\n\tcommand: __( 'Command' ),\n\tview: __( 'View' ),\n\tedit: __( 'Edit' ),\n\taction: __( 'Action' ),\n\tworkflow: __( 'Workflow' ),\n};\n\n/**\n * Function that checks if the parameter is a valid icon.\n * Taken from @wordpress/blocks/src/api/utils.js and copied\n * in case requirements diverge and to avoid a dependency on @wordpress/blocks.\n *\n * @param {*} icon Parameter to be checked.\n *\n * @return {boolean} True if the parameter is a valid icon and false otherwise.\n */\n\nexport function isValidIcon( icon ) {\n\treturn (\n\t\t!! icon &&\n\t\t( typeof icon === 'string' ||\n\t\t\tisValidElement( icon ) ||\n\t\t\ttypeof icon === 'function' ||\n\t\t\ticon instanceof Component )\n\t);\n}\n\nfunction CommandMenuLoader( {\n\tname,\n\tsearch,\n\thook,\n\tsetLoader,\n\tclose,\n\tcategory,\n} ) {\n\tconst { isLoading, commands = [] } = hook( { search } ) ?? {};\n\tuseEffect( () => {\n\t\tsetLoader( name, isLoading );\n\t}, [ setLoader, name, isLoading ] );\n\n\tif ( ! commands.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ commands.map( ( command ) => {\n\t\t\t\tconst commandCategory = command.category ?? category;\n\t\t\t\treturn (\n\t\t\t\t\t<Command.Item\n\t\t\t\t\t\tkey={ command.name }\n\t\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\t\tkeywords={ command.keywords }\n\t\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\t\tid={ command.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t\t'has-icon':\n\t\t\t\t\t\t\t\t\tCATEGORY_ICONS[ commandCategory ] ||\n\t\t\t\t\t\t\t\t\tcommand.icon,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ CATEGORY_ICONS[ commandCategory ] && (\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={ CATEGORY_ICONS[ commandCategory ] }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! CATEGORY_ICONS[ commandCategory ] &&\n\t\t\t\t\t\t\t\tisValidIcon( command.icon ) && (\n\t\t\t\t\t\t\t\t\t<Icon icon={ command.icon } />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<span className=\"commands-command-menu__item-label\">\n\t\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] && (\n\t\t\t\t\t\t\t\t<span className=\"commands-command-menu__item-category\">\n\t\t\t\t\t\t\t\t\t{ CATEGORY_LABELS[ commandCategory ] }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Command.Item>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport function CommandMenuLoaderWrapper( {\n\thook,\n\tsearch,\n\tsetLoader,\n\tclose,\n\tcategory,\n} ) {\n\t// The \"hook\" prop is actually a custom React hook\n\t// so to avoid breaking the rules of hooks\n\t// the CommandMenuLoaderWrapper component need to be\n\t// remounted on each hook prop change\n\t// We use the key state to make sure we do that properly.\n\tconst currentLoaderRef = useRef( hook );\n\tconst [ key, setKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tif ( currentLoaderRef.current !== hook ) {\n\t\t\tcurrentLoaderRef.current = hook;\n\t\t\tsetKey( ( prevKey ) => prevKey + 1 );\n\t\t}\n\t}, [ hook ] );\n\n\treturn (\n\t\t<CommandMenuLoader\n\t\t\tkey={ key }\n\t\t\thook={ currentLoaderRef.current }\n\t\t\tsearch={ search }\n\t\t\tsetLoader={ setLoader }\n\t\t\tclose={ close }\n\t\t\tcategory={ category }\n\t\t/>\n\t);\n}\n\nexport function CommandMenuGroup( { isContextual, search, setLoader, close } ) {\n\tconst { commands, loaders } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCommands, getCommandLoaders } = select( commandsStore );\n\t\t\treturn {\n\t\t\t\tcommands: getCommands( isContextual ),\n\t\t\t\tloaders: getCommandLoaders( isContextual ),\n\t\t\t};\n\t\t},\n\t\t[ isContextual ]\n\t);\n\n\tif ( ! commands.length && ! loaders.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Command.Group>\n\t\t\t{ commands.map( ( command ) => (\n\t\t\t\t<Command.Item\n\t\t\t\t\tkey={ command.name }\n\t\t\t\t\tvalue={ command.searchLabel ?? command.label }\n\t\t\t\t\tkeywords={ command.keywords }\n\t\t\t\t\tonSelect={ () => command.callback( { close } ) }\n\t\t\t\t\tid={ command.name }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName={ clsx( 'commands-command-menu__item', {\n\t\t\t\t\t\t\t'has-icon':\n\t\t\t\t\t\t\t\tCATEGORY_ICONS[ command.category ] ||\n\t\t\t\t\t\t\t\tcommand.icon,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ CATEGORY_ICONS[ command.category ] ? (\n\t\t\t\t\t\t\t<Icon icon={ CATEGORY_ICONS[ command.category ] } />\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tcommand.icon && <Icon icon={ command.icon } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t\t\ttext={ command.label }\n\t\t\t\t\t\t\t\thighlight={ search }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ CATEGORY_LABELS[ command.category ] && (\n\t\t\t\t\t\t\t<span className=\"commands-command-menu__item-category\">\n\t\t\t\t\t\t\t\t{ CATEGORY_LABELS[ command.category ] }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</Command.Item>\n\t\t\t) ) }\n\t\t\t{ loaders.map( ( loader ) => (\n\t\t\t\t<CommandMenuLoaderWrapper\n\t\t\t\t\tkey={ loader.name }\n\t\t\t\t\thook={ loader.hook }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\tclose={ close }\n\t\t\t\t\tcategory={ loader.category }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Command.Group>\n\t);\n}\n\nfunction CommandInput( { isOpen, search, setSearch } ) {\n\tconst commandMenuInput = useRef();\n\tconst _value = useCommandState( ( state ) => state.value );\n\tconst selectedItemId = useMemo( () => {\n\t\tconst item = document.querySelector(\n\t\t\t`[cmdk-item=\"\"][data-value=\"${ _value }\"]`\n\t\t);\n\t\treturn item?.getAttribute( 'id' );\n\t}, [ _value ] );\n\tuseEffect( () => {\n\t\t// Focus the command palette input when mounting the modal.\n\t\tif ( isOpen ) {\n\t\t\tcommandMenuInput.current.focus();\n\t\t}\n\t}, [ isOpen ] );\n\treturn (\n\t\t<Command.Input\n\t\t\tref={ commandMenuInput }\n\t\t\tvalue={ search }\n\t\t\tonValueChange={ setSearch }\n\t\t\tplaceholder={ inputLabel }\n\t\t\taria-activedescendant={ selectedItemId }\n\t\t/>\n\t);\n}\n\n/**\n * @ignore\n */\nexport function CommandMenu() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst isOpen = useSelect(\n\t\t( select ) => select( commandsStore ).isOpen(),\n\t\t[]\n\t);\n\tconst { open, close } = useDispatch( commandsStore );\n\tconst [ loaders, setLoaders ] = useState( {} );\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/commands',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the command palette.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'k',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/commands',\n\t\t/** @type {React.KeyboardEventHandler} */\n\t\twithIgnoreIMEEvents( ( event ) => {\n\t\t\t// Bails to avoid obscuring the effect of the preceding handler(s).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tif ( isOpen ) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\topen();\n\t\t\t}\n\t\t} ),\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst setLoader = useCallback(\n\t\t( name, value ) =>\n\t\t\tsetLoaders( ( current ) => ( {\n\t\t\t\t...current,\n\t\t\t\t[ name ]: value,\n\t\t\t} ) ),\n\t\t[]\n\t);\n\tconst closeAndReset = () => {\n\t\tsetSearch( '' );\n\t\tclose();\n\t};\n\n\tif ( ! isOpen ) {\n\t\treturn false;\n\t}\n\n\tconst isLoading = Object.values( loaders ).some( Boolean );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"commands-command-menu\"\n\t\t\toverlayClassName=\"commands-command-menu__overlay\"\n\t\t\tonRequestClose={ closeAndReset }\n\t\t\t__experimentalHideHeader\n\t\t\tcontentLabel={ __( 'Command palette' ) }\n\t\t>\n\t\t\t<div className=\"commands-command-menu__container\">\n\t\t\t\t<Command label={ inputLabel }>\n\t\t\t\t\t<div className=\"commands-command-menu__header\">\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"commands-command-menu__header-search-icon\"\n\t\t\t\t\t\t\ticon={ inputIcon }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommandInput\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetSearch={ setSearch }\n\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Command.List label={ __( 'Command suggestions' ) }>\n\t\t\t\t\t\t{ search && ! isLoading && (\n\t\t\t\t\t\t\t<Command.Empty>\n\t\t\t\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t\t\t\t</Command.Empty>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\tisContextual\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<CommandMenuGroup\n\t\t\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\t\t\tsetLoader={ setLoader }\n\t\t\t\t\t\t\t\tclose={ closeAndReset }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Command.List>\n\t\t\t\t</Command>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAyC;AACzC,kBAAiB;AAKjB,kBAAuC;AACvC,qBAQO;AACP,kBAAmB;AACnB,wBAKO;AACP,gCAGO;AACP,mBAAsD;AAKtD,mBAAuC;AACvC,yBAAuB;AAgErB;AA9DF,IAAM,EAAE,oBAAoB,QAAI,2BAAQ,kBAAAA,WAAsB;AAE9D,IAAM,iBAAa,gBAAI,8BAA+B;AAOtD,IAAM,iBAAiB;AAAA,EACtB,MAAM;AACP;AAKA,IAAM,kBAAkB;AAAA,EACvB,aAAS,gBAAI,SAAU;AAAA,EACvB,UAAM,gBAAI,MAAO;AAAA,EACjB,UAAM,gBAAI,MAAO;AAAA,EACjB,YAAQ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,QAAS;AACf,WAAO;AAAA,EACR;AAEA,QAAM,YAAY,OAAO,OAAQ,OAAQ,EAAE,KAAM,OAAQ;AAEzD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,kBAAiB;AAAA,MACjB,gBAAiB;AAAA,MACjB,0BAAwB;AAAA,MACxB,kBAAe,gBAAI,iBAAkB;AAAA,MAErC,sDAAC,SAAI,WAAU,oCACd,uDAAC,uBAAQ,OAAQ,YAChB;AAAA,qDAAC,SAAI,WAAU,iCACd;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,MAAO,aAAAE;AAAA;AAAA,UACR;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WACD;AAAA,QACA,6CAAC,oBAAQ,MAAR,EAAa,WAAQ,gBAAI,qBAAsB,GAC7C;AAAA,oBAAU,CAAE,aACb,4CAAC,oBAAQ,OAAR,EACE,8BAAI,mBAAoB,GAC3B;AAAA,UAED;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA,OAAQ;AAAA,cACR,cAAY;AAAA;AAAA,UACb;AAAA,UACE,UACD;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA,OAAQ;AAAA;AAAA,UACT;AAAA,WAEF;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["componentsPrivateApis", "HStack", "clsx", "commandsStore", "keyboardShortcutsStore", "inputIcon"]
|
|
7
7
|
}
|
|
@@ -34,7 +34,8 @@ function useCommandLoader(loader) {
|
|
|
34
34
|
registerCommandLoader({
|
|
35
35
|
name: loader.name,
|
|
36
36
|
hook: loader.hook,
|
|
37
|
-
context: loader.context
|
|
37
|
+
context: loader.context,
|
|
38
|
+
category: loader.category
|
|
38
39
|
});
|
|
39
40
|
return () => {
|
|
40
41
|
unregisterCommandLoader(loader.name);
|
|
@@ -43,6 +44,7 @@ function useCommandLoader(loader) {
|
|
|
43
44
|
loader.name,
|
|
44
45
|
loader.hook,
|
|
45
46
|
loader.context,
|
|
47
|
+
loader.category,
|
|
46
48
|
loader.disabled,
|
|
47
49
|
registerCommandLoader,
|
|
48
50
|
unregisterCommandLoader
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/use-command-loader.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0B;AAC1B,kBAA4B;AAK5B,mBAAuC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command loader to the command palette. Used for dynamic commands.\n *\n * @param {import('../store/actions').WPCommandLoaderConfig} loader command loader config.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { addQueryArgs } from '@wordpress/url';\n * import { useCommandLoader } from '@wordpress/commands';\n * import { page } from '@wordpress/icons';\n * import { useSelect } from '@wordpress/data';\n * import { store as coreStore } from '@wordpress/core-data';\n * import { useMemo } from '@wordpress/element';\n *\n * function usePageSearchCommandLoader( { search } ) {\n * // Retrieve the pages for the \"search\" term.\n * const { records, isLoading } = useSelect(\n * ( select ) => {\n * const { getEntityRecords } = select( coreStore );\n * const query = {\n * search: !! search ? search : undefined,\n * per_page: 10,\n * orderby: search ? 'relevance' : 'date',\n * };\n * return {\n * records: getEntityRecords( 'postType', 'page', query ),\n * isLoading: ! select( coreStore ).hasFinishedResolution(\n * 'getEntityRecords',\n * [ 'postType', 'page', query ]\n * ),\n * };\n * },\n * [ search ]\n * );\n *\n * // Create the commands.\n * const commands = useMemo( () => {\n * return ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n * return {\n * name: record.title?.rendered + ' ' + record.id,\n * label: record.title?.rendered\n * ? record.title?.rendered\n * : __( '(no title)' ),\n * icon: page,\n * category: 'edit',\n * callback: ( { close } ) => {\n * const args = {\n * \t\t\t\t\t\t\tp: '/page',\n * \t\t\t\t\t\t\tpostId: record.id,\n * };\n * document.location = addQueryArgs( 'site-editor.php', args );\n * close();\n * },\n * };\n * } );\n * }, [ records ] );\n *\n * return {\n * commands,\n * isLoading,\n * };\n * }\n *\n * useCommandLoader( {\n * name: 'myplugin/page-search',\n * hook: usePageSearchCommandLoader,\n * } );\n * ```\n */\nexport default function useCommandLoader( loader ) {\n\tconst { registerCommandLoader, unregisterCommandLoader } =\n\t\tuseDispatch( commandsStore );\n\tuseEffect( () => {\n\t\tif ( loader.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommandLoader( {\n\t\t\tname: loader.name,\n\t\t\thook: loader.hook,\n\t\t\tcontext: loader.context,\n\t\t\tcategory: loader.category,\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommandLoader( loader.name );\n\t\t};\n\t}, [\n\t\tloader.name,\n\t\tloader.hook,\n\t\tloader.context,\n\t\tloader.category,\n\t\tloader.disabled,\n\t\tregisterCommandLoader,\n\t\tunregisterCommandLoader,\n\t] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0B;AAC1B,kBAA4B;AAK5B,mBAAuC;AAwExB,SAAR,iBAAmC,QAAS;AAClD,QAAM,EAAE,uBAAuB,wBAAwB,QACtD,yBAAa,aAAAA,KAAc;AAC5B,gCAAW,MAAM;AAChB,QAAK,OAAO,UAAW;AACtB;AAAA,IACD;AACA,0BAAuB;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,IAClB,CAAE;AACF,WAAO,MAAM;AACZ,8BAAyB,OAAO,IAAK;AAAA,IACtC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": ["commandsStore"]
|
|
7
7
|
}
|
|
@@ -39,6 +39,7 @@ function useCommand(command) {
|
|
|
39
39
|
registerCommand({
|
|
40
40
|
name: command.name,
|
|
41
41
|
context: command.context,
|
|
42
|
+
category: command.category,
|
|
42
43
|
label: command.label,
|
|
43
44
|
searchLabel: command.searchLabel,
|
|
44
45
|
icon: command.icon,
|
|
@@ -54,6 +55,7 @@ function useCommand(command) {
|
|
|
54
55
|
command.searchLabel,
|
|
55
56
|
command.icon,
|
|
56
57
|
command.context,
|
|
58
|
+
command.category,
|
|
57
59
|
command.keywords,
|
|
58
60
|
command.disabled,
|
|
59
61
|
registerCommand,
|
|
@@ -84,6 +86,7 @@ function useCommands(commands) {
|
|
|
84
86
|
registerCommand({
|
|
85
87
|
name: command.name,
|
|
86
88
|
context: command.context,
|
|
89
|
+
category: command.category,
|
|
87
90
|
label: command.label,
|
|
88
91
|
searchLabel: command.searchLabel,
|
|
89
92
|
icon: command.icon,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/use-command.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, pencil } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: pencil,\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkC;AAClC,kBAA4B;AAK5B,mBAAuC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as commandsStore } from '../store';\n\n/**\n * Attach a command to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n *\n * @example\n * ```js\n * import { useCommand } from '@wordpress/commands';\n * import { plus } from '@wordpress/icons';\n *\n * useCommand( {\n * name: 'myplugin/my-command-name',\n * label: __( 'Add new post' ),\n *\t icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * } );\n * ```\n */\nexport function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbackRef = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallbackRef.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\n\t\tif ( command.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tregisterCommand( {\n\t\t\tname: command.name,\n\t\t\tcontext: command.context,\n\t\t\tcategory: command.category,\n\t\t\tlabel: command.label,\n\t\t\tsearchLabel: command.searchLabel,\n\t\t\ticon: command.icon,\n\t\t\tkeywords: command.keywords,\n\t\t\tcallback: ( ...args ) => currentCallbackRef.current( ...args ),\n\t\t} );\n\t\treturn () => {\n\t\t\tunregisterCommand( command.name );\n\t\t};\n\t}, [\n\t\tcommand.name,\n\t\tcommand.label,\n\t\tcommand.searchLabel,\n\t\tcommand.icon,\n\t\tcommand.context,\n\t\tcommand.category,\n\t\tcommand.keywords,\n\t\tcommand.disabled,\n\t\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n\n/**\n * Attach multiple commands to the command palette. Used for static commands.\n *\n * @param {import('../store/actions').WPCommandConfig[]} commands Array of command configs.\n *\n * @example\n * ```js\n * import { useCommands } from '@wordpress/commands';\n * import { plus, pencil } from '@wordpress/icons';\n *\n * useCommands( [\n * {\n * name: 'myplugin/add-post',\n * label: __( 'Add new post' ),\n * icon: plus,\n * category: 'command',\n * callback: ({ close }) => {\n * document.location.href = 'post-new.php';\n * close();\n * },\n * },\n * {\n * name: 'myplugin/edit-posts',\n * label: __( 'Edit posts' ),\n * icon: pencil,\n * category: 'view',\n * callback: ({ close }) => {\n * document.location.href = 'edit.php';\n * close();\n * },\n * },\n * ] );\n * ```\n */\nexport function useCommands( commands ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallbacksRef = useRef( {} );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.callback ) {\n\t\t\t\tcurrentCallbacksRef.current[ command.name ] = command.callback;\n\t\t\t}\n\t\t} );\n\t}, [ commands ] );\n\n\tuseEffect( () => {\n\t\tif ( ! commands ) {\n\t\t\treturn;\n\t\t}\n\t\tcommands.forEach( ( command ) => {\n\t\t\tif ( command.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tregisterCommand( {\n\t\t\t\tname: command.name,\n\t\t\t\tcontext: command.context,\n\t\t\t\tcategory: command.category,\n\t\t\t\tlabel: command.label,\n\t\t\t\tsearchLabel: command.searchLabel,\n\t\t\t\ticon: command.icon,\n\t\t\t\tkeywords: command.keywords,\n\t\t\t\tcallback: ( ...args ) => {\n\t\t\t\t\tconst callback =\n\t\t\t\t\t\tcurrentCallbacksRef.current[ command.name ];\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tcallback( ...args );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tcommands.forEach( ( command ) => {\n\t\t\t\tunregisterCommand( command.name );\n\t\t\t} );\n\t\t};\n\t}, [ commands, registerCommand, unregisterCommand ] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkC;AAClC,kBAA4B;AAK5B,mBAAuC;AAwBhC,SAAS,WAAY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AAChC,UAAK,QAAQ,UAAW;AACvB;AAAA,MACD;AACA,sBAAiB;AAAA,QAChB,MAAM,QAAQ;AAAA,QACd,SAAS,QAAQ;AAAA,QACjB,UAAU,QAAQ;AAAA,QAClB,OAAO,QAAQ;AAAA,QACf,aAAa,QAAQ;AAAA,QACrB,MAAM,QAAQ;AAAA,QACd,UAAU,QAAQ;AAAA,QAClB,UAAU,IAAK,SAAU;AACxB,gBAAM,WACL,oBAAoB,QAAS,QAAQ,IAAK;AAC3C,cAAK,UAAW;AACf,qBAAU,GAAG,IAAK;AAAA,UACnB;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAEF,WAAO,MAAM;AACZ,eAAS,QAAS,CAAE,YAAa;AAChC,0BAAmB,QAAQ,IAAK;AAAA,MACjC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,UAAU,iBAAiB,iBAAkB,CAAE;AACrD;",
|
|
6
6
|
"names": ["commandsStore"]
|
|
7
7
|
}
|
package/build/store/actions.cjs
CHANGED
|
@@ -27,10 +27,21 @@ __export(actions_exports, {
|
|
|
27
27
|
unregisterCommandLoader: () => unregisterCommandLoader
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(actions_exports);
|
|
30
|
+
var REGISTERABLE_CATEGORIES = /* @__PURE__ */ new Set([
|
|
31
|
+
"command",
|
|
32
|
+
"view",
|
|
33
|
+
"edit",
|
|
34
|
+
"action"
|
|
35
|
+
]);
|
|
30
36
|
function registerCommand(config) {
|
|
37
|
+
let { category } = config;
|
|
38
|
+
if (!category || !REGISTERABLE_CATEGORIES.has(category)) {
|
|
39
|
+
category = "action";
|
|
40
|
+
}
|
|
31
41
|
return {
|
|
32
42
|
type: "REGISTER_COMMAND",
|
|
33
|
-
...config
|
|
43
|
+
...config,
|
|
44
|
+
category
|
|
34
45
|
};
|
|
35
46
|
}
|
|
36
47
|
function unregisterCommand(name) {
|
|
@@ -40,9 +51,14 @@ function unregisterCommand(name) {
|
|
|
40
51
|
};
|
|
41
52
|
}
|
|
42
53
|
function registerCommandLoader(config) {
|
|
54
|
+
let { category } = config;
|
|
55
|
+
if (!category || !REGISTERABLE_CATEGORIES.has(category)) {
|
|
56
|
+
category = "action";
|
|
57
|
+
}
|
|
43
58
|
return {
|
|
44
59
|
type: "REGISTER_COMMAND_LOADER",
|
|
45
|
-
...config
|
|
60
|
+
...config,
|
|
61
|
+
category
|
|
46
62
|
};
|
|
47
63
|
}
|
|
48
64
|
function unregisterCommandLoader(name) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/actions.js"],
|
|
4
|
-
"sourcesContent": ["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPCommandConfig\n *\n * @property {string}
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * @typedef {'command'|'view'|'edit'|'workflow'|'action'} WPCommandCategory\n */\n\n/**\n * Command categories allowed via registerCommand.\n * The 'workflow' category is reserved for internal use\n * and cannot be registered through this API.\n *\n * @type {Set<WPCommandCategory>}\n */\nconst REGISTERABLE_CATEGORIES = new Set( [\n\t'command',\n\t'view',\n\t'edit',\n\t'action',\n] );\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPCommandConfig\n *\n * @property {string} name Command name.\n * @property {string} label Command label.\n * @property {string=} searchLabel Command search label.\n * @property {string=} context Command context.\n * @property {WPCommandCategory=} category Command category.\n * @property {React.JSX.Element} icon Command icon.\n * @property {Function} callback Command callback.\n * @property {boolean} disabled Whether to disable the command.\n * @property {string[]=} keywords Command keywords for search matching.\n */\n\n/**\n * @typedef {(search: string) => WPCommandConfig[]} WPCommandLoaderHook hoo\n */\n\n/**\n * Command loader config.\n *\n * @typedef {Object} WPCommandLoaderConfig\n *\n * @property {string} name Command loader name.\n * @property {string=} context Command loader context.\n * @property {WPCommandCategory=} category Command loader category.\n * @property {WPCommandLoaderHook} hook Command loader hook.\n * @property {boolean} disabled Whether to disable the command loader.\n */\n\n/**\n * Returns an action object used to register a new command.\n *\n * @param {WPCommandConfig} config Command config.\n *\n * @return {Object} action.\n */\nexport function registerCommand( config ) {\n\tlet { category } = config;\n\n\t// Defaults to 'action' if no category is provided or if the category is invalid. Future versions will emit a warning.\n\tif ( ! category || ! REGISTERABLE_CATEGORIES.has( category ) ) {\n\t\tcategory = 'action';\n\t}\n\n\treturn {\n\t\ttype: 'REGISTER_COMMAND',\n\t\t...config,\n\t\tcategory,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a command.\n *\n * @param {string} name Command name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommand( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND',\n\t\tname,\n\t};\n}\n\n/**\n * Register command loader.\n *\n * @param {WPCommandLoaderConfig} config Command loader config.\n *\n * @return {Object} action.\n */\nexport function registerCommandLoader( config ) {\n\tlet { category } = config;\n\n\t// Defaults to 'action' if no category is provided or if the category is invalid. Future versions will emit a warning.\n\tif ( ! category || ! REGISTERABLE_CATEGORIES.has( category ) ) {\n\t\tcategory = 'action';\n\t}\n\n\treturn {\n\t\ttype: 'REGISTER_COMMAND_LOADER',\n\t\t...config,\n\t\tcategory,\n\t};\n}\n\n/**\n * Unregister command loader hook.\n *\n * @param {string} name Command loader name.\n *\n * @return {Object} action.\n */\nexport function unregisterCommandLoader( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_COMMAND_LOADER',\n\t\tname,\n\t};\n}\n\n/**\n * Opens the command palette.\n *\n * @return {Object} action.\n */\nexport function open() {\n\treturn {\n\t\ttype: 'OPEN',\n\t};\n}\n\n/**\n * Closes the command palette.\n *\n * @return {Object} action.\n */\nexport function close() {\n\treturn {\n\t\ttype: 'CLOSE',\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,IAAM,0BAA0B,oBAAI,IAAK;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAyCK,SAAS,gBAAiB,QAAS;AACzC,MAAI,EAAE,SAAS,IAAI;AAGnB,MAAK,CAAE,YAAY,CAAE,wBAAwB,IAAK,QAAS,GAAI;AAC9D,eAAW;AAAA,EACZ;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AASO,SAAS,kBAAmB,MAAO;AACzC,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AASO,SAAS,sBAAuB,QAAS;AAC/C,MAAI,EAAE,SAAS,IAAI;AAGnB,MAAK,CAAE,YAAY,CAAE,wBAAwB,IAAK,QAAS,GAAI;AAC9D,eAAW;AAAA,EACZ;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AASO,SAAS,wBAAyB,MAAO;AAC/C,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AAOO,SAAS,OAAO;AACtB,SAAO;AAAA,IACN,MAAM;AAAA,EACP;AACD;AAOO,SAAS,QAAQ;AACvB,SAAO;AAAA,IACN,MAAM;AAAA,EACP;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/store/reducer.cjs
CHANGED
|
@@ -33,6 +33,7 @@ function commands(state = {}, action) {
|
|
|
33
33
|
label: action.label,
|
|
34
34
|
searchLabel: action.searchLabel,
|
|
35
35
|
context: action.context,
|
|
36
|
+
category: action.category,
|
|
36
37
|
callback: action.callback,
|
|
37
38
|
icon: action.icon,
|
|
38
39
|
keywords: action.keywords
|
|
@@ -53,6 +54,7 @@ function commandLoaders(state = {}, action) {
|
|
|
53
54
|
[action.name]: {
|
|
54
55
|
name: action.name,
|
|
55
56
|
context: action.context,
|
|
57
|
+
category: action.category,
|
|
56
58
|
hook: action.hook
|
|
57
59
|
}
|
|
58
60
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/reducer.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAUhC,SAAS,SAAU,QAAQ,CAAC,GAAG,QAAS;AACvC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,OAAO,OAAO;AAAA,UACd,aAAa,OAAO;AAAA,UACpB,SAAS,OAAO;AAAA,UAChB,UAAU,OAAO;AAAA,UACjB,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,QAClB;AAAA,MACD;AAAA,IACD,KAAK,sBAAsB;AAC1B,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,eAAgB,QAAQ,CAAC,GAAG,QAAS;AAC7C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,IAAK,GAAG;AAAA,UAChB,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,UAChB,MAAM,OAAO;AAAA,QACd;AAAA,MACD;AAAA,IACD,KAAK,6BAA6B;AACjC,YAAM,EAAE,CAAE,OAAO,IAAK,GAAG,GAAG,GAAG,eAAe,IAAI;AAClD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,OAAQ,QAAQ,OAAO,QAAS;AACxC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,EACT;AAEA,SAAO;AACR;AAUA,SAAS,QAAS,QAAQ,QAAQ,QAAS;AAC1C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACR;AAEA,IAAM,cAAU,6BAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,IAAO,kBAAQ;",
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tlabel: action.label,\n\t\t\t\t\tsearchLabel: action.searchLabel,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\ticon: action.icon,\n\t\t\t\t\tkeywords: action.keywords,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tname: action.name,\n\t\t\t\t\tcontext: action.context,\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\thook: action.hook,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette open state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction isOpen( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN':\n\t\t\treturn true;\n\t\tcase 'CLOSE':\n\t\t\treturn false;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command palette's active context.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nfunction context( state = 'root', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CONTEXT':\n\t\t\treturn action.context;\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n\tisOpen,\n\tcontext,\n} );\n\nexport default reducer;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAUhC,SAAS,SAAU,QAAQ,CAAC,GAAG,QAAS;AACvC,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,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