@wordpress/edit-site 5.10.0 → 5.11.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 (252) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +7 -22
  3. package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
  4. package/build/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +11 -21
  5. package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
  6. package/build/components/add-new-template/new-template.js +98 -65
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/block-editor/index.js +1 -3
  9. package/build/components/block-editor/index.js.map +1 -1
  10. package/build/components/create-template-part-modal/index.js +6 -7
  11. package/build/components/create-template-part-modal/index.js.map +1 -1
  12. package/build/components/editor/index.js +15 -40
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/editor-canvas-container/index.js +10 -3
  15. package/build/components/editor-canvas-container/index.js.map +1 -1
  16. package/build/components/global-styles/screen-block.js +80 -3
  17. package/build/components/global-styles/screen-block.js.map +1 -1
  18. package/build/components/global-styles/screen-revisions/index.js +3 -10
  19. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  20. package/build/components/global-styles/screen-revisions/revisions-buttons.js +16 -18
  21. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  22. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
  23. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  24. package/build/components/global-styles/screen-root.js +4 -4
  25. package/build/components/global-styles/screen-root.js.map +1 -1
  26. package/build/components/global-styles/style-variations-container.js +6 -10
  27. package/build/components/global-styles/style-variations-container.js.map +1 -1
  28. package/build/components/global-styles/ui.js +9 -9
  29. package/build/components/global-styles/ui.js.map +1 -1
  30. package/build/components/header-edit-mode/document-actions/index.js +28 -103
  31. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  32. package/build/components/header-edit-mode/index.js +14 -1
  33. package/build/components/header-edit-mode/index.js.map +1 -1
  34. package/build/components/layout/hooks.js +54 -0
  35. package/build/components/layout/hooks.js.map +1 -0
  36. package/build/components/layout/index.js +45 -98
  37. package/build/components/layout/index.js.map +1 -1
  38. package/build/components/list/actions/index.js +5 -2
  39. package/build/components/list/actions/index.js.map +1 -1
  40. package/build/components/resizable-frame/index.js +242 -0
  41. package/build/components/resizable-frame/index.js.map +1 -0
  42. package/build/components/revisions/index.js +2 -1
  43. package/build/components/revisions/index.js.map +1 -1
  44. package/build/components/secondary-sidebar/list-view-sidebar.js +4 -3
  45. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  46. package/build/components/sidebar/index.js +4 -4
  47. package/build/components/sidebar/index.js.map +1 -1
  48. package/build/components/sidebar-edit-mode/template-revisions/index.js +1 -1
  49. package/build/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
  50. package/build/components/sidebar-navigation-screen-global-styles/index.js +75 -11
  51. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  52. package/build/components/sidebar-navigation-screen-main/index.js +24 -33
  53. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  54. package/build/components/sidebar-navigation-screen-navigation-menu/index.js +162 -0
  55. package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
  56. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +17 -0
  57. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
  58. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +53 -103
  59. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +87 -0
  61. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
  62. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +14 -71
  63. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  64. package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +53 -0
  65. package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
  66. package/build/components/sidebar-navigation-screen-templates/index.js +36 -11
  67. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  68. package/build/components/site-hub/index.js +1 -3
  69. package/build/components/site-hub/index.js.map +1 -1
  70. package/build/components/style-book/index.js +93 -19
  71. package/build/components/style-book/index.js.map +1 -1
  72. package/build/components/use-edited-entity-record/index.js +8 -4
  73. package/build/components/use-edited-entity-record/index.js.map +1 -1
  74. package/build/hooks/commands/use-edit-mode-commands.js +105 -0
  75. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -0
  76. package/build/store/actions.js +5 -3
  77. package/build/store/actions.js.map +1 -1
  78. package/build-module/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +8 -20
  79. package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
  80. package/build-module/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -22
  81. package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
  82. package/build-module/components/add-new-template/new-template.js +98 -67
  83. package/build-module/components/add-new-template/new-template.js.map +1 -1
  84. package/build-module/components/block-editor/index.js +1 -3
  85. package/build-module/components/block-editor/index.js.map +1 -1
  86. package/build-module/components/create-template-part-modal/index.js +7 -8
  87. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  88. package/build-module/components/editor/index.js +16 -43
  89. package/build-module/components/editor/index.js.map +1 -1
  90. package/build-module/components/editor-canvas-container/index.js +7 -3
  91. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  92. package/build-module/components/global-styles/screen-block.js +82 -4
  93. package/build-module/components/global-styles/screen-block.js.map +1 -1
  94. package/build-module/components/global-styles/screen-revisions/index.js +3 -10
  95. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  96. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +16 -19
  97. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  98. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
  99. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  100. package/build-module/components/global-styles/screen-root.js +4 -4
  101. package/build-module/components/global-styles/screen-root.js.map +1 -1
  102. package/build-module/components/global-styles/style-variations-container.js +7 -11
  103. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  104. package/build-module/components/global-styles/ui.js +10 -10
  105. package/build-module/components/global-styles/ui.js.map +1 -1
  106. package/build-module/components/header-edit-mode/document-actions/index.js +31 -107
  107. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  108. package/build-module/components/header-edit-mode/index.js +14 -2
  109. package/build-module/components/header-edit-mode/index.js.map +1 -1
  110. package/build-module/components/layout/hooks.js +41 -0
  111. package/build-module/components/layout/hooks.js.map +1 -0
  112. package/build-module/components/layout/index.js +46 -101
  113. package/build-module/components/layout/index.js.map +1 -1
  114. package/build-module/components/list/actions/index.js +6 -3
  115. package/build-module/components/list/actions/index.js.map +1 -1
  116. package/build-module/components/resizable-frame/index.js +228 -0
  117. package/build-module/components/resizable-frame/index.js.map +1 -0
  118. package/build-module/components/revisions/index.js +2 -1
  119. package/build-module/components/revisions/index.js.map +1 -1
  120. package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
  121. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  122. package/build-module/components/sidebar/index.js +3 -3
  123. package/build-module/components/sidebar/index.js.map +1 -1
  124. package/build-module/components/sidebar-edit-mode/template-revisions/index.js +1 -1
  125. package/build-module/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
  126. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +70 -14
  127. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  128. package/build-module/components/sidebar-navigation-screen-main/index.js +21 -32
  129. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  130. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +141 -0
  131. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
  132. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +10 -0
  133. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
  134. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +52 -103
  135. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  136. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +71 -0
  137. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
  138. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +12 -71
  139. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  140. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +40 -0
  141. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
  142. package/build-module/components/sidebar-navigation-screen-templates/index.js +35 -11
  143. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  144. package/build-module/components/site-hub/index.js +1 -3
  145. package/build-module/components/site-hub/index.js.map +1 -1
  146. package/build-module/components/style-book/index.js +93 -20
  147. package/build-module/components/style-book/index.js.map +1 -1
  148. package/build-module/components/use-edited-entity-record/index.js +8 -4
  149. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  150. package/build-module/hooks/commands/use-edit-mode-commands.js +86 -0
  151. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -0
  152. package/build-module/store/actions.js +5 -3
  153. package/build-module/store/actions.js.map +1 -1
  154. package/build-style/style-rtl.css +233 -210
  155. package/build-style/style.css +234 -210
  156. package/package.json +37 -37
  157. package/src/components/add-new-template/add-custom-generic-template-modal-content.js +82 -0
  158. package/src/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -26
  159. package/src/components/add-new-template/new-template.js +139 -153
  160. package/src/components/add-new-template/style.scss +79 -66
  161. package/src/components/block-editor/index.js +2 -3
  162. package/src/components/create-template-part-modal/index.js +19 -25
  163. package/src/components/editor/index.js +16 -45
  164. package/src/components/editor/style.scss +21 -6
  165. package/src/components/editor-canvas-container/index.js +28 -19
  166. package/src/components/global-styles/screen-block.js +74 -3
  167. package/src/components/global-styles/screen-revisions/index.js +3 -11
  168. package/src/components/global-styles/screen-revisions/revisions-buttons.js +33 -25
  169. package/src/components/global-styles/screen-revisions/style.scss +3 -2
  170. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +16 -3
  171. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -19
  172. package/src/components/global-styles/screen-root.js +5 -3
  173. package/src/components/global-styles/style-variations-container.js +13 -18
  174. package/src/components/global-styles/style.scss +3 -0
  175. package/src/components/global-styles/ui.js +11 -9
  176. package/src/components/header-edit-mode/document-actions/index.js +26 -129
  177. package/src/components/header-edit-mode/document-actions/style.scss +28 -59
  178. package/src/components/header-edit-mode/index.js +18 -0
  179. package/src/components/header-edit-mode/style.scss +1 -0
  180. package/src/components/layout/hooks.js +46 -0
  181. package/src/components/layout/index.js +56 -125
  182. package/src/components/layout/style.scss +8 -2
  183. package/src/components/list/actions/index.js +12 -5
  184. package/src/components/list/style.scss +1 -0
  185. package/src/components/resizable-frame/index.js +253 -0
  186. package/src/components/resizable-frame/style.scss +69 -0
  187. package/src/components/revisions/index.js +1 -0
  188. package/src/components/secondary-sidebar/list-view-sidebar.js +2 -1
  189. package/src/components/sidebar/index.js +4 -4
  190. package/src/components/sidebar-edit-mode/template-revisions/index.js +1 -2
  191. package/src/components/sidebar-navigation-item/style.scss +9 -0
  192. package/src/components/sidebar-navigation-screen/style.scss +1 -2
  193. package/src/components/sidebar-navigation-screen-global-styles/index.js +106 -21
  194. package/src/components/sidebar-navigation-screen-main/index.js +35 -52
  195. package/src/components/sidebar-navigation-screen-navigation-menu/index.js +157 -0
  196. package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +9 -0
  197. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +63 -117
  198. package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +83 -0
  199. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +6 -72
  200. package/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +47 -0
  201. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +6 -20
  202. package/src/components/sidebar-navigation-screen-templates/index.js +53 -14
  203. package/src/components/site-hub/index.js +8 -9
  204. package/src/components/start-template-options/style.scss +20 -21
  205. package/src/components/style-book/index.js +132 -43
  206. package/src/components/style-book/style.scss +19 -0
  207. package/src/components/use-edited-entity-record/index.js +12 -3
  208. package/src/hooks/commands/use-edit-mode-commands.js +79 -0
  209. package/src/store/actions.js +4 -5
  210. package/src/store/test/utils.js +15 -5
  211. package/src/style.scss +1 -1
  212. package/build/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
  213. package/build/components/add-new-template/add-custom-template-modal.js.map +0 -1
  214. package/build/components/global-styles/border-panel.js +0 -135
  215. package/build/components/global-styles/border-panel.js.map +0 -1
  216. package/build/components/navigate-to-link/index.js +0 -51
  217. package/build/components/navigate-to-link/index.js.map +0 -1
  218. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -19
  219. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
  220. package/build/components/template-details/edit-template-title.js +0 -42
  221. package/build/components/template-details/edit-template-title.js.map +0 -1
  222. package/build/components/template-details/index.js +0 -103
  223. package/build/components/template-details/index.js.map +0 -1
  224. package/build/components/template-details/template-areas.js +0 -166
  225. package/build/components/template-details/template-areas.js.map +0 -1
  226. package/build/components/template-details/template-part-area-selector.js +0 -48
  227. package/build/components/template-details/template-part-area-selector.js.map +0 -1
  228. package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
  229. package/build-module/components/add-new-template/add-custom-template-modal.js.map +0 -1
  230. package/build-module/components/global-styles/border-panel.js +0 -125
  231. package/build-module/components/global-styles/border-panel.js.map +0 -1
  232. package/build-module/components/navigate-to-link/index.js +0 -39
  233. package/build-module/components/navigate-to-link/index.js.map +0 -1
  234. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -11
  235. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
  236. package/build-module/components/template-details/edit-template-title.js +0 -33
  237. package/build-module/components/template-details/edit-template-title.js.map +0 -1
  238. package/build-module/components/template-details/index.js +0 -83
  239. package/build-module/components/template-details/index.js.map +0 -1
  240. package/build-module/components/template-details/template-areas.js +0 -145
  241. package/build-module/components/template-details/template-areas.js.map +0 -1
  242. package/build-module/components/template-details/template-part-area-selector.js +0 -36
  243. package/build-module/components/template-details/template-part-area-selector.js.map +0 -1
  244. package/src/components/add-new-template/add-custom-generic-template-modal.js +0 -101
  245. package/src/components/global-styles/border-panel.js +0 -114
  246. package/src/components/navigate-to-link/index.js +0 -46
  247. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -9
  248. package/src/components/template-details/edit-template-title.js +0 -41
  249. package/src/components/template-details/index.js +0 -113
  250. package/src/components/template-details/style.scss +0 -72
  251. package/src/components/template-details/template-areas.js +0 -167
  252. package/src/components/template-details/template-part-area-selector.js +0 -39
@@ -5,16 +5,25 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.SidebarNavigationItemGlobalStyles = SidebarNavigationItemGlobalStyles;
8
9
  exports.default = SidebarNavigationScreenGlobalStyles;
9
10
 
10
11
  var _element = require("@wordpress/element");
11
12
 
13
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
14
+
12
15
  var _i18n = require("@wordpress/i18n");
13
16
 
14
17
  var _icons = require("@wordpress/icons");
15
18
 
16
19
  var _data = require("@wordpress/data");
17
20
 
21
+ var _coreData = require("@wordpress/core-data");
22
+
23
+ var _components = require("@wordpress/components");
24
+
25
+ var _compose = require("@wordpress/compose");
26
+
18
27
  var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
19
28
 
20
29
  var _styleVariationsContainer = _interopRequireDefault(require("../global-styles/style-variations-container"));
@@ -25,6 +34,10 @@ var _store = require("../../store");
25
34
 
26
35
  var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
27
36
 
37
+ var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigation-item"));
38
+
39
+ var _styleBook = _interopRequireDefault(require("../style-book"));
40
+
28
41
  /**
29
42
  * WordPress dependencies
30
43
  */
@@ -32,27 +45,78 @@ var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
32
45
  /**
33
46
  * Internal dependencies
34
47
  */
35
- function SidebarNavigationScreenGlobalStyles() {
48
+ function SidebarNavigationItemGlobalStyles(props) {
36
49
  const {
37
50
  openGeneralSidebar
38
51
  } = (0, _data.useDispatch)(_store.store);
39
52
  const {
40
53
  setCanvasMode
41
54
  } = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
42
- return (0, _element.createElement)(_sidebarNavigationScreen.default, {
55
+ const hasGlobalStyleVariations = (0, _data.useSelect)(select => {
56
+ var _select$__experimenta;
57
+
58
+ return !!((_select$__experimenta = select(_coreData.store).__experimentalGetCurrentThemeGlobalStylesVariations()) !== null && _select$__experimenta !== void 0 && _select$__experimenta.length);
59
+ }, []);
60
+
61
+ if (hasGlobalStyleVariations) {
62
+ return (0, _element.createElement)(_components.__experimentalNavigatorButton, (0, _extends2.default)({}, props, {
63
+ as: _sidebarNavigationItem.default,
64
+ path: "/wp_global_styles"
65
+ }));
66
+ }
67
+
68
+ return (0, _element.createElement)(_sidebarNavigationItem.default, (0, _extends2.default)({}, props, {
69
+ onClick: () => {
70
+ // switch to edit mode.
71
+ setCanvasMode('edit'); // open global styles sidebar.
72
+
73
+ openGeneralSidebar('edit-site/global-styles');
74
+ }
75
+ }));
76
+ }
77
+
78
+ function SidebarNavigationScreenGlobalStyles() {
79
+ const {
80
+ openGeneralSidebar
81
+ } = (0, _data.useDispatch)(_store.store);
82
+ const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
83
+ const {
84
+ setCanvasMode,
85
+ setEditorCanvasContainerView
86
+ } = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
87
+ const isStyleBookOpened = (0, _data.useSelect)(select => 'style-book' === (0, _privateApis.unlock)(select(_store.store)).getEditorCanvasContainerView(), []);
88
+
89
+ const openGlobalStyles = async () => Promise.all([setCanvasMode('edit'), openGeneralSidebar('edit-site/global-styles')]);
90
+
91
+ const openStyleBook = async () => {
92
+ await openGlobalStyles(); // Open the Style Book once the canvas mode is set to edit,
93
+ // and the global styles sidebar is open. This ensures that
94
+ // the Style Book is not prematurely closed.
95
+
96
+ setEditorCanvasContainerView('style-book');
97
+ };
98
+
99
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_sidebarNavigationScreen.default, {
43
100
  title: (0, _i18n.__)('Styles'),
44
101
  description: (0, _i18n.__)('Choose a different style combination for the theme styles.'),
45
102
  content: (0, _element.createElement)(_styleVariationsContainer.default, null),
46
- actions: (0, _element.createElement)(_sidebarButton.default, {
103
+ actions: (0, _element.createElement)("div", null, !isMobileViewport && (0, _element.createElement)(_sidebarButton.default, {
104
+ icon: _icons.seen,
105
+ label: (0, _i18n.__)('Style Book'),
106
+ onClick: () => setEditorCanvasContainerView(!isStyleBookOpened ? 'style-book' : undefined),
107
+ isPressed: isStyleBookOpened
108
+ }), (0, _element.createElement)(_sidebarButton.default, {
47
109
  icon: _icons.edit,
48
110
  label: (0, _i18n.__)('Edit styles'),
49
- onClick: () => {
50
- // switch to edit mode.
51
- setCanvasMode('edit'); // open global styles sidebar.
52
-
53
- openGeneralSidebar('edit-site/global-styles');
54
- }
55
- })
56
- });
111
+ onClick: async () => await openGlobalStyles()
112
+ }))
113
+ }), isStyleBookOpened && !isMobileViewport && (0, _element.createElement)(_styleBook.default, {
114
+ enableResizing: false,
115
+ isSelected: () => false,
116
+ onClick: openStyleBook,
117
+ onSelect: openStyleBook,
118
+ showCloseButton: false,
119
+ showTabs: false
120
+ }));
57
121
  }
58
122
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js"],"names":["SidebarNavigationScreenGlobalStyles","openGeneralSidebar","editSiteStore","setCanvasMode","edit"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAKA;AACA;AACA;AAOe,SAASA,mCAAT,GAA+C;AAC7D,QAAM;AAAEC,IAAAA;AAAF,MAAyB,uBAAaC,YAAb,CAA/B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaD,YAAb,CAAR,CAA1B;AACA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAG,cAAI,QAAJ,CADT;AAEC,IAAA,WAAW,EAAG,cACb,4DADa,CAFf;AAKC,IAAA,OAAO,EAAG,4BAAC,iCAAD,OALX;AAMC,IAAA,OAAO,EACN,4BAAC,sBAAD;AACC,MAAA,IAAI,EAAGE,WADR;AAEC,MAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,MAAA,OAAO,EAAG,MAAM;AACf;AACAD,QAAAA,aAAa,CAAE,MAAF,CAAb,CAFe,CAGf;;AACAF,QAAAA,kBAAkB,CAAE,yBAAF,CAAlB;AACA;AARF;AAPF,IADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { edit } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport StyleVariationsContainer from '../global-styles/style-variations-container';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\n\nexport default function SidebarNavigationScreenGlobalStyles() {\n\tconst { openGeneralSidebar } = useDispatch( editSiteStore );\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Styles' ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Choose a different style combination for the theme styles.'\n\t\t\t) }\n\t\t\tcontent={ <StyleVariationsContainer /> }\n\t\t\tactions={\n\t\t\t\t<SidebarButton\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit styles' ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t// switch to edit mode.\n\t\t\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t\t\t\t// open global styles sidebar.\n\t\t\t\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js"],"names":["SidebarNavigationItemGlobalStyles","props","openGeneralSidebar","editSiteStore","setCanvasMode","hasGlobalStyleVariations","select","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","length","SidebarNavigationItem","SidebarNavigationScreenGlobalStyles","isMobileViewport","setEditorCanvasContainerView","isStyleBookOpened","getEditorCanvasContainerView","openGlobalStyles","Promise","all","openStyleBook","seen","undefined","edit"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAQA;AACA;AACA;AASO,SAASA,iCAAT,CAA4CC,KAA5C,EAAoD;AAC1D,QAAM;AAAEC,IAAAA;AAAF,MAAyB,uBAAaC,YAAb,CAA/B;AACA,QAAM;AAAEC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DACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAG,cAAI,QAAJ,CADT;AAEC,IAAA,WAAW,EAAG,cACb,4DADa,CAFf;AAKC,IAAA,OAAO,EAAG,4BAAC,iCAAD,OALX;AAMC,IAAA,OAAO,EACN,yCACG,CAAED,gBAAF,IACD,4BAAC,sBAAD;AACC,MAAA,IAAI,EAAGQ,WADR;AAEC,MAAA,KAAK,EAAG,cAAI,YAAJ,CAFT;AAGC,MAAA,OAAO,EAAG,MACTP,4BAA4B,CAC3B,CAAEC,iBAAF,GACG,YADH,GAEGO,SAHwB,CAJ9B;AAUC,MAAA,SAAS,EAAGP;AAVb,MAFF,EAeC,4BAAC,sBAAD;AACC,MAAA,IAAI,EAAGQ,WADR;AAEC,MAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,MAAA,OAAO,EAAG,YAAY,MAAMN,gBAAgB;AAH7C,MAfD;AAPF,IADD,EA+BGF,iBAAiB,IAAI,CAAEF,gBAAvB,IACD,4BAAC,kBAAD;AACC,IAAA,cAAc,EAAG,KADlB;AAEC,IAAA,UAAU,EAAG,MAAM,KAFpB;AAGC,IAAA,OAAO,EAAGO,aAHX;AAIC,IAAA,QAAQ,EAAGA,aAJZ;AAKC,IAAA,eAAe,EAAG,KALnB;AAMC,IAAA,QAAQ,EAAG;AANZ,IAhCF,CADD;AA4CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { edit, seen } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalNavigatorButton as NavigatorButton } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport StyleVariationsContainer from '../global-styles/style-variations-container';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport StyleBook from '../style-book';\n\nexport function SidebarNavigationItemGlobalStyles( props ) {\n\tconst { openGeneralSidebar } = useDispatch( editSiteStore );\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst hasGlobalStyleVariations = useSelect(\n\t\t( select ) =>\n\t\t\t!! select(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations()?.length,\n\t\t[]\n\t);\n\tif ( hasGlobalStyleVariations ) {\n\t\treturn (\n\t\t\t<NavigatorButton\n\t\t\t\t{ ...props }\n\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\tpath=\"/wp_global_styles\"\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<SidebarNavigationItem\n\t\t\t{ ...props }\n\t\t\tonClick={ () => {\n\t\t\t\t// switch to edit mode.\n\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t\t// open global styles sidebar.\n\t\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nexport default function SidebarNavigationScreenGlobalStyles() {\n\tconst { openGeneralSidebar } = useDispatch( editSiteStore );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { setCanvasMode, setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\n\tconst isStyleBookOpened = useSelect(\n\t\t( select ) =>\n\t\t\t'style-book' ===\n\t\t\tunlock( select( editSiteStore ) ).getEditorCanvasContainerView(),\n\t\t[]\n\t);\n\n\tconst openGlobalStyles = async () =>\n\t\tPromise.all( [\n\t\t\tsetCanvasMode( 'edit' ),\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' ),\n\t\t] );\n\n\tconst openStyleBook = async () => {\n\t\tawait openGlobalStyles();\n\t\t// Open the Style Book once the canvas mode is set to edit,\n\t\t// and the global styles sidebar is open. This ensures that\n\t\t// the Style Book is not prematurely closed.\n\t\tsetEditorCanvasContainerView( 'style-book' );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SidebarNavigationScreen\n\t\t\t\ttitle={ __( 'Styles' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Choose a different style combination for the theme styles.'\n\t\t\t\t) }\n\t\t\t\tcontent={ <StyleVariationsContainer /> }\n\t\t\t\tactions={\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\t\t\ticon={ seen }\n\t\t\t\t\t\t\t\tlabel={ __( 'Style Book' ) }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tsetEditorCanvasContainerView(\n\t\t\t\t\t\t\t\t\t\t! isStyleBookOpened\n\t\t\t\t\t\t\t\t\t\t\t? 'style-book'\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tisPressed={ isStyleBookOpened }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\t\tlabel={ __( 'Edit styles' ) }\n\t\t\t\t\t\t\tonClick={ async () => await openGlobalStyles() }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isStyleBookOpened && ! isMobileViewport && (\n\t\t\t\t<StyleBook\n\t\t\t\t\tenableResizing={ false }\n\t\t\t\t\tisSelected={ () => false }\n\t\t\t\t\tonClick={ openStyleBook }\n\t\t\t\t\tonSelect={ openStyleBook }\n\t\t\t\t\tshowCloseButton={ false }\n\t\t\t\t\tshowTabs={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -17,12 +17,18 @@ var _icons = require("@wordpress/icons");
17
17
 
18
18
  var _data = require("@wordpress/data");
19
19
 
20
- var _coreData = require("@wordpress/core-data");
21
-
22
20
  var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
23
21
 
24
22
  var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigation-item"));
25
23
 
24
+ var _sidebarNavigationScreenGlobalStyles = require("../sidebar-navigation-screen-global-styles");
25
+
26
+ var _privateApis = require("../../private-apis");
27
+
28
+ var _store = require("../../store");
29
+
30
+ var _navigatorButton = _interopRequireDefault(require("../sidebar-navigation-screen-navigation-menus/navigator-button"));
31
+
26
32
  /**
27
33
  * WordPress dependencies
28
34
  */
@@ -31,42 +37,27 @@ var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigati
31
37
  * Internal dependencies
32
38
  */
33
39
  function SidebarNavigationScreenMain() {
34
- const {
35
- hasNavigationMenus,
36
- hasGlobalStyleVariations
37
- } = (0, _data.useSelect)(select => {
38
- var _experimentalGetCurr;
39
-
40
- const {
41
- getEntityRecords,
42
- __experimentalGetCurrentThemeGlobalStylesVariations
43
- } = select(_coreData.store); // The query needs to be the same as in the "SidebarNavigationScreenNavigationMenus" component,
44
- // to avoid double network calls.
45
-
46
- const navigationMenus = getEntityRecords('postType', 'wp_navigation', {
47
- per_page: 1,
48
- status: 'publish',
49
- order: 'desc',
50
- orderby: 'date'
51
- });
52
- return {
53
- hasNavigationMenus: !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length),
54
- hasGlobalStyleVariations: !!((_experimentalGetCurr = __experimentalGetCurrentThemeGlobalStylesVariations()) !== null && _experimentalGetCurr !== void 0 && _experimentalGetCurr.length)
55
- };
40
+ const editorCanvasContainerView = (0, _data.useSelect)(select => {
41
+ return (0, _privateApis.unlock)(select(_store.store)).getEditorCanvasContainerView();
56
42
  }, []);
57
- const showNavigationScreen = process.env.IS_GUTENBERG_PLUGIN ? hasNavigationMenus : false;
43
+ const {
44
+ setEditorCanvasContainerView
45
+ } = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store)); // Clear the editor canvas container view when accessing the main navigation screen.
46
+
47
+ (0, _element.useEffect)(() => {
48
+ if (editorCanvasContainerView) {
49
+ setEditorCanvasContainerView(undefined);
50
+ }
51
+ }, [editorCanvasContainerView, setEditorCanvasContainerView]);
58
52
  return (0, _element.createElement)(_sidebarNavigationScreen.default, {
59
53
  isRoot: true,
60
54
  title: (0, _i18n.__)('Design'),
61
55
  description: (0, _i18n.__)('Customize the appearance of your website using the block editor.'),
62
- content: (0, _element.createElement)(_components.__experimentalItemGroup, null, showNavigationScreen && (0, _element.createElement)(_components.__experimentalNavigatorButton, {
63
- as: _sidebarNavigationItem.default,
64
- path: "/navigation",
56
+ content: (0, _element.createElement)(_components.__experimentalItemGroup, null, (0, _element.createElement)(_navigatorButton.default, {
65
57
  withChevron: true,
66
- icon: _icons.navigation
67
- }, (0, _i18n.__)('Navigation')), hasGlobalStyleVariations && (0, _element.createElement)(_components.__experimentalNavigatorButton, {
68
- as: _sidebarNavigationItem.default,
69
- path: "/wp_global_styles",
58
+ icon: _icons.navigation,
59
+ as: _sidebarNavigationItem.default
60
+ }, (0, _i18n.__)('Navigation')), (0, _element.createElement)(_sidebarNavigationScreenGlobalStyles.SidebarNavigationItemGlobalStyles, {
70
61
  withChevron: true,
71
62
  icon: _icons.styles
72
63
  }, (0, _i18n.__)('Styles')), (0, _element.createElement)(_components.__experimentalNavigatorButton, {
@@ -84,7 +75,7 @@ function SidebarNavigationScreenMain() {
84
75
  path: "/wp_template_part",
85
76
  withChevron: true,
86
77
  icon: _icons.symbol
87
- }, (0, _i18n.__)('Template Parts')))
78
+ }, (0, _i18n.__)('Library')))
88
79
  });
89
80
  }
90
81
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["SidebarNavigationScreenMain","hasNavigationMenus","hasGlobalStyleVariations","select","getEntityRecords","__experimentalGetCurrentThemeGlobalStylesVariations","coreStore","navigationMenus","per_page","status","order","orderby","length","showNavigationScreen","process","env","IS_GUTENBERG_PLUGIN","SidebarNavigationItem","navigation","styles","page","layout","symbol"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIe,SAASA,2BAAT,GAAuC;AACrD,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAAmD,qBACtDC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,gBADK;AAELC,MAAAA;AAFK,QAGFF,MAAM,CAAEG,eAAF,CAHV,CADa,CAKb;AACA;;AACA,UAAMC,eAAe,GAAGH,gBAAgB,CACvC,UADuC,EAEvC,eAFuC,EAGvC;AACCI,MAAAA,QAAQ,EAAE,CADX;AAECC,MAAAA,MAAM,EAAE,SAFT;AAGCC,MAAAA,KAAK,EAAE,MAHR;AAICC,MAAAA,OAAO,EAAE;AAJV,KAHuC,CAAxC;AAUA,WAAO;AACNV,MAAAA,kBAAkB,EAAE,CAAC,EAAEM,eAAF,aAAEA,eAAF,eAAEA,eAAe,CAAEK,MAAnB,CADf;AAENV,MAAAA,wBAAwB,EACvB,CAAC,0BAAEG,mDAAmD,EAArD,iDAAE,qBACAO,MADF;AAHI,KAAP;AAMA,GAxBuD,EAyBxD,EAzBwD,CAAzD;AA2BA,QAAMC,oBAAoB,GAAGC,OAAO,CAACC,GAAR,CAAYC,mBAAZ,GAC1Bf,kBAD0B,GAE1B,KAFH;AAGA,SACC,4BAAC,gCAAD;AACC,IAAA,MAAM,MADP;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,WAAW,EAAG,cACb,kEADa,CAHf;AAMC,IAAA,OAAO,EACN,4BAAC,mCAAD,QACGY,oBAAoB,IACrB,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGI,8BADN;AAEC,MAAA,IAAI,EAAC,aAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGC;AAJR,OAMG,cAAI,YAAJ,CANH,CAFF,EAWGhB,wBAAwB,IACzB,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGe,8BADN;AAEC,MAAA,IAAI,EAAC,mBAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGE;AAJR,OAMG,cAAI,QAAJ,CANH,CAZF,EAsBC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGF,8BADN;AAEC,MAAA,IAAI,EAAC,OAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGG;AAJR,OAMG,cAAI,OAAJ,CANH,CAtBD,EA8BC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGH,8BADN;AAEC,MAAA,IAAI,EAAC,cAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGI;AAJR,OAMG,cAAI,WAAJ,CANH,CA9BD,EAsCC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGJ,8BADN;AAEC,MAAA,IAAI,EAAC,mBAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGK;AAJR,OAMG,cAAI,gBAAJ,CANH,CAtCD;AAPF,IADD;AA0DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalNavigatorButton as NavigatorButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { layout, symbol, navigation, styles, page } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\n\nexport default function SidebarNavigationScreenMain() {\n\tconst { hasNavigationMenus, hasGlobalStyleVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecords,\n\t\t\t\t__experimentalGetCurrentThemeGlobalStylesVariations,\n\t\t\t} = select( coreStore );\n\t\t\t// The query needs to be the same as in the \"SidebarNavigationScreenNavigationMenus\" component,\n\t\t\t// to avoid double network calls.\n\t\t\tconst navigationMenus = getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\t{\n\t\t\t\t\tper_page: 1,\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\torder: 'desc',\n\t\t\t\t\torderby: 'date',\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn {\n\t\t\t\thasNavigationMenus: !! navigationMenus?.length,\n\t\t\t\thasGlobalStyleVariations:\n\t\t\t\t\t!! __experimentalGetCurrentThemeGlobalStylesVariations()\n\t\t\t\t\t\t?.length,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst showNavigationScreen = process.env.IS_GUTENBERG_PLUGIN\n\t\t? hasNavigationMenus\n\t\t: false;\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot\n\t\t\ttitle={ __( 'Design' ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Customize the appearance of your website using the block editor.'\n\t\t\t) }\n\t\t\tcontent={\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t{ showNavigationScreen && (\n\t\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\t\tpath=\"/navigation\"\n\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\ticon={ navigation }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Navigation' ) }\n\t\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t) }\n\t\t\t\t\t{ hasGlobalStyleVariations && (\n\t\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\t\tpath=\"/wp_global_styles\"\n\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\ticon={ styles }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Styles' ) }\n\t\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/page\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ page }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Pages' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Templates' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template_part\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template Parts' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t</ItemGroup>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["SidebarNavigationScreenMain","editorCanvasContainerView","select","editSiteStore","getEditorCanvasContainerView","setEditorCanvasContainerView","undefined","navigation","SidebarNavigationItem","styles","page","layout","symbol"],"mappings":";;;;;;;;;AAWA;;AARA;;AAIA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AAWA;AACA;AACA;AAQe,SAASA,2BAAT,GAAuC;AACrD,QAAMC,yBAAyB,GAAG,qBAAaC,MAAF,IAAc;AAC1D,WAAO,yBAAQA,MAAM,CAAEC,YAAF,CAAd,EAAkCC,4BAAlC,EAAP;AACA,GAFiC,EAE/B,EAF+B,CAAlC;AAIA,QAAM;AAAEC,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avigatorButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { layout, symbol, navigation, styles, page } from '@wordpress/icons';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { SidebarNavigationItemGlobalStyles } from '../sidebar-navigation-screen-global-styles';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport SidebarNavigationScreenNavigationMenuButton from '../sidebar-navigation-screen-navigation-menus/navigator-button';\n\nexport default function SidebarNavigationScreenMain() {\n\tconst editorCanvasContainerView = useSelect( ( select ) => {\n\t\treturn unlock( select( editSiteStore ) ).getEditorCanvasContainerView();\n\t}, [] );\n\n\tconst { setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\n\t// Clear the editor canvas container view when accessing the main navigation screen.\n\tuseEffect( () => {\n\t\tif ( editorCanvasContainerView ) {\n\t\t\tsetEditorCanvasContainerView( undefined );\n\t\t}\n\t}, [ editorCanvasContainerView, setEditorCanvasContainerView ] );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot\n\t\t\ttitle={ __( 'Design' ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Customize the appearance of your website using the block editor.'\n\t\t\t) }\n\t\t\tcontent={\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<SidebarNavigationScreenNavigationMenuButton\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ navigation }\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Navigation' ) }\n\t\t\t\t\t</SidebarNavigationScreenNavigationMenuButton>\n\n\t\t\t\t\t<SidebarNavigationItemGlobalStyles\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ styles }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Styles' ) }\n\t\t\t\t\t</SidebarNavigationItemGlobalStyles>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/page\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ page }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Pages' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Templates' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template_part\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Library' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t</ItemGroup>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = SidebarNavigationScreenNavigationMenu;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _coreData = require("@wordpress/core-data");
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _i18n = require("@wordpress/i18n");
17
+
18
+ var _data = require("@wordpress/data");
19
+
20
+ var _router = require("@wordpress/router");
21
+
22
+ var _blockEditor = require("@wordpress/block-editor");
23
+
24
+ var _blocks = require("@wordpress/blocks");
25
+
26
+ var _htmlEntities = require("@wordpress/html-entities");
27
+
28
+ var _privateApis = require("../../private-apis");
29
+
30
+ var _store = require("../../store");
31
+
32
+ var _isPreviewingTheme = require("../../utils/is-previewing-theme");
33
+
34
+ var _sidebarNavigationScreenNavigationMenus = require("../sidebar-navigation-screen-navigation-menus");
35
+
36
+ var _navigationMenuContent = _interopRequireDefault(require("../sidebar-navigation-screen-navigation-menus/navigation-menu-content"));
37
+
38
+ /**
39
+ * WordPress dependencies
40
+ */
41
+
42
+ /**
43
+ * Internal dependencies
44
+ */
45
+ const {
46
+ useHistory
47
+ } = (0, _privateApis.unlock)(_router.privateApis);
48
+
49
+ const noop = () => {};
50
+
51
+ function SidebarNavigationScreenNavigationMenu() {
52
+ var _navigationMenu$title, _navigationMenu$conte;
53
+
54
+ const postType = `wp_navigation`;
55
+ const {
56
+ params: {
57
+ postId
58
+ }
59
+ } = (0, _components.__experimentalUseNavigator)();
60
+ const {
61
+ record: navigationMenu,
62
+ isResolving: isLoading
63
+ } = (0, _coreData.useEntityRecord)('postType', postType, postId);
64
+ const menuTitle = (navigationMenu === null || navigationMenu === void 0 ? void 0 : (_navigationMenu$title = navigationMenu.title) === null || _navigationMenu$title === void 0 ? void 0 : _navigationMenu$title.rendered) || (navigationMenu === null || navigationMenu === void 0 ? void 0 : navigationMenu.slug);
65
+
66
+ if (isLoading) {
67
+ return (0, _element.createElement)(_sidebarNavigationScreenNavigationMenus.SidebarNavigationScreenWrapper, {
68
+ description: (0, _i18n.__)('Navigation menus are a curated collection of blocks that allow visitors to get around your site.')
69
+ }, (0, _element.createElement)(_components.Spinner, {
70
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__loading"
71
+ }));
72
+ }
73
+
74
+ if (!isLoading && !navigationMenu) {
75
+ return (0, _element.createElement)(_sidebarNavigationScreenNavigationMenus.SidebarNavigationScreenWrapper, {
76
+ description: (0, _i18n.__)('Navigation Menu missing.')
77
+ });
78
+ }
79
+
80
+ if (!(navigationMenu !== null && navigationMenu !== void 0 && (_navigationMenu$conte = navigationMenu.content) !== null && _navigationMenu$conte !== void 0 && _navigationMenu$conte.raw)) {
81
+ return (0, _element.createElement)(_sidebarNavigationScreenNavigationMenus.SidebarNavigationScreenWrapper, {
82
+ title: (0, _htmlEntities.decodeEntities)(menuTitle),
83
+ description: (0, _i18n.__)('This Navigation Menu is empty.')
84
+ });
85
+ }
86
+
87
+ return (0, _element.createElement)(_sidebarNavigationScreenNavigationMenus.SidebarNavigationScreenWrapper, {
88
+ title: (0, _htmlEntities.decodeEntities)(menuTitle),
89
+ description: (0, _i18n.__)('Navigation menus are a curated collection of blocks that allow visitors to get around your site.')
90
+ }, (0, _element.createElement)(NavigationMenuEditor, {
91
+ navigationMenu: navigationMenu
92
+ }));
93
+ }
94
+
95
+ function NavigationMenuEditor(_ref) {
96
+ let {
97
+ navigationMenu
98
+ } = _ref;
99
+ const history = useHistory();
100
+ const onSelect = (0, _element.useCallback)(selectedBlock => {
101
+ const {
102
+ attributes,
103
+ name
104
+ } = selectedBlock;
105
+
106
+ if (attributes.kind === 'post-type' && attributes.id && attributes.type && history) {
107
+ history.push({
108
+ postType: attributes.type,
109
+ postId: attributes.id,
110
+ ...((0, _isPreviewingTheme.isPreviewingTheme)() && {
111
+ theme_preview: (0, _isPreviewingTheme.currentlyPreviewingTheme)()
112
+ })
113
+ });
114
+ }
115
+
116
+ if (name === 'core/page-list-item' && attributes.id && history) {
117
+ history.push({
118
+ postType: 'page',
119
+ postId: attributes.id,
120
+ ...((0, _isPreviewingTheme.isPreviewingTheme)() && {
121
+ theme_preview: (0, _isPreviewingTheme.currentlyPreviewingTheme)()
122
+ })
123
+ });
124
+ }
125
+ }, [history]);
126
+ const {
127
+ storedSettings
128
+ } = (0, _data.useSelect)(select => {
129
+ const {
130
+ getSettings
131
+ } = (0, _privateApis.unlock)(select(_store.store));
132
+ return {
133
+ storedSettings: getSettings(false)
134
+ };
135
+ }, []);
136
+ const blocks = (0, _element.useMemo)(() => {
137
+ if (!NavigationMenuEditor) {
138
+ return [];
139
+ }
140
+
141
+ return [(0, _blocks.createBlock)('core/navigation', {
142
+ ref: navigationMenu === null || navigationMenu === void 0 ? void 0 : navigationMenu.id
143
+ })];
144
+ }, [navigationMenu]);
145
+
146
+ if (!navigationMenu || !(blocks !== null && blocks !== void 0 && blocks.length)) {
147
+ return null;
148
+ }
149
+
150
+ return (0, _element.createElement)(_blockEditor.BlockEditorProvider, {
151
+ settings: storedSettings,
152
+ value: blocks,
153
+ onChange: noop,
154
+ onInput: noop
155
+ }, (0, _element.createElement)("div", {
156
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__content"
157
+ }, (0, _element.createElement)(_navigationMenuContent.default, {
158
+ rootClientId: blocks[0].clientId,
159
+ onSelect: onSelect
160
+ })));
161
+ }
162
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js"],"names":["useHistory","routerPrivateApis","noop","SidebarNavigationScreenNavigationMenu","postType","params","postId","record","navigationMenu","isResolving","isLoading","menuTitle","title","rendered","slug","content","raw","NavigationMenuEditor","history","onSelect","selectedBlock","attributes","name","kind","id","type","push","theme_preview","storedSettings","select","getSettings","editSiteStore","blocks","ref","length","clientId"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AA1BA;AACA;AACA;;AAcA;AACA;AACA;AAUA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,yBAAQC,mBAAR,CAAvB;;AACA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEe,SAASC,qCAAT,GAAiD;AAAA;;AAC/D,QAAMC,QAAQ,GAAI,eAAlB;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADH,MAEF,6CAFJ;AAIA,QAAM;AAAEC,IAAAA,MAAM,EAAEC,cAAV;AAA0BC,IAAAA,WAAW,EAAEC;AAAvC,MAAqD,+BAC1D,UAD0D,EAE1DN,QA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,EAAGN,cADZ;AAEC,IAAA,KAAK,EAAGI,MAFT;AAGC,IAAA,QAAQ,EAAG9B,IAHZ;AAIC,IAAA,OAAO,EAAGA;AAJX,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,8BAAD;AACC,IAAA,YAAY,EAAG8B,MAAM,CAAE,CAAF,CAAN,CAAYG,QAD5B;AAEC,IAAA,QAAQ,EAAGhB;AAFZ,IADD,CAND,CADD;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityRecord } from '@wordpress/core-data';\nimport {\n\t__experimentalUseNavigator as useNavigator,\n\tSpinner,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { BlockEditorProvider } from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from '../../utils/is-previewing-theme';\nimport { SidebarNavigationScreenWrapper } from '../sidebar-navigation-screen-navigation-menus';\nimport NavigationMenuContent from '../sidebar-navigation-screen-navigation-menus/navigation-menu-content';\n\nconst { useHistory } = unlock( routerPrivateApis );\nconst noop = () => {};\n\nexport default function SidebarNavigationScreenNavigationMenu() {\n\tconst postType = `wp_navigation`;\n\tconst {\n\t\tparams: { postId },\n\t} = useNavigator();\n\n\tconst { record: navigationMenu, isResolving: isLoading } = useEntityRecord(\n\t\t'postType',\n\t\tpostType,\n\t\tpostId\n\t);\n\n\tconst menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug;\n\n\tif ( isLoading ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Navigation menus are a curated collection of blocks that allow visitors to get around your site.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t<Spinner className=\"edit-site-sidebar-navigation-screen-navigation-menus__loading\" />\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t);\n\t}\n\n\tif ( ! isLoading && ! navigationMenu ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper\n\t\t\t\tdescription={ __( 'Navigation Menu missing.' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( ! navigationMenu?.content?.raw ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper\n\t\t\t\ttitle={ decodeEntities( menuTitle ) }\n\t\t\t\tdescription={ __( 'This Navigation Menu is empty.' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreenWrapper\n\t\t\ttitle={ decodeEntities( menuTitle ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Navigation menus are a curated collection of blocks that allow visitors to get around your site.'\n\t\t\t) }\n\t\t>\n\t\t\t<NavigationMenuEditor navigationMenu={ navigationMenu } />\n\t\t</SidebarNavigationScreenWrapper>\n\t);\n}\n\nfunction NavigationMenuEditor( { navigationMenu } ) {\n\tconst history = useHistory();\n\n\tconst onSelect = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes, name } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\ttheme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( name === 'core/page-list-item' && attributes.id && history ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: 'page',\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\ttheme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tconst { storedSettings } = useSelect( ( select ) => {\n\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\n\t\treturn {\n\t\t\tstoredSettings: getSettings( false ),\n\t\t};\n\t}, [] );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( ! NavigationMenuEditor ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\tcreateBlock( 'core/navigation', { ref: navigationMenu?.id } ),\n\t\t];\n\t}, [ navigationMenu ] );\n\n\tif ( ! navigationMenu || ! blocks?.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ storedSettings }\n\t\t\tvalue={ blocks }\n\t\t\tonChange={ noop }\n\t\t\tonInput={ noop }\n\t\t>\n\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus__content\">\n\t\t\t\t<NavigationMenuContent\n\t\t\t\t\trootClientId={ blocks[ 0 ].clientId }\n\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PRELOADED_NAVIGATION_MENUS_QUERY = void 0;
7
+ // This requested is preloaded in `gutenberg_preload_navigation_posts`.
8
+ // As unbounded queries are limited to 100 by `fetchAllMiddleware`
9
+ // on apiFetch this query is limited to 100.
10
+ const PRELOADED_NAVIGATION_MENUS_QUERY = {
11
+ per_page: 100,
12
+ status: 'publish',
13
+ order: 'desc',
14
+ orderby: 'date'
15
+ };
16
+ exports.PRELOADED_NAVIGATION_MENUS_QUERY = PRELOADED_NAVIGATION_MENUS_QUERY;
17
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/constants.js"],"names":["PRELOADED_NAVIGATION_MENUS_QUERY","per_page","status","order","orderby"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,MAAMA,gCAAgC,GAAG;AAC/CC,EAAAA,QAAQ,EAAE,GADqC;AAE/CC,EAAAA,MAAM,EAAE,SAFuC;AAG/CC,EAAAA,KAAK,EAAE,MAHwC;AAI/CC,EAAAA,OAAO,EAAE;AAJsC,CAAzC","sourcesContent":["// This requested is preloaded in `gutenberg_preload_navigation_posts`.\n// As unbounded queries are limited to 100 by `fetchAllMiddleware`\n// on apiFetch this query is limited to 100.\nexport const PRELOADED_NAVIGATION_MENUS_QUERY = {\n\tper_page: 100,\n\tstatus: 'publish',\n\torder: 'desc',\n\torderby: 'date',\n};\n"]}