@wordpress/edit-site 3.0.14 → 3.0.18-next.33ec3857e2.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/build/components/add-new-template/new-template-part.js +29 -18
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +30 -23
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/app/index.js +51 -0
  6. package/build/components/app/index.js.map +1 -0
  7. package/build/components/block-editor/back-button.js +8 -20
  8. package/build/components/block-editor/back-button.js.map +1 -1
  9. package/build/components/block-editor/index.js +2 -1
  10. package/build/components/block-editor/index.js.map +1 -1
  11. package/build/components/block-editor/resizable-editor.js +1 -0
  12. package/build/components/block-editor/resizable-editor.js.map +1 -1
  13. package/build/components/create-template-part-modal/index.js +0 -2
  14. package/build/components/create-template-part-modal/index.js.map +1 -1
  15. package/build/components/edit-template-part-menu-button/index.js +20 -8
  16. package/build/components/edit-template-part-menu-button/index.js.map +1 -1
  17. package/build/components/editor/index.js +11 -30
  18. package/build/components/editor/index.js.map +1 -1
  19. package/build/components/global-styles/border-panel.js +81 -22
  20. package/build/components/global-styles/border-panel.js.map +1 -1
  21. package/build/components/global-styles/gradients-palette-panel.js +10 -10
  22. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  23. package/build/components/global-styles/screen-background-color.js +9 -10
  24. package/build/components/global-styles/screen-background-color.js.map +1 -1
  25. package/build/components/global-styles/screen-colors.js +1 -1
  26. package/build/components/global-styles/screen-colors.js.map +1 -1
  27. package/build/components/global-styles/screen-link-color.js +6 -10
  28. package/build/components/global-styles/screen-link-color.js.map +1 -1
  29. package/build/components/global-styles/screen-root.js +8 -2
  30. package/build/components/global-styles/screen-root.js.map +1 -1
  31. package/build/components/global-styles/screen-text-color.js +6 -10
  32. package/build/components/global-styles/screen-text-color.js.map +1 -1
  33. package/build/components/global-styles/ui.js +27 -14
  34. package/build/components/global-styles/ui.js.map +1 -1
  35. package/build/components/global-styles/use-global-styles-output.js +1 -2
  36. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  37. package/build/components/header/document-actions/index.js +3 -6
  38. package/build/components/header/document-actions/index.js.map +1 -1
  39. package/build/components/list/actions/index.js +1 -0
  40. package/build/components/list/actions/index.js.map +1 -1
  41. package/build/components/list/index.js +17 -15
  42. package/build/components/list/index.js.map +1 -1
  43. package/build/components/list/table.js +4 -4
  44. package/build/components/list/table.js.map +1 -1
  45. package/build/components/navigation-sidebar/index.js +12 -13
  46. package/build/components/navigation-sidebar/index.js.map +1 -1
  47. package/build/components/navigation-sidebar/navigation-panel/index.js +26 -24
  48. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  49. package/build/components/navigation-sidebar/navigation-toggle/index.js +3 -1
  50. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  51. package/build/components/routes/index.js +60 -0
  52. package/build/components/routes/index.js.map +1 -0
  53. package/build/components/routes/link.js +65 -0
  54. package/build/components/routes/link.js.map +1 -0
  55. package/build/components/routes/use-title.js +57 -0
  56. package/build/components/routes/use-title.js.map +1 -0
  57. package/build/components/sidebar/default-sidebar.js +4 -2
  58. package/build/components/sidebar/default-sidebar.js.map +1 -1
  59. package/build/components/sidebar/global-styles-sidebar.js +11 -0
  60. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  61. package/build/components/sidebar/template-card/template-areas.js +7 -4
  62. package/build/components/sidebar/template-card/template-areas.js.map +1 -1
  63. package/build/components/template-details/index.js +12 -10
  64. package/build/components/template-details/index.js.map +1 -1
  65. package/build/components/template-details/template-areas.js +27 -10
  66. package/build/components/template-details/template-areas.js.map +1 -1
  67. package/build/components/template-part-converter/convert-to-template-part.js +7 -12
  68. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  69. package/build/components/url-query-controller/index.js +41 -50
  70. package/build/components/url-query-controller/index.js.map +1 -1
  71. package/build/components/welcome-guide/editor.js +6 -0
  72. package/build/components/welcome-guide/editor.js.map +1 -1
  73. package/build/components/welcome-guide/index.js +1 -28
  74. package/build/components/welcome-guide/index.js.map +1 -1
  75. package/build/components/welcome-guide/styles.js +18 -1
  76. package/build/components/welcome-guide/styles.js.map +1 -1
  77. package/build/index.js +29 -35
  78. package/build/index.js.map +1 -1
  79. package/build/plugins/index.js +3 -23
  80. package/build/plugins/index.js.map +1 -1
  81. package/build/plugins/site-export.js +67 -0
  82. package/build/plugins/site-export.js.map +1 -0
  83. package/build/plugins/welcome-guide-menu-item.js +1 -7
  84. package/build/plugins/welcome-guide-menu-item.js.map +1 -1
  85. package/build/store/actions.js +0 -27
  86. package/build/store/actions.js.map +1 -1
  87. package/build/store/constants.js +1 -14
  88. package/build/store/constants.js.map +1 -1
  89. package/build/store/reducer.js +7 -16
  90. package/build/store/reducer.js.map +1 -1
  91. package/build/store/selectors.js +1 -31
  92. package/build/store/selectors.js.map +1 -1
  93. package/build/utils/get-is-list-page.js +23 -0
  94. package/build/utils/get-is-list-page.js.map +1 -0
  95. package/build/utils/history.js +35 -0
  96. package/build/utils/history.js.map +1 -0
  97. package/build-module/components/add-new-template/new-template-part.js +27 -16
  98. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  99. package/build-module/components/add-new-template/new-template.js +28 -18
  100. package/build-module/components/add-new-template/new-template.js.map +1 -1
  101. package/build-module/components/app/index.js +35 -0
  102. package/build-module/components/app/index.js.map +1 -0
  103. package/build-module/components/block-editor/back-button.js +8 -19
  104. package/build-module/components/block-editor/back-button.js.map +1 -1
  105. package/build-module/components/block-editor/index.js +2 -1
  106. package/build-module/components/block-editor/index.js.map +1 -1
  107. package/build-module/components/block-editor/resizable-editor.js +1 -0
  108. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  109. package/build-module/components/create-template-part-modal/index.js +0 -2
  110. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  111. package/build-module/components/edit-template-part-menu-button/index.js +17 -9
  112. package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
  113. package/build-module/components/editor/index.js +13 -33
  114. package/build-module/components/editor/index.js.map +1 -1
  115. package/build-module/components/global-styles/border-panel.js +82 -23
  116. package/build-module/components/global-styles/border-panel.js.map +1 -1
  117. package/build-module/components/global-styles/gradients-palette-panel.js +10 -10
  118. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  119. package/build-module/components/global-styles/screen-background-color.js +9 -11
  120. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  121. package/build-module/components/global-styles/screen-colors.js +1 -1
  122. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  123. package/build-module/components/global-styles/screen-link-color.js +7 -11
  124. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  125. package/build-module/components/global-styles/screen-root.js +9 -4
  126. package/build-module/components/global-styles/screen-root.js.map +1 -1
  127. package/build-module/components/global-styles/screen-text-color.js +7 -11
  128. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  129. package/build-module/components/global-styles/ui.js +26 -14
  130. package/build-module/components/global-styles/ui.js.map +1 -1
  131. package/build-module/components/global-styles/use-global-styles-output.js +1 -2
  132. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  133. package/build-module/components/header/document-actions/index.js +3 -6
  134. package/build-module/components/header/document-actions/index.js.map +1 -1
  135. package/build-module/components/list/actions/index.js +1 -0
  136. package/build-module/components/list/actions/index.js.map +1 -1
  137. package/build-module/components/list/index.js +15 -15
  138. package/build-module/components/list/index.js.map +1 -1
  139. package/build-module/components/list/table.js +4 -4
  140. package/build-module/components/list/table.js.map +1 -1
  141. package/build-module/components/navigation-sidebar/index.js +13 -13
  142. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  143. package/build-module/components/navigation-sidebar/navigation-panel/index.js +24 -24
  144. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  145. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +3 -1
  146. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  147. package/build-module/components/routes/index.js +47 -0
  148. package/build-module/components/routes/index.js.map +1 -0
  149. package/build-module/components/routes/link.js +51 -0
  150. package/build-module/components/routes/link.js.map +1 -0
  151. package/build-module/components/routes/use-title.js +44 -0
  152. package/build-module/components/routes/use-title.js.map +1 -0
  153. package/build-module/components/sidebar/default-sidebar.js +4 -2
  154. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  155. package/build-module/components/sidebar/global-styles-sidebar.js +9 -0
  156. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  157. package/build-module/components/sidebar/template-card/template-areas.js +8 -4
  158. package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
  159. package/build-module/components/template-details/index.js +10 -9
  160. package/build-module/components/template-details/index.js.map +1 -1
  161. package/build-module/components/template-details/template-areas.js +24 -9
  162. package/build-module/components/template-details/template-areas.js.map +1 -1
  163. package/build-module/components/template-part-converter/convert-to-template-part.js +7 -12
  164. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  165. package/build-module/components/url-query-controller/index.js +40 -49
  166. package/build-module/components/url-query-controller/index.js.map +1 -1
  167. package/build-module/components/welcome-guide/editor.js +7 -1
  168. package/build-module/components/welcome-guide/editor.js.map +1 -1
  169. package/build-module/components/welcome-guide/index.js +2 -26
  170. package/build-module/components/welcome-guide/index.js.map +1 -1
  171. package/build-module/components/welcome-guide/styles.js +18 -2
  172. package/build-module/components/welcome-guide/styles.js.map +1 -1
  173. package/build-module/index.js +28 -33
  174. package/build-module/index.js.map +1 -1
  175. package/build-module/plugins/index.js +2 -18
  176. package/build-module/plugins/index.js.map +1 -1
  177. package/build-module/plugins/site-export.js +51 -0
  178. package/build-module/plugins/site-export.js.map +1 -0
  179. package/build-module/plugins/welcome-guide-menu-item.js +2 -7
  180. package/build-module/plugins/welcome-guide-menu-item.js.map +1 -1
  181. package/build-module/store/actions.js +0 -23
  182. package/build-module/store/actions.js.map +1 -1
  183. package/build-module/store/constants.js +0 -11
  184. package/build-module/store/constants.js.map +1 -1
  185. package/build-module/store/reducer.js +7 -16
  186. package/build-module/store/reducer.js.map +1 -1
  187. package/build-module/store/selectors.js +1 -27
  188. package/build-module/store/selectors.js.map +1 -1
  189. package/build-module/utils/get-is-list-page.js +16 -0
  190. package/build-module/utils/get-is-list-page.js.map +1 -0
  191. package/build-module/utils/history.js +25 -0
  192. package/build-module/utils/history.js.map +1 -0
  193. package/build-style/style-rtl.css +36 -61
  194. package/build-style/style.css +36 -61
  195. package/package.json +29 -28
  196. package/src/components/add-new-template/new-template-part.js +29 -11
  197. package/src/components/add-new-template/new-template.js +26 -12
  198. package/src/components/app/index.js +47 -0
  199. package/src/components/block-editor/back-button.js +6 -14
  200. package/src/components/block-editor/index.js +1 -0
  201. package/src/components/block-editor/resizable-editor.js +1 -0
  202. package/src/components/block-editor/style.scss +10 -18
  203. package/src/components/create-template-part-modal/index.js +0 -2
  204. package/src/components/edit-template-part-menu-button/index.js +16 -5
  205. package/src/components/editor/index.js +105 -131
  206. package/src/components/global-styles/border-panel.js +106 -42
  207. package/src/components/global-styles/gradients-palette-panel.js +12 -12
  208. package/src/components/global-styles/screen-background-color.js +7 -10
  209. package/src/components/global-styles/screen-colors.js +1 -1
  210. package/src/components/global-styles/screen-link-color.js +6 -14
  211. package/src/components/global-styles/screen-root.js +17 -7
  212. package/src/components/global-styles/screen-text-color.js +6 -14
  213. package/src/components/global-styles/style.scss +6 -17
  214. package/src/components/global-styles/test/use-global-styles-output.js +7 -1
  215. package/src/components/global-styles/ui.js +50 -25
  216. package/src/components/global-styles/use-global-styles-output.js +0 -1
  217. package/src/components/header/document-actions/index.js +3 -9
  218. package/src/components/header/document-actions/style.scss +1 -9
  219. package/src/components/header/style.scss +2 -1
  220. package/src/components/list/actions/index.js +1 -0
  221. package/src/components/list/index.js +11 -12
  222. package/src/components/list/style.scss +6 -11
  223. package/src/components/list/table.js +5 -5
  224. package/src/components/navigation-sidebar/index.js +18 -17
  225. package/src/components/navigation-sidebar/navigation-panel/index.js +16 -22
  226. package/src/components/navigation-sidebar/navigation-toggle/index.js +2 -0
  227. package/src/components/routes/index.js +53 -0
  228. package/src/components/routes/link.js +44 -0
  229. package/src/components/routes/use-title.js +56 -0
  230. package/src/components/sidebar/default-sidebar.js +2 -0
  231. package/src/components/sidebar/global-styles-sidebar.js +9 -0
  232. package/src/components/sidebar/style.scss +21 -14
  233. package/src/components/sidebar/template-card/template-areas.js +16 -4
  234. package/src/components/template-details/index.js +8 -6
  235. package/src/components/template-details/template-areas.js +31 -8
  236. package/src/components/template-part-converter/convert-to-template-part.js +4 -2
  237. package/src/components/url-query-controller/index.js +34 -45
  238. package/src/components/welcome-guide/editor.js +10 -1
  239. package/src/components/welcome-guide/index.js +6 -25
  240. package/src/components/welcome-guide/styles.js +20 -2
  241. package/src/index.js +33 -36
  242. package/src/plugins/index.js +2 -32
  243. package/src/plugins/site-export.js +52 -0
  244. package/src/plugins/welcome-guide-menu-item.js +2 -16
  245. package/src/store/actions.js +0 -23
  246. package/src/store/constants.js +0 -12
  247. package/src/store/reducer.js +12 -26
  248. package/src/store/selectors.js +1 -27
  249. package/src/store/test/reducer.js +22 -39
  250. package/src/store/test/selectors.js +3 -34
  251. package/src/utils/get-is-list-page.js +11 -0
  252. package/src/utils/history.js +35 -0
package/build/index.js CHANGED
@@ -36,7 +36,6 @@ Object.defineProperty(exports, "__experimentalNavigationToggle", {
36
36
  }
37
37
  });
38
38
  exports.initializeEditor = initializeEditor;
39
- exports.initializeList = initializeList;
40
39
  exports.reinitializeEditor = reinitializeEditor;
41
40
 
42
41
  var _element = require("@wordpress/element");
@@ -53,15 +52,17 @@ var _editor = require("@wordpress/editor");
53
52
 
54
53
  var _viewport = require("@wordpress/viewport");
55
54
 
55
+ var _url = require("@wordpress/url");
56
+
56
57
  require("./plugins");
57
58
 
58
59
  require("./hooks");
59
60
 
60
61
  var _store = require("./store");
61
62
 
62
- var _editor2 = _interopRequireDefault(require("./components/editor"));
63
+ var _app = _interopRequireDefault(require("./components/app"));
63
64
 
64
- var _list = _interopRequireDefault(require("./components/list"));
65
+ var _getIsListPage = _interopRequireDefault(require("./utils/get-is-list-page"));
65
66
 
66
67
  var _mainDashboardButton = _interopRequireDefault(require("./components/main-dashboard-button"));
67
68
 
@@ -90,11 +91,31 @@ var _pluginMoreMenuItem = _interopRequireDefault(require("./components/header/pl
90
91
  * @param {?Object} settings Editor settings object.
91
92
  */
92
93
  function reinitializeEditor(target, settings) {
94
+ // This will be a no-op if the target doesn't have any React nodes.
93
95
  (0, _element.unmountComponentAtNode)(target);
94
- const reboot = reinitializeEditor.bind(null, target, settings);
95
- (0, _element.render)((0, _element.createElement)(_editor2.default, {
96
- initialSettings: settings,
97
- onError: reboot
96
+ const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
97
+ // so that we won't trigger unnecessary re-renders with useEffect.
98
+
99
+ {
100
+ (0, _data.dispatch)(_store.store).updateSettings(settings); // Keep the defaultTemplateTypes in the core/editor settings too,
101
+ // so that they can be selected with core/editor selectors in any editor.
102
+ // This is needed because edit-site doesn't initialize with EditorProvider,
103
+ // which internally uses updateEditorSettings as well.
104
+
105
+ (0, _data.dispatch)(_editor.store).updateEditorSettings({
106
+ defaultTemplateTypes: settings.defaultTemplateTypes,
107
+ defaultTemplatePartAreas: settings.defaultTemplatePartAreas
108
+ });
109
+ const isLandingOnListPage = (0, _getIsListPage.default)((0, _url.getQueryArgs)(window.location.href));
110
+
111
+ if (isLandingOnListPage) {
112
+ // Default the navigation panel to be opened when we're in a bigger
113
+ // screen and land in the list screen.
114
+ (0, _data.dispatch)(_store.store).setIsNavigationPanelOpened((0, _data.select)(_viewport.store).isViewportMatch('medium'));
115
+ }
116
+ }
117
+ (0, _element.render)((0, _element.createElement)(_app.default, {
118
+ reboot: reboot
98
119
  }), target);
99
120
  }
100
121
  /**
@@ -111,7 +132,6 @@ function initializeEditor(id, settings) {
111
132
  settings.__experimentalFetchRichUrlData = _coreData.__experimentalFetchUrlData;
112
133
  settings.__experimentalSpotlightEntityBlocks = ['core/template-part'];
113
134
  const target = document.getElementById(id);
114
- const reboot = reinitializeEditor.bind(null, target, settings);
115
135
 
116
136
  (0, _data.dispatch)(_blocks.store).__experimentalReapplyBlockTypeFilters();
117
137
 
@@ -123,32 +143,6 @@ function initializeEditor(id, settings) {
123
143
  });
124
144
  }
125
145
 
126
- (0, _element.render)((0, _element.createElement)(_editor2.default, {
127
- initialSettings: settings,
128
- onError: reboot
129
- }), target);
130
- }
131
- /**
132
- * Initializes the site editor templates list screen.
133
- *
134
- * @param {string} id ID of the root element to render the screen in.
135
- * @param {string} templateType The type of the list. "wp_template" or "wp_template_part".
136
- * @param {Object} settings Editor settings.
137
- */
138
-
139
-
140
- function initializeList(id, templateType, settings) {
141
- const target = document.getElementById(id);
142
- (0, _data.dispatch)(_editor.store).updateEditorSettings({
143
- defaultTemplateTypes: settings.defaultTemplateTypes,
144
- defaultTemplatePartAreas: settings.defaultTemplatePartAreas
145
- }); // Default the navigation panel to be opened when we're in a bigger screen.
146
- // We update the store synchronously before rendering so that we won't
147
- // trigger an unnecessary re-render with useEffect.
148
-
149
- (0, _data.dispatch)(_store.store).setIsNavigationPanelOpened((0, _data.select)(_viewport.store).isViewportMatch('medium'));
150
- (0, _element.render)((0, _element.createElement)(_list.default, {
151
- templateType: templateType
152
- }), target);
146
+ reinitializeEditor(target, settings);
153
147
  }
154
148
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","reboot","bind","initializeEditor","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","initializeList","templateType","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","editSiteStore","setIsNavigationPanelOpened","viewportStore","isViewportMatch"],"mapp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IAAA,eAAe,EAAGlB,QAA1B;AAAqC,IAAA,OAAO,EAAGC;AAA/C,IADD,EAECF,MAFD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASoB,cAAT,CAAyBf,EAAzB,EAA6BgB,YAA7B,EAA2CpB,QAA3C,EAAsD;AAC5D,QAAMD,MAAM,GAAGY,QAAQ,CAACC,cAAT,CAAyBR,EAAzB,CAAf;AAEA,sBAAUiB,aAAV,EAAwBC,oBAAxB,CAA8C;AAC7CC,IAAAA,oBAAoB,EAAEvB,QAAQ,CAACuB,oBADc;AAE7CC,IAAAA,wBAAwB,EAAExB,QAAQ,CAACwB;AAFU,GAA9C,EAH4D,CAQ5D;AACA;AACA;;AACA,sBAAUC,YAAV,EAA0BC,0BAA1B,CACC,kBAAQC,eAAR,EAAwBC,eAAxB,CAAyC,QAAzC,CADD;AAIA,uBAAQ,4BAAC,aAAD;AAAM,IAAA,YAAY,EAAGR;AAArB,IAAR,EAAgDrB,MAAhD;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch, select } from '@wordpress/data';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as viewportStore } from '@wordpress/viewport';\n\n/**\n * Internal dependencies\n */\nimport './plugins';\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport Editor from './components/editor';\nimport List from './components/list';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport function reinitializeEditor( target, settings ) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\trender(\n\t\t<Editor initialSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\trender(\n\t\t<Editor initialSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes the site editor templates list screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {string} templateType The type of the list. \"wp_template\" or \"wp_template_part\".\n * @param {Object} settings Editor settings.\n */\nexport function initializeList( id, templateType, settings ) {\n\tconst target = document.getElementById( id );\n\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Default the navigation panel to be opened when we're in a bigger screen.\n\t// We update the store synchronously before rendering so that we won't\n\t// trigger an unnecessary re-render with useEffect.\n\tdispatch( editSiteStore ).setIsNavigationPanelOpened(\n\t\tselect( viewportStore ).isViewportMatch( 'medium' )\n\t);\n\n\trender( <List templateType={ templateType } />, target );\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","reboot","bind","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","viewportStore","isViewportMatch","initializeEditor","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAqEA;;AACA;;AACA;;AACA;;AACA;;AAlGA;AACA;AACA;;AAgBA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CAA6BC,MAA7B,EAAqCC,QAArC,EAAgD;AACtD;AACA,uCAAwBD,MAAxB;AACA,QAAME,MAAM,GAAGH,kBAAkB,CAACI,IAAnB,CAAyB,IAAzB,EAA+BH,MAA/B,EAAuCC,QAAvC,CAAf,CAHsD,CAKtD;AACA;;AACA;AACC,wBAAUG,YAAV,EAA0BC,cAA1B,CAA0CJ,QAA1C,EADD,CAEC;AACA;AACA;AACA;;AACA,wBAAUK,aAAV,EAAwBC,oBAAxB,CAA8C;AAC7CC,MAAAA,oBAAoB,EAAEP,QAAQ,CAACO,oBADc;AAE7CC,MAAAA,wBAAwB,EAAER,QAAQ,CAACQ;AAFU,KAA9C;AAKA,UAAMC,mBAAmB,GAAG,4BAC3B,uBAAcC,MAAM,CAACC,QAAP,CAAgBC,IAA9B,CAD2B,CAA5B;;AAIA,QAAKH,mBAAL,EAA2B;AAC1B;AACA;AACA,0BAAUN,YAAV,EAA0BU,0BAA1B,CACC,kBAAQC,eAAR,EAAwBC,eAAxB,CAAyC,QAAzC,CADD;AAGA;AACD;AAED,uBAAQ,4BAAC,YAAD;AAAa,IAAA,MAAM,EAAGd;AAAtB,IAAR,EAA2CF,MAA3C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASiB,gBAAT,CAA2BC,EAA3B,EAA+BjB,QAA/B,EAA0C;AAChDA,EAAAA,QAAQ,CAACkB,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6CpB,QAA7C,CADD;;AAEAA,EAAAA,QAAQ,CAACqB,8BAAT,GAA0CC,oCAA1C;AACAtB,EAAAA,QAAQ,CAACuB,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMxB,MAAM,GAAGyB,QAAQ,CAACC,cAAT,CAAyBR,EAAzB,CAAf;;AAEA,sBAAUS,aAAV,EAAwBC,qCAAxB;;AACA;;AACA,MAAKC,OAAO,CAACC,GAAR,CAAYC,eAAZ,KAAgC,CAArC,EAAyC;AACxC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAE;AAD4B,KAA9C;AAGA;;AAEDjC,EAAAA,kBAAkB,CAAEC,MAAF,EAAUC,QAAV,CAAlB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch, select } from '@wordpress/data';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as viewportStore } from '@wordpress/viewport';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport './plugins';\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport EditSiteApp from './components/app';\nimport getIsListPage from './utils/get-is-list-page';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport function reinitializeEditor( target, settings ) {\n\t// This will be a no-op if the target doesn't have any React nodes.\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\t{\n\t\tdispatch( editSiteStore ).updateSettings( settings );\n\t\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t\t// so that they can be selected with core/editor selectors in any editor.\n\t\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t\t// which internally uses updateEditorSettings as well.\n\t\tdispatch( editorStore ).updateEditorSettings( {\n\t\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t\t} );\n\n\t\tconst isLandingOnListPage = getIsListPage(\n\t\t\tgetQueryArgs( window.location.href )\n\t\t);\n\n\t\tif ( isLandingOnListPage ) {\n\t\t\t// Default the navigation panel to be opened when we're in a bigger\n\t\t\t// screen and land in the list screen.\n\t\t\tdispatch( editSiteStore ).setIsNavigationPanelOpened(\n\t\t\t\tselect( viewportStore ).isViewportMatch( 'medium' )\n\t\t\t);\n\t\t}\n\t}\n\n\trender( <EditSiteApp reboot={ reboot } />, target );\n}\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\treinitializeEditor( target, settings );\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\n"]}
@@ -4,25 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
 
5
5
  var _element = require("@wordpress/element");
6
6
 
7
- var _downloadjs = _interopRequireDefault(require("downloadjs"));
8
-
9
- var _components = require("@wordpress/components");
10
-
11
- var _i18n = require("@wordpress/i18n");
12
-
13
7
  var _plugins = require("@wordpress/plugins");
14
8
 
15
- var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
16
-
17
- var _icons = require("@wordpress/icons");
18
-
19
9
  var _toolsMoreMenuGroup = _interopRequireDefault(require("../components/header/tools-more-menu-group"));
20
10
 
21
- var _welcomeGuideMenuItem = _interopRequireDefault(require("./welcome-guide-menu-item"));
11
+ var _siteExport = _interopRequireDefault(require("./site-export"));
22
12
 
23
- /**
24
- * External dependencies
25
- */
13
+ var _welcomeGuideMenuItem = _interopRequireDefault(require("./welcome-guide-menu-item"));
26
14
 
27
15
  /**
28
16
  * WordPress dependencies
@@ -33,15 +21,7 @@ var _welcomeGuideMenuItem = _interopRequireDefault(require("./welcome-guide-menu
33
21
  */
34
22
  (0, _plugins.registerPlugin)('edit-site', {
35
23
  render() {
36
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_toolsMoreMenuGroup.default, null, (0, _element.createElement)(_components.MenuItem, {
37
- role: "menuitem",
38
- icon: _icons.download,
39
- onClick: () => (0, _apiFetch.default)({
40
- path: '/wp-block-editor/v1/export',
41
- parse: false
42
- }).then(res => res.blob()).then(blob => (0, _downloadjs.default)(blob, 'edit-site-export.zip', 'application/zip')),
43
- info: (0, _i18n.__)('Download your templates and template parts.')
44
- }, (0, _i18n.__)('Export')), (0, _element.createElement)(_welcomeGuideMenuItem.default, null)));
24
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_toolsMoreMenuGroup.default, null, (0, _element.createElement)(_siteExport.default, null), (0, _element.createElement)(_welcomeGuideMenuItem.default, null)));
45
25
  }
46
26
 
47
27
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/plugins/index.js"],"names":["render","download","path","parse","then","res","blob"],"mappings":";;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIA,6BAAgB,WAAhB,EAA6B;AAC5BA,EAAAA,MAAM,GAAG;AACR,WACC,qDACC,4BAAC,2BAAD,QACC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAC,UADN;AAEC,MAAA,IAAI,EAAGC,eAFR;AAGC,MAAA,OAAO,EAAG,MACT,uBAAU;AACTC,QAAAA,IAAI,EAAE,4BADG;AAETC,QAAAA,KAAK,EAAE;AAFE,OAAV,EAIEC,IAJF,CAIUC,GAAF,IAAWA,GAAG,CAACC,IAAJ,EAJnB,EAKEF,IALF,CAKUE,IAAF,IACN,yBACCA,IADD,EAEC,sBAFD,EAGC,iBAHD,CANF,CAJF;AAiBC,MAAA,IAAI,EAAG,cACN,6CADM;AAjBR,OAqBG,cAAI,QAAJ,CArBH,CADD,EAwBC,4BAAC,6BAAD,OAxBD,CADD,CADD;AA8BA;;AAhC2B,CAA7B","sourcesContent":["/**\n * External dependencies\n */\nimport downloadjs from 'downloadjs';\n\n/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport apiFetch from '@wordpress/api-fetch';\nimport { download } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\n\nregisterPlugin( 'edit-site', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ToolsMoreMenuGroup>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\ticon={ download }\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tapiFetch( {\n\t\t\t\t\t\t\t\tpath: '/wp-block-editor/v1/export',\n\t\t\t\t\t\t\t\tparse: false,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t.then( ( res ) => res.blob() )\n\t\t\t\t\t\t\t\t.then( ( blob ) =>\n\t\t\t\t\t\t\t\t\tdownloadjs(\n\t\t\t\t\t\t\t\t\t\tblob,\n\t\t\t\t\t\t\t\t\t\t'edit-site-export.zip',\n\t\t\t\t\t\t\t\t\t\t'application/zip'\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}\n\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t'Download your templates and template parts.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Export' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t</ToolsMoreMenuGroup>\n\t\t\t</>\n\t\t);\n\t},\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/plugins/index.js"],"names":["render"],"mappings":";;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,6BAAgB,WAAhB,EAA6B;AAC5BA,EAAAA,MAAM,GAAG;AACR,WACC,qDACC,4BAAC,2BAAD,QACC,4BAAC,mBAAD,OADD,EAEC,4BAAC,6BAAD,OAFD,CADD,CADD;AAQA;;AAV2B,CAA7B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerPlugin } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';\nimport SiteExport from './site-export';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\n\nregisterPlugin( 'edit-site', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ToolsMoreMenuGroup>\n\t\t\t\t\t<SiteExport />\n\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t</ToolsMoreMenuGroup>\n\t\t\t</>\n\t\t);\n\t},\n} );\n"]}
@@ -0,0 +1,67 @@
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 = SiteExport;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _downloadjs = _interopRequireDefault(require("downloadjs"));
13
+
14
+ var _i18n = require("@wordpress/i18n");
15
+
16
+ var _components = require("@wordpress/components");
17
+
18
+ var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
19
+
20
+ var _icons = require("@wordpress/icons");
21
+
22
+ var _data = require("@wordpress/data");
23
+
24
+ var _notices = require("@wordpress/notices");
25
+
26
+ /**
27
+ * External dependencies
28
+ */
29
+
30
+ /**
31
+ * WordPress dependencies
32
+ */
33
+ function SiteExport() {
34
+ const {
35
+ createErrorNotice
36
+ } = (0, _data.useDispatch)(_notices.store);
37
+
38
+ async function handleExport() {
39
+ try {
40
+ const response = await (0, _apiFetch.default)({
41
+ path: '/wp-block-editor/v1/export',
42
+ parse: false
43
+ });
44
+ const blob = await response.blob();
45
+ (0, _downloadjs.default)(blob, 'edit-site-export.zip', 'application/zip');
46
+ } catch (errorResponse) {
47
+ let error = {};
48
+
49
+ try {
50
+ error = await errorResponse.json();
51
+ } catch (e) {}
52
+
53
+ const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the site export.');
54
+ createErrorNotice(errorMessage, {
55
+ type: 'snackbar'
56
+ });
57
+ }
58
+ }
59
+
60
+ return (0, _element.createElement)(_components.MenuItem, {
61
+ role: "menuitem",
62
+ icon: _icons.download,
63
+ onClick: handleExport,
64
+ info: (0, _i18n.__)('Download your templates and template parts.')
65
+ }, (0, _i18n.__)('Export'));
66
+ }
67
+ //# sourceMappingURL=site-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/plugins/site-export.js"],"names":["SiteExport","createErrorNotice","noticesStore","handleExport","response","path","parse","blob","errorResponse","error","json","e","errorMessage","message","code","type","download"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;AAQe,SAASA,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;;AAEA,iBAAeC,YAAf,GAA8B;AAC7B,QAAI;AACH,YAAMC,QAAQ,GAAG,MAAM,uBAAU;AAChCC,QAAAA,IAAI,EAAE,4BAD0B;AAEhCC,QAAAA,KAAK,EAAE;AAFyB,OAAV,CAAvB;AAIA,YAAMC,IAAI,GAAG,MAAMH,QAAQ,CAACG,IAAT,EAAnB;AAEA,+BAAYA,IAAZ,EAAkB,sBAAlB,EAA0C,iBAA1C;AACA,KARD,CAQE,OAAQC,aAAR,EAAwB;AACzB,UAAIC,KAAK,GAAG,EAAZ;;AACA,UAAI;AACHA,QAAAA,KAAK,GAAG,MAAMD,aAAa,CAACE,IAAd,EAAd;AACA,OAFD,CAEE,OAAQC,CAAR,EAAY,CAAE;;AAChB,YAAMC,YAAY,GACjBH,KAAK,CAACI,OAAN,IAAiBJ,KAAK,CAACK,IAAN,KAAe,eAAhC,GACGL,KAAK,CAACI,OADT,GAEG,cAAI,mDAAJ,CAHJ;AAKAZ,MAAAA,iBAAiB,CAAEW,YAAF,EAAgB;AAAEG,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA;AACD;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAC,UADN;AAEC,IAAA,IAAI,EAAGC,eAFR;AAGC,IAAA,OAAO,EAAGb,YAHX;AAIC,IAAA,IAAI,EAAG,cAAI,6CAAJ;AAJR,KAMG,cAAI,QAAJ,CANH,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport downloadjs from 'downloadjs';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport apiFetch from '@wordpress/api-fetch';\nimport { download } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function SiteExport() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function handleExport() {\n\t\ttry {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tpath: '/wp-block-editor/v1/export',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t\tconst blob = await response.blob();\n\n\t\t\tdownloadjs( blob, 'edit-site-export.zip', 'application/zip' );\n\t\t} catch ( errorResponse ) {\n\t\t\tlet error = {};\n\t\t\ttry {\n\t\t\t\terror = await errorResponse.json();\n\t\t\t} catch ( e ) {}\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the site export.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\trole=\"menuitem\"\n\t\t\ticon={ download }\n\t\t\tonClick={ handleExport }\n\t\t\tinfo={ __( 'Download your templates and template parts.' ) }\n\t\t>\n\t\t\t{ __( 'Export' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
@@ -13,8 +13,6 @@ var _data = require("@wordpress/data");
13
13
 
14
14
  var _components = require("@wordpress/components");
15
15
 
16
- var _interface = require("@wordpress/interface");
17
-
18
16
  var _store = require("../store");
19
17
 
20
18
  /**
@@ -28,12 +26,8 @@ function WelcomeGuideMenuItem() {
28
26
  const {
29
27
  toggleFeature
30
28
  } = (0, _data.useDispatch)(_store.store);
31
- const isStylesOpen = (0, _data.useSelect)(select => {
32
- const sidebar = select(_interface.store).getActiveComplementaryArea(_store.store.name);
33
- return sidebar === 'edit-site/global-styles';
34
- }, []);
35
29
  return (0, _element.createElement)(_components.MenuItem, {
36
- onClick: () => toggleFeature(isStylesOpen ? 'welcomeGuideStyles' : 'welcomeGuide')
30
+ onClick: () => toggleFeature('welcomeGuide')
37
31
  }, (0, _i18n.__)('Welcome Guide'));
38
32
  }
39
33
  //# sourceMappingURL=welcome-guide-menu-item.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/plugins/welcome-guide-menu-item.js"],"names":["WelcomeGuideMenuItem","toggleFeature","editSiteStore","isStylesOpen","select","sidebar","interfaceStore","getActiveComplementaryArea","name"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AACA,QAAMC,YAAY,GAAG,qBAAaC,MAAF,IAAc;AAC7C,UAAMC,OAAO,GAAGD,MAAM,CAAEE,gBAAF,CAAN,CAAyBC,0BAAzB,CACfL,aAAcM,IADC,CAAhB;AAIA,WAAOH,OAAO,KAAK,yBAAnB;AACA,GANoB,EAMlB,EANkB,CAArB;AAQA,SACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MACTJ,aAAa,CACZE,YAAY,GAAG,oBAAH,GAA0B,cAD1B;AAFf,KAOG,cAAI,eAAJ,CAPH,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../store';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\tconst isStylesOpen = useSelect( ( select ) => {\n\t\tconst sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\teditSiteStore.name\n\t\t);\n\n\t\treturn sidebar === 'edit-site/global-styles';\n\t}, [] );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () =>\n\t\t\t\ttoggleFeature(\n\t\t\t\t\tisStylesOpen ? 'welcomeGuideStyles' : 'welcomeGuide'\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t{ __( 'Welcome Guide' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/plugins/welcome-guide-menu-item.js"],"names":["WelcomeGuideMenuItem","toggleFeature","editSiteStore"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AAEA,SACC,4BAAC,oBAAD;AAAU,IAAA,OAAO,EAAG,MAAMD,aAAa,CAAE,cAAF;AAAvC,KACG,cAAI,eAAJ,CADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../store';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<MenuItem onClick={ () => toggleFeature( 'welcomeGuide' ) }>\n\t\t\t{ __( 'Welcome Guide' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
@@ -8,10 +8,8 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.__experimentalSetPreviewDeviceType = __experimentalSetPreviewDeviceType;
9
9
  exports.addTemplate = addTemplate;
10
10
  exports.closeGeneralSidebar = closeGeneralSidebar;
11
- exports.goBack = goBack;
12
11
  exports.openGeneralSidebar = openGeneralSidebar;
13
12
  exports.openNavigationPanelToMenu = openNavigationPanelToMenu;
14
- exports.pushTemplatePart = pushTemplatePart;
15
13
  exports.removeTemplate = removeTemplate;
16
14
  exports.revertTemplate = revertTemplate;
17
15
  exports.setHomeTemplateId = setHomeTemplateId;
@@ -184,21 +182,6 @@ function setTemplatePart(templatePartId) {
184
182
  templatePartId
185
183
  };
186
184
  }
187
- /**
188
- * Returns an action object used to push a template part to navigation history.
189
- *
190
- * @param {string} templatePartId The template part ID.
191
- *
192
- * @return {Object} Action object.
193
- */
194
-
195
-
196
- function pushTemplatePart(templatePartId) {
197
- return {
198
- type: 'PUSH_TEMPLATE_PART',
199
- templatePartId
200
- };
201
- }
202
185
  /**
203
186
  * Updates the homeTemplateId state with the templateId of the page resolved
204
187
  * from the given path.
@@ -250,16 +233,6 @@ function* setPage(page) {
250
233
  };
251
234
  return templateId;
252
235
  }
253
- /**
254
- * Go back to the current editing page.
255
- */
256
-
257
-
258
- function goBack() {
259
- return {
260
- type: 'GO_BACK'
261
- };
262
- }
263
236
  /**
264
237
  * Displays the site homepage for editing in the editor.
265
238
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","controls","resolveSelect","coreStore","slug","page","context","addTemplate","newTemplate","dispatch","content","id","blocks","undoIgnore","removeTemplate","force","lastError","select","noticesStore","title","rendered","error","errorMessage","message","code","setTemplatePart","templatePartId","pushTemplatePart","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","goBack","showHomepage","show_on_front","showOnFront","page_on_front","frontpageId","siteUrl","editSiteStoreName","homeTemplate","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","openGeneralSidebar","name","interfaceStore","closeGeneralSidebar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,kCAAT,CAA6CC,UAA7C,EAA0D;AAChE,SAAO;AACNF,IAAAA,IAAI,EAAE,yBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAUC,WAAV,CAAuBC,UAAvB,EAAmCC,YAAnC,EAAkD;AACxD,QAAMC,WAAW,GAAG;AAAED,IAAAA;AAAF,GAApB;;AACA,MAAK,CAAEA,YAAP,EAAsB;AACrB,UAAME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Q,QAAT,CACLS,cADK,EAEL,qBAFK,EAGL,cAAI,oBAAJ,CAHK,EAIL;AACCzB,QAAAA,IAAI,EAAE,UADP;AAEC2E,QAAAA,OAAO,EAAE,CACR;AACCC,UAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;AAECC,UAAAA,OAAO,EAAEJ;AAFV,SADQ;AAFV,OAJK,CAAN;AAcA,KA3BD,MA2BO;AACN,YAAMjE,eAASQ,QAAT,CACLS,cADK,EAEL,qBAFK,EAGL,cAAI,oBAAJ,CAHK,CAAN;AAKA;AACD,GA/GD,CA+GE,OAAQG,KAAR,EAAgB;AACjB,UAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cAAI,wCAAJ,CAHJ;AAIA,UAAMtB,eAASQ,QAAT,CACLS,cADK,EAEL,mBAFK,EAGLI,YAHK,EAIL;AAAE7B,MAAAA,IAAI,EAAE;AAAR,KAJK,CAAN;AAMA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAU8E,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMvE,eAASQ,QAAT,CACLgE,gBADK,EAEL,yBAFK,EAGL9B,qBAHK,EAIL6B,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUE,mBAAV,GAAgC;AACtC,QAAMzE,eAASQ,QAAT,CACLgE,gBADK,EAEL,0BAFK,EAGL9B,qBAHK,CAAN;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * Adds a new template, and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template.\n *\n * @param {Object} template The template object.\n */\nexport function* removeTemplate( template ) {\n\ttry {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'deleteEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{ force: true }\n\t\t);\n\n\t\tconst lastError = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getLastEntityDeleteError',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" removed.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n\n/**\n * Returns an action object used to set a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Returns an action object used to push a template part to navigation history.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function pushTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'PUSH_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\n\t\tpage.path = getPathAndQueryString( entity.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\n\t\t\t: {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Go back to the current editing page.\n */\nexport function goBack() {\n\treturn {\n\t\ttype: 'GO_BACK',\n\t};\n}\n\n/**\n * Displays the site homepage for editing in the editor.\n */\nexport function* showHomepage() {\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'getEntityRecord',\n\t\t'root',\n\t\t'site'\n\t);\n\n\tconst { siteUrl } = yield controls.select(\n\t\teditSiteStoreName,\n\t\t'getSettings'\n\t);\n\n\tconst page = {\n\t\tpath: siteUrl,\n\t\tcontext:\n\t\t\tshowOnFront === 'page'\n\t\t\t\t? {\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: frontpageId,\n\t\t\t\t }\n\t\t\t\t: {},\n\t};\n\n\tconst homeTemplate = yield* setPage( page );\n\tyield setHomeTemplateId( homeTemplate );\n}\n\n/**\n * Returns an action object used to set the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport function* revertTemplate( template, { allowUndo = true } = {} ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = async () => {\n\t\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' )\n\t\t\t);\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","controls","resolveSelect","coreStore","slug","page","context","addTemplate","newTemplate","dispatch","content","id","blocks","undoIgnore","removeTemplate","force","lastError","select","noticesStore","title","rendered","error","errorMessage","message","code","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","showHomepage","show_on_front","showOnFront","page_on_front","frontpageId","siteUrl","editSiteStoreName","homeTemplate","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","openGeneralSidebar","name","interfaceStore","closeGeneralSidebar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,kCAAT,CAA6CC,UAA7C,EAA0D;AAChE,SAAO;AACNF,IAAAA,IAAI,EAAE,yBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAUC,WAAV,CAAuBC,UAAvB,EAAmCC,YAAnC,EAAkD;AACxD,QAAMC,WAAW,GAAG;AAAED,IAAAA;AAAF,GAApB;;AACA,MAAK,CAAEA,YAAP,EAAsB;AACrB,UAAME,QAAQ,GAAG,MAAMC,eAASC,aAAT,CACtBC,eADsB,EAEtB,iBAFsB,EAGtB,UAHsB,EAItB,aAJsB,EAKtBN,UALsB,CAAvB;AAOAE,IAAAA,WAAW,CAACD,YAAZ,GAA2BE,QAA3B,aAA2BA,QAA3B,uBAA2BA,QAAQ,CAAEI,IAArC;AACA;;AACD,SAAO;AACNX,IAAAA,IAAI,EAAE,cADA;AAENI,IAAAA,UAFM;AAGNQ,IAAAA,IAAI,EAAE;AAAEC,MAAAA,OAAO,EAAEP;AAAX;AAHA,GAAP;AAKA;AAED;AACA;AAC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JK,CAAN;AAMA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAU4E,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMrE,eAASQ,QAAT,CACL8D,gBADK,EAEL,yBAFK,EAGL9B,qBAHK,EAIL6B,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUE,mBAAV,GAAgC;AACtC,QAAMvE,eAASQ,QAAT,CACL8D,gBADK,EAEL,0BAFK,EAGL9B,qBAHK,CAAN;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * Adds a new template, and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template.\n *\n * @param {Object} template The template object.\n */\nexport function* removeTemplate( template ) {\n\ttry {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'deleteEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{ force: true }\n\t\t);\n\n\t\tconst lastError = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getLastEntityDeleteError',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" removed.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n\n/**\n * Returns an action object used to set a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\n\t\tpage.path = getPathAndQueryString( entity.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\n\t\t\t: {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Displays the site homepage for editing in the editor.\n */\nexport function* showHomepage() {\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'getEntityRecord',\n\t\t'root',\n\t\t'site'\n\t);\n\n\tconst { siteUrl } = yield controls.select(\n\t\teditSiteStoreName,\n\t\t'getSettings'\n\t);\n\n\tconst page = {\n\t\tpath: siteUrl,\n\t\tcontext:\n\t\t\tshowOnFront === 'page'\n\t\t\t\t? {\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: frontpageId,\n\t\t\t\t }\n\t\t\t\t: {},\n\t};\n\n\tconst homeTemplate = yield* setPage( page );\n\tyield setHomeTemplateId( homeTemplate );\n}\n\n/**\n * Returns an action object used to set the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport function* revertTemplate( template, { allowUndo = true } = {} ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = async () => {\n\t\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' )\n\t\t\t);\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n"]}
@@ -3,13 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TEMPLATE_PART_AREA_TO_NAME = exports.TEMPLATE_PART_AREA_SIDEBAR = exports.TEMPLATE_PART_AREA_HEADER = exports.TEMPLATE_PART_AREA_GENERAL = exports.TEMPLATE_PART_AREA_FOOTER = exports.STORE_NAME = void 0;
7
-
8
- var _i18n = require("@wordpress/i18n");
9
-
10
- /**
11
- * WordPress dependencies
12
- */
6
+ exports.TEMPLATE_PART_AREA_SIDEBAR = exports.TEMPLATE_PART_AREA_HEADER = exports.TEMPLATE_PART_AREA_GENERAL = exports.TEMPLATE_PART_AREA_FOOTER = exports.STORE_NAME = void 0;
13
7
 
14
8
  /**
15
9
  * The identifier for the data store.
@@ -26,11 +20,4 @@ const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
26
20
  exports.TEMPLATE_PART_AREA_SIDEBAR = TEMPLATE_PART_AREA_SIDEBAR;
27
21
  const TEMPLATE_PART_AREA_GENERAL = 'uncategorized';
28
22
  exports.TEMPLATE_PART_AREA_GENERAL = TEMPLATE_PART_AREA_GENERAL;
29
- const TEMPLATE_PART_AREA_TO_NAME = {
30
- [TEMPLATE_PART_AREA_HEADER]: (0, _i18n.__)('Header'),
31
- [TEMPLATE_PART_AREA_FOOTER]: (0, _i18n.__)('Footer'),
32
- [TEMPLATE_PART_AREA_SIDEBAR]: (0, _i18n.__)('Sidebar'),
33
- [TEMPLATE_PART_AREA_GENERAL]: (0, _i18n.__)('General')
34
- };
35
- exports.TEMPLATE_PART_AREA_TO_NAME = TEMPLATE_PART_AREA_TO_NAME;
36
23
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/constants.js"],"names":["STORE_NAME","TEMPLATE_PART_AREA_HEADER","TEMPLATE_PART_AREA_FOOTER","TEMPLATE_PART_AREA_SIDEBAR","TEMPLATE_PART_AREA_GENERAL","TEMPLATE_PART_AREA_TO_NAME"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,gBAAnB;;AAEA,MAAMC,yBAAyB,GAAG,QAAlC;;AACA,MAAMC,yBAAyB,GAAG,QAAlC;;AACA,MAAMC,0BAA0B,GAAG,SAAnC;;AACA,MAAMC,0BAA0B,GAAG,eAAnC;;AAEA,MAAMC,0BAA0B,GAAG;AACzC,GAAEJ,yBAAF,GAA+B,cAAI,QAAJ,CADU;AAEzC,GAAEC,yBAAF,GAA+B,cAAI,QAAJ,CAFU;AAGzC,GAAEC,0BAAF,GAAgC,cAAI,SAAJ,CAHS;AAIzC,GAAEC,0BAAF,GAAgC,cAAI,SAAJ;AAJS,CAAnC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/edit-site';\n\nexport const TEMPLATE_PART_AREA_HEADER = 'header';\nexport const TEMPLATE_PART_AREA_FOOTER = 'footer';\nexport const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';\nexport const TEMPLATE_PART_AREA_GENERAL = 'uncategorized';\n\nexport const TEMPLATE_PART_AREA_TO_NAME = {\n\t[ TEMPLATE_PART_AREA_HEADER ]: __( 'Header' ),\n\t[ TEMPLATE_PART_AREA_FOOTER ]: __( 'Footer' ),\n\t[ TEMPLATE_PART_AREA_SIDEBAR ]: __( 'Sidebar' ),\n\t[ TEMPLATE_PART_AREA_GENERAL ]: __( 'General' ),\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/constants.js"],"names":["STORE_NAME","TEMPLATE_PART_AREA_HEADER","TEMPLATE_PART_AREA_FOOTER","TEMPLATE_PART_AREA_SIDEBAR","TEMPLATE_PART_AREA_GENERAL"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,gBAAnB;;AAEA,MAAMC,yBAAyB,GAAG,QAAlC;;AACA,MAAMC,yBAAyB,GAAG,QAAlC;;AACA,MAAMC,0BAA0B,GAAG,SAAnC;;AACA,MAAMC,0BAA0B,GAAG,eAAnC","sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/edit-site';\n\nexport const TEMPLATE_PART_AREA_HEADER = 'header';\nexport const TEMPLATE_PART_AREA_FOOTER = 'footer';\nexport const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';\nexport const TEMPLATE_PART_AREA_GENERAL = 'uncategorized';\n"]}
@@ -102,40 +102,31 @@ function settings() {
102
102
  * Reducer keeping track of the currently edited Post Type,
103
103
  * Post Id and the context provided to fill the content of the block editor.
104
104
  *
105
- * @param {Array} state Current state history.
105
+ * @param {Object} state Current edited post.
106
106
  * @param {Object} action Dispatched action.
107
107
  *
108
- * @return {Array} Updated state.
108
+ * @return {Object} Updated state.
109
109
  */
110
110
 
111
111
 
112
112
  function editedPost() {
113
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
113
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
114
114
  let action = arguments.length > 1 ? arguments[1] : undefined;
115
115
 
116
116
  switch (action.type) {
117
117
  case 'SET_TEMPLATE':
118
118
  case 'SET_PAGE':
119
- return [{
119
+ return {
120
120
  type: 'wp_template',
121
121
  id: action.templateId,
122
122
  page: action.page
123
- }];
123
+ };
124
124
 
125
125
  case 'SET_TEMPLATE_PART':
126
- return [{
127
- type: 'wp_template_part',
128
- id: action.templatePartId
129
- }];
130
-
131
- case 'PUSH_TEMPLATE_PART':
132
- return [...state, {
126
+ return {
133
127
  type: 'wp_template_part',
134
128
  id: action.templatePartId
135
- }];
136
-
137
- case 'GO_BACK':
138
- return state.slice(0, -1);
129
+ };
139
130
  }
140
131
 
141
132
  return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/reducer.js"],"names":["preferences","features","state","PREFERENCES_DEFAULTS","action","type","feature","deviceType","settings","editedPost","id","templateId","page","templatePartId","slice","homeTemplateId","navigationPanel","menu","MENU_ROOT","isOpen","value","blockInserterPanel","listViewPanel"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,2BAAiB;AAC3CC,EAAAA,QAAQ,GAAkD;AAAA,QAAhDC,KAAgD,uEAAxCC,+BAAqBF,QAAmB;AAAA,QAATG,MAAS;;AACzD,YAASA,MAAM,CAACC,IAAhB;AACC,WAAK,gBAAL;AAAuB;AACtB,iBAAO,EACN,GAAGH,KADG;AAEN,aAAEE,MAAM,CAACE,OAAT,GAAoB,CAAEJ,KAAK,CAAEE,MAAM,CAACE,OAAT;AAFrB,WAAP;AAIA;;AACD;AACC,eAAOJ,KAAP;AARF;AAUA;;AAZ0C,CAAjB,CAApB;AAeP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASK,UAAT,GAAiD;AAAA,MAA5BL,KAA4B,uEAApB,SAAoB;AAAA,MAATE,MAAS;;AACvD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACG,UAAd;AAFF;;AAKA,SAAOL,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,QAAT,GAAwC;AAAA,MAArBN,KAAqB,uEAAb,EAAa;AAAA,MAATE,MAAS;;AAC9C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,iBAAL;AACC,aAAO,EACN,GAAGH,KADG;AAEN,WAAGE,MAAM,CAACI;AAFJ,OAAP;AAFF;;AAQA,SAAON,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,UAAT,GAA0C;AAAA,MAArBP,KAAqB,uEAAb,EAAa;AAAA,MAATE,MAA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A;AACA;;;AACO,SAASoB,aAAT,GAAgD;AAAA,MAAxBpB,KAAwB,uEAAhB,KAAgB;AAAA,MAATE,MAAS;;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACC,aAAOD,MAAM,CAACe,MAAP,GAAgB,KAAhB,GAAwBjB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOE,MAAM,CAACgB,KAAP,GAAe,KAAf,GAAuBlB,KAA9B;;AACD,SAAK,yBAAL;AACC,aAAOE,MAAM,CAACe,MAAd;AARF;;AAUA,SAAOjB,KAAP;AACA;;eAEc,2BAAiB;AAC/BF,EAAAA,WAD+B;AAE/BO,EAAAA,UAF+B;AAG/BC,EAAAA,QAH+B;AAI/BC,EAAAA,UAJ+B;AAK/BM,EAAAA,cAL+B;AAM/BC,EAAAA,eAN+B;AAO/BK,EAAAA,kBAP+B;AAQ/BC,EAAAA;AAR+B,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { PREFERENCES_DEFAULTS } from './defaults';\nimport { MENU_ROOT } from '../components/navigation-sidebar/navigation-panel/constants';\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n * @return {Object} Updated state.\n */\nexport const preferences = combineReducers( {\n\tfeatures( state = PREFERENCES_DEFAULTS.features, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'TOGGLE_FEATURE': {\n\t\t\t\treturn {\n\t\t\t\t\t...state,\n\t\t\t\t\t[ action.feature ]: ! state[ action.feature ],\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn state;\n\t\t}\n\t},\n} );\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the settings.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function settings( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the currently edited Post Type,\n * Post Id and the context provided to fill the content of the block editor.\n *\n * @param {Array} state Current state history.\n * @param {Object} action Dispatched action.\n *\n * @return {Array} Updated state.\n */\nexport function editedPost( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE':\n\t\tcase 'SET_PAGE':\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: 'wp_template',\n\t\t\t\t\tid: action.templateId,\n\t\t\t\t\tpage: action.page,\n\t\t\t\t},\n\t\t\t];\n\t\tcase 'SET_TEMPLATE_PART':\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: 'wp_template_part',\n\t\t\t\t\tid: action.templatePartId,\n\t\t\t\t},\n\t\t\t];\n\t\tcase 'PUSH_TEMPLATE_PART':\n\t\t\treturn [\n\t\t\t\t...state,\n\t\t\t\t{\n\t\t\t\t\ttype: 'wp_template_part',\n\t\t\t\t\tid: action.templatePartId,\n\t\t\t\t},\n\t\t\t];\n\t\tcase 'GO_BACK':\n\t\t\treturn state.slice( 0, -1 );\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the site's homepage.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function homeTemplateId( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_HOME_TEMPLATE':\n\t\t\treturn action.homeTemplateId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the navigation panel, such as its active menu\n * and whether it should be opened or closed.\n *\n * Note: this reducer interacts with the inserter and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function navigationPanel(\n\tstate = { menu: MENU_ROOT, isOpen: false },\n\taction\n) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_NAVIGATION_PANEL_ACTIVE_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisOpen: true,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: ! action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen ? false : state.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.value ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.value ? false : state.isOpen,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the navigation and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {boolean|Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the navigation and inserter panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tpreferences,\n\tdeviceType,\n\tsettings,\n\teditedPost,\n\thomeTemplateId,\n\tnavigationPanel,\n\tblockInserterPanel,\n\tlistViewPanel,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/reducer.js"],"names":["preferences","features","state","PREFERENCES_DEFAULTS","action","type","feature","deviceType","settings","editedPost","id","templateId","page","templatePartId","homeTemplateId","navigationPanel","menu","MENU_ROOT","isOpen","value","blockInserterPanel","listViewPanel"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,2BAAiB;AAC3CC,EAAAA,QAAQ,GAAkD;AAAA,QAAhDC,KAAgD,uEAAxCC,+BAAqBF,QAAmB;AAAA,QAATG,MAAS;;AACzD,YAASA,MAAM,CAACC,IAAhB;AACC,WAAK,gBAAL;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AFjD;AAEuD;AAC7DE,QAAAA,MAAM,EAAEd,MAAM,CAACe,KAAP,GAAe,KAAf,GAAuBjB,KAAK,CAACgB;AAH/B,OAAP;AAzBF;;AA+BA,SAAOhB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASkB,kBAAT,GAAqD;AAAA,MAAxBlB,KAAwB,uEAAhB,KAAgB;AAAA,MAATE,MAAS;;AAC3D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACA,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACc,MAAP,GAAgB,KAAhB,GAAwBhB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOE,MAAM,CAACe,KAAd;AAPF;;AASA,SAAOjB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASmB,aAAT,GAAgD;AAAA,MAAxBnB,KAAwB,uEAAhB,KAAgB;AAAA,MAATE,MAAS;;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACC,aAAOD,MAAM,CAACc,MAAP,GAAgB,KAAhB,GAAwBhB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOE,MAAM,CAACe,KAAP,GAAe,KAAf,GAAuBjB,KAA9B;;AACD,SAAK,yBAAL;AACC,aAAOE,MAAM,CAACc,MAAd;AARF;;AAUA,SAAOhB,KAAP;AACA;;eAEc,2BAAiB;AAC/BF,EAAAA,WAD+B;AAE/BO,EAAAA,UAF+B;AAG/BC,EAAAA,QAH+B;AAI/BC,EAAAA,UAJ+B;AAK/BK,EAAAA,cAL+B;AAM/BC,EAAAA,eAN+B;AAO/BK,EAAAA,kBAP+B;AAQ/BC,EAAAA;AAR+B,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { PREFERENCES_DEFAULTS } from './defaults';\nimport { MENU_ROOT } from '../components/navigation-sidebar/navigation-panel/constants';\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n * @return {Object} Updated state.\n */\nexport const preferences = combineReducers( {\n\tfeatures( state = PREFERENCES_DEFAULTS.features, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'TOGGLE_FEATURE': {\n\t\t\t\treturn {\n\t\t\t\t\t...state,\n\t\t\t\t\t[ action.feature ]: ! state[ action.feature ],\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn state;\n\t\t}\n\t},\n} );\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the settings.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function settings( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the currently edited Post Type,\n * Post Id and the context provided to fill the content of the block editor.\n *\n * @param {Object} state Current edited post.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editedPost( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE':\n\t\tcase 'SET_PAGE':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template',\n\t\t\t\tid: action.templateId,\n\t\t\t\tpage: action.page,\n\t\t\t};\n\t\tcase 'SET_TEMPLATE_PART':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template_part',\n\t\t\t\tid: action.templatePartId,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the site's homepage.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function homeTemplateId( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_HOME_TEMPLATE':\n\t\t\treturn action.homeTemplateId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the navigation panel, such as its active menu\n * and whether it should be opened or closed.\n *\n * Note: this reducer interacts with the inserter and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function navigationPanel(\n\tstate = { menu: MENU_ROOT, isOpen: false },\n\taction\n) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_NAVIGATION_PANEL_ACTIVE_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisOpen: true,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: ! action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen ? false : state.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.value ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.value ? false : state.isOpen,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the navigation and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {boolean|Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the navigation and inserter panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tpreferences,\n\tdeviceType,\n\tsettings,\n\teditedPost,\n\thomeTemplateId,\n\tnavigationPanel,\n\tblockInserterPanel,\n\tlistViewPanel,\n} );\n"]}