@wordpress/commands 0.6.0 → 0.6.2
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.
|
@@ -40,7 +40,7 @@ function useCommand(command) {
|
|
|
40
40
|
label: command.label,
|
|
41
41
|
searchLabel: command.searchLabel,
|
|
42
42
|
icon: command.icon,
|
|
43
|
-
callback: currentCallback.current
|
|
43
|
+
callback: (...args) => currentCallback.current(...args)
|
|
44
44
|
});
|
|
45
45
|
return () => {
|
|
46
46
|
unregisterCommand(command.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useCommand","command","registerCommand","unregisterCommand","commandsStore","currentCallback","callback","current","name","context","label","searchLabel","icon"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyC,uBAAaC,YAAb,CAA/C;AACA,QAAMC,eAAe,GAAG,qBAAQJ,OAAO,CAACK,QAAhB,CAAxB;AACA,0BAAW,MAAM;AAChBD,IAAAA,eAAe,CAACE,OAAhB,GAA0BN,OAAO,CAACK,QAAlC;AACA,GAFD,EAEG,CAAEL,OAAO,CAACK,QAAV,CAFH;AAIA,0BAAW,MAAM;AAChBJ,IAAAA,eAAe,CAAE;AAChBM,MAAAA,IAAI,EAAEP,OAAO,CAACO,IADE;AAEhBC,MAAAA,OAAO,EAAER,OAAO,CAACQ,OAFD;AAGhBC,MAAAA,KAAK,EAAET,OAAO,CAACS,KAHC;AAIhBC,MAAAA,WAAW,EAAEV,OAAO,CAACU,WAJL;AAKhBC,MAAAA,IAAI,EAAEX,OAAO,CAACW,IALE;AAMhBN,MAAAA,QAAQ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useCommand","command","registerCommand","unregisterCommand","commandsStore","currentCallback","callback","current","name","context","label","searchLabel","icon","args"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyC,uBAAaC,YAAb,CAA/C;AACA,QAAMC,eAAe,GAAG,qBAAQJ,OAAO,CAACK,QAAhB,CAAxB;AACA,0BAAW,MAAM;AAChBD,IAAAA,eAAe,CAACE,OAAhB,GAA0BN,OAAO,CAACK,QAAlC;AACA,GAFD,EAEG,CAAEL,OAAO,CAACK,QAAV,CAFH;AAIA,0BAAW,MAAM;AAChBJ,IAAAA,eAAe,CAAE;AAChBM,MAAAA,IAAI,EAAEP,OAAO,CAACO,IADE;AAEhBC,MAAAA,OAAO,EAAER,OAAO,CAACQ,OAFD;AAGhBC,MAAAA,KAAK,EAAET,OAAO,CAACS,KAHC;AAIhBC,MAAAA,WAAW,EAAEV,OAAO,CAACU,WAJL;AAKhBC,MAAAA,IAAI,EAAEX,OAAO,CAACW,IALE;AAMhBN,MAAAA,QAAQ,EAAE,CAAE,GAAGO,IAAL,KAAeR,eAAe,CAACE,OAAhB,CAAyB,GAAGM,IAA5B;AANT,KAAF,CAAf;AAQA,WAAO,MAAM;AACZV,MAAAA,iBAAiB,CAAEF,OAAO,CAACO,IAAV,CAAjB;AACA,KAFD;AAGA,GAZD,EAYG,CACFP,OAAO,CAACO,IADN,EAEFP,OAAO,CAACS,KAFN,EAGFT,OAAO,CAACU,WAHN,EAIFV,OAAO,CAACW,IAJN,EAKFX,OAAO,CAACQ,OALN,EAMFP,eANE,EAOFC,iBAPE,CAZH;AAqBA","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 Global command menu.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\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\tcallback: ( ...args ) => currentCallback.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\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n"]}
|
|
@@ -30,7 +30,7 @@ export default function useCommand(command) {
|
|
|
30
30
|
label: command.label,
|
|
31
31
|
searchLabel: command.searchLabel,
|
|
32
32
|
icon: command.icon,
|
|
33
|
-
callback: currentCallback.current
|
|
33
|
+
callback: (...args) => currentCallback.current(...args)
|
|
34
34
|
});
|
|
35
35
|
return () => {
|
|
36
36
|
unregisterCommand(command.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useEffect","useRef","useDispatch","store","commandsStore","useCommand","command","registerCommand","unregisterCommand","currentCallback","callback","current","name","context","label","searchLabel","icon"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyCN,WAAW,CAAEE,aAAF,CAA1D;AACA,QAAMK,eAAe,GAAGR,MAAM,CAAEK,OAAO,CAACI,QAAV,CAA9B;AACAV,EAAAA,SAAS,CAAE,MAAM;AAChBS,IAAAA,eAAe,CAACE,OAAhB,GAA0BL,OAAO,CAACI,QAAlC;AACA,GAFQ,EAEN,CAAEJ,OAAO,CAACI,QAAV,CAFM,CAAT;AAIAV,EAAAA,SAAS,CAAE,MAAM;AAChBO,IAAAA,eAAe,CAAE;AAChBK,MAAAA,IAAI,EAAEN,OAAO,CAACM,IADE;AAEhBC,MAAAA,OAAO,EAAEP,OAAO,CAACO,OAFD;AAGhBC,MAAAA,KAAK,EAAER,OAAO,CAACQ,KAHC;AAIhBC,MAAAA,WAAW,EAAET,OAAO,CAACS,WAJL;AAKhBC,MAAAA,IAAI,EAAEV,OAAO,CAACU,IALE;AAMhBN,MAAAA,QAAQ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/hooks/use-command.js"],"names":["useEffect","useRef","useDispatch","store","commandsStore","useCommand","command","registerCommand","unregisterCommand","currentCallback","callback","current","name","context","label","searchLabel","icon","args"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,UAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,UAAT,CAAqBC,OAArB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAyCN,WAAW,CAAEE,aAAF,CAA1D;AACA,QAAMK,eAAe,GAAGR,MAAM,CAAEK,OAAO,CAACI,QAAV,CAA9B;AACAV,EAAAA,SAAS,CAAE,MAAM;AAChBS,IAAAA,eAAe,CAACE,OAAhB,GAA0BL,OAAO,CAACI,QAAlC;AACA,GAFQ,EAEN,CAAEJ,OAAO,CAACI,QAAV,CAFM,CAAT;AAIAV,EAAAA,SAAS,CAAE,MAAM;AAChBO,IAAAA,eAAe,CAAE;AAChBK,MAAAA,IAAI,EAAEN,OAAO,CAACM,IADE;AAEhBC,MAAAA,OAAO,EAAEP,OAAO,CAACO,OAFD;AAGhBC,MAAAA,KAAK,EAAER,OAAO,CAACQ,KAHC;AAIhBC,MAAAA,WAAW,EAAET,OAAO,CAACS,WAJL;AAKhBC,MAAAA,IAAI,EAAEV,OAAO,CAACU,IALE;AAMhBN,MAAAA,QAAQ,EAAE,CAAE,GAAGO,IAAL,KAAeR,eAAe,CAACE,OAAhB,CAAyB,GAAGM,IAA5B;AANT,KAAF,CAAf;AAQA,WAAO,MAAM;AACZT,MAAAA,iBAAiB,CAAEF,OAAO,CAACM,IAAV,CAAjB;AACA,KAFD;AAGA,GAZQ,EAYN,CACFN,OAAO,CAACM,IADN,EAEFN,OAAO,CAACQ,KAFN,EAGFR,OAAO,CAACS,WAHN,EAIFT,OAAO,CAACU,IAJN,EAKFV,OAAO,CAACO,OALN,EAMFN,eANE,EAOFC,iBAPE,CAZM,CAAT;AAqBA","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 Global command menu.\n *\n * @param {import('../store/actions').WPCommandConfig} command command config.\n */\nexport default function useCommand( command ) {\n\tconst { registerCommand, unregisterCommand } = useDispatch( commandsStore );\n\tconst currentCallback = useRef( command.callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = command.callback;\n\t}, [ command.callback ] );\n\n\tuseEffect( () => {\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\tcallback: ( ...args ) => currentCallback.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\tregisterCommand,\n\t\tunregisterCommand,\n\t] );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/commands",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Handles the commands menu.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/components": "^25.1.
|
|
31
|
-
"@wordpress/data": "^9.5.
|
|
32
|
-
"@wordpress/element": "^5.12.
|
|
33
|
-
"@wordpress/i18n": "^4.35.
|
|
34
|
-
"@wordpress/icons": "^9.26.
|
|
35
|
-
"@wordpress/keyboard-shortcuts": "^4.12.
|
|
36
|
-
"@wordpress/private-apis": "^0.17.
|
|
30
|
+
"@wordpress/components": "^25.1.2",
|
|
31
|
+
"@wordpress/data": "^9.5.1",
|
|
32
|
+
"@wordpress/element": "^5.12.1",
|
|
33
|
+
"@wordpress/i18n": "^4.35.1",
|
|
34
|
+
"@wordpress/icons": "^9.26.2",
|
|
35
|
+
"@wordpress/keyboard-shortcuts": "^4.12.1",
|
|
36
|
+
"@wordpress/private-apis": "^0.17.1",
|
|
37
37
|
"cmdk": "^0.2.0",
|
|
38
38
|
"rememo": "^4.0.2"
|
|
39
39
|
},
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "a00463f06c90ae6705951861eb889e67a52bf448"
|
|
47
47
|
}
|
package/src/hooks/use-command.js
CHANGED
|
@@ -28,7 +28,7 @@ export default function useCommand( command ) {
|
|
|
28
28
|
label: command.label,
|
|
29
29
|
searchLabel: command.searchLabel,
|
|
30
30
|
icon: command.icon,
|
|
31
|
-
callback: currentCallback.current,
|
|
31
|
+
callback: ( ...args ) => currentCallback.current( ...args ),
|
|
32
32
|
} );
|
|
33
33
|
return () => {
|
|
34
34
|
unregisterCommand( command.name );
|