@wordpress/edit-site 3.0.2 → 3.0.3

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/README.md +1 -1
  2. package/build/components/block-editor/back-button.js +60 -0
  3. package/build/components/block-editor/back-button.js.map +1 -0
  4. package/build/components/block-editor/index.js +18 -4
  5. package/build/components/block-editor/index.js.map +1 -1
  6. package/build/components/edit-template-part-menu-button/index.js +63 -0
  7. package/build/components/edit-template-part-menu-button/index.js.map +1 -0
  8. package/build/components/editor/global-styles-provider.js +1 -1
  9. package/build/components/editor/global-styles-provider.js.map +1 -1
  10. package/build/components/editor/index.js +7 -7
  11. package/build/components/editor/index.js.map +1 -1
  12. package/build/components/editor/utils.js +1 -1
  13. package/build/components/editor/utils.js.map +1 -1
  14. package/build/components/{sidebar → global-styles}/border-panel.js +0 -0
  15. package/build/components/global-styles/border-panel.js.map +1 -0
  16. package/build/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
  17. package/build/components/global-styles/color-palette-panel.js.map +1 -0
  18. package/build/components/{sidebar → global-styles}/color-panel.js +7 -11
  19. package/build/components/global-styles/color-panel.js.map +1 -0
  20. package/build/components/global-styles/context-menu.js +58 -0
  21. package/build/components/global-styles/context-menu.js.map +1 -0
  22. package/build/components/{sidebar → global-styles}/dimensions-panel.js +6 -7
  23. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  24. package/build/components/global-styles/header.js +54 -0
  25. package/build/components/global-styles/header.js.map +1 -0
  26. package/build/components/global-styles/index.js +89 -0
  27. package/build/components/global-styles/index.js.map +1 -0
  28. package/build/components/global-styles/navigation-button.js +43 -0
  29. package/build/components/global-styles/navigation-button.js.map +1 -0
  30. package/build/components/global-styles/palette.js +57 -0
  31. package/build/components/global-styles/palette.js.map +1 -0
  32. package/build/components/global-styles/preview.js +59 -0
  33. package/build/components/global-styles/preview.js.map +1 -0
  34. package/build/components/global-styles/screen-block-list.js +76 -0
  35. package/build/components/global-styles/screen-block-list.js.map +1 -0
  36. package/build/components/global-styles/screen-block.js +45 -0
  37. package/build/components/global-styles/screen-block.js.map +1 -0
  38. package/build/components/global-styles/screen-color-palette.js +48 -0
  39. package/build/components/global-styles/screen-color-palette.js.map +1 -0
  40. package/build/components/global-styles/screen-colors.js +51 -0
  41. package/build/components/global-styles/screen-colors.js.map +1 -0
  42. package/build/components/global-styles/screen-layout.js +60 -0
  43. package/build/components/global-styles/screen-layout.js.map +1 -0
  44. package/build/components/global-styles/screen-root.js +44 -0
  45. package/build/components/global-styles/screen-root.js.map +1 -0
  46. package/build/components/global-styles/screen-typography.js +50 -0
  47. package/build/components/global-styles/screen-typography.js.map +1 -0
  48. package/build/components/global-styles/subtitle.js +25 -0
  49. package/build/components/global-styles/subtitle.js.map +1 -0
  50. package/build/components/{sidebar → global-styles}/typography-panel.js +1 -3
  51. package/build/components/global-styles/typography-panel.js.map +1 -0
  52. package/build/components/header/plugin-more-menu-item/index.js +82 -0
  53. package/build/components/header/plugin-more-menu-item/index.js.map +1 -0
  54. package/build/components/header/plugin-sidebar-more-menu-item/index.js +75 -0
  55. package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
  56. package/build/components/header/undo-redo/redo.js +1 -1
  57. package/build/components/header/undo-redo/redo.js.map +1 -1
  58. package/build/components/header/undo-redo/undo.js +1 -1
  59. package/build/components/header/undo-redo/undo.js.map +1 -1
  60. package/build/components/keyboard-shortcuts/index.js +2 -10
  61. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  62. package/build/components/navigation-sidebar/index.js +1 -1
  63. package/build/components/navigation-sidebar/index.js.map +1 -1
  64. package/build/components/navigation-sidebar/navigation-panel/constants.js +10 -10
  65. package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  66. package/build/components/save-button/index.js +1 -1
  67. package/build/components/save-button/index.js.map +1 -1
  68. package/build/components/secondary-sidebar/inserter-sidebar.js +2 -1
  69. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  70. package/build/components/sidebar/global-styles-sidebar.js +11 -161
  71. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  72. package/build/components/sidebar/index.js +1 -6
  73. package/build/components/sidebar/index.js.map +1 -1
  74. package/build/components/sidebar/plugin-sidebar/index.js +95 -0
  75. package/build/components/sidebar/plugin-sidebar/index.js.map +1 -0
  76. package/build/components/template-details/index.js +12 -6
  77. package/build/components/template-details/index.js.map +1 -1
  78. package/build/components/template-details/template-areas.js +73 -0
  79. package/build/components/template-details/template-areas.js.map +1 -0
  80. package/build/components/template-part-converter/index.js +1 -1
  81. package/build/components/template-part-converter/index.js.map +1 -1
  82. package/build/components/url-query-controller/index.js +1 -1
  83. package/build/components/url-query-controller/index.js.map +1 -1
  84. package/build/index.js +24 -0
  85. package/build/index.js.map +1 -1
  86. package/build/store/actions.js +54 -1
  87. package/build/store/actions.js.map +1 -1
  88. package/build/store/constants.js +19 -1
  89. package/build/store/constants.js.map +1 -1
  90. package/build/store/reducer.js +16 -7
  91. package/build/store/reducer.js.map +1 -1
  92. package/build/store/selectors.js +91 -9
  93. package/build/store/selectors.js.map +1 -1
  94. package/build-module/components/block-editor/back-button.js +48 -0
  95. package/build-module/components/block-editor/back-button.js.map +1 -0
  96. package/build-module/components/block-editor/index.js +15 -4
  97. package/build-module/components/block-editor/index.js.map +1 -1
  98. package/build-module/components/edit-template-part-menu-button/index.js +49 -0
  99. package/build-module/components/edit-template-part-menu-button/index.js.map +1 -0
  100. package/build-module/components/editor/global-styles-provider.js +1 -1
  101. package/build-module/components/editor/global-styles-provider.js.map +1 -1
  102. package/build-module/components/editor/index.js +4 -5
  103. package/build-module/components/editor/index.js.map +1 -1
  104. package/build-module/components/editor/utils.js +1 -1
  105. package/build-module/components/editor/utils.js.map +1 -1
  106. package/build-module/components/{sidebar → global-styles}/border-panel.js +0 -0
  107. package/build-module/components/global-styles/border-panel.js.map +1 -0
  108. package/build-module/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
  109. package/build-module/components/global-styles/color-palette-panel.js.map +1 -0
  110. package/build-module/components/{sidebar → global-styles}/color-panel.js +8 -12
  111. package/build-module/components/global-styles/color-panel.js.map +1 -0
  112. package/build-module/components/global-styles/context-menu.js +41 -0
  113. package/build-module/components/global-styles/context-menu.js.map +1 -0
  114. package/build-module/components/{sidebar → global-styles}/dimensions-panel.js +6 -7
  115. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  116. package/build-module/components/global-styles/header.js +41 -0
  117. package/build-module/components/global-styles/header.js.map +1 -0
  118. package/build-module/components/global-styles/index.js +70 -0
  119. package/build-module/components/global-styles/index.js.map +1 -0
  120. package/build-module/components/global-styles/navigation-button.js +31 -0
  121. package/build-module/components/global-styles/navigation-button.js.map +1 -0
  122. package/build-module/components/global-styles/palette.js +43 -0
  123. package/build-module/components/global-styles/palette.js.map +1 -0
  124. package/build-module/components/global-styles/preview.js +50 -0
  125. package/build-module/components/global-styles/preview.js.map +1 -0
  126. package/build-module/components/global-styles/screen-block-list.js +58 -0
  127. package/build-module/components/global-styles/screen-block-list.js.map +1 -0
  128. package/build-module/components/global-styles/screen-block.js +32 -0
  129. package/build-module/components/global-styles/screen-block.js.map +1 -0
  130. package/build-module/components/global-styles/screen-color-palette.js +35 -0
  131. package/build-module/components/global-styles/screen-color-palette.js.map +1 -0
  132. package/build-module/components/global-styles/screen-colors.js +38 -0
  133. package/build-module/components/global-styles/screen-colors.js.map +1 -0
  134. package/build-module/components/global-styles/screen-layout.js +44 -0
  135. package/build-module/components/global-styles/screen-layout.js.map +1 -0
  136. package/build-module/components/global-styles/screen-root.js +29 -0
  137. package/build-module/components/global-styles/screen-root.js.map +1 -0
  138. package/build-module/components/global-styles/screen-typography.js +37 -0
  139. package/build-module/components/global-styles/screen-typography.js.map +1 -0
  140. package/build-module/components/global-styles/subtitle.js +17 -0
  141. package/build-module/components/global-styles/subtitle.js.map +1 -0
  142. package/build-module/components/{sidebar → global-styles}/typography-panel.js +1 -2
  143. package/build-module/components/global-styles/typography-panel.js.map +1 -0
  144. package/build-module/components/header/plugin-more-menu-item/index.js +70 -0
  145. package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -0
  146. package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
  147. package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
  148. package/build-module/components/header/undo-redo/redo.js +1 -1
  149. package/build-module/components/header/undo-redo/redo.js.map +1 -1
  150. package/build-module/components/header/undo-redo/undo.js +1 -1
  151. package/build-module/components/header/undo-redo/undo.js.map +1 -1
  152. package/build-module/components/keyboard-shortcuts/index.js +3 -11
  153. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  154. package/build-module/components/navigation-sidebar/index.js +1 -1
  155. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  156. package/build-module/components/navigation-sidebar/navigation-panel/constants.js +5 -3
  157. package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  158. package/build-module/components/save-button/index.js +1 -1
  159. package/build-module/components/save-button/index.js.map +1 -1
  160. package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
  161. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  162. package/build-module/components/sidebar/global-styles-sidebar.js +13 -159
  163. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  164. package/build-module/components/sidebar/index.js +2 -7
  165. package/build-module/components/sidebar/index.js.map +1 -1
  166. package/build-module/components/sidebar/plugin-sidebar/index.js +84 -0
  167. package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -0
  168. package/build-module/components/template-details/index.js +13 -8
  169. package/build-module/components/template-details/index.js.map +1 -1
  170. package/build-module/components/template-details/template-areas.js +60 -0
  171. package/build-module/components/template-details/template-areas.js.map +1 -0
  172. package/build-module/components/template-part-converter/index.js +1 -1
  173. package/build-module/components/template-part-converter/index.js.map +1 -1
  174. package/build-module/components/url-query-controller/index.js +1 -1
  175. package/build-module/components/url-query-controller/index.js.map +1 -1
  176. package/build-module/index.js +3 -0
  177. package/build-module/index.js.map +1 -1
  178. package/build-module/store/actions.js +45 -1
  179. package/build-module/store/actions.js.map +1 -1
  180. package/build-module/store/constants.js +13 -0
  181. package/build-module/store/constants.js.map +1 -1
  182. package/build-module/store/reducer.js +16 -7
  183. package/build-module/store/reducer.js.map +1 -1
  184. package/build-module/store/selectors.js +85 -9
  185. package/build-module/store/selectors.js.map +1 -1
  186. package/build-style/style-rtl.css +122 -17
  187. package/build-style/style.css +122 -17
  188. package/package.json +26 -26
  189. package/src/components/block-editor/back-button.js +44 -0
  190. package/src/components/block-editor/index.js +16 -1
  191. package/src/components/block-editor/style.scss +26 -0
  192. package/src/components/edit-template-part-menu-button/index.js +57 -0
  193. package/src/components/editor/global-styles-provider.js +1 -1
  194. package/src/components/editor/index.js +5 -8
  195. package/src/components/editor/utils.js +1 -0
  196. package/src/components/{sidebar → global-styles}/border-panel.js +0 -0
  197. package/src/components/{sidebar → global-styles}/color-palette-panel.js +13 -11
  198. package/src/components/{sidebar → global-styles}/color-panel.js +12 -17
  199. package/src/components/global-styles/context-menu.js +54 -0
  200. package/src/components/{sidebar → global-styles}/dimensions-panel.js +6 -10
  201. package/src/components/global-styles/header.js +50 -0
  202. package/src/components/global-styles/index.js +81 -0
  203. package/src/components/global-styles/navigation-button.js +35 -0
  204. package/src/components/global-styles/palette.js +67 -0
  205. package/src/components/global-styles/preview.js +41 -0
  206. package/src/components/global-styles/screen-block-list.js +59 -0
  207. package/src/components/global-styles/screen-block.js +28 -0
  208. package/src/components/global-styles/screen-color-palette.js +33 -0
  209. package/src/components/global-styles/screen-colors.js +36 -0
  210. package/src/components/global-styles/screen-layout.js +45 -0
  211. package/src/components/global-styles/screen-root.js +43 -0
  212. package/src/components/global-styles/screen-typography.js +33 -0
  213. package/src/components/global-styles/style.scss +35 -0
  214. package/src/components/global-styles/subtitle.js +10 -0
  215. package/src/components/{sidebar → global-styles}/typography-panel.js +1 -2
  216. package/src/components/header/plugin-more-menu-item/index.js +71 -0
  217. package/src/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
  218. package/src/components/header/undo-redo/redo.js +4 -1
  219. package/src/components/header/undo-redo/undo.js +4 -1
  220. package/src/components/keyboard-shortcuts/index.js +25 -40
  221. package/src/components/navigation-sidebar/index.js +1 -1
  222. package/src/components/navigation-sidebar/navigation-panel/constants.js +9 -4
  223. package/src/components/navigation-sidebar/navigation-panel/style.scss +1 -0
  224. package/src/components/save-button/index.js +1 -1
  225. package/src/components/secondary-sidebar/inserter-sidebar.js +1 -0
  226. package/src/components/sidebar/global-styles-sidebar.js +14 -187
  227. package/src/components/sidebar/index.js +2 -7
  228. package/src/components/sidebar/plugin-sidebar/index.js +80 -0
  229. package/src/components/sidebar/style.scss +40 -0
  230. package/src/components/template-details/index.js +17 -7
  231. package/src/components/template-details/style.scss +36 -27
  232. package/src/components/template-details/template-areas.js +66 -0
  233. package/src/components/template-part-converter/index.js +1 -1
  234. package/src/components/url-query-controller/index.js +1 -1
  235. package/src/index.js +3 -0
  236. package/src/store/actions.js +53 -1
  237. package/src/store/constants.js +15 -0
  238. package/src/store/reducer.js +26 -12
  239. package/src/store/selectors.js +96 -9
  240. package/src/store/test/reducer.js +40 -23
  241. package/src/store/test/selectors.js +34 -3
  242. package/src/style.scss +1 -0
  243. package/build/components/sidebar/border-panel.js.map +0 -1
  244. package/build/components/sidebar/color-palette-panel.js.map +0 -1
  245. package/build/components/sidebar/color-panel.js.map +0 -1
  246. package/build/components/sidebar/dimensions-panel.js.map +0 -1
  247. package/build/components/sidebar/typography-panel.js.map +0 -1
  248. package/build-module/components/sidebar/border-panel.js.map +0 -1
  249. package/build-module/components/sidebar/color-palette-panel.js.map +0 -1
  250. package/build-module/components/sidebar/color-panel.js.map +0 -1
  251. package/build-module/components/sidebar/dimensions-panel.js.map +0 -1
  252. package/build-module/components/sidebar/typography-panel.js.map +0 -1
@@ -3,7 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.STORE_NAME = void 0;
6
+ exports.TEMPLATE_PART_AREA_TO_NAME = exports.TEMPLATE_PART_AREA_SIDEBAR = exports.TEMPLATE_PART_AREA_FOOTER = exports.TEMPLATE_PART_AREA_HEADER = exports.STORE_NAME = void 0;
7
+
8
+ var _i18n = require("@wordpress/i18n");
9
+
10
+ /**
11
+ * WordPress dependencies
12
+ */
7
13
 
8
14
  /**
9
15
  * The identifier for the data store.
@@ -12,4 +18,16 @@ exports.STORE_NAME = void 0;
12
18
  */
13
19
  const STORE_NAME = 'core/edit-site';
14
20
  exports.STORE_NAME = STORE_NAME;
21
+ const TEMPLATE_PART_AREA_HEADER = 'header';
22
+ exports.TEMPLATE_PART_AREA_HEADER = TEMPLATE_PART_AREA_HEADER;
23
+ const TEMPLATE_PART_AREA_FOOTER = 'footer';
24
+ exports.TEMPLATE_PART_AREA_FOOTER = TEMPLATE_PART_AREA_FOOTER;
25
+ const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
26
+ exports.TEMPLATE_PART_AREA_SIDEBAR = TEMPLATE_PART_AREA_SIDEBAR;
27
+ const TEMPLATE_PART_AREA_TO_NAME = {
28
+ [TEMPLATE_PART_AREA_HEADER]: (0, _i18n.__)('Header'),
29
+ [TEMPLATE_PART_AREA_FOOTER]: (0, _i18n.__)('Footer'),
30
+ [TEMPLATE_PART_AREA_SIDEBAR]: (0, _i18n.__)('Sidebar')
31
+ };
32
+ exports.TEMPLATE_PART_AREA_TO_NAME = TEMPLATE_PART_AREA_TO_NAME;
15
33
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/constants.js"],"names":["STORE_NAME"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,gBAAnB","sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/edit-site';\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_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;;AAEA,MAAMC,0BAA0B,GAAG;AACzC,GAAEH,yBAAF,GAA+B,cAAI,QAAJ,CADU;AAEzC,GAAEC,yBAAF,GAA+B,cAAI,QAAJ,CAFU;AAGzC,GAAEC,0BAAF,GAAgC,cAAI,SAAJ;AAHS,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';\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};\n"]}
@@ -92,28 +92,37 @@ function settings(state = {}, action) {
92
92
  * Reducer keeping track of the currently edited Post Type,
93
93
  * Post Id and the context provided to fill the content of the block editor.
94
94
  *
95
- * @param {Object} state Current state.
95
+ * @param {Array} state Current state history.
96
96
  * @param {Object} action Dispatched action.
97
97
  *
98
- * @return {Object} Updated state.
98
+ * @return {Array} Updated state.
99
99
  */
100
100
 
101
101
 
102
- function editedPost(state = {}, action) {
102
+ function editedPost(state = [], action) {
103
103
  switch (action.type) {
104
104
  case 'SET_TEMPLATE':
105
105
  case 'SET_PAGE':
106
- return {
106
+ return [{
107
107
  type: 'wp_template',
108
108
  id: action.templateId,
109
109
  page: action.page
110
- };
110
+ }];
111
111
 
112
112
  case 'SET_TEMPLATE_PART':
113
- return {
113
+ return [{
114
114
  type: 'wp_template_part',
115
115
  id: action.templatePartId
116
- };
116
+ }];
117
+
118
+ case 'PUSH_TEMPLATE_PART':
119
+ return [...state, {
120
+ type: 'wp_template_part',
121
+ id: action.templatePartId
122
+ }];
123
+
124
+ case 'GO_BACK':
125
+ return state.slice(0, -1);
117
126
  }
118
127
 
119
128
  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","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,CAAEC,KAAK,GAAGC,+BAAqBF,QAA/B,EAAyCG,MAAzC,EAAkD;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,CAAqBL,KAAK,GAAG,SAA7B,EAAwCE,MAAxC,EAAiD;AACvD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACG,UAA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D,SAAK,wBAAL;AACC,aAAOE,MAAM,CAACe,KAAd;AAPF;;AASA,SAAOjB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASmB,aAAT,CAAwBnB,KAAK,GAAG,KAAhC,EAAuCE,MAAvC,EAAgD;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 state.\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"]}
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,CAAEC,KAAK,GAAGC,+BAAqBF,QAA/B,EAAyCG,MAAzC,EAAkD;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;;AAZ0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A/B,GAA2ChB,KAAK,CAACe,IAFjD;AAEuD;AAC7DE,QAAAA,MAAM,EAAEf,MAAM,CAACgB,KAAP,GAAe,KAAf,GAAuBlB,KAAK,CAACiB;AAH/B,OAAP;AAzBF;;AA+BA,SAAOjB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASmB,kBAAT,CAA6BnB,KAAK,GAAG,KAArC,EAA4CE,MAA5C,EAAqD;AAC3D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,+BAAL;AACC,aAAO,KAAP;;AACD,SAAK,gCAAL;AACA,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACe,MAAP,GAAgB,KAAhB,GAAwBjB,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOE,MAAM,CAACgB,KAAd;AAPF;;AASA,SAAOlB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASoB,aAAT,CAAwBpB,KAAK,GAAG,KAAhC,EAAuCE,MAAvC,EAAgD;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"]}
@@ -10,13 +10,15 @@ exports.__experimentalGetPreviewDeviceType = __experimentalGetPreviewDeviceType;
10
10
  exports.getHomeTemplateId = getHomeTemplateId;
11
11
  exports.getEditedPostType = getEditedPostType;
12
12
  exports.getEditedPostId = getEditedPostId;
13
+ exports.getPreviousEditedPostType = getPreviousEditedPostType;
14
+ exports.getPreviousEditedPostId = getPreviousEditedPostId;
13
15
  exports.getPage = getPage;
14
16
  exports.getNavigationPanelActiveMenu = getNavigationPanelActiveMenu;
15
17
  exports.isNavigationOpened = isNavigationOpened;
16
18
  exports.isInserterOpened = isInserterOpened;
17
19
  exports.__experimentalGetInsertionPoint = __experimentalGetInsertionPoint;
18
20
  exports.isListViewOpened = isListViewOpened;
19
- exports.getCurrentTemplateNavigationPanelSubMenu = exports.getSettings = exports.getCanUserCreateMedia = void 0;
21
+ exports.getTemplateAreaBlocks = exports.getCurrentTemplateNavigationPanelSubMenu = exports.getSettings = exports.getCanUserCreateMedia = void 0;
20
22
 
21
23
  var _lodash = require("lodash");
22
24
 
@@ -28,6 +30,8 @@ var _data = require("@wordpress/data");
28
30
 
29
31
  var _mediaUtils = require("@wordpress/media-utils");
30
32
 
33
+ var _blocks = require("@wordpress/blocks");
34
+
31
35
  var _constants = require("../components/navigation-sidebar/navigation-panel/constants");
32
36
 
33
37
  var _templateHierarchy = require("../components/navigation-sidebar/navigation-panel/template-hierarchy");
@@ -44,6 +48,10 @@ var _templateHierarchy = require("../components/navigation-sidebar/navigation-pa
44
48
  * Internal dependencies
45
49
  */
46
50
 
51
+ /**
52
+ * @typedef {'template'|'template_type'} TemplateType Template type.
53
+ */
54
+
47
55
  /**
48
56
  * Returns whether the given feature is enabled or not.
49
57
  *
@@ -128,29 +136,61 @@ exports.getSettings = getSettings;
128
136
  function getHomeTemplateId(state) {
129
137
  return state.homeTemplateId;
130
138
  }
139
+
140
+ function getCurrentEditedPost(state) {
141
+ return state.editedPost[state.editedPost.length - 1] || {};
142
+ }
143
+
144
+ function getPreviousEditedPost(state) {
145
+ return state.editedPost[state.editedPost.length - 2] || {};
146
+ }
131
147
  /**
132
148
  * Returns the current edited post type (wp_template or wp_template_part).
133
149
  *
134
150
  * @param {Object} state Global application state.
135
151
  *
136
- * @return {number?} Template ID.
152
+ * @return {TemplateType?} Template type.
137
153
  */
138
154
 
139
155
 
140
156
  function getEditedPostType(state) {
141
- return state.editedPost.type;
157
+ return getCurrentEditedPost(state).type;
142
158
  }
143
159
  /**
144
160
  * Returns the ID of the currently edited template or template part.
145
161
  *
146
162
  * @param {Object} state Global application state.
147
163
  *
148
- * @return {number?} Post ID.
164
+ * @return {string?} Post ID.
149
165
  */
150
166
 
151
167
 
152
168
  function getEditedPostId(state) {
153
- return state.editedPost.id;
169
+ return getCurrentEditedPost(state).id;
170
+ }
171
+ /**
172
+ * Returns the previous edited post type (wp_template or wp_template_part).
173
+ *
174
+ * @param {Object} state Global application state.
175
+ *
176
+ * @return {TemplateType?} Template type.
177
+ */
178
+
179
+
180
+ function getPreviousEditedPostType(state) {
181
+ return getPreviousEditedPost(state).type;
182
+ }
183
+ /**
184
+ * Returns the ID of the previous edited template or template part.
185
+ *
186
+ * @param {Object} state Global application state.
187
+ *
188
+ * @return {string?} Post ID.
189
+ */
190
+
191
+
192
+ function getPreviousEditedPostId(state) {
193
+ return getPreviousEditedPost(state).id;
154
194
  }
155
195
  /**
156
196
  * Returns the current page object.
@@ -162,7 +202,7 @@ function getEditedPostId(state) {
162
202
 
163
203
 
164
204
  function getPage(state) {
165
- return state.editedPost.page;
205
+ return getCurrentEditedPost(state).page;
166
206
  }
167
207
  /**
168
208
  * Returns the active menu in the navigation panel.
@@ -242,18 +282,20 @@ function isInserterOpened(state) {
242
282
  *
243
283
  * @param {Object} state Global application state.
244
284
  *
245
- * @return {Object} The root client ID and index to insert at.
285
+ * @return {Object} The root client ID, index to insert at and starting filter value.
246
286
  */
247
287
 
248
288
 
249
289
  function __experimentalGetInsertionPoint(state) {
250
290
  const {
251
291
  rootClientId,
252
- insertionIndex
292
+ insertionIndex,
293
+ filterValue
253
294
  } = state.blockInserterPanel;
254
295
  return {
255
296
  rootClientId,
256
- insertionIndex
297
+ insertionIndex,
298
+ filterValue
257
299
  };
258
300
  }
259
301
  /**
@@ -268,4 +310,44 @@ function __experimentalGetInsertionPoint(state) {
268
310
  function isListViewOpened(state) {
269
311
  return state.listViewPanel;
270
312
  }
313
+ /**
314
+ * Returns the template part blocks grouped by areas for the current edited template.
315
+ *
316
+ * @param {Object} state Global application state.
317
+ * @return {Object} Template part blocks by areas.
318
+ */
319
+
320
+
321
+ const getTemplateAreaBlocks = (0, _data.createRegistrySelector)(select => state => {
322
+ const templateType = getEditedPostType(state);
323
+ const templateId = getEditedPostId(state);
324
+ const template = select(_coreData.store).getEditedEntityRecord('postType', templateType, templateId);
325
+ const templateParts = select(_coreData.store).getEntityRecords('postType', 'wp_template_part', {
326
+ per_page: -1
327
+ });
328
+ const templatePartsById = (0, _lodash.keyBy)(templateParts, templatePart => templatePart.id);
329
+ const templatePartBlocksByAreas = {};
330
+
331
+ for (const block of (_template$blocks = template.blocks) !== null && _template$blocks !== void 0 ? _template$blocks : []) {
332
+ var _template$blocks;
333
+
334
+ if ((0, _blocks.isTemplatePart)(block)) {
335
+ const {
336
+ attributes: {
337
+ theme,
338
+ slug
339
+ }
340
+ } = block;
341
+ const templatePartId = `${theme}//${slug}`;
342
+ const templatePart = templatePartsById[templatePartId];
343
+
344
+ if (templatePart) {
345
+ templatePartBlocksByAreas[templatePart.area] = block;
346
+ }
347
+ }
348
+ }
349
+
350
+ return templatePartBlocksByAreas;
351
+ });
352
+ exports.getTemplateAreaBlocks = getTemplateAreaBlocks;
271
353
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["isFeatureActive","state","feature","preferences","features","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","select","coreDataStore","canUser","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","__experimentalSetIsInserterOpened","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","homeTemplateId","getEditedPostType","editedPost","type","getEditedPostId","id","getPage","page","getNavigationPanelActiveMenu","navigationPanel","menu","getCurrentTemplateNavigationPanelSubMenu","templateType","templateId","template","getEntityRecord","MENU_ROOT","find","submenu","area","MENU_TEMPLATE_PARTS","templates","getEntityRecords","per_page","showOnFront","getEditedEntityRecord","show_on_front","slug","MENU_TEMPLATES_UNUSED","isNavigationOpened","isOpen","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","isListViewOpened","listViewPanel"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AAMA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,KAA1B,EAAiCC,OAAjC,EAA2C;AACjD,SAAO,iBAAKD,KAAK,CAACE,WAAN,CAAkBC,QAAvB,EAAiC,CAAEF,OAAF,CAAjC,EAA8C,KAA9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,kCAAT,CAA6CJ,KAA7C,EAAqD;AAC3D,SAAOA,KAAK,CAACK,UAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,kCAA0BC,MAAF,IAAc,MAC1EA,MAAM,CAAEC,eAAF,CAAN,CAAwBC,OAAxB,CAAiC,QAAjC,EAA2C,OAA3C,CADoC,CAA9B;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,WAAW,GAAG,qBAC1B,CAAEV,KAAF,EAASW,iBAA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,aAHF;;AAKA,MACC,6CACCZ,QAAQ,CAACa,IADV,EAEC,iBAAKN,SAAL,EAAgB,MAAhB,CAFD,EAGCG,WAHD,CADD,EAME;AACD,WAAOI,gCAAP;AACA;;AAED,SAAO,4CAAqBd,QAAQ,CAACa,IAA9B,CAAP;AACA,CA/CsD,CAAjD;AAkDP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASE,kBAAT,CAA6BtD,KAA7B,EAAqC;AAC3C,SAAOA,KAAK,CAACkC,eAAN,CAAsBqB,MAA7B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,gBAAT,CAA2BxD,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAACyD,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,+BAAT,CAA0C1D,KAA1C,EAAkD;AACxD,QAAM;AAAE2D,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmC5D,KAAK,CAACyD,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,gBAAT,CAA2B7D,KAA3B,EAAmC;AACzC,SAAOA,KAAK,CAAC8D,aAAb;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, map } from 'lodash';\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_TEMPLATES_UNUSED,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../components/navigation-sidebar/navigation-panel/constants';\nimport {\n\tgetTemplateLocation,\n\tisTemplateSuperseded,\n} from '../components/navigation-sidebar/navigation-panel/template-hierarchy';\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector( ( select ) => () =>\n\tselect( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: isFeatureActive( state, 'focusMode' ),\n\t\t\thasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\tisFeatureActive( state, 'focusMode' ),\n\t\tisFeatureActive( state, 'fixedToolbar' ),\n\t]\n);\n\n/**\n * Returns the current home template ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Home template ID.\n */\nexport function getHomeTemplateId( state ) {\n\treturn state.homeTemplateId;\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Template ID.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.type;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the current page object.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn state.editedPost.page;\n}\n\n/**\n * Returns the active menu in the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Active menu.\n */\nexport function getNavigationPanelActiveMenu( state ) {\n\treturn state.navigationPanel.menu;\n}\n\n/**\n * Returns the current template or template part's corresponding\n * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} The current template or template part's sub menu.\n */\nexport const getCurrentTemplateNavigationPanelSubMenu = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = templateId\n\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\ttemplateId\n\t\t\t )\n\t\t\t: null;\n\n\t\tif ( ! template ) {\n\t\t\treturn MENU_ROOT;\n\t\t}\n\n\t\tif ( 'wp_template_part' === templateType ) {\n\t\t\treturn (\n\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t\t\t( submenu ) => submenu.area === template?.area\n\t\t\t\t)?.menu || MENU_TEMPLATE_PARTS\n\t\t\t);\n\t\t}\n\n\t\tconst templates = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t}\n\t\t);\n\t\tconst showOnFront = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t).show_on_front;\n\n\t\tif (\n\t\t\tisTemplateSuperseded(\n\t\t\t\ttemplate.slug,\n\t\t\t\tmap( templates, 'slug' ),\n\t\t\t\tshowOnFront\n\t\t\t)\n\t\t) {\n\t\t\treturn MENU_TEMPLATES_UNUSED;\n\t\t}\n\n\t\treturn getTemplateLocation( template.slug );\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the navigation panel should be open; false if closed.\n */\nexport function isNavigationOpened( state ) {\n\treturn state.navigationPanel.isOpen;\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["isFeatureActive","state","feature","preferences","features","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","select","coreDataStore","canUser","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","__experimentalSetIsInserterOpened","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","homeTemplateId","getCurrentEditedPost","editedPost","length","getPreviousEditedPost","getEditedPostType","type","getEditedPostId","id","getPreviousEditedPostType","getPreviousEditedPostId","getPage","page","getNavigationPanelActiveMenu","navigationPanel","menu","getCurrentTemplateNavigationPanelSubMenu","templateType","templateId","template","getEntityRecord","MENU_ROOT","find","submenu","area","MENU_TEMPLATE_PARTS","templates","getEntityRecords","per_page","showOnFront","getEditedEntityRecord","show_on_front","slug","MENU_TEMPLATES_UNUSED","isNavigationOpened","isOpen","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","getTemplateAreaBlocks","templateParts","templatePartsById","templatePart","templatePartBlocksByAreas","block","blocks","attributes","theme","templatePartId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;;AAYA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,KAA1B,EAAiCC,OAAjC,EAA2C;AACjD,SAAO,iBAAKD,KAAK,CAACE,WAAN,CAAkBC,QAAvB,EAAiC,CAAEF,OAAF,CAAjC,EAA8C,KAA9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,kCAAT,CAA6CJ,KAA7C,EAAqD;AAC3D,SAAOA,KAAK,CAACK,UAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,kCAA0BC,MAAF,IAAc,MAC1EA,MAAM,CAAEC,eAAF,CAAN,CAAwBC,OAAxB,CAAiC,QAAjC,EAA2C,OAA3C,CADoC,CAA9B;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,WAAW,GAAG,qBAC1B,CAAEV,KAAF,EAASW,iBAAT,KAAgC;AAC/B,QAAMC,QAAQ,GAAG,EAChB,GAAGZ,KAAK,CA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CAAzB,GAAiDyB,KAAjD;AACA;AACD;AACD;;AAED,SAAOD,yBAAP;AACA,CAvCmC,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { get, map, keyBy } from 'lodash';\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_TEMPLATES_UNUSED,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../components/navigation-sidebar/navigation-panel/constants';\nimport {\n\tgetTemplateLocation,\n\tisTemplateSuperseded,\n} from '../components/navigation-sidebar/navigation-panel/template-hierarchy';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector( ( select ) => () =>\n\tselect( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: isFeatureActive( state, 'focusMode' ),\n\t\t\thasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\tisFeatureActive( state, 'focusMode' ),\n\t\tisFeatureActive( state, 'fixedToolbar' ),\n\t]\n);\n\n/**\n * Returns the current home template ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Home template ID.\n */\nexport function getHomeTemplateId( state ) {\n\treturn state.homeTemplateId;\n}\n\nfunction getCurrentEditedPost( state ) {\n\treturn state.editedPost[ state.editedPost.length - 1 ] || {};\n}\n\nfunction getPreviousEditedPost( state ) {\n\treturn state.editedPost[ state.editedPost.length - 2 ] || {};\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn getCurrentEditedPost( state ).type;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn getCurrentEditedPost( state ).id;\n}\n\n/**\n * Returns the previous edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getPreviousEditedPostType( state ) {\n\treturn getPreviousEditedPost( state ).type;\n}\n\n/**\n * Returns the ID of the previous edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getPreviousEditedPostId( state ) {\n\treturn getPreviousEditedPost( state ).id;\n}\n\n/**\n * Returns the current page object.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn getCurrentEditedPost( state ).page;\n}\n\n/**\n * Returns the active menu in the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Active menu.\n */\nexport function getNavigationPanelActiveMenu( state ) {\n\treturn state.navigationPanel.menu;\n}\n\n/**\n * Returns the current template or template part's corresponding\n * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} The current template or template part's sub menu.\n */\nexport const getCurrentTemplateNavigationPanelSubMenu = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = templateId\n\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\ttemplateId\n\t\t\t )\n\t\t\t: null;\n\n\t\tif ( ! template ) {\n\t\t\treturn MENU_ROOT;\n\t\t}\n\n\t\tif ( 'wp_template_part' === templateType ) {\n\t\t\treturn (\n\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t\t\t( submenu ) => submenu.area === template?.area\n\t\t\t\t)?.menu || MENU_TEMPLATE_PARTS\n\t\t\t);\n\t\t}\n\n\t\tconst templates = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t}\n\t\t);\n\t\tconst showOnFront = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t).show_on_front;\n\n\t\tif (\n\t\t\tisTemplateSuperseded(\n\t\t\t\ttemplate.slug,\n\t\t\t\tmap( templates, 'slug' ),\n\t\t\t\tshowOnFront\n\t\t\t)\n\t\t) {\n\t\t\treturn MENU_TEMPLATES_UNUSED;\n\t\t}\n\n\t\treturn getTemplateLocation( template.slug );\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the navigation panel should be open; false if closed.\n */\nexport function isNavigationOpened( state ) {\n\treturn state.navigationPanel.isOpen;\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the template part blocks grouped by areas for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Object} Template part blocks by areas.\n */\nexport const getTemplateAreaBlocks = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t}\n\t\t);\n\t\tconst templatePartsById = keyBy(\n\t\t\ttemplateParts,\n\t\t\t( templatePart ) => templatePart.id\n\t\t);\n\n\t\tconst templatePartBlocksByAreas = {};\n\n\t\tfor ( const block of template.blocks ?? [] ) {\n\t\t\tif ( isTemplatePart( block ) ) {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\tif ( templatePart ) {\n\t\t\t\t\ttemplatePartBlocksByAreas[ templatePart.area ] = block;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn templatePartBlocksByAreas;\n\t}\n);\n"]}
@@ -0,0 +1,48 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { Button } from '@wordpress/components';
7
+ import { arrowLeft } from '@wordpress/icons';
8
+ import { useSelect, useDispatch } from '@wordpress/data';
9
+ import { __ } from '@wordpress/i18n';
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+
14
+ import { store as editSiteStore } from '../../store';
15
+
16
+ function BackButton() {
17
+ const {
18
+ isTemplatePart,
19
+ previousTemplateId
20
+ } = useSelect(select => {
21
+ const {
22
+ getEditedPostType,
23
+ getPreviousEditedPostId
24
+ } = select(editSiteStore);
25
+ return {
26
+ isTemplatePart: getEditedPostType() === 'wp_template_part',
27
+ previousTemplateId: getPreviousEditedPostId()
28
+ };
29
+ }, []);
30
+ const {
31
+ goBack
32
+ } = useDispatch(editSiteStore);
33
+
34
+ if (!isTemplatePart || !previousTemplateId) {
35
+ return null;
36
+ }
37
+
38
+ return createElement(Button, {
39
+ className: "edit-site-visual-editor__back-button",
40
+ icon: arrowLeft,
41
+ onClick: () => {
42
+ goBack();
43
+ }
44
+ }, __('Back'));
45
+ }
46
+
47
+ export default BackButton;
48
+ //# sourceMappingURL=back-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/back-button.js"],"names":["Button","arrowLeft","useSelect","useDispatch","__","store","editSiteStore","BackButton","isTemplatePart","previousTemplateId","select","getEditedPostType","getPreviousEditedPostId","goBack"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,uBAAvB;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,UAAT,GAAsB;AACrB,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAyCP,SAAS,CAAIQ,MAAF,IAAc;AACvE,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAiDF,MAAM,CAC5DJ,aAD4D,CAA7D;AAIA,WAAO;AACNE,MAAAA,cAAc,EAAEG,iBAAiB,OAAO,kBADlC;AAENF,MAAAA,kBAAkB,EAAEG,uBAAuB;AAFrC,KAAP;AAIA,GATuD,EASrD,EATqD,CAAxD;AAUA,QAAM;AAAEC,IAAAA;AAAF,MAAaV,WAAW,CAAEG,aAAF,CAA9B;;AAEA,MAAK,CAAEE,cAAF,IAAoB,CAAEC,kBAA3B,EAAgD;AAC/C,WAAO,IAAP;AACA;;AAED,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,sCADX;AAEC,IAAA,IAAI,EAAGR,SAFR;AAGC,IAAA,OAAO,EAAG,MAAM;AACfY,MAAAA,MAAM;AACN;AALF,KAOGT,EAAE,CAAE,MAAF,CAPL,CADD;AAWA;;AAED,eAAeG,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { arrowLeft } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nfunction BackButton() {\n\tconst { isTemplatePart, previousTemplateId } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getPreviousEditedPostId } = select(\n\t\t\teditSiteStore\n\t\t);\n\n\t\treturn {\n\t\t\tisTemplatePart: getEditedPostType() === 'wp_template_part',\n\t\t\tpreviousTemplateId: getPreviousEditedPostId(),\n\t\t};\n\t}, [] );\n\tconst { goBack } = useDispatch( editSiteStore );\n\n\tif ( ! isTemplatePart || ! previousTemplateId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-site-visual-editor__back-button\"\n\t\t\ticon={ arrowLeft }\n\t\t\tonClick={ () => {\n\t\t\t\tgoBack();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Back' ) }\n\t\t</Button>\n\t);\n}\n\nexport default BackButton;\n"]}
@@ -1,9 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { createElement } from "@wordpress/element";
3
3
 
4
+ /**
5
+ * External dependencies
6
+ */
7
+ import classnames from 'classnames';
4
8
  /**
5
9
  * WordPress dependencies
6
10
  */
11
+
7
12
  import { useSelect, useDispatch } from '@wordpress/data';
8
13
  import { useCallback, useRef } from '@wordpress/element';
9
14
  import { useEntityBlockEditor } from '@wordpress/core-data';
@@ -18,6 +23,8 @@ import NavigateToLink from '../navigate-to-link';
18
23
  import { SidebarInspectorFill } from '../sidebar';
19
24
  import { store as editSiteStore } from '../../store';
20
25
  import BlockInspectorButton from './block-inspector-button';
26
+ import EditTemplatePartMenuButton from '../edit-template-part-menu-button';
27
+ import BackButton from './back-button';
21
28
  const LAYOUT = {
22
29
  type: 'default',
23
30
  // At the root level of the site editor, no alignments should be allowed.
@@ -53,26 +60,30 @@ export default function BlockEditor({
53
60
  const ref = useMouseMoveTypingReset();
54
61
  const contentRef = useRef();
55
62
  const mergedRefs = useMergeRefs([contentRef, useTypingObserver()]);
63
+ const isTemplatePart = templateType === 'wp_template_part';
56
64
  return createElement(BlockEditorProvider, {
57
65
  settings: settings,
58
66
  value: blocks,
59
67
  onInput: onInput,
60
68
  onChange: onChange,
61
69
  useSubRegistry: false
62
- }, createElement(TemplatePartConverter, null), createElement(__experimentalLinkControl.ViewerFill, null, useCallback(fillProps => createElement(NavigateToLink, _extends({}, fillProps, {
70
+ }, createElement(EditTemplatePartMenuButton, null), createElement(TemplatePartConverter, null), createElement(__experimentalLinkControl.ViewerFill, null, useCallback(fillProps => createElement(NavigateToLink, _extends({}, fillProps, {
63
71
  activePage: page,
64
72
  onActivePageChange: setPage
65
73
  })), [page])), createElement(SidebarInspectorFill, null, createElement(BlockInspector, null)), createElement(BlockTools, {
66
- className: "edit-site-visual-editor",
74
+ className: classnames('edit-site-visual-editor', {
75
+ 'is-focus-mode': isTemplatePart
76
+ }),
67
77
  __unstableContentRef: contentRef
68
- }, createElement(Iframe, {
78
+ }, createElement(BackButton, null), createElement(Iframe, {
69
79
  style: resizedCanvasStyles,
70
80
  head: createElement(EditorStyles, {
71
81
  styles: settings.styles
72
82
  }),
73
83
  ref: ref,
74
84
  contentRef: mergedRefs,
75
- name: "editor-canvas"
85
+ name: "editor-canvas",
86
+ className: "edit-site-visual-editor__editor-canvas"
76
87
  }, createElement(BlockList, {
77
88
  className: "edit-site-block-editor__block-list wp-site-blocks",
78
89
  __experimentalLayout: LAYOUT
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["useSelect","useDispatch","useCallback","useRef","useEntityBlockEditor","BlockEditorProvider","__experimentalLinkControl","BlockInspector","BlockList","BlockTools","__unstableBlockSettingsMenuFirstItem","__experimentalUseResizeCanvas","useResizeCanvas","__unstableUseTypingObserver","useTypingObserver","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","useMergeRefs","TemplatePartConverter","NavigateToLink","SidebarInspectorFill","store","editSiteStore","BlockInspectorButton","LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","templateType","page","deviceType","select","getSettings","getEditedPostType","getPage","__experimentalGetPreviewDeviceType","blocks","onInput","onChange","setPage","resizedCanvasStyles","ref","contentRef","mergedRefs","fillProps","styles","onClose"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SACCC,mBADD,EAECC,yBAFD,EAGCC,cAHD,EAICC,SAJD,EAKCC,UALD,EAMCC,oCAND,EAOCC,6BAA6B,IAAIC,eAPlC,EAQCC,2BAA2B,IAAIC,iBARhC,EASCC,iCAAiC,IAAIC,uBATtC,EAUCC,sBAAsB,IAAIC,YAV3B,EAWCC,gBAAgB,IAAIC,MAXrB,QAYO,yBAZP;AAaA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,IAAI,EAAE,SADQ;AAEd;AACAC,EAAAA,UAAU,EAAE;AAHE,CAAf;AAMA,eAAe,SAASC,WAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAA8C;AAC5D,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA,IAA1B;AAAgCC,IAAAA;AAAhC,MAA+CpC,SAAS,CAC3DqC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,WADK;AAELC,MAAAA,iBAFK;AAGLC,MAAAA,OAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEX,aAAF,CALV;AAMA,WAAO;AACNO,MAAAA,QAAQ,EAAEK,WAAW,CAAEN,iBAAF,CADf;AAENE,MAAAA,YAAY,EA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AACkB;AAAhC,MAFR;AAGC,IAAA,GAAG,EAAGJ,GAHP;AAIC,IAAA,UAAU,EAAGE,UAJd;AAKC,IAAA,IAAI,EAAC;AALN,KAOC,cAAC,SAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,oBAAoB,EAAGrB;AAFxB,IAPD,CAJD,EAgBC,cAAC,oCAAD,QACG,CAAE;AAAEwB,IAAAA;AAAF,GAAF,KACD,cAAC,oBAAD;AAAsB,IAAA,OAAO,EAAGA;AAAhC,IAFF,CAhBD,CAvBD,CADD;AAgDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockList,\n\tBlockTools,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n} from '@wordpress/block-editor';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartConverter from '../template-part-converter';\nimport NavigateToLink from '../navigate-to-link';\nimport { SidebarInspectorFill } from '../sidebar';\nimport { store as editSiteStore } from '../../store';\nimport BlockInspectorButton from './block-inspector-button';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor( { setIsInserterOpen } ) {\n\tconst { settings, templateType, page, deviceType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tgetEditedPostType,\n\t\t\t\tgetPage,\n\t\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\t} = select( editSiteStore );\n\t\t\treturn {\n\t\t\t\tsettings: getSettings( setIsInserterOpen ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\tpage: getPage(),\n\t\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\tconst { setPage } = useDispatch( editSiteStore );\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, true );\n\tconst ref = useMouseMoveTypingReset();\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<TemplatePartConverter />\n\t\t\t<__experimentalLinkControl.ViewerFill>\n\t\t\t\t{ useCallback(\n\t\t\t\t\t( fillProps ) => (\n\t\t\t\t\t\t<NavigateToLink\n\t\t\t\t\t\t\t{ ...fillProps }\n\t\t\t\t\t\t\tactivePage={ page }\n\t\t\t\t\t\t\tonActivePageChange={ setPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\t[ page ]\n\t\t\t\t) }\n\t\t\t</__experimentalLinkControl.ViewerFill>\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t<BlockTools\n\t\t\t\tclassName=\"edit-site-visual-editor\"\n\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t>\n\t\t\t\t<Iframe\n\t\t\t\t\tstyle={ resizedCanvasStyles }\n\t\t\t\t\thead={ <EditorStyles styles={ settings.styles } /> }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t\tname=\"editor-canvas\"\n\t\t\t\t>\n\t\t\t\t\t<BlockList\n\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t/>\n\t\t\t\t</Iframe>\n\t\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t\t</BlockTools>\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["classnames","useSelect","useDispatch","useCallback","useRef","useEntityBlockEditor","BlockEditorProvider","__experimentalLinkControl","BlockInspector","BlockList","BlockTools","__unstableBlockSettingsMenuFirstItem","__experimentalUseResizeCanvas","useResizeCanvas","__unstableUseTypingObserver","useTypingObserver","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","useMergeRefs","TemplatePartConverter","NavigateToLink","SidebarInspectorFill","store","editSiteStore","BlockInspectorButton","EditTemplatePartMenuButton","BackButton","LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","templateType","page","deviceType","select","getSettings","getEditedPostType","getPage","__experimentalGetPreviewDeviceType","blocks","onInput","onChange","setPage","resizedCanvasStyles","ref","contentRef","mergedRefs","isTemplatePart","fillProps","styles","onClose"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SACCC,mBADD,EAECC,yBAFD,EAGCC,cAHD,EAICC,SAJD,EAKCC,UALD,EAMCC,oCAND,EAOCC,6BAA6B,IAAIC,eAPlC,EA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;AANX,KAQC,cAAC,SAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,oBAAoB,EAAGrB;AAFxB,IARD,CAPD,EAoBC,cAAC,oCAAD,QACG,CAAE;AAAEyB,IAAAA;AAAF,GAAF,KACD,cAAC,oBAAD;AAAsB,IAAA,OAAO,EAAGA;AAAhC,IAFF,CApBD,CAxBD,CADD;AAqDA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockList,\n\tBlockTools,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n} from '@wordpress/block-editor';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartConverter from '../template-part-converter';\nimport NavigateToLink from '../navigate-to-link';\nimport { SidebarInspectorFill } from '../sidebar';\nimport { store as editSiteStore } from '../../store';\nimport BlockInspectorButton from './block-inspector-button';\nimport EditTemplatePartMenuButton from '../edit-template-part-menu-button';\nimport BackButton from './back-button';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor( { setIsInserterOpen } ) {\n\tconst { settings, templateType, page, deviceType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tgetEditedPostType,\n\t\t\t\tgetPage,\n\t\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\t} = select( editSiteStore );\n\n\t\t\treturn {\n\t\t\t\tsettings: getSettings( setIsInserterOpen ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\tpage: getPage(),\n\t\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\tconst { setPage } = useDispatch( editSiteStore );\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, true );\n\tconst ref = useMouseMoveTypingReset();\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<EditTemplatePartMenuButton />\n\t\t\t<TemplatePartConverter />\n\t\t\t<__experimentalLinkControl.ViewerFill>\n\t\t\t\t{ useCallback(\n\t\t\t\t\t( fillProps ) => (\n\t\t\t\t\t\t<NavigateToLink\n\t\t\t\t\t\t\t{ ...fillProps }\n\t\t\t\t\t\t\tactivePage={ page }\n\t\t\t\t\t\t\tonActivePageChange={ setPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\t[ page ]\n\t\t\t\t) }\n\t\t\t</__experimentalLinkControl.ViewerFill>\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t<BlockTools\n\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t'is-focus-mode': isTemplatePart,\n\t\t\t\t} ) }\n\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t>\n\t\t\t\t<BackButton />\n\t\t\t\t<Iframe\n\t\t\t\t\tstyle={ resizedCanvasStyles }\n\t\t\t\t\thead={ <EditorStyles styles={ settings.styles } /> }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t\tname=\"editor-canvas\"\n\t\t\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t\t>\n\t\t\t\t\t<BlockList\n\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t/>\n\t\t\t\t</Iframe>\n\t\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t\t</BlockTools>\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { useSelect, useDispatch } from '@wordpress/data';
7
+ import { store as blockEditorStore, BlockSettingsMenuControls } from '@wordpress/block-editor';
8
+ import { store as coreStore } from '@wordpress/core-data';
9
+ import { MenuItem } from '@wordpress/components';
10
+ import { isTemplatePart } from '@wordpress/blocks';
11
+ import { __, sprintf } from '@wordpress/i18n';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { store as editSiteStore } from '../../store';
17
+ export default function EditTemplatePartMenuButton() {
18
+ const selectedTemplatePart = useSelect(select => {
19
+ const block = select(blockEditorStore).getSelectedBlock();
20
+
21
+ if (block && isTemplatePart(block)) {
22
+ const {
23
+ theme,
24
+ slug
25
+ } = block.attributes;
26
+ return select(coreStore).getEntityRecord('postType', 'wp_template_part', // Ideally this should be an official public API.
27
+ `${theme}//${slug}`);
28
+ }
29
+ }, []);
30
+ const {
31
+ pushTemplatePart
32
+ } = useDispatch(editSiteStore);
33
+
34
+ if (!selectedTemplatePart) {
35
+ return null;
36
+ }
37
+
38
+ return createElement(BlockSettingsMenuControls, null, ({
39
+ onClose
40
+ }) => createElement(MenuItem, {
41
+ onClick: () => {
42
+ pushTemplatePart(selectedTemplatePart.id);
43
+ onClose();
44
+ }
45
+ },
46
+ /* translators: %s: template part title */
47
+ sprintf(__('Edit %s'), selectedTemplatePart.slug)));
48
+ }
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/edit-template-part-menu-button/index.js"],"names":["useSelect","useDispatch","store","blockEditorStore","BlockSettingsMenuControls","coreStore","MenuItem","isTemplatePart","__","sprintf","editSiteStore","EditTemplatePartMenuButton","selectedTemplatePart","select","block","getSelectedBlock","theme","slug","attributes","getEntityRecord","pushTemplatePart","onClose","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,KAAK,IAAIC,gBADV,EAECC,yBAFD,QAGO,yBAHP;AAIA,SAASF,KAAK,IAAIG,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASP,KAAK,IAAIQ,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,0BAAT,GAAsC;AACpD,QAAMC,oBAAoB,GAAGZ,SAAS,CAAIa,MAAF,IAAc;AACrD,UAAMC,KAAK,GAAGD,MAAM,CAAEV,gBAAF,CAAN,CAA2BY,gBAA3B,EAAd;;AAEA,QAAKD,KAAK,IAAIP,cAAc,CAAEO,KAAF,CAA5B,EAAwC;AACvC,YAAM;AAAEE,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAkBH,KAAK,CAACI,UAA9B;AAEA,aAAOL,MAAM,CAAER,SAAF,CAAN,CAAoBc,eAApB,CACN,UADM,EAEN,kBAFM,EAGN;AACC,SAAGH,KAAO,KAAKC,IAAM,EAJhB,CAAP;AAMA;AACD,GAbqC,EAanC,EAbmC,CAAtC;AAcA,QAAM;AAAEG,IAAAA;AAAF,MAAuBnB,WAAW,CAAES,aAAF,CAAxC;;AAEA,MAAK,CAAEE,oBAAP,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC,cAAC,yBAAD,QACG,CAAE;AAAES,IAAAA;AAAF,GAAF,KACD,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfD,MAAAA,gBAAgB,CAAER,oBAAoB,CAACU,EAAvB,CAAhB;AACAD,MAAAA,OAAO;AACP;AAJF;AAOE;AACAZ,EAAAA,OAAO,CAAED,EAAE,CAAE,SAAF,CAAJ,EAAmBI,oBAAoB,CAACK,IAAxC,CART,CAFF,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tBlockSettingsMenuControls,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { MenuItem } from '@wordpress/components';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function EditTemplatePartMenuButton() {\n\tconst selectedTemplatePart = useSelect( ( select ) => {\n\t\tconst block = select( blockEditorStore ).getSelectedBlock();\n\n\t\tif ( block && isTemplatePart( block ) ) {\n\t\t\tconst { theme, slug } = block.attributes;\n\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t// Ideally this should be an official public API.\n\t\t\t\t`${ theme }//${ slug }`\n\t\t\t);\n\t\t}\n\t}, [] );\n\tconst { pushTemplatePart } = useDispatch( editSiteStore );\n\n\tif ( ! selectedTemplatePart ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tpushTemplatePart( selectedTemplatePart.id );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\tsprintf( __( 'Edit %s' ), selectedTemplatePart.slug )\n\t\t\t\t\t}\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"]}
@@ -123,7 +123,7 @@ export default function GlobalStylesProvider({
123
123
  blockTypes: select(blocksStore).getBlockTypes(),
124
124
  settings: select(editSiteStore).getSettings()
125
125
  };
126
- });
126
+ }, []);
127
127
  const {
128
128
  updateSettings
129
129
  } = useDispatch(editSiteStore);