@wordpress/core-commands 0.7.0 → 0.9.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/admin-navigation-commands.js +34 -8
  3. package/build/admin-navigation-commands.js.map +1 -1
  4. package/build/hooks.js +20 -0
  5. package/build/hooks.js.map +1 -0
  6. package/build/index.js +0 -1
  7. package/build/index.js.map +1 -1
  8. package/build/lock-unlock.js +1 -2
  9. package/build/lock-unlock.js.map +1 -1
  10. package/build/private-apis.js +1 -5
  11. package/build/private-apis.js.map +1 -1
  12. package/build/site-editor-navigation-commands.js +35 -41
  13. package/build/site-editor-navigation-commands.js.map +1 -1
  14. package/build/utils/order-entity-records-by-search.js +26 -0
  15. package/build/utils/order-entity-records-by-search.js.map +1 -0
  16. package/build-module/admin-navigation-commands.js +34 -5
  17. package/build-module/admin-navigation-commands.js.map +1 -1
  18. package/build-module/hooks.js +12 -0
  19. package/build-module/hooks.js.map +1 -0
  20. package/build-module/index.js.map +1 -1
  21. package/build-module/lock-unlock.js.map +1 -1
  22. package/build-module/private-apis.js +0 -2
  23. package/build-module/private-apis.js.map +1 -1
  24. package/build-module/site-editor-navigation-commands.js +36 -33
  25. package/build-module/site-editor-navigation-commands.js.map +1 -1
  26. package/build-module/utils/order-entity-records-by-search.js +20 -0
  27. package/build-module/utils/order-entity-records-by-search.js.map +1 -0
  28. package/package.json +14 -12
  29. package/src/admin-navigation-commands.js +35 -5
  30. package/src/hooks.js +19 -0
  31. package/src/site-editor-navigation-commands.js +39 -16
  32. package/src/utils/order-entity-records-by-search.js +25 -0
  33. package/src/utils/test/order-entity-records-by-search.js +83 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.9.0 (2023-08-16)
6
+
7
+ ## 0.8.0 (2023-08-10)
8
+
5
9
  ## 0.7.0 (2023-07-20)
6
10
 
7
11
  ## 0.6.0 (2023-07-05)
@@ -4,17 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useAdminNavigationCommands = useAdminNavigationCommands;
7
-
8
7
  var _commands = require("@wordpress/commands");
9
-
10
8
  var _i18n = require("@wordpress/i18n");
11
-
12
9
  var _icons = require("@wordpress/icons");
13
-
10
+ var _url = require("@wordpress/url");
11
+ var _router = require("@wordpress/router");
12
+ var _hooks = require("./hooks");
13
+ var _lockUnlock = require("./lock-unlock");
14
14
  /**
15
15
  * WordPress dependencies
16
16
  */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ const {
23
+ useHistory
24
+ } = (0, _lockUnlock.unlock)(_router.privateApis);
17
25
  function useAdminNavigationCommands() {
26
+ const history = useHistory();
27
+ const isTemplatesAccessible = (0, _hooks.useIsTemplatesAccessible)();
28
+ const isBlockBasedTheme = (0, _hooks.useIsBlockBasedTheme)();
29
+ const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
18
30
  (0, _commands.useCommand)({
19
31
  name: 'core/add-new-post',
20
32
  label: (0, _i18n.__)('Add new post'),
@@ -33,11 +45,25 @@ function useAdminNavigationCommands() {
33
45
  });
34
46
  (0, _commands.useCommand)({
35
47
  name: 'core/manage-reusable-blocks',
36
- label: (0, _i18n.__)('Manage all of my patterns'),
37
- callback: () => {
38
- document.location.href = 'edit.php?post_type=wp_block';
48
+ label: (0, _i18n.__)('Open patterns'),
49
+ callback: ({
50
+ close
51
+ }) => {
52
+ if (isTemplatesAccessible && isBlockBasedTheme) {
53
+ const args = {
54
+ path: '/patterns'
55
+ };
56
+ if (isSiteEditor) {
57
+ history.push(args);
58
+ } else {
59
+ document.location = (0, _url.addQueryArgs)('site-editor.php', args);
60
+ }
61
+ close();
62
+ } else {
63
+ document.location.href = 'edit.php?post_type=wp_block';
64
+ }
39
65
  },
40
- icon: _icons.external
66
+ icon: isSiteEditor ? _icons.symbol : _icons.external
41
67
  });
42
68
  }
43
69
  //# sourceMappingURL=admin-navigation-commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"names":["useAdminNavigationCommands","name","label","icon","plus","callback","document","location","href","external"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKO,SAASA,0BAAT,GAAsC;AAC5C,4BAAY;AACXC,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,cAAJ,CAFI;AAGXC,IAAAA,IAAI,EAAEC,WAHK;AAIXC,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,cAAzB;AACA;AANU,GAAZ;AAQA,4BAAY;AACXP,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,cAAJ,CAFI;AAGXC,IAAAA,IAAI,EAAEC,WAHK;AAIXC,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA;AANU,GAAZ;AAQA,4BAAY;AACXP,IAAAA,IAAI,EAAE,6BADK;AAEXC,IAAAA,KAAK,EAAE,cAAI,2BAAJ,CAFI;AAGXG,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA,KALU;AAMXL,IAAAA,IAAI,EAAEM;AANK,GAAZ;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { external, plus } from '@wordpress/icons';\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/manage-reusable-blocks',\n\t\tlabel: __( 'Manage all of my patterns' ),\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t},\n\t\ticon: external,\n\t} );\n}\n"]}
1
+ {"version":3,"names":["_commands","require","_i18n","_icons","_url","_router","_hooks","_lockUnlock","useHistory","unlock","routerPrivateApis","useAdminNavigationCommands","history","isTemplatesAccessible","useIsTemplatesAccessible","isBlockBasedTheme","useIsBlockBasedTheme","isSiteEditor","getPath","window","location","href","includes","useCommand","name","label","__","icon","plus","callback","document","close","args","path","push","addQueryArgs","symbol","external"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { external, plus, symbol } from '@wordpress/icons';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport function useAdminNavigationCommands() {\n\tconst history = useHistory();\n\tconst isTemplatesAccessible = useIsTemplatesAccessible();\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/manage-reusable-blocks',\n\t\tlabel: __( 'Open patterns' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tif ( isTemplatesAccessible && isBlockBasedTheme ) {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/patterns',\n\t\t\t\t};\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t}\n\t\t},\n\t\ticon: isSiteEditor ? symbol : external,\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,OAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EAAEO;AAAW,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAE3C,SAASC,0BAA0BA,CAAA,EAAG;EAC5C,MAAMC,OAAO,GAAGJ,UAAU,CAAC,CAAC;EAC5B,MAAMK,qBAAqB,GAAG,IAAAC,+BAAwB,EAAC,CAAC;EACxD,MAAMC,iBAAiB,GAAG,IAAAC,2BAAoB,EAAC,CAAC;EAEhD,MAAMC,YAAY,GAAG,IAAAC,YAAO,EAAEC,MAAM,CAACC,QAAQ,CAACC,IAAK,CAAC,EAAEC,QAAQ,CAC7D,iBACD,CAAC;EAED,IAAAC,oBAAU,EAAE;IACXC,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,cAAe,CAAC;IAC3BC,IAAI,EAAEC,WAAI;IACVC,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACV,QAAQ,CAACC,IAAI,GAAG,cAAc;IACxC;EACD,CAAE,CAAC;EACH,IAAAE,oBAAU,EAAE;IACXC,IAAI,EAAE,mBAAmB;IACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,cAAe,CAAC;IAC3BC,IAAI,EAAEC,WAAI;IACVC,QAAQ,EAAEA,CAAA,KAAM;MACfC,QAAQ,CAACV,QAAQ,CAACC,IAAI,GAAG,6BAA6B;IACvD;EACD,CAAE,CAAC;EACH,IAAAE,oBAAU,EAAE;IACXC,IAAI,EAAE,6BAA6B;IACnCC,KAAK,EAAE,IAAAC,QAAE,EAAE,eAAgB,CAAC;IAC5BG,QAAQ,EAAEA,CAAE;MAAEE;IAAM,CAAC,KAAM;MAC1B,IAAKlB,qBAAqB,IAAIE,iBAAiB,EAAG;QACjD,MAAMiB,IAAI,GAAG;UACZC,IAAI,EAAE;QACP,CAAC;QACD,IAAKhB,YAAY,EAAG;UACnBL,OAAO,CAACsB,IAAI,CAAEF,IAAK,CAAC;QACrB,CAAC,MAAM;UACNF,QAAQ,CAACV,QAAQ,GAAG,IAAAe,iBAAY,EAAE,iBAAiB,EAAEH,IAAK,CAAC;QAC5D;QACAD,KAAK,CAAC,CAAC;MACR,CAAC,MAAM;QACND,QAAQ,CAACV,QAAQ,CAACC,IAAI,GAAG,6BAA6B;MACvD;IACD,CAAC;IACDM,IAAI,EAAEV,YAAY,GAAGmB,aAAM,GAAGC;EAC/B,CAAE,CAAC;AACJ"}
package/build/hooks.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsBlockBasedTheme = useIsBlockBasedTheme;
7
+ exports.useIsTemplatesAccessible = useIsTemplatesAccessible;
8
+ var _coreData = require("@wordpress/core-data");
9
+ var _data = require("@wordpress/data");
10
+ /**
11
+ * WordPress dependencies
12
+ */
13
+
14
+ function useIsTemplatesAccessible() {
15
+ return (0, _data.useSelect)(select => select(_coreData.store).canUser('read', 'templates'), []);
16
+ }
17
+ function useIsBlockBasedTheme() {
18
+ return (0, _data.useSelect)(select => select(_coreData.store).getCurrentTheme()?.is_block_theme, []);
19
+ }
20
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_coreData","require","_data","useIsTemplatesAccessible","useSelect","select","coreStore","canUser","useIsBlockBasedTheme","getCurrentTheme","is_block_theme"],"sources":["@wordpress/core-commands/src/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\nexport function useIsTemplatesAccessible() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).canUser( 'read', 'templates' ),\n\t\t[]\n\t);\n}\n\nexport function useIsBlockBasedTheme() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIO,SAASE,wBAAwBA,CAAA,EAAG;EAC1C,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACC,OAAO,CAAE,MAAM,EAAE,WAAY,CAAC,EAChE,EACD,CAAC;AACF;AAEO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAO,IAAAJ,eAAS,EACbC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACG,eAAe,CAAC,CAAC,EAAEC,cAAc,EACnE,EACD,CAAC;AACF"}
package/build/index.js CHANGED
@@ -9,6 +9,5 @@ Object.defineProperty(exports, "privateApis", {
9
9
  return _privateApis.privateApis;
10
10
  }
11
11
  });
12
-
13
12
  var _privateApis = require("./private-apis");
14
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { privateApis } from './private-apis';\n"]}
1
+ {"version":3,"names":["_privateApis","require"],"sources":["@wordpress/core-commands/src/index.js"],"sourcesContent":["export { privateApis } from './private-apis';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA"}
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.unlock = exports.lock = void 0;
7
-
8
7
  var _privateApis = require("@wordpress/private-apis");
9
-
10
8
  /**
11
9
  * WordPress dependencies
12
10
  */
11
+
13
12
  const {
14
13
  lock,
15
14
  unlock
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/lock-unlock.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,0BAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/core-commands'\n\t);\n"]}
1
+ {"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/core-commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/core-commands'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,8GAA8G,EAC9G,0BACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
@@ -4,21 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.privateApis = void 0;
7
-
8
7
  var _adminNavigationCommands = require("./admin-navigation-commands");
9
-
10
8
  var _siteEditorNavigationCommands = require("./site-editor-navigation-commands");
11
-
12
9
  var _lockUnlock = require("./lock-unlock");
13
-
14
10
  /**
15
11
  * Internal dependencies
16
12
  */
13
+
17
14
  function useCommands() {
18
15
  (0, _adminNavigationCommands.useAdminNavigationCommands)();
19
16
  (0, _siteEditorNavigationCommands.useSiteEditorNavigationCommands)();
20
17
  }
21
-
22
18
  const privateApis = {};
23
19
  exports.privateApis = privateApis;
24
20
  (0, _lockUnlock.lock)(privateApis, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/private-apis.js"],"names":["useCommands","privateApis"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,SAASA,WAAT,GAAuB;AACtB;AACA;AACA;;AAEM,MAAMC,WAAW,GAAG,EAApB;;AACP,sBAAMA,WAAN,EAAmB;AAClBD,EAAAA;AADkB,CAAnB","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { lock } from './lock-unlock';\n\nfunction useCommands() {\n\tuseAdminNavigationCommands();\n\tuseSiteEditorNavigationCommands();\n}\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommands,\n} );\n"]}
1
+ {"version":3,"names":["_adminNavigationCommands","require","_siteEditorNavigationCommands","_lockUnlock","useCommands","useAdminNavigationCommands","useSiteEditorNavigationCommands","privateApis","exports","lock"],"sources":["@wordpress/core-commands/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { useAdminNavigationCommands } from './admin-navigation-commands';\nimport { useSiteEditorNavigationCommands } from './site-editor-navigation-commands';\nimport { lock } from './lock-unlock';\n\nfunction useCommands() {\n\tuseAdminNavigationCommands();\n\tuseSiteEditorNavigationCommands();\n}\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseCommands,\n} );\n"],"mappings":";;;;;;AAGA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA,SAASG,WAAWA,CAAA,EAAG;EACtB,IAAAC,mDAA0B,EAAC,CAAC;EAC5B,IAAAC,6DAA+B,EAAC,CAAC;AAClC;AAEO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAD,WAAA,GAAAA,WAAA;AAC9B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBH;AACD,CAAE,CAAC"}
@@ -4,25 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useSiteEditorNavigationCommands = useSiteEditorNavigationCommands;
7
-
8
7
  var _commands = require("@wordpress/commands");
9
-
10
8
  var _i18n = require("@wordpress/i18n");
11
-
12
9
  var _element = require("@wordpress/element");
13
-
14
10
  var _data = require("@wordpress/data");
15
-
16
11
  var _coreData = require("@wordpress/core-data");
17
-
18
12
  var _icons = require("@wordpress/icons");
19
-
20
13
  var _router = require("@wordpress/router");
21
-
22
14
  var _url = require("@wordpress/url");
23
-
15
+ var _hooks = require("./hooks");
24
16
  var _lockUnlock = require("./lock-unlock");
25
-
17
+ var _orderEntityRecordsBySearch = require("./utils/order-entity-records-by-search");
26
18
  /**
27
19
  * WordPress dependencies
28
20
  */
@@ -30,6 +22,7 @@ var _lockUnlock = require("./lock-unlock");
30
22
  /**
31
23
  * Internal dependencies
32
24
  */
25
+
33
26
  const {
34
27
  useHistory
35
28
  } = (0, _lockUnlock.unlock)(_router.privateApis);
@@ -39,7 +32,6 @@ const icons = {
39
32
  wp_template: _icons.layout,
40
33
  wp_template_part: _icons.symbolFilled
41
34
  };
42
-
43
35
  const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader({
44
36
  search
45
37
  }) {
@@ -65,8 +57,20 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
65
57
  isLoading: !select(_coreData.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query])
66
58
  };
67
59
  }, [supportsSearch, search]);
60
+
61
+ /*
62
+ * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.
63
+ * We need to sort the results based on the search query to avoid removing relevant
64
+ * records below using .slice().
65
+ */
66
+ const orderedRecords = (0, _element.useMemo)(() => {
67
+ if (supportsSearch) {
68
+ return records !== null && records !== void 0 ? records : [];
69
+ }
70
+ return (0, _orderEntityRecordsBySearch.orderEntityRecordsBySearch)(records, search).slice(0, 10);
71
+ }, [supportsSearch, records, search]);
68
72
  const commands = (0, _element.useMemo)(() => {
69
- return (records !== null && records !== void 0 ? records : []).slice(0, 10).map(record => {
73
+ return orderedRecords.map(record => {
70
74
  const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
71
75
  const extraArgs = isSiteEditor ? {
72
76
  canvas: (0, _url.getQueryArg)(window.location.href, 'canvas')
@@ -85,37 +89,38 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
85
89
  ...extraArgs
86
90
  };
87
91
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
88
-
89
92
  if (isSiteEditor) {
90
93
  history.push(args);
91
94
  } else {
92
95
  document.location = targetUrl;
93
96
  }
94
-
95
97
  close();
96
98
  }
97
99
  };
98
100
  });
99
- }, [records, history]);
101
+ }, [orderedRecords, history]);
100
102
  return {
101
103
  commands,
102
104
  isLoading
103
105
  };
104
106
  };
105
-
106
107
  const usePageNavigationCommandLoader = getNavigationCommandLoaderPerPostType('page');
107
108
  const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('post');
108
109
  const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template');
109
110
  const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template_part');
110
-
111
111
  function useSiteEditorBasicNavigationCommands() {
112
112
  const history = useHistory();
113
113
  const isSiteEditor = (0, _url.getPath)(window.location.href)?.includes('site-editor.php');
114
+ const isTemplatesAccessible = (0, _hooks.useIsTemplatesAccessible)();
115
+ const isBlockBasedTheme = (0, _hooks.useIsBlockBasedTheme)();
114
116
  const commands = (0, _element.useMemo)(() => {
115
117
  const result = [];
118
+ if (!isTemplatesAccessible || !isBlockBasedTheme) {
119
+ return result;
120
+ }
116
121
  result.push({
117
122
  name: 'core/edit-site/open-navigation',
118
- label: (0, _i18n.__)('Open navigation'),
123
+ label: (0, _i18n.__)('Navigation'),
119
124
  icon: _icons.navigation,
120
125
  callback: ({
121
126
  close
@@ -124,61 +129,55 @@ function useSiteEditorBasicNavigationCommands() {
124
129
  path: '/navigation'
125
130
  };
126
131
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
127
-
128
132
  if (isSiteEditor) {
129
133
  history.push(args);
130
134
  } else {
131
135
  document.location = targetUrl;
132
136
  }
133
-
134
137
  close();
135
138
  }
136
139
  });
137
140
  result.push({
138
- name: 'core/edit-site/open-pages',
139
- label: (0, _i18n.__)('Open pages'),
140
- icon: _icons.page,
141
+ name: 'core/edit-site/open-styles',
142
+ label: (0, _i18n.__)('Styles'),
143
+ icon: _icons.styles,
141
144
  callback: ({
142
145
  close
143
146
  }) => {
144
147
  const args = {
145
- path: '/page'
148
+ path: '/wp_global_styles'
146
149
  };
147
150
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
148
-
149
151
  if (isSiteEditor) {
150
152
  history.push(args);
151
153
  } else {
152
154
  document.location = targetUrl;
153
155
  }
154
-
155
156
  close();
156
157
  }
157
158
  });
158
159
  result.push({
159
- name: 'core/edit-site/open-style-variations',
160
- label: (0, _i18n.__)('Open style variations'),
161
- icon: _icons.styles,
160
+ name: 'core/edit-site/open-pages',
161
+ label: (0, _i18n.__)('Pages'),
162
+ icon: _icons.page,
162
163
  callback: ({
163
164
  close
164
165
  }) => {
165
166
  const args = {
166
- path: '/wp_global_styles'
167
+ path: '/page'
167
168
  };
168
169
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
169
-
170
170
  if (isSiteEditor) {
171
171
  history.push(args);
172
172
  } else {
173
173
  document.location = targetUrl;
174
174
  }
175
-
176
175
  close();
177
176
  }
178
177
  });
179
178
  result.push({
180
179
  name: 'core/edit-site/open-templates',
181
- label: (0, _i18n.__)('Open templates'),
180
+ label: (0, _i18n.__)('Templates'),
182
181
  icon: _icons.layout,
183
182
  callback: ({
184
183
  close
@@ -187,19 +186,17 @@ function useSiteEditorBasicNavigationCommands() {
187
186
  path: '/wp_template'
188
187
  };
189
188
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
190
-
191
189
  if (isSiteEditor) {
192
190
  history.push(args);
193
191
  } else {
194
192
  document.location = targetUrl;
195
193
  }
196
-
197
194
  close();
198
195
  }
199
196
  });
200
197
  result.push({
201
- name: 'core/edit-site/open-template-parts',
202
- label: (0, _i18n.__)('Open patterns'),
198
+ name: 'core/edit-site/open-patterns',
199
+ label: (0, _i18n.__)('Patterns'),
203
200
  icon: _icons.symbol,
204
201
  callback: ({
205
202
  close
@@ -208,24 +205,21 @@ function useSiteEditorBasicNavigationCommands() {
208
205
  path: '/patterns'
209
206
  };
210
207
  const targetUrl = (0, _url.addQueryArgs)('site-editor.php', args);
211
-
212
208
  if (isSiteEditor) {
213
209
  history.push(args);
214
210
  } else {
215
211
  document.location = targetUrl;
216
212
  }
217
-
218
213
  close();
219
214
  }
220
215
  });
221
216
  return result;
222
- }, [history, isSiteEditor]);
217
+ }, [history, isSiteEditor, isTemplatesAccessible, isBlockBasedTheme]);
223
218
  return {
224
219
  commands,
225
220
  isLoading: false
226
221
  };
227
222
  }
228
-
229
223
  function useSiteEditorNavigationCommands() {
230
224
  (0, _commands.useCommandLoader)({
231
225
  name: 'core/edit-site/navigate-pages',
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"names":["useHistory","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","supportsSearch","includes","records","isLoading","select","getEntityRecords","coreStore","query","undefined","per_page","orderby","status","hasFinishedResolution","commands","slice","map","record","isSiteEditor","window","location","href","extraArgs","canvas","name","id","searchLabel","title","rendered","label","icon","callback","close","args","postId","targetUrl","push","document","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","result","navigation","path","styles","symbol","useSiteEditorNavigationCommands","hook","context"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AASA;;AACA;;AAKA;;AAvBA;AACA;AACA;;AAkBA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;AAEA,MAAMC,KAAK,GAAG;AACbC,EAAAA,IAAI,EAAJA,WADa;AAEbC,EAAAA,IAAI,EAAJA,WAFa;AAGbC,EAAAA,WAAW,EAAEC,aAHA;AAIbC,EAAAA,gBAAgB,EAAEC;AAJL,CAAd;;AAOA,MAAMC,qCAAqC,GAAKC,QAAF,IAC7C,SAASC,0BAAT,CAAqC;AAAEC,EAAAA;AAAF,CAArC,EAAkD;AACjD,QAAMC,OAAO,GAAGb,UAAU,EAA1B;AACA,QAAMc,cAAc,GAAG,CAAE,CAAE,aAAF,EAAiB,kBA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MAAAA,KAAK,EAAE,cAAI,eAAJ,CAFK;AAGZC,MAAAA,IAAI,EAAEiB,aAHM;AAIZhB,MAAAA,QAAQ,EAAE,CAAE;AAAEC,QAAAA;AAAF,OAAF,KAAiB;AAC1B,cAAMC,IAAI,GAAG;AACZY,UAAAA,IAAI,EAAE;AADM,SAAb;AAGA,cAAMV,SAAS,GAAG,uBAAc,iBAAd,EAAiCF,IAAjC,CAAlB;;AACA,YAAKf,YAAL,EAAoB;AACnBlB,UAAAA,OAAO,CAACoC,IAAR,CAAcH,IAAd;AACA,SAFD,MAEO;AACNI,UAAAA,QAAQ,CAACjB,QAAT,GAAoBe,SAApB;AACA;;AACDH,QAAAA,KAAK;AACL;AAfW,KAAb;AAiBA,WAAOW,MAAP;AACA,GA5FgB,EA4Fd,CAAE3C,OAAF,EAAWkB,YAAX,CA5Fc,CAAjB;AA8FA,SAAO;AACNJ,IAAAA,QADM;AAENV,IAAAA,SAAS,EAAE;AAFL,GAAP;AAIA;;AAEM,SAAS4C,+BAAT,GAA2C;AACjD,kCAAkB;AACjBxB,IAAAA,IAAI,EAAE,+BADW;AAEjByB,IAAAA,IAAI,EAAEX;AAFW,GAAlB;AAIA,kCAAkB;AACjBd,IAAAA,IAAI,EAAE,+BADW;AAEjByB,IAAAA,IAAI,EAAEV;AAFW,GAAlB;AAIA,kCAAkB;AACjBf,IAAAA,IAAI,EAAE,mCADW;AAEjByB,IAAAA,IAAI,EAAET;AAFW,GAAlB;AAIA,kCAAkB;AACjBhB,IAAAA,IAAI,EAAE,wCADW;AAEjByB,IAAAA,IAAI,EAAER;AAFW,GAAlB;AAIA,kCAAkB;AACjBjB,IAAAA,IAAI,EAAE,iCADW;AAEjByB,IAAAA,IAAI,EAAEP,oCAFW;AAGjBQ,IAAAA,OAAO,EAAE;AAHQ,GAAlB;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n\tsymbol,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t);\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\t\tconst query = supportsSearch\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsearch: !! search ? search : undefined,\n\t\t\t\t\t\t\tper_page: 10,\n\t\t\t\t\t\t\torderby: search ? 'relevance' : 'date',\n\t\t\t\t\t\t\tstatus: [\n\t\t\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t\t\t'future',\n\t\t\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t\t\t'private',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t };\n\t\t\t\treturn {\n\t\t\t\t\trecords: getEntityRecords( 'postType', postType, query ),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ supportsSearch, search ]\n\t\t);\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? { canvas: getQueryArg( window.location.href, 'canvas' ) }\n\t\t\t\t\t: {};\n\t\t\t\treturn {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ records, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\tlabel: __( 'Open navigation' ),\n\t\t\ticon: navigation,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/navigation',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-pages',\n\t\t\tlabel: __( 'Open pages' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/page',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-style-variations',\n\t\t\tlabel: __( 'Open style variations' ),\n\t\t\ticon: styles,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-templates',\n\t\t\tlabel: __( 'Open templates' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_template',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-template-parts',\n\t\t\tlabel: __( 'Open patterns' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/patterns',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t\treturn result;\n\t}, [ history, isSiteEditor ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"]}
1
+ {"version":3,"names":["_commands","require","_i18n","_element","_data","_coreData","_icons","_router","_url","_hooks","_lockUnlock","_orderEntityRecordsBySearch","useHistory","unlock","routerPrivateApis","icons","post","page","wp_template","layout","wp_template_part","symbolFilled","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","history","supportsSearch","includes","records","isLoading","useSelect","select","getEntityRecords","coreStore","query","undefined","per_page","orderby","status","hasFinishedResolution","orderedRecords","useMemo","orderEntityRecordsBySearch","slice","commands","map","record","isSiteEditor","getPath","window","location","href","extraArgs","canvas","getQueryArg","name","id","searchLabel","title","rendered","label","__","icon","callback","close","args","postId","targetUrl","addQueryArgs","push","document","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useSiteEditorBasicNavigationCommands","isTemplatesAccessible","useIsTemplatesAccessible","isBlockBasedTheme","useIsBlockBasedTheme","result","navigation","path","styles","symbol","useSiteEditorNavigationCommands","useCommandLoader","hook","context"],"sources":["@wordpress/core-commands/src/site-editor-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommandLoader } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tpost,\n\tpage,\n\tlayout,\n\tsymbol,\n\tsymbolFilled,\n\tstyles,\n\tnavigation,\n} from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';\nimport { unlock } from './lock-unlock';\nimport { orderEntityRecordsBySearch } from './utils/order-entity-records-by-search';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst icons = {\n\tpost,\n\tpage,\n\twp_template: layout,\n\twp_template_part: symbolFilled,\n};\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst history = useHistory();\n\t\tconst supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t);\n\t\tconst { records, isLoading } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\t\tconst query = supportsSearch\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsearch: !! search ? search : undefined,\n\t\t\t\t\t\t\tper_page: 10,\n\t\t\t\t\t\t\torderby: search ? 'relevance' : 'date',\n\t\t\t\t\t\t\tstatus: [\n\t\t\t\t\t\t\t\t'publish',\n\t\t\t\t\t\t\t\t'future',\n\t\t\t\t\t\t\t\t'draft',\n\t\t\t\t\t\t\t\t'pending',\n\t\t\t\t\t\t\t\t'private',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t };\n\t\t\t\treturn {\n\t\t\t\t\trecords: getEntityRecords( 'postType', postType, query ),\n\t\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ supportsSearch, search ]\n\t\t);\n\n\t\t/*\n\t\t * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.\n\t\t * We need to sort the results based on the search query to avoid removing relevant\n\t\t * records below using .slice().\n\t\t */\n\t\tconst orderedRecords = useMemo( () => {\n\t\t\tif ( supportsSearch ) {\n\t\t\t\treturn records ?? [];\n\t\t\t}\n\n\t\t\treturn orderEntityRecordsBySearch( records, search ).slice( 0, 10 );\n\t\t}, [ supportsSearch, records, search ] );\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn orderedRecords.map( ( record ) => {\n\t\t\t\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t\t\t\t'site-editor.php'\n\t\t\t\t);\n\t\t\t\tconst extraArgs = isSiteEditor\n\t\t\t\t\t? { canvas: getQueryArg( window.location.href, 'canvas' ) }\n\t\t\t\t\t: {};\n\t\t\t\treturn {\n\t\t\t\t\tname: postType + '-' + record.id,\n\t\t\t\t\tsearchLabel: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\ticon: icons[ postType ],\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tconst args = {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\t...extraArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst targetUrl = addQueryArgs(\n\t\t\t\t\t\t\t'site-editor.php',\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\t\t\thistory.push( args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ orderedRecords, history ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template_part' );\n\nfunction useSiteEditorBasicNavigationCommands() {\n\tconst history = useHistory();\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\tconst isTemplatesAccessible = useIsTemplatesAccessible();\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\tconst commands = useMemo( () => {\n\t\tconst result = [];\n\n\t\tif ( ! isTemplatesAccessible || ! isBlockBasedTheme ) {\n\t\t\treturn result;\n\t\t}\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-navigation',\n\t\t\tlabel: __( 'Navigation' ),\n\t\t\ticon: navigation,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/navigation',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-styles',\n\t\t\tlabel: __( 'Styles' ),\n\t\t\ticon: styles,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-pages',\n\t\t\tlabel: __( 'Pages' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/page',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-templates',\n\t\t\tlabel: __( 'Templates' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/wp_template',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\tresult.push( {\n\t\t\tname: 'core/edit-site/open-patterns',\n\t\t\tlabel: __( 'Patterns' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/patterns',\n\t\t\t\t};\n\t\t\t\tconst targetUrl = addQueryArgs( 'site-editor.php', args );\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = targetUrl;\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\n\t\treturn result;\n\t}, [ history, isSiteEditor, isTemplatesAccessible, isBlockBasedTheme ] );\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport function useSiteEditorNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/basic-navigation',\n\t\thook: useSiteEditorBasicNavigationCommands,\n\t\tcontext: 'site-editor',\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AASA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,2BAAA,GAAAV,OAAA;AAzBA;AACA;AACA;;AAkBA;AACA;AACA;;AAKA,MAAM;EAAEW;AAAW,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAElD,MAAMC,KAAK,GAAG;EACbC,IAAI,EAAJA,WAAI;EACJC,IAAI,EAAJA,WAAI;EACJC,WAAW,EAAEC,aAAM;EACnBC,gBAAgB,EAAEC;AACnB,CAAC;AAED,MAAMC,qCAAqC,GAAKC,QAAQ,IACvD,SAASC,0BAA0BA,CAAE;EAAEC;AAAO,CAAC,EAAG;EACjD,MAAMC,OAAO,GAAGd,UAAU,CAAC,CAAC;EAC5B,MAAMe,cAAc,GAAG,CAAE,CAAE,aAAa,EAAE,kBAAkB,CAAE,CAACC,QAAQ,CACtEL,QACD,CAAC;EACD,MAAM;IAAEM,OAAO;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EACrCC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAiB,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IAChD,MAAMC,KAAK,GAAGR,cAAc,GACzB;MACAF,MAAM,EAAE,CAAC,CAAEA,MAAM,GAAGA,MAAM,GAAGW,SAAS;MACtCC,QAAQ,EAAE,EAAE;MAC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ityRecordsBySearch;
7
+ function orderEntityRecordsBySearch(records = [], search = '') {
8
+ if (!Array.isArray(records) || !records.length) {
9
+ return [];
10
+ }
11
+ if (!search) {
12
+ return records;
13
+ }
14
+ const priority = [];
15
+ const nonPriority = [];
16
+ for (let i = 0; i < records.length; i++) {
17
+ const record = records[i];
18
+ if (record?.title?.raw?.toLowerCase()?.includes(search?.toLowerCase())) {
19
+ priority.push(record);
20
+ } else {
21
+ nonPriority.push(record);
22
+ }
23
+ }
24
+ return priority.concat(nonPriority);
25
+ }
26
+ //# sourceMappingURL=order-entity-records-by-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["orderEntityRecordsBySearch","records","search","Array","isArray","length","priority","nonPriority","i","record","title","raw","toLowerCase","includes","push","concat"],"sources":["@wordpress/core-commands/src/utils/order-entity-records-by-search.js"],"sourcesContent":["export function orderEntityRecordsBySearch( records = [], search = '' ) {\n\tif ( ! Array.isArray( records ) || ! records.length ) {\n\t\treturn [];\n\t}\n\n\tif ( ! search ) {\n\t\treturn records;\n\t}\n\n\tconst priority = [];\n\tconst nonPriority = [];\n\n\tfor ( let i = 0; i < records.length; i++ ) {\n\t\tconst record = records[ i ];\n\t\tif (\n\t\t\trecord?.title?.raw?.toLowerCase()?.includes( search?.toLowerCase() )\n\t\t) {\n\t\t\tpriority.push( record );\n\t\t} else {\n\t\t\tnonPriority.push( record );\n\t\t}\n\t}\n\n\treturn priority.concat( nonPriority );\n}\n"],"mappings":";;;;;;AAAO,SAASA,0BAA0BA,CAAEC,OAAO,GAAG,EAAE,EAAEC,MAAM,GAAG,EAAE,EAAG;EACvE,IAAK,CAAEC,KAAK,CAACC,OAAO,CAAEH,OAAQ,CAAC,IAAI,CAAEA,OAAO,CAACI,MAAM,EAAG;IACrD,OAAO,EAAE;EACV;EAEA,IAAK,CAAEH,MAAM,EAAG;IACf,OAAOD,OAAO;EACf;EAEA,MAAMK,QAAQ,GAAG,EAAE;EACnB,MAAMC,WAAW,GAAG,EAAE;EAEtB,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,OAAO,CAACI,MAAM,EAAEG,CAAC,EAAE,EAAG;IAC1C,MAAMC,MAAM,GAAGR,OAAO,CAAEO,CAAC,CAAE;IAC3B,IACCC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,CAAC,CAAC,EAAEC,QAAQ,CAAEX,MAAM,EAAEU,WAAW,CAAC,CAAE,CAAC,EACnE;MACDN,QAAQ,CAACQ,IAAI,CAAEL,MAAO,CAAC;IACxB,CAAC,MAAM;MACNF,WAAW,CAACO,IAAI,CAAEL,MAAO,CAAC;IAC3B;EACD;EAEA,OAAOH,QAAQ,CAACS,MAAM,CAAER,WAAY,CAAC;AACtC"}
@@ -3,8 +3,23 @@
3
3
  */
4
4
  import { useCommand } from '@wordpress/commands';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { external, plus } from '@wordpress/icons';
6
+ import { external, plus, symbol } from '@wordpress/icons';
7
+ import { addQueryArgs, getPath } from '@wordpress/url';
8
+ import { privateApis as routerPrivateApis } from '@wordpress/router';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';
14
+ import { unlock } from './lock-unlock';
15
+ const {
16
+ useHistory
17
+ } = unlock(routerPrivateApis);
7
18
  export function useAdminNavigationCommands() {
19
+ const history = useHistory();
20
+ const isTemplatesAccessible = useIsTemplatesAccessible();
21
+ const isBlockBasedTheme = useIsBlockBasedTheme();
22
+ const isSiteEditor = getPath(window.location.href)?.includes('site-editor.php');
8
23
  useCommand({
9
24
  name: 'core/add-new-post',
10
25
  label: __('Add new post'),
@@ -23,11 +38,25 @@ export function useAdminNavigationCommands() {
23
38
  });
24
39
  useCommand({
25
40
  name: 'core/manage-reusable-blocks',
26
- label: __('Manage all of my patterns'),
27
- callback: () => {
28
- document.location.href = 'edit.php?post_type=wp_block';
41
+ label: __('Open patterns'),
42
+ callback: ({
43
+ close
44
+ }) => {
45
+ if (isTemplatesAccessible && isBlockBasedTheme) {
46
+ const args = {
47
+ path: '/patterns'
48
+ };
49
+ if (isSiteEditor) {
50
+ history.push(args);
51
+ } else {
52
+ document.location = addQueryArgs('site-editor.php', args);
53
+ }
54
+ close();
55
+ } else {
56
+ document.location.href = 'edit.php?post_type=wp_block';
57
+ }
29
58
  },
30
- icon: external
59
+ icon: isSiteEditor ? symbol : external
31
60
  });
32
61
  }
33
62
  //# sourceMappingURL=admin-navigation-commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"names":["useCommand","__","external","plus","useAdminNavigationCommands","name","label","icon","callback","document","location","href"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,qBAA3B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AAEA,OAAO,SAASC,0BAAT,GAAsC;AAC5CJ,EAAAA,UAAU,CAAE;AACXK,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAEL,EAAE,CAAE,cAAF,CAFE;AAGXM,IAAAA,IAAI,EAAEJ,IAHK;AAIXK,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,cAAzB;AACA;AANU,GAAF,CAAV;AAQAX,EAAAA,UAAU,CAAE;AACXK,IAAAA,IAAI,EAAE,mBADK;AAEXC,IAAAA,KAAK,EAAEL,EAAE,CAAE,cAAF,CAFE;AAGXM,IAAAA,IAAI,EAAEJ,IAHK;AAIXK,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA;AANU,GAAF,CAAV;AAQAX,EAAAA,UAAU,CAAE;AACXK,IAAAA,IAAI,EAAE,6BADK;AAEXC,IAAAA,KAAK,EAAEL,EAAE,CAAE,2BAAF,CAFE;AAGXO,IAAAA,QAAQ,EAAE,MAAM;AACfC,MAAAA,QAAQ,CAACC,QAAT,CAAkBC,IAAlB,GAAyB,6BAAzB;AACA,KALU;AAMXJ,IAAAA,IAAI,EAAEL;AANK,GAAF,CAAV;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { external, plus } from '@wordpress/icons';\n\nexport function useAdminNavigationCommands() {\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/manage-reusable-blocks',\n\t\tlabel: __( 'Manage all of my patterns' ),\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t},\n\t\ticon: external,\n\t} );\n}\n"]}
1
+ {"version":3,"names":["useCommand","__","external","plus","symbol","addQueryArgs","getPath","privateApis","routerPrivateApis","useIsTemplatesAccessible","useIsBlockBasedTheme","unlock","useHistory","useAdminNavigationCommands","history","isTemplatesAccessible","isBlockBasedTheme","isSiteEditor","window","location","href","includes","name","label","icon","callback","document","close","args","path","push"],"sources":["@wordpress/core-commands/src/admin-navigation-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCommand } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { external, plus, symbol } from '@wordpress/icons';\nimport { addQueryArgs, getPath } from '@wordpress/url';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { useIsTemplatesAccessible, useIsBlockBasedTheme } from './hooks';\nimport { unlock } from './lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport function useAdminNavigationCommands() {\n\tconst history = useHistory();\n\tconst isTemplatesAccessible = useIsTemplatesAccessible();\n\tconst isBlockBasedTheme = useIsBlockBasedTheme();\n\n\tconst isSiteEditor = getPath( window.location.href )?.includes(\n\t\t'site-editor.php'\n\t);\n\n\tuseCommand( {\n\t\tname: 'core/add-new-post',\n\t\tlabel: __( 'Add new post' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/add-new-page',\n\t\tlabel: __( 'Add new page' ),\n\t\ticon: plus,\n\t\tcallback: () => {\n\t\t\tdocument.location.href = 'post-new.php?post_type=page';\n\t\t},\n\t} );\n\tuseCommand( {\n\t\tname: 'core/manage-reusable-blocks',\n\t\tlabel: __( 'Open patterns' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tif ( isTemplatesAccessible && isBlockBasedTheme ) {\n\t\t\t\tconst args = {\n\t\t\t\t\tpath: '/patterns',\n\t\t\t\t};\n\t\t\t\tif ( isSiteEditor ) {\n\t\t\t\t\thistory.push( args );\n\t\t\t\t} else {\n\t\t\t\t\tdocument.location = addQueryArgs( 'site-editor.php', args );\n\t\t\t\t}\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\tdocument.location.href = 'edit.php?post_type=wp_block';\n\t\t\t}\n\t\t},\n\t\ticon: isSiteEditor ? symbol : external,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,qBAAqB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,IAAI,EAAEC,MAAM,QAAQ,kBAAkB;AACzD,SAASC,YAAY,EAAEC,OAAO,QAAQ,gBAAgB;AACtD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASC,wBAAwB,EAAEC,oB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,QAAQ,GAAGd,YAAY,CAAE,iBAAiB,EAAEuB,IAAK,CAAC;QAC5D;QACAD,KAAK,CAAC,CAAC;MACR,CAAC,MAAM;QACND,QAAQ,CAACP,QAAQ,CAACC,IAAI,GAAG,6BAA6B;MACvD;IACD,CAAC;IACDI,IAAI,EAAEP,YAAY,GAAGb,MAAM,GAAGF;EAC/B,CAAE,CAAC;AACJ"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as coreStore } from '@wordpress/core-data';
5
+ import { useSelect } from '@wordpress/data';
6
+ export function useIsTemplatesAccessible() {
7
+ return useSelect(select => select(coreStore).canUser('read', 'templates'), []);
8
+ }
9
+ export function useIsBlockBasedTheme() {
10
+ return useSelect(select => select(coreStore).getCurrentTheme()?.is_block_theme, []);
11
+ }
12
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["store","coreStore","useSelect","useIsTemplatesAccessible","select","canUser","useIsBlockBasedTheme","getCurrentTheme","is_block_theme"],"sources":["@wordpress/core-commands/src/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\nexport function useIsTemplatesAccessible() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).canUser( 'read', 'templates' ),\n\t\t[]\n\t);\n}\n\nexport function useIsBlockBasedTheme() {\n\treturn useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,OAAO,SAASC,wBAAwBA,CAAA,EAAG;EAC1C,OAAOD,SAAS,CACbE,MAAM,IAAMA,MAAM,CAAEH,SAAU,CAAC,CAACI,OAAO,CAAE,MAAM,EAAE,WAAY,CAAC,EAChE,EACD,CAAC;AACF;AAEA,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAOJ,SAAS,CACbE,MAAM,IAAMA,MAAM,CAAEH,SAAU,CAAC,CAACM,eAAe,CAAC,CAAC,EAAEC,cAAc,EACnE,EACD,CAAC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/index.js"],"names":["privateApis"],"mappings":"AAAA,SAASA,WAAT,QAA4B,gBAA5B","sourcesContent":["export { privateApis } from './private-apis';\n"]}
1
+ {"version":3,"names":["privateApis"],"sources":["@wordpress/core-commands/src/index.js"],"sourcesContent":["export { privateApis } from './private-apis';\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-commands/src/lock-unlock.js"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,yBAAjE;AAEA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZF,gDAAgD,CAC/C,8GAD+C,EAE/C,0BAF+C,CAD1C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/core-commands'\n\t);\n"]}
1
+ {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/core-commands/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/core-commands'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,8GAA8G,EAC9G,0BACD,CAAC"}