@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
@@ -15,14 +15,14 @@ var _data = require("@wordpress/data");
15
15
 
16
16
  var _components = require("@wordpress/components");
17
17
 
18
- var _url = require("@wordpress/url");
19
-
20
- var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
21
-
22
18
  var _i18n = require("@wordpress/i18n");
23
19
 
24
20
  var _notices = require("@wordpress/notices");
25
21
 
22
+ var _coreData = require("@wordpress/core-data");
23
+
24
+ var _routes = require("../routes");
25
+
26
26
  var _createTemplatePartModal = _interopRequireDefault(require("../create-template-part-modal"));
27
27
 
28
28
  /**
@@ -40,10 +40,17 @@ function NewTemplatePart(_ref) {
40
40
  let {
41
41
  postType
42
42
  } = _ref;
43
+ const history = (0, _routes.useHistory)();
43
44
  const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
44
45
  const {
45
46
  createErrorNotice
46
47
  } = (0, _data.useDispatch)(_notices.store);
48
+ const {
49
+ saveEntityRecord
50
+ } = (0, _data.useDispatch)(_coreData.store);
51
+ const {
52
+ getLastEntitySaveError
53
+ } = (0, _data.useSelect)(_coreData.store);
47
54
 
48
55
  async function createTemplatePart(_ref2) {
49
56
  let {
@@ -59,26 +66,30 @@ function NewTemplatePart(_ref) {
59
66
  }
60
67
 
61
68
  try {
62
- const templatePart = await (0, _apiFetch.default)({
63
- path: '/wp/v2/template-parts',
64
- method: 'POST',
65
- data: {
66
- slug: (0, _lodash.kebabCase)(title),
67
- title,
68
- content: '',
69
- area
70
- }
71
- }); // Navigate to the created template part editor.
72
-
73
- window.location.href = (0, _url.addQueryArgs)(window.location.href, {
74
- postId: templatePart.id,
75
- postType: 'wp_template_part'
69
+ const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
70
+ slug: (0, _lodash.kebabCase)(title),
71
+ title,
72
+ content: '',
73
+ area
76
74
  });
75
+ const lastEntitySaveError = getLastEntitySaveError('postType', 'wp_template_part', templatePart.id);
76
+
77
+ if (lastEntitySaveError) {
78
+ throw lastEntitySaveError;
79
+ }
80
+
81
+ setIsModalOpen(false); // Navigate to the created template part editor.
82
+
83
+ history.push({
84
+ postId: templatePart.id,
85
+ postType: templatePart.type
86
+ }); // TODO: Add a success notice?
77
87
  } catch (error) {
78
88
  const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the template part.');
79
89
  createErrorNotice(errorMessage, {
80
90
  type: 'snackbar'
81
91
  });
92
+ setIsModalOpen(false);
82
93
  }
83
94
  }
84
95
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["NewTemplatePart","postType","isModalOpen","setIsModalOpen","createErrorNotice","noticesStore","createTemplatePart","title","area","type","templatePart","path","method","data","slug","content","window","location","href","postId","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A,qDADA,CAHJ;AAOAnB,MAAAA,iBAAiB,CAAEkB,YAAF,EAAgB;AAAEb,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA;AACD;;AAED,SACC,qDACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfN,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA;AAJF,KAMGF,QAAQ,CAACwB,MAAT,CAAgBC,OANnB,CADD,EASGxB,WAAW,IACZ,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGG;AAFZ,IAVF,CADD;AAkBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function NewTemplatePart( { postType } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function createTemplatePart( { title, area } ) {\n\t\tif ( ! title ) {\n\t\t\tcreateErrorNotice( __( 'Title is not defined.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templatePart = await apiFetch( {\n\t\t\t\tpath: '/wp/v2/template-parts',\n\t\t\t\tmethod: 'POST',\n\t\t\t\tdata: {\n\t\t\t\t\tslug: kebabCase( title ),\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: '',\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\t// Navigate to the created template part editor.\n\t\t\twindow.location.href = addQueryArgs( window.location.href, {\n\t\t\t\tpostId: templatePart.id,\n\t\t\t\tpostType: 'wp_template_part',\n\t\t\t} );\n\t\t} catch ( error ) {\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: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ postType.labels.add_new }\n\t\t\t</Button>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\tonCreate={ createTemplatePart }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["NewTemplatePart","postType","history","isModalOpen","setIsModalOpen","createErrorNotice","noticesStore","saveEntityRecord","coreStore","getLastEntitySaveError","createTemplatePart","title","area","type","templatePart","slug","content","lastEntitySaveError","id","push","postId","error","errorMessage","message","code","labels","add_new"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAIe,SAASA,eAAT,OAAyC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACvD,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaC,cAA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,CAAE,KAAF,CAAd;AACA;AACD;;AAED,SACC,qDACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfA,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA;AAJF,KAMGH,QAAQ,CAACwB,MAAT,CAAgBC,OANnB,CADD,EASGvB,WAAW,IACZ,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGM;AAFZ,IAVF,CADD;AAkBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from '../routes';\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function NewTemplatePart( { postType } ) {\n\tconst history = useHistory();\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { getLastEntitySaveError } = useSelect( coreStore );\n\n\tasync function createTemplatePart( { title, area } ) {\n\t\tif ( ! title ) {\n\t\t\tcreateErrorNotice( __( 'Title is not defined.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: kebabCase( title ),\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: '',\n\t\t\t\t\tarea,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst lastEntitySaveError = getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePart.id\n\t\t\t);\n\t\t\tif ( lastEntitySaveError ) {\n\t\t\t\tthrow lastEntitySaveError;\n\t\t\t}\n\n\t\t\tsetIsModalOpen( false );\n\n\t\t\t// Navigate to the created template part editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: templatePart.id,\n\t\t\t\tpostType: templatePart.type,\n\t\t\t} );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\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: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tsetIsModalOpen( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ postType.labels.add_new }\n\t\t\t</Button>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\tonCreate={ createTemplatePart }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -19,14 +17,12 @@ var _coreData = require("@wordpress/core-data");
19
17
 
20
18
  var _editor = require("@wordpress/editor");
21
19
 
22
- var _url = require("@wordpress/url");
23
-
24
- var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
25
-
26
20
  var _i18n = require("@wordpress/i18n");
27
21
 
28
22
  var _notices = require("@wordpress/notices");
29
23
 
24
+ var _routes = require("../routes");
25
+
30
26
  /**
31
27
  * External dependencies
32
28
  */
@@ -34,12 +30,17 @@ var _notices = require("@wordpress/notices");
34
30
  /**
35
31
  * WordPress dependencies
36
32
  */
33
+
34
+ /**
35
+ * Internal dependencies
36
+ */
37
37
  const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single-post', 'page', 'archive', 'search', '404', 'index'];
38
38
 
39
39
  function NewTemplate(_ref) {
40
40
  let {
41
41
  postType
42
42
  } = _ref;
43
+ const history = (0, _routes.useHistory)();
43
44
  const {
44
45
  templates,
45
46
  defaultTemplateTypes
@@ -49,9 +50,15 @@ function NewTemplate(_ref) {
49
50
  }),
50
51
  defaultTemplateTypes: select(_editor.store).__experimentalGetDefaultTemplateTypes()
51
52
  }), []);
53
+ const {
54
+ saveEntityRecord
55
+ } = (0, _data.useDispatch)(_coreData.store);
52
56
  const {
53
57
  createErrorNotice
54
58
  } = (0, _data.useDispatch)(_notices.store);
59
+ const {
60
+ getLastEntitySaveError
61
+ } = (0, _data.useSelect)(_coreData.store);
55
62
 
56
63
  async function createTemplate(_ref2) {
57
64
  let {
@@ -65,24 +72,24 @@ function NewTemplate(_ref) {
65
72
  } = (0, _lodash.find)(defaultTemplateTypes, {
66
73
  slug
67
74
  });
68
- const template = await (0, _apiFetch.default)({
69
- path: '/wp/v2/templates',
70
- method: 'POST',
71
- data: {
72
- excerpt: description,
73
- // Slugs need to be strings, so this is for template `404`
74
- slug: slug.toString(),
75
- status: 'publish',
76
- title
77
- }
78
- }); // Navigate to the created template editor.
79
-
80
- window.location.href = (0, _url.addQueryArgs)(window.location.href, {
81
- postId: template.id,
82
- postType: 'wp_template'
83
- }); // Wait for async navigation to happen before closing the modal.
75
+ const template = await saveEntityRecord('postType', 'wp_template', {
76
+ excerpt: description,
77
+ // Slugs need to be strings, so this is for template `404`
78
+ slug: slug.toString(),
79
+ status: 'publish',
80
+ title
81
+ });
82
+ const lastEntitySaveError = getLastEntitySaveError('postType', 'wp_template', template.id);
84
83
 
85
- await new Promise(() => {});
84
+ if (lastEntitySaveError) {
85
+ throw lastEntitySaveError;
86
+ } // Navigate to the created template editor.
87
+
88
+
89
+ history.push({
90
+ postId: template.id,
91
+ postType: template.type
92
+ }); // TODO: Add a success notice?
86
93
  } catch (error) {
87
94
  const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the template.');
88
95
  createErrorNotice(errorMessage, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["DEFAULT_TEMPLATE_SLUGS","NewTemplate","postType","templates","defaultTemplateTypes","select","coreStore","getEntityRecords","per_page","editorStore","__experimentalGetDefaultTemplateTypes","createErrorNotice","noticesStore","createTemplate","slug","title","description","template","path","method","data","excerpt","toString","status","window","location","href","postId","id","Promise","error","errorMessage","message","code","type","existingTemplateSlugs","missingTemplates","length","labels","add_new","add_new_item","noArrow","variant"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;AAeA,MAAMA,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,aAF8B,EAG9B,MAH8B,EAI9B,SAJ8B,EAK9B,QAL8B,EAM9B,KAN8B,EAO9B,OAP8B,CAA/B;;AAUe,SAASC,WAAT,OAAqC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACnD,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAsC,qBACzCC,MAAF,KAAgB;AACfF,IAAAA,SAAS,EAAEE,MAAM,CAAEC,eAAF,CAAN,CAAoBC,gBAApB,CACV,UADU,EAEV,aAFU,EAGV;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAHU,CADI;AAMfJ,IAAAA,oBAAoB,EAAEC,MAAM,CAC3BI,aAD2B,CAAN,CAEpBC,qCAFoB;AAN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A,QAAMiC,gBAAgB,GAAG,oBACxBhC,oBADwB,EAEtBa,QAAF,IACC,sBAAUjB,sBAAV,EAAkCiB,QAAQ,CAACH,IAA3C,KACA,CAAE,sBAAUqB,qBAAV,EAAiClB,QAAQ,CAACH,IAA1C,CAJqB,CAAzB;;AAOA,MAAK,CAAEsB,gBAAgB,CAACC,MAAxB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAG,IAFR;AAGC,IAAA,IAAI,EAAGnC,QAAQ,CAACoC,MAAT,CAAgBC,OAHxB;AAIC,IAAA,KAAK,EAAGrC,QAAQ,CAACoC,MAAT,CAAgBE,YAJzB;AAKC,IAAA,YAAY,EAAG;AACdC,MAAAA,OAAO,EAAE;AADK,KALhB;AAQC,IAAA,WAAW,EAAG;AACbC,MAAAA,OAAO,EAAE;AADI;AARf,KAYG,MACD,4BAAC,yBAAD;AAAe,IAAA,SAAS,EAAC;AAAzB,KACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAGxC,QAAQ,CAACoC,MAAT,CAAgBE;AAAnC,KACG,iBACDJ,gBADC,EAED;AAAA,QAAE;AAAErB,MAAAA,KAAF;AAASC,MAAAA,WAAT;AAAsBF,MAAAA;AAAtB,KAAF;AAAA,WACC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAGE,WADR;AAEC,MAAA,GAAG,EAAGF,IAFP;AAGC,MAAA,OAAO,EAAG,MAAM;AACfD,QAAAA,cAAc,CAAE;AAAEC,UAAAA;AAAF,SAAF,CAAd,CADe,CAEf;AACA;AANF,OAQGC,KARH,CADD;AAAA,GAFC,CADH,CADD,CAbF,CADD;AAoCA","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, find, includes, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single-post',\n\t'page',\n\t'archive',\n\t'search',\n\t'404',\n\t'index',\n];\n\nexport default function NewTemplate( { postType } ) {\n\tconst { templates, defaultTemplateTypes } = useSelect(\n\t\t( select ) => ( {\n\t\t\ttemplates: select( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{ per_page: -1 }\n\t\t\t),\n\t\t\tdefaultTemplateTypes: select(\n\t\t\t\teditorStore\n\t\t\t).__experimentalGetDefaultTemplateTypes(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function createTemplate( { slug } ) {\n\t\ttry {\n\t\t\tconst { title, description } = find( defaultTemplateTypes, {\n\t\t\t\tslug,\n\t\t\t} );\n\n\t\t\tconst template = await apiFetch( {\n\t\t\t\tpath: '/wp/v2/templates',\n\t\t\t\tmethod: 'POST',\n\t\t\t\tdata: {\n\t\t\t\t\texcerpt: description,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\twindow.location.href = addQueryArgs( window.location.href, {\n\t\t\t\tpostId: template.id,\n\t\t\t\tpostType: 'wp_template',\n\t\t\t} );\n\n\t\t\t// Wait for async navigation to happen before closing the modal.\n\t\t\tawait new Promise( () => {} );\n\t\t} catch ( error ) {\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 template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t}\n\n\tconst existingTemplateSlugs = map( templates, 'slug' );\n\n\tconst missingTemplates = filter(\n\t\tdefaultTemplateTypes,\n\t\t( template ) =>\n\t\t\tincludes( DEFAULT_TEMPLATE_SLUGS, template.slug ) &&\n\t\t\t! includes( existingTemplateSlugs, template.slug )\n\t);\n\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\ticon={ null }\n\t\t\ttext={ postType.labels.add_new }\n\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\tpopoverProps={ {\n\t\t\t\tnoArrow: false,\n\t\t\t} }\n\t\t\ttoggleProps={ {\n\t\t\t\tvariant: 'primary',\n\t\t\t} }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t{ map(\n\t\t\t\t\t\t\tmissingTemplates,\n\t\t\t\t\t\t\t( { title, description, slug } ) => (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tcreateTemplate( { slug } );\n\t\t\t\t\t\t\t\t\t\t// We will be navigated way so no need to close the dropdown.\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</NavigableMenu>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["DEFAULT_TEMPLATE_SLUGS","NewTemplate","postType","history","templates","defaultTemplateTypes","select","coreStore","getEntityRecords","per_page","editorStore","__experimentalGetDefaultTemplateTypes","saveEntityRecord","createErrorNotice","noticesStore","getLastEntitySaveError","createTemplate","slug","title","description","template","excerpt","toString","status","lastEntitySaveError","id","push","postId","type","error","errorMessage","message","code","existingTemplateSlugs","missingTemplates","length","labels","add_new","add_new_item","noArrow","variant"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,aAF8B,EAG9B,MAH8B,EAI9B,SAJ8B,EAK9B,QAL8B,EAM9B,KAN8B,EAO9B,OAP8B,CAA/B;;AAUe,SAASC,WAAT,OAAqC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACnD,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAsC,qBACzCC,MAAF,KAAgB;AACfF,IAAAA,SAAS,EAAEE,MAAM,CAAEC,eAAF,CAAN,CAAoBC,gBAApB,CACV,UADU,EAEV,aAFU,EAGV;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAHU,CADI;AAMfJ,IAAAA,oBAAoB,EAAEC,MAAM,CAC3BI,aAD2B,CAAN,CAEpBC,qCAFoB;AANP,GAAhB,CAD2C,EAW3C,EAX2C,CAA5C;AAaA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaL,eAAb,CAA7B;AACA,QAAM;AAAEM,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA6B,qBAAWR,eAAX,CAAnC;;AAE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V,EAAiCb,QAAQ,CAACH,IAA1C,CAJqB,CAAzB;;AAOA,MAAK,CAAEiB,gBAAgB,CAACC,MAAxB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAG,IAFR;AAGC,IAAA,IAAI,EAAGjC,QAAQ,CAACkC,MAAT,CAAgBC,OAHxB;AAIC,IAAA,KAAK,EAAGnC,QAAQ,CAACkC,MAAT,CAAgBE,YAJzB;AAKC,IAAA,YAAY,EAAG;AACdC,MAAAA,OAAO,EAAE;AADK,KALhB;AAQC,IAAA,WAAW,EAAG;AACbC,MAAAA,OAAO,EAAE;AADI;AARf,KAYG,MACD,4BAAC,yBAAD;AAAe,IAAA,SAAS,EAAC;AAAzB,KACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAGtC,QAAQ,CAACkC,MAAT,CAAgBE;AAAnC,KACG,iBACDJ,gBADC,EAED;AAAA,QAAE;AAAEhB,MAAAA,KAAF;AAASC,MAAAA,WAAT;AAAsBF,MAAAA;AAAtB,KAAF;AAAA,WACC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAGE,WADR;AAEC,MAAA,GAAG,EAAGF,IAFP;AAGC,MAAA,OAAO,EAAG,MAAM;AACfD,QAAAA,cAAc,CAAE;AAAEC,UAAAA;AAAF,SAAF,CAAd,CADe,CAEf;AACA;AANF,OAQGC,KARH,CADD;AAAA,GAFC,CADH,CADD,CAbF,CADD;AAoCA","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, find, includes, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from '../routes';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single-post',\n\t'page',\n\t'archive',\n\t'search',\n\t'404',\n\t'index',\n];\n\nexport default function NewTemplate( { postType } ) {\n\tconst history = useHistory();\n\tconst { templates, defaultTemplateTypes } = useSelect(\n\t\t( select ) => ( {\n\t\t\ttemplates: select( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{ per_page: -1 }\n\t\t\t),\n\t\t\tdefaultTemplateTypes: select(\n\t\t\t\teditorStore\n\t\t\t).__experimentalGetDefaultTemplateTypes(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { getLastEntitySaveError } = useSelect( coreStore );\n\n\tasync function createTemplate( { slug } ) {\n\t\ttry {\n\t\t\tconst { title, description } = find( defaultTemplateTypes, {\n\t\t\t\tslug,\n\t\t\t} );\n\n\t\t\tconst template = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\texcerpt: description,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst lastEntitySaveError = getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplate.id\n\t\t\t);\n\t\t\tif ( lastEntitySaveError ) {\n\t\t\t\tthrow lastEntitySaveError;\n\t\t\t}\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: template.id,\n\t\t\t\tpostType: template.type,\n\t\t\t} );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\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 template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t}\n\n\tconst existingTemplateSlugs = map( templates, 'slug' );\n\n\tconst missingTemplates = filter(\n\t\tdefaultTemplateTypes,\n\t\t( template ) =>\n\t\t\tincludes( DEFAULT_TEMPLATE_SLUGS, template.slug ) &&\n\t\t\t! includes( existingTemplateSlugs, template.slug )\n\t);\n\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\ticon={ null }\n\t\t\ttext={ postType.labels.add_new }\n\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\tpopoverProps={ {\n\t\t\t\tnoArrow: false,\n\t\t\t} }\n\t\t\ttoggleProps={ {\n\t\t\t\tvariant: 'primary',\n\t\t\t} }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t{ map(\n\t\t\t\t\t\t\tmissingTemplates,\n\t\t\t\t\t\t\t( { title, description, slug } ) => (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tcreateTemplate( { slug } );\n\t\t\t\t\t\t\t\t\t\t// We will be navigated way so no need to close the dropdown.\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</NavigableMenu>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
@@ -0,0 +1,51 @@
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 = EditSiteApp;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ var _editor = require("@wordpress/editor");
15
+
16
+ var _routes = require("../routes");
17
+
18
+ var _editor2 = _interopRequireDefault(require("../editor"));
19
+
20
+ var _list = _interopRequireDefault(require("../list"));
21
+
22
+ var _navigationSidebar = _interopRequireDefault(require("../navigation-sidebar"));
23
+
24
+ var _getIsListPage = _interopRequireDefault(require("../../utils/get-is-list-page"));
25
+
26
+ /**
27
+ * WordPress dependencies
28
+ */
29
+
30
+ /**
31
+ * Internal dependencies
32
+ */
33
+ function EditSiteApp(_ref) {
34
+ let {
35
+ reboot
36
+ } = _ref;
37
+ return (0, _element.createElement)(_components.SlotFillProvider, null, (0, _element.createElement)(_editor.UnsavedChangesWarning, null), (0, _element.createElement)(_routes.Routes, null, _ref2 => {
38
+ let {
39
+ params
40
+ } = _ref2;
41
+ const isListPage = (0, _getIsListPage.default)(params);
42
+ return (0, _element.createElement)(_element.Fragment, null, isListPage ? (0, _element.createElement)(_list.default, null) : (0, _element.createElement)(_editor2.default, {
43
+ onError: reboot
44
+ }), (0, _element.createElement)(_navigationSidebar.default // Open the navigation sidebar by default when in the list page.
45
+ , {
46
+ isDefaultOpen: !!isListPage,
47
+ activeTemplateType: isListPage ? params.postType : undefined
48
+ }));
49
+ }));
50
+ }
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/app/index.js"],"names":["EditSiteApp","reboot","params","isListPage","postType","undefined"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;AAOe,SAASA,WAAT,OAAmC;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AACjD,SACC,4BAAC,4BAAD,QACC,4BAAC,6BAAD,OADD,EAGC,4BAAC,cAAD,QACG,SAAkB;AAAA,QAAhB;AAAEC,MAAAA;AAAF,KAAgB;AACnB,UAAMC,UAAU,GAAG,4BAAeD,MAAf,CAAnB;AAEA,WACC,qDACGC,UAAU,GACX,4BAAC,aAAD,OADW,GAGX,4BAAC,gBAAD;AAAQ,MAAA,OAAO,EAAGF;AAAlB,MAJF,EAQC,4BAAC,0BAAD,CACC;AADD;AAEC,MAAA,aAAa,EAAG,CAAC,CAAEE,UAFpB;AAGC,MAAA,kBAAkB,EACjBA,UAAU,GAAGD,MAAM,CAACE,QAAV,GAAqBC;AAJjC,MARD,CADD;AAkBA,GAtBF,CAHD,CADD;AA8BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { UnsavedChangesWarning } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { Routes } from '../routes';\nimport Editor from '../editor';\nimport List from '../list';\nimport NavigationSidebar from '../navigation-sidebar';\nimport getIsListPage from '../../utils/get-is-list-page';\n\nexport default function EditSiteApp( { reboot } ) {\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<UnsavedChangesWarning />\n\n\t\t\t<Routes>\n\t\t\t\t{ ( { params } ) => {\n\t\t\t\t\tconst isListPage = getIsListPage( params );\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ isListPage ? (\n\t\t\t\t\t\t\t\t<List />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Editor onError={ reboot } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ /* Keep the instance of the sidebar to ensure focus will not be lost\n\t\t\t\t\t\t\t * when navigating to other pages. */ }\n\t\t\t\t\t\t\t<NavigationSidebar\n\t\t\t\t\t\t\t\t// Open the navigation sidebar by default when in the list page.\n\t\t\t\t\t\t\t\tisDefaultOpen={ !! isListPage }\n\t\t\t\t\t\t\t\tactiveTemplateType={\n\t\t\t\t\t\t\t\t\tisListPage ? params.postType : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</Routes>\n\t\t</SlotFillProvider>\n\t);\n}\n"]}
@@ -11,11 +11,9 @@ var _components = require("@wordpress/components");
11
11
 
12
12
  var _icons = require("@wordpress/icons");
13
13
 
14
- var _data = require("@wordpress/data");
15
-
16
14
  var _i18n = require("@wordpress/i18n");
17
15
 
18
- var _store = require("../../store");
16
+ var _routes = require("../routes");
19
17
 
20
18
  /**
21
19
  * WordPress dependencies
@@ -25,22 +23,12 @@ var _store = require("../../store");
25
23
  * Internal dependencies
26
24
  */
27
25
  function BackButton() {
28
- const {
29
- isTemplatePart,
30
- previousTemplateId
31
- } = (0, _data.useSelect)(select => {
32
- const {
33
- getEditedPostType,
34
- getPreviousEditedPostId
35
- } = select(_store.store);
36
- return {
37
- isTemplatePart: getEditedPostType() === 'wp_template_part',
38
- previousTemplateId: getPreviousEditedPostId()
39
- };
40
- }, []);
41
- const {
42
- goBack
43
- } = (0, _data.useDispatch)(_store.store);
26
+ var _location$state;
27
+
28
+ const location = (0, _routes.useLocation)();
29
+ const history = (0, _routes.useHistory)();
30
+ const isTemplatePart = location.params.postType === 'wp_template_part';
31
+ const previousTemplateId = (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.fromTemplateId;
44
32
 
45
33
  if (!isTemplatePart || !previousTemplateId) {
46
34
  return null;
@@ -50,7 +38,7 @@ function BackButton() {
50
38
  className: "edit-site-visual-editor__back-button",
51
39
  icon: _icons.arrowLeft,
52
40
  onClick: () => {
53
- goBack();
41
+ history.back();
54
42
  }
55
43
  }, (0, _i18n.__)('Back'));
56
44
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/back-button.js"],"names":["BackButton","isTemplatePart","previousTemplateId","select","getEditedPostType","getPreviousEditedPostId","editSiteStore","goBack","arrowLeft"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,UAAT,GAAsB;AACrB,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAyC,qBAAaC,MAAF,IAAc;AACvE,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAiDF,MAAM,CAC5DG,YAD4D,CAA7D;AAIA,WAAO;AACNL,MAAAA,cAAc,EAAEG,iBAAiB,OAAO,kBADlC;AAENF,MAAAA,kBAAkB,EAAEG,uBAAuB;AAFrC,KAAP;AAIA,GAT8C,EAS5C,EAT4C,CAA/C;AAUA,QAAM;AAAEE,IAAAA;AAAF,MAAa,uBAAaD,YAAb,CAAnB;;AAEA,MAAK,CAAEL,cAAF,IAAoB,CAAEC,kBAA3B,EAAgD;AAC/C,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,sCADX;AAEC,IAAA,IAAI,EAAGM,gBAFR;AAGC,IAAA,OAAO,EAAG,MAAM;AACfD,MAAAA,MAAM;AACN;AALF,KAOG,cAAI,MAAJ,CAPH,CADD;AAWA;;eAEcP,U","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
+ {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/back-button.js"],"names":["BackButton","location","history","isTemplatePart","params","postType","previousTemplateId","state","fromTemplateId","arrowLeft","back"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,UAAT,GAAsB;AAAA;;AACrB,QAAMC,QAAQ,GAAG,0BAAjB;AACA,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAMC,cAAc,GAAGF,QAAQ,CAACG,MAAT,CAAgBC,QAAhB,KAA6B,kBAApD;AACA,QAAMC,kBAAkB,sBAAGL,QAAQ,CAACM,KAAZ,oDAAG,gBAAgBC,cAA3C;;AAEA,MAAK,CAAEL,cAAF,IAAoB,CAAEG,kBAA3B,EAAgD;AAC/C,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,sCADX;AAEC,IAAA,IAAI,EAAGG,gBAFR;AAGC,IAAA,OAAO,EAAG,MAAM;AACfP,MAAAA,OAAO,CAACQ,IAAR;AACA;AALF,KAOG,cAAI,MAAJ,CAPH,CADD;AAWA;;eAEcV,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { arrowLeft } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useLocation, useHistory } from '../routes';\n\nfunction BackButton() {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst isTemplatePart = location.params.postType === 'wp_template_part';\n\tconst previousTemplateId = location.state?.fromTemplateId;\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\thistory.back();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Back' ) }\n\t\t</Button>\n\t);\n}\n\nexport default BackButton;\n"]}
@@ -119,7 +119,8 @@ function BlockEditor(_ref) {
119
119
  contentRef: mergedRefs
120
120
  }, (0, _element.createElement)(_blockEditor.BlockList, {
121
121
  className: "edit-site-block-editor__block-list wp-site-blocks",
122
- __experimentalLayout: LAYOUT
122
+ __experimentalLayout: LAYOUT,
123
+ renderAppender: isTemplatePart ? false : undefined
123
124
  })), (0, _element.createElement)(_blockEditor.__unstableBlockSettingsMenuFirstItem, null, _ref2 => {
124
125
  let {
125
126
  onClose
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","templateType","templateId","page","select","getSettings","getEditedPostType","getEditedPostId","getPage","editSiteStore","blocks","onInput","onChange","setPage","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","blockEditorStore","isTemplatePart","fillProps","event","target","currentTarget","onClose"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AAUA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAMA,MAAM,GAAG;AACdC,EAAAA,IAAI,EAAE,SADQ;AAEd;AACAC,EAAAA,UAAU,EAAE;AAHE,CAAf;;AAMe,SAASC,WAAT,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2B,UAA3B,QACG,0BACCQ,SAAF,IACC,4BAAC,uBAAD,6BACMA,SADN;AAEC,IAAA,UAAU,EAAGjB,IAFd;AAGC,IAAA,kBAAkB,EAAGU;AAHtB,KAFA,EAQD,CAAEV,IAAF,CARC,CADH,CATD,EAqBC,4BAAC,6BAAD,QACC,4BAAC,2BAAD,OADD,CArBD,EAwBC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAG,yBAAY,yBAAZ,EAAuC;AAClD,uBAAiBgB;AADiC,KAAvC,CADb;AAIC,IAAA,oBAAoB,EAAGL,UAJxB;AAKC,IAAA,OAAO,EAAKO,KAAF,IAAa;AACtB;AACA,UAAKA,KAAK,CAACC,MAAN,KAAiBD,KAAK,CAACE,aAA5B,EAA4C;AAC3CN,QAAAA,kBAAkB;AAClB;AACD;AAVF,KAYC,4BAAC,mBAAD,OAZD,EAcC,4BAAC,wBAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAGf,UAFP;AAGC,IAAA,cAAc,EACbiB,cAAc,IACd;AACA,KAAEH,gBANJ;AAQC,IAAA,QAAQ,EAAGhB,QARZ;AASC,IAAA,UAAU,EAAGe;AATd,KAWC,4BAAC,sBAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,oBAAoB,EAAGpB;AAFxB,IAXD,CAdD,EA+BC,4BAAC,iDAAD,QACG;AAAA,QAAE;AAAE6B,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,6BAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CA/BD,CAxBD,EA6DC,4BAAC,uCAAD,OA7DD,CADD;AAiEA","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\tBlockList,\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useMergeRefs, useViewportMatch } from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\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';\nimport ResizableEditor from './resizable-editor';\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, templateId, page } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tgetEditedPostType,\n\t\t\t\tgetEditedPostId,\n\t\t\t\tgetPage,\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\ttemplateId: getEditedPostId(),\n\t\t\t\tpage: getPage(),\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 contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\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\tonClick={ ( event ) => {\n\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BackButton />\n\n\t\t\t\t<ResizableEditor\n\t\t\t\t\t// Reinitialize the editor and reset the states when the template changes.\n\t\t\t\t\tkey={ templateId }\n\t\t\t\t\tenableResizing={\n\t\t\t\t\t\tisTemplatePart &&\n\t\t\t\t\t\t// Disable resizing in mobile viewport.\n\t\t\t\t\t\t! isMobileViewport\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tcontentRef={ mergedRefs }\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</ResizableEditor>\n\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\t<ReusableBlocksMenuItems />\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","templateType","templateId","page","select","getSettings","getEditedPostType","getEditedPostId","getPage","editSiteStore","blocks","onInput","onChange","setPage","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","blockEditorStore","isTemplatePart","fillProps","event","target","currentTarget","undefined","onClose"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AAUA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAMA,MAAM,GAAG;AACdC,EAAAA,IAAI,EAAE,SADQ;AAEd;AACAC,EAAAA,UAAU,EAAE;AAHE,CAAf;;AAMe,SAASC,WAAT,OAA8C;AAAA,MAAxB;AAAEC,IAAAA;AAAF,GAAwB;AAC5D,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA,UAA1B;AAAsCC,IAAAA;AAAtC,MAA+C,qBAClDC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,WADK;AAELC,MAAAA,iBAFK;AAGLC,MAAAA,eAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEK,YAAF,CALV;AAOA,WAAO;AACNT,MAAAA,QAAQ,EAAEK,WAAW,CAAEN,iBAAF,CADf;AAENE,MAAAA,YAAY,EAAEK,iBAAiB,EAFzB;AAGNJ,MAAAA,UAAU,EAAEK,eAA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,KAAK,CAACE,aAA5B,EAA4C;AAC3CN,QAAAA,kBAAkB;AAClB;AACD;AAVF,KAYC,4BAAC,mBAAD,OAZD,EAcC,4BAAC,wBAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAGf,UAFP;AAGC,IAAA,cAAc,EACbiB,cAAc,IACd;AACA,KAAEH,gBANJ;AAQC,IAAA,QAAQ,EAAGhB,QARZ;AASC,IAAA,UAAU,EAAGe;AATd,KAWC,4BAAC,sBAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,oBAAoB,EAAGpB,MAFxB;AAGC,IAAA,cAAc,EAAGwB,cAAc,GAAG,KAAH,GAAWK;AAH3C,IAXD,CAdD,EAgCC,4BAAC,iDAAD,QACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,6BAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CAhCD,CAxBD,EA8DC,4BAAC,uCAAD,OA9DD,CADD;AAkEA","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\tBlockList,\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useMergeRefs, useViewportMatch } from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\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';\nimport ResizableEditor from './resizable-editor';\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, templateId, page } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tgetEditedPostType,\n\t\t\t\tgetEditedPostId,\n\t\t\t\tgetPage,\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\ttemplateId: getEditedPostId(),\n\t\t\t\tpage: getPage(),\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 contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\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\tonClick={ ( event ) => {\n\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BackButton />\n\n\t\t\t\t<ResizableEditor\n\t\t\t\t\t// Reinitialize the editor and reset the states when the template changes.\n\t\t\t\t\tkey={ templateId }\n\t\t\t\t\tenableResizing={\n\t\t\t\t\t\tisTemplatePart &&\n\t\t\t\t\t\t// Disable resizing in mobile viewport.\n\t\t\t\t\t\t! isMobileViewport\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tcontentRef={ mergedRefs }\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\trenderAppender={ isTemplatePart ? false : undefined }\n\t\t\t\t\t/>\n\t\t\t\t</ResizableEditor>\n\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\t<ReusableBlocksMenuItems />\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
@@ -124,6 +124,7 @@ function ResizableEditor(_ref) {
124
124
  }), (0, _element.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing.
125
125
  // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
126
126
  `.edit-site-block-editor__block-list { display: flow-root; }`)),
127
+ assets: settings.__unstableResolvedAssets,
127
128
  ref: ref,
128
129
  name: "editor-canvas",
129
130
  className: "edit-site-visual-editor__editor-canvas"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/resizable-editor.js"],"names":["DEFAULT_STYLES","width","height","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","top","right","bottom","left","ResizableEditor","enableResizing","settings","props","deviceType","select","editSiteStore","__experimentalGetPreviewDeviceType","deviceStyles","setWidth","setHeight","iframeRef","mouseMoveTypingResetRef","ref","autoResizeIframeHeight","iframe","current","resizeObserver","contentWindow","ResizeObserver","contentDocument","querySelector","offsetHeight","observe","documentElement","disconnect","resizeWidthBy","deltaPixels","offsetWidth","event","direction","element","style","styles"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAYA;AACA;AACA;AAIA,MAAMA,cAAc,GAAG;AACtBC,EAAAA,KAAK,EAAE,MADe;AAEtBC,EAAAA,MAAM,EAAE;AAFc,CAAvB,C,CAKA;;AACA,MAAMC,sBAAsB,GAAG;AAC9BC,EAAAA,QAAQ,EAAEC,SADoB;AAE9BC,EAAAA,UAAU,EAAED,SAFkB;AAG9BE,EAAAA,MAAM,EAAEF,SAHsB;AAI9BJ,EAAAA,KAAK,EAAEI,SAJuB;AAK9BH,EAAAA,MAAM,EAAEG,SALsB;AAM9BG,EAAAA,GAAG,EAAEH,SANyB;AAO9BI,EAAAA,KAAK,EAAEJ,SAPuB;AAQ9BK,EAAAA,MAAM,EAAEL,SARsB;AAS9BM,EAAAA,IAAI,EAAEN;AATwB,CAA/B;;AAYA,SAASO,eAAT,OAAmE;AAAA,MAAzC;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;A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AxCD,CADD;AA4DA;;eAEcH,e","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { ResizableBox } from '@wordpress/components';\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport ResizeHandle from './resize-handle';\n\nconst DEFAULT_STYLES = {\n\twidth: '100%',\n\theight: '100%',\n};\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nfunction ResizableEditor( { enableResizing, settings, ...props } ) {\n\tconst deviceType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t[]\n\t);\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ width, setWidth ] = useState( DEFAULT_STYLES.width );\n\tconst [ height, setHeight ] = useState( DEFAULT_STYLES.height );\n\tconst iframeRef = useRef();\n\tconst mouseMoveTypingResetRef = useMouseMoveTypingReset();\n\tconst ref = useMergeRefs( [ iframeRef, mouseMoveTypingResetRef ] );\n\n\tuseEffect(\n\t\tfunction autoResizeIframeHeight() {\n\t\t\tconst iframe = iframeRef.current;\n\n\t\t\tif ( ! iframe || ! enableResizing ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst resizeObserver = new iframe.contentWindow.ResizeObserver(\n\t\t\t\t() => {\n\t\t\t\t\tsetHeight(\n\t\t\t\t\t\tiframe.contentDocument.querySelector(\n\t\t\t\t\t\t\t`.edit-site-block-editor__block-list`\n\t\t\t\t\t\t).offsetHeight\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// Observing the <html> rather than the <body> because the latter\n\t\t\t// gets destroyed and remounted after initialization in <Iframe>.\n\t\t\tresizeObserver.observe( iframe.contentDocument.documentElement );\n\n\t\t\treturn () => {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t};\n\t\t},\n\t\t[ enableResizing ]\n\t);\n\n\tconst resizeWidthBy = useCallback( ( deltaPixels ) => {\n\t\tif ( iframeRef.current ) {\n\t\t\tsetWidth( iframeRef.current.offsetWidth + deltaPixels );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t\tonResizeStop={ ( event, direction, element ) => {\n\t\t\t\tsetWidth( element.style.width );\n\t\t\t} }\n\t\t\tminWidth={ 300 }\n\t\t\tmaxWidth=\"100%\"\n\t\t\tmaxHeight=\"100%\"\n\t\t\tenable={ {\n\t\t\t\tright: enableResizing,\n\t\t\t\tleft: enableResizing,\n\t\t\t} }\n\t\t\tshowHandle={ enableResizing }\n\t\t\t// The editor is centered horizontally, resizing it only\n\t\t\t// moves half the distance. Hence double the ratio to correctly\n\t\t\t// align the cursor to the resizer handle.\n\t\t\tresizeRatio={ 2 }\n\t\t\thandleComponent={ {\n\t\t\t\tleft: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"left\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tright: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"right\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t} }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tstyle={ enableResizing ? undefined : deviceStyles }\n\t\t\t\thead={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t<style>{\n\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t`.edit-site-block-editor__block-list { display: flow-root; }`\n\t\t\t\t\t\t}</style>\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tref={ ref }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableEditor;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/resizable-editor.js"],"names":["DEFAULT_STYLES","width","height","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","top","right","bottom","left","ResizableEditor","enableResizing","settings","props","deviceType","select","editSiteStore","__experimentalGetPreviewDeviceType","deviceStyles","setWidth","setHeight","iframeRef","mouseMoveTypingResetRef","ref","autoResizeIframeHeight","iframe","current","resizeObserver","contentWindow","ResizeObserver","contentDocument","querySelector","offsetHeight","observe","documentElement","disconnect","resizeWidthBy","deltaPixels","offsetWidth","event","direction","element","style","styles","__unstableResolvedAssets"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAYA;AACA;AACA;AAIA,MAAMA,cAAc,GAAG;AACtBC,EAAAA,KAAK,EAAE,MADe;AAEtBC,EAAAA,MAAM,EAAE;AAFc,CAAvB,C,CAKA;;AACA,MAAMC,sBAAsB,GAAG;AAC9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A,YAAY,EAAG;AACdM,MAAAA,IAAI,EAAER,sBADQ;AAEdM,MAAAA,KAAK,EAAEN;AAFO;AAnChB,KAwCC,4BAAC,6BAAD;AACC,IAAA,KAAK,EAAGU,cAAc,GAAGR,SAAH,GAAee,YADtC;AAEC,IAAA,IAAI,EACH,qDACC,4BAAC,mCAAD;AAAc,MAAA,MAAM,EAAGN,QAAQ,CAAC+B;AAAhC,MADD,EAEC,2CACC;AACA;AACC,iEAHF,CAFD,CAHF;AAYC,IAAA,MAAM,EAAG/B,QAAQ,CAACgC,wBAZnB;AAaC,IAAA,GAAG,EAAGrB,GAbP;AAcC,IAAA,IAAI,EAAC,eAdN;AAeC,IAAA,SAAS,EAAC;AAfX,KAgBMV,KAhBN,EAxCD,CADD;AA6DA;;eAEcH,e","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { ResizableBox } from '@wordpress/components';\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport ResizeHandle from './resize-handle';\n\nconst DEFAULT_STYLES = {\n\twidth: '100%',\n\theight: '100%',\n};\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nfunction ResizableEditor( { enableResizing, settings, ...props } ) {\n\tconst deviceType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t[]\n\t);\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ width, setWidth ] = useState( DEFAULT_STYLES.width );\n\tconst [ height, setHeight ] = useState( DEFAULT_STYLES.height );\n\tconst iframeRef = useRef();\n\tconst mouseMoveTypingResetRef = useMouseMoveTypingReset();\n\tconst ref = useMergeRefs( [ iframeRef, mouseMoveTypingResetRef ] );\n\n\tuseEffect(\n\t\tfunction autoResizeIframeHeight() {\n\t\t\tconst iframe = iframeRef.current;\n\n\t\t\tif ( ! iframe || ! enableResizing ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst resizeObserver = new iframe.contentWindow.ResizeObserver(\n\t\t\t\t() => {\n\t\t\t\t\tsetHeight(\n\t\t\t\t\t\tiframe.contentDocument.querySelector(\n\t\t\t\t\t\t\t`.edit-site-block-editor__block-list`\n\t\t\t\t\t\t).offsetHeight\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// Observing the <html> rather than the <body> because the latter\n\t\t\t// gets destroyed and remounted after initialization in <Iframe>.\n\t\t\tresizeObserver.observe( iframe.contentDocument.documentElement );\n\n\t\t\treturn () => {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t};\n\t\t},\n\t\t[ enableResizing ]\n\t);\n\n\tconst resizeWidthBy = useCallback( ( deltaPixels ) => {\n\t\tif ( iframeRef.current ) {\n\t\t\tsetWidth( iframeRef.current.offsetWidth + deltaPixels );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t\tonResizeStop={ ( event, direction, element ) => {\n\t\t\t\tsetWidth( element.style.width );\n\t\t\t} }\n\t\t\tminWidth={ 300 }\n\t\t\tmaxWidth=\"100%\"\n\t\t\tmaxHeight=\"100%\"\n\t\t\tenable={ {\n\t\t\t\tright: enableResizing,\n\t\t\t\tleft: enableResizing,\n\t\t\t} }\n\t\t\tshowHandle={ enableResizing }\n\t\t\t// The editor is centered horizontally, resizing it only\n\t\t\t// moves half the distance. Hence double the ratio to correctly\n\t\t\t// align the cursor to the resizer handle.\n\t\t\tresizeRatio={ 2 }\n\t\t\thandleComponent={ {\n\t\t\t\tleft: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"left\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tright: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"right\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t} }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tstyle={ enableResizing ? undefined : deviceStyles }\n\t\t\t\thead={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t<style>{\n\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t`.edit-site-block-editor__block-list { display: flow-root; }`\n\t\t\t\t\t\t}</style>\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tassets={ settings.__unstableResolvedAssets }\n\t\t\t\tref={ ref }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableEditor;\n"]}
@@ -56,8 +56,6 @@ function CreateTemplatePartModal(_ref) {
56
56
  title,
57
57
  area
58
58
  });
59
- setIsSubmitting(false);
60
- closeModal();
61
59
  }
62
60
  }, (0, _element.createElement)(_components.TextControl, {
63
61
  label: (0, _i18n.__)('Name'),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/create-template-part-modal/index.js"],"names":["CreateTemplatePartModal","closeModal","onCreate","title","setTitle","area","setArea","TEMPLATE_PART_AREA_GENERAL","isSubmitting","setIsSubmitting","instanceId","templatePartAreas","select","editorStore","__experimentalGetDefaultTemplatePartAreas","event","preventDefault","map","icon","label","value","description","check"],"mappings":";;;;;;;AAiBA;;AAdA;;AACA;;AAYA;;AAEA;;AACA;;AACA;;AAKA;;AAzBA;AACA;AACA;;AAoBA;AACA;AACA;AAGe,SAASA,uBAAT,OAA6D;AAAA,MAA3B;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAA2B;AAC3E,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,EAAV,CAA5B;AACA,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAUC,qCAAV,CAA1B;AACA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AACA,QAAMC,UAAU,GAAG,4BAAeV,uBAAf,CAAnB;AAEA,QAAMW,iBAAiB,GAAG,qBACvBC,MAAF,IACCA,MAAM,CAAEC,aAAF,CAAN,CAAsBC,yCAAtB,EAFwB,EAGzB,EAHyB,CAA1B;AAMA,SACC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,cAAI,wBAAJ,CADT;AAEC,IAAA,UAAU,EAAG,cAAI,OAAJ,CAFd;AAGC,IAAA,cAAc,EAAGb,UAHlB;AAIC,IAAA,gBAAgB,EAAC;AAJlB,KAMC;AACC,IAAA,QAAQ,EAAG,MAAQc,KAAR,IAAmB;AAC7BA,MAAAA,KAAK,CAACC,cAAN;;AACA,UAAK,CAAEb,KAAP,EAAe;AACd;AACA;;AACDM,MAAAA,eAAe,CAAE,IAAF,CAAf;AACA,YAAMP,QAAQ,CAAE;AAAEC,QAAAA,KAAF;AAASE,QA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;AAAb,MAFF,CATD,CALD,CADD;AAAA,GADC,CAPH,CALD,CAlBD,EAyDC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfrB,MAAAA,UAAU;AACV;AAJF,KAMG,cAAI,QAAJ,CANH,CADD,CAJD,EAcC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAEE,KAHd;AAIC,IAAA,MAAM,EAAGK;AAJV,KAMG,cAAI,QAAJ,CANH,CADD,CAdD,CAzDD,CAND,CADD;AA4FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tFlexBlock,\n\tButton,\n\tModal,\n\t__experimentalRadioGroup as RadioGroup,\n\t__experimentalRadio as Radio,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PART_AREA_GENERAL } from '../../store/constants';\n\nexport default function CreateTemplatePartModal( { closeModal, onCreate } ) {\n\tconst [ title, setTitle ] = useState( '' );\n\tconst [ area, setArea ] = useState( TEMPLATE_PART_AREA_GENERAL );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create a template part' ) }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t\toverlayClassName=\"edit-site-create-template-part-modal\"\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( ! title ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetIsSubmitting( true );\n\t\t\t\t\tawait onCreate( { title, area } );\n\t\t\t\t\tsetIsSubmitting( false );\n\t\t\t\t\tcloseModal();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<BaseControl\n\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-base-control\"\n\t\t\t\t>\n\t\t\t\t\t<RadioGroup\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-radio-group\"\n\t\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t\tchecked={ area }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ templatePartAreas.map(\n\t\t\t\t\t\t\t( { icon, label, area: value, description } ) => (\n\t\t\t\t\t\t\t\t<Radio\n\t\t\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-radio\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Flex align=\"start\" justify=\"start\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock className=\"edit-site-create-template-part-modal__option-label\">\n\t\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t\t\t<div>{ description }</div>\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\n\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"edit-site-create-template-part-modal__checkbox\">\n\t\t\t\t\t\t\t\t\t\t\t{ area === value && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t\t</Radio>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RadioGroup>\n\t\t\t\t</BaseControl>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__modal-actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={ ! title }\n\t\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/create-template-part-modal/index.js"],"names":["CreateTemplatePartModal","closeModal","onCreate","title","setTitle","area","setArea","TEMPLATE_PART_AREA_GENERAL","isSubmitting","setIsSubmitting","instanceId","templatePartAreas","select","editorStore","__experimentalGetDefaultTemplatePartAreas","event","preventDefault","map","icon","label","value","description","check"],"mappings":";;;;;;;AAiBA;;AAdA;;AACA;;AAYA;;AAEA;;AACA;;AACA;;AAKA;;AAzBA;AACA;AACA;;AAoBA;AACA;AACA;AAGe,SAASA,uBAAT,OAA6D;AAAA,MAA3B;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAA2B;AAC3E,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,EAAV,CAA5B;AACA,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAUC,qCAAV,CAA1B;AACA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AACA,QAAMC,UAAU,GAAG,4BAAeV,uBAAf,CAAnB;AAEA,QAAMW,iBAAiB,GAAG,qBACvBC,MAAF,IACCA,MAAM,CAAEC,aAAF,CAAN,CAAsBC,yCAAtB,EAFwB,EAGzB,EAHyB,CAA1B;AAMA,SACC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,cAAI,wBAAJ,CADT;AAEC,IAAA,UAAU,EAAG,cAAI,OAAJ,CAFd;AAGC,IAAA,cAAc,EAAGb,UAHlB;AAIC,IAAA,gBAAgB,EAAC;AAJlB,KAMC;AACC,IAAA,QAAQ,EAAG,MAAQc,KAAR,IAAmB;AAC7BA,MAAAA,KAAK,CAACC,cAAN;;AACA,UAAK,CAAEb,KAAP,EAAe;AACd;AACA;;AACDM,MAAAA,eAAe,CAAE,IAAF,CAAf;AACA,YAAMP,QAAQ,CAAE;AAA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,GADC,CAPH,CALD,CAhBD,EAuDC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfrB,MAAAA,UAAU;AACV;AAJF,KAMG,cAAI,QAAJ,CANH,CADD,CAJD,EAcC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAEE,KAHd;AAIC,IAAA,MAAM,EAAGK;AAJV,KAMG,cAAI,QAAJ,CANH,CADD,CAdD,CAvDD,CAND,CADD;AA0FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tFlexBlock,\n\tButton,\n\tModal,\n\t__experimentalRadioGroup as RadioGroup,\n\t__experimentalRadio as Radio,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PART_AREA_GENERAL } from '../../store/constants';\n\nexport default function CreateTemplatePartModal( { closeModal, onCreate } ) {\n\tconst [ title, setTitle ] = useState( '' );\n\tconst [ area, setArea ] = useState( TEMPLATE_PART_AREA_GENERAL );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create a template part' ) }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t\toverlayClassName=\"edit-site-create-template-part-modal\"\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( ! title ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetIsSubmitting( true );\n\t\t\t\t\tawait onCreate( { title, area } );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<BaseControl\n\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-base-control\"\n\t\t\t\t>\n\t\t\t\t\t<RadioGroup\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-radio-group\"\n\t\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t\tchecked={ area }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ templatePartAreas.map(\n\t\t\t\t\t\t\t( { icon, label, area: value, description } ) => (\n\t\t\t\t\t\t\t\t<Radio\n\t\t\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-radio\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Flex align=\"start\" justify=\"start\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock className=\"edit-site-create-template-part-modal__option-label\">\n\t\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t\t\t<div>{ description }</div>\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\n\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"edit-site-create-template-part-modal__checkbox\">\n\t\t\t\t\t\t\t\t\t\t\t{ area === value && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t\t</Radio>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RadioGroup>\n\t\t\t\t</BaseControl>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__modal-actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={ ! title }\n\t\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -7,6 +9,8 @@ exports.default = EditTemplatePartMenuButton;
7
9
 
8
10
  var _element = require("@wordpress/element");
9
11
 
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
10
14
  var _data = require("@wordpress/data");
11
15
 
12
16
  var _blockEditor = require("@wordpress/block-editor");
@@ -19,7 +23,9 @@ var _blocks = require("@wordpress/blocks");
19
23
 
20
24
  var _i18n = require("@wordpress/i18n");
21
25
 
22
- var _store = require("../../store");
26
+ var _routes = require("../routes");
27
+
28
+ var _link = require("../routes/link");
23
29
 
24
30
  /**
25
31
  * WordPress dependencies
@@ -46,6 +52,9 @@ function EditTemplatePartMenuItem(_ref2) {
46
52
  selectedClientId,
47
53
  onClose
48
54
  } = _ref2;
55
+ const {
56
+ params
57
+ } = (0, _routes.useLocation)();
49
58
  const selectedTemplatePart = (0, _data.useSelect)(select => {
50
59
  const block = select(_blockEditor.store).getBlock(selectedClientId);
51
60
 
@@ -58,20 +67,23 @@ function EditTemplatePartMenuItem(_ref2) {
58
67
  `${theme}//${slug}`);
59
68
  }
60
69
  }, [selectedClientId]);
61
- const {
62
- pushTemplatePart
63
- } = (0, _data.useDispatch)(_store.store);
70
+ const linkProps = (0, _link.useLink)({
71
+ postId: selectedTemplatePart === null || selectedTemplatePart === void 0 ? void 0 : selectedTemplatePart.id,
72
+ postType: selectedTemplatePart === null || selectedTemplatePart === void 0 ? void 0 : selectedTemplatePart.type
73
+ }, {
74
+ fromTemplateId: params.postId
75
+ });
64
76
 
65
77
  if (!selectedTemplatePart) {
66
78
  return null;
67
79
  }
68
80
 
69
- return (0, _element.createElement)(_components.MenuItem, {
70
- onClick: () => {
71
- pushTemplatePart(selectedTemplatePart.id);
81
+ return (0, _element.createElement)(_components.MenuItem, (0, _extends2.default)({}, linkProps, {
82
+ onClick: event => {
83
+ linkProps.onClick(event);
72
84
  onClose();
73
85
  }
74
- },
86
+ }),
75
87
  /* translators: %s: template part title */
76
88
  (0, _i18n.sprintf)((0, _i18n.__)('Edit %s'), selectedTemplatePart.slug));
77
89
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/edit-template-part-menu-button/index.js"],"names":["EditTemplatePartMenuButton","selectedClientIds","onClose","EditTemplatePartMenuItem","selectedClientId","selectedTemplatePart","select","block","blockEditorStore","getBlock","theme","slug","attributes","coreStore","getEntityRecord","pushTemplatePart","editSiteStore","id"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAWA;AACA;AACA;AAGe,SAASA,0BAAT,GAAsC;AACpD,SACC,4BAAC,sCAAD,QACG;AAAA,QAAE;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,KAAF;AAAA,WACD,4BAAC,wBAAD;AACC,MAAA,gBAAgB,EAAGD,iBAAiB,CAAE,CAAF,CADrC;AAEC,MAAA,OAAO,EAAGC;AAFX,MADC;AAAA,GADH,CADD;AAUA;;AAED,SAASC,wBAAT,QAAmE;AAAA,MAAhC;AAAEC,IAAAA,gBAAF;AAAoBF,IAAAA;AAApB,GAAgC;AAClE,QAAMG,oBAAoB,GAAG,qBAC1BC,MAAF,IAAc;AACb,UAAMC,KAAK,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,QAA3B,CACbL,gBADa,CAAd;;AAIA,QAAKG,KAAK,IAAI,4BAAgBA,KAAhB,CAAd,EAAwC;AACvC,YAAM;AAAEG,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAkBJ,KAAK,CAACK,UAA9B;AAEA,aAAON,MAAM,CAAEO,eAAF,CAAN,CAAoBC,eAApB,CACN,UADM,EAEN,kBAFM,EAGN;AACC,SAAGJ,KAAO,KAAKC,IAAM,EAJhB,CAAP;AAMA;AACD,GAhB2B,EAiB5B,CAAEP,gBAAF,CAjB4B,CAA7B;AAoBA,QAAM;AAAEW,IAAAA;AAAF,MAAuB,uBAAaC,YAAb,CAA7B;;AAEA,MAAK,CAAEX,oBAAP,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfU,MAAAA,gBAAgB,CAAEV,oBAAoB,CAACY,EAAvB,CAAhB;AACAf,MAAAA,OAAO;AACP;AAJF;AAOE;AACA,qBAAS,cAAI,SAAJ,CAAT,EAA0BG,oBAAoB,CAACM,IAA/C,CARF,CADD;AAaA","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\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<EditTemplatePartMenuItem\n\t\t\t\t\tselectedClientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n\nfunction EditTemplatePartMenuItem( { selectedClientId, onClose } ) {\n\tconst selectedTemplatePart = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock(\n\t\t\t\tselectedClientId\n\t\t\t);\n\n\t\t\tif ( block && isTemplatePart( block ) ) {\n\t\t\t\tconst { theme, slug } = block.attributes;\n\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t// Ideally this should be an official public API.\n\t\t\t\t\t`${ theme }//${ slug }`\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ selectedClientId ]\n\t);\n\n\tconst { pushTemplatePart } = useDispatch( editSiteStore );\n\n\tif ( ! selectedTemplatePart ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\tpushTemplatePart( selectedTemplatePart.id );\n\t\t\t\tonClose();\n\t\t\t} }\n\t\t>\n\t\t\t{\n\t\t\t\t/* translators: %s: template part title */\n\t\t\t\tsprintf( __( 'Edit %s' ), selectedTemplatePart.slug )\n\t\t\t}\n\t\t</MenuItem>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/edit-template-part-menu-button/index.js"],"names":["EditTemplatePartMenuButton","selectedClientIds","onClose","EditTemplatePartMenuItem","selectedClientId","params","selectedTemplatePart","select","block","blockEditorStore","getBlock","theme","slug","attributes","coreStore","getEntityRecord","linkProps","postId","id","postType","type","fromTemplateId","event","onClick"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAWA;AACA;AACA;AAIe,SAASA,0BAAT,GAAsC;AACpD,SACC,4BAAC,sCAAD,QACG;AAAA,QAAE;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,KAAF;AAAA,WACD,4BAAC,wBAAD;AACC,MAAA,gBAAgB,EAAGD,iBAAiB,CAAE,CAAF,CADrC;AAEC,MAAA,OAAO,EAAGC;AAFX,MADC;AAAA,GADH,CADD;AAUA;;AAED,SAASC,wBAAT,QAAmE;AAAA,MAAhC;AAAEC,IAAAA,gBAAF;AAAoBF,IAAAA;AAApB,GAAgC;AAClE,QAAM;AAAEG,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,oBAAoB,GAAG,qBAC1BC,MAAF,IAAc;AACb,UAAMC,KAAK,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,QAA3B,CACbN,gBADa,CAAd;;AAIA,QAAKI,KAAK,IAAI,4BAAgBA,KAAhB,CAAd,EAAwC;AACvC,YAAM;AAAEG,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAkBJ,KAAK,CAACK,UAA9B;AAEA,aAAON,MAAM,CAAEO,eAAF,CAAN,CAAoBC,eAApB,CACN,UADM,EAEN,kBAFM,EAGN;AACC,SAAGJ,KAAO,KAAKC,IAAM,EAJhB,CAAP;AAMA;AACD,GAhB2B,EAiB5B,CAAER,gBAAF,CAjB4B,CAA7B;AAoBA,QAAMY,SAAS,GAAG,mBACjB;AACCC,IAAAA,MAAM,EAAEX,oBAAF,aAAEA,oBAAF,uBAAEA,oBAAoB,CAAEY,EAD/B;AAECC,IAAAA,QAAQ,EAAEb,oBAAF,aAAEA,oBAAF,uBAAEA,oBAAoB,CAAEc;AAFjC,GADiB,EAKjB;AACCC,IAAAA,cAAc,EAAEhB,MAAM,CAACY;AADxB,GALiB,CAAlB;;AAUA,MAAK,CAAEX,oBAAP,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD,6BACMU,SADN;AAEC,IAAA,OAAO,EAAKM,KAAF,IAAa;AACtBN,MAAAA,SAAS,CAACO,OAAV,CAAmBD,KAAnB;AACApB,MAAAA,OAAO;AACP;AALF;AAQE;AACA,qBAAS,cAAI,SAAJ,CAAT,EAA0BI,oBAAoB,CAACM,IAA/C,CATF,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } 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 { useLocation } from '../routes';\nimport { useLink } from '../routes/link';\n\nexport default function EditTemplatePartMenuButton() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<EditTemplatePartMenuItem\n\t\t\t\t\tselectedClientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n\nfunction EditTemplatePartMenuItem( { selectedClientId, onClose } ) {\n\tconst { params } = useLocation();\n\tconst selectedTemplatePart = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock(\n\t\t\t\tselectedClientId\n\t\t\t);\n\n\t\t\tif ( block && isTemplatePart( block ) ) {\n\t\t\t\tconst { theme, slug } = block.attributes;\n\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t// Ideally this should be an official public API.\n\t\t\t\t\t`${ theme }//${ slug }`\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ selectedClientId ]\n\t);\n\n\tconst linkProps = useLink(\n\t\t{\n\t\t\tpostId: selectedTemplatePart?.id,\n\t\t\tpostType: selectedTemplatePart?.type,\n\t\t},\n\t\t{\n\t\t\tfromTemplateId: params.postId,\n\t\t}\n\t);\n\n\tif ( ! selectedTemplatePart ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...linkProps }\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tlinkProps.onClick( event );\n\t\t\t\tonClose();\n\t\t\t} }\n\t\t>\n\t\t\t{\n\t\t\t\t/* translators: %s: template part title */\n\t\t\t\tsprintf( __( 'Edit %s' ), selectedTemplatePart.slug )\n\t\t\t}\n\t\t</MenuItem>\n\t);\n}\n"]}