@wordpress/edit-site 4.19.0 → 5.0.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 (319) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +1 -0
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/index.js +8 -5
  5. package/build/components/add-new-template/index.js.map +1 -1
  6. package/build/components/add-new-template/new-template-part.js +21 -6
  7. package/build/components/add-new-template/new-template-part.js.map +1 -1
  8. package/build/components/add-new-template/new-template.js +12 -8
  9. package/build/components/add-new-template/new-template.js.map +1 -1
  10. package/build/components/app/index.js +15 -30
  11. package/build/components/app/index.js.map +1 -1
  12. package/build/components/block-editor/editor-canvas.js +64 -0
  13. package/build/components/block-editor/editor-canvas.js.map +1 -0
  14. package/build/components/block-editor/index.js +61 -59
  15. package/build/components/block-editor/index.js.map +1 -1
  16. package/build/components/block-editor/resizable-editor.js +10 -44
  17. package/build/components/block-editor/resizable-editor.js.map +1 -1
  18. package/build/components/editor/index.js +80 -127
  19. package/build/components/editor/index.js.map +1 -1
  20. package/build/components/global-styles/block-preview-panel.js +42 -0
  21. package/build/components/global-styles/block-preview-panel.js.map +1 -0
  22. package/build/components/global-styles/context-menu.js +6 -2
  23. package/build/components/global-styles/context-menu.js.map +1 -1
  24. package/build/components/global-styles/custom-css.js +61 -0
  25. package/build/components/global-styles/custom-css.js.map +1 -0
  26. package/build/components/global-styles/dimensions-panel.js +2 -6
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  28. package/build/components/global-styles/global-styles-provider.js +15 -2
  29. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  30. package/build/components/global-styles/hooks.js +5 -2
  31. package/build/components/global-styles/hooks.js.map +1 -1
  32. package/build/components/global-styles/palette.js +1 -1
  33. package/build/components/global-styles/palette.js.map +1 -1
  34. package/build/components/global-styles/screen-block-list.js +2 -1
  35. package/build/components/global-styles/screen-block-list.js.map +1 -1
  36. package/build/components/global-styles/screen-block.js +10 -2
  37. package/build/components/global-styles/screen-block.js.map +1 -1
  38. package/build/components/global-styles/screen-border.js +43 -0
  39. package/build/components/global-styles/screen-border.js.map +1 -0
  40. package/build/components/global-styles/screen-colors.js +1 -1
  41. package/build/components/global-styles/screen-colors.js.map +1 -1
  42. package/build/components/global-styles/screen-css.js +42 -0
  43. package/build/components/global-styles/screen-css.js.map +1 -0
  44. package/build/components/global-styles/screen-layout.js +0 -5
  45. package/build/components/global-styles/screen-layout.js.map +1 -1
  46. package/build/components/global-styles/screen-root.js +14 -1
  47. package/build/components/global-styles/screen-root.js.map +1 -1
  48. package/build/components/global-styles/screen-style-variations.js +3 -3
  49. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  50. package/build/components/global-styles/ui.js +50 -4
  51. package/build/components/global-styles/ui.js.map +1 -1
  52. package/build/components/global-styles/use-global-styles-output.js +5 -1
  53. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  54. package/build/components/global-styles/utils.js +3 -3
  55. package/build/components/global-styles/utils.js.map +1 -1
  56. package/build/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -8
  57. package/build/components/global-styles-renderer/index.js.map +1 -0
  58. package/build/components/header-edit-mode/document-actions/index.js +12 -5
  59. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  60. package/build/components/header-edit-mode/index.js +19 -12
  61. package/build/components/header-edit-mode/index.js.map +1 -1
  62. package/build/components/keyboard-shortcuts/index.js +11 -1
  63. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  64. package/build/components/layout/index.js +231 -0
  65. package/build/components/layout/index.js.map +1 -0
  66. package/build/components/list/header.js +5 -1
  67. package/build/components/list/header.js.map +1 -1
  68. package/build/components/list/index.js +4 -22
  69. package/build/components/list/index.js.map +1 -1
  70. package/build/components/navigate-to-link/index.js +1 -3
  71. package/build/components/navigate-to-link/index.js.map +1 -1
  72. package/build/components/routes/index.js +1 -1
  73. package/build/components/routes/index.js.map +1 -1
  74. package/build/components/sidebar/index.js +42 -0
  75. package/build/components/sidebar/index.js.map +1 -0
  76. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +24 -4
  77. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  78. package/build/components/sidebar-edit-mode/index.js +1 -1
  79. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-item/index.js +53 -0
  81. package/build/components/sidebar-navigation-item/index.js.map +1 -0
  82. package/build/components/sidebar-navigation-screen/index.js +49 -0
  83. package/build/components/sidebar-navigation-screen/index.js.map +1 -0
  84. package/build/components/sidebar-navigation-screen-main/index.js +76 -0
  85. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -0
  86. package/build/components/sidebar-navigation-screen-templates/index.js +188 -0
  87. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -0
  88. package/build/components/site-icon/index.js +70 -0
  89. package/build/components/site-icon/index.js.map +1 -0
  90. package/build/components/site-title/index.js +55 -0
  91. package/build/components/site-title/index.js.map +1 -0
  92. package/build/components/style-book/index.js +173 -0
  93. package/build/components/style-book/index.js.map +1 -0
  94. package/build/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +5 -4
  95. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
  96. package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +53 -0
  97. package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
  98. package/build/index.js +2 -45
  99. package/build/index.js.map +1 -1
  100. package/build/store/actions.js +93 -43
  101. package/build/store/actions.js.map +1 -1
  102. package/build/store/reducer.js +35 -107
  103. package/build/store/reducer.js.map +1 -1
  104. package/build/store/selectors.js +69 -78
  105. package/build/store/selectors.js.map +1 -1
  106. package/build-module/components/add-new-template/add-custom-template-modal.js +1 -0
  107. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  108. package/build-module/components/add-new-template/index.js +7 -5
  109. package/build-module/components/add-new-template/index.js.map +1 -1
  110. package/build-module/components/add-new-template/new-template-part.js +18 -6
  111. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  112. package/build-module/components/add-new-template/new-template.js +13 -9
  113. package/build-module/components/add-new-template/new-template.js.map +1 -1
  114. package/build-module/components/app/index.js +15 -28
  115. package/build-module/components/app/index.js.map +1 -1
  116. package/build-module/components/block-editor/editor-canvas.js +51 -0
  117. package/build-module/components/block-editor/editor-canvas.js.map +1 -0
  118. package/build-module/components/block-editor/index.js +61 -60
  119. package/build-module/components/block-editor/index.js.map +1 -1
  120. package/build-module/components/block-editor/resizable-editor.js +11 -40
  121. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  122. package/build-module/components/editor/index.js +81 -124
  123. package/build-module/components/editor/index.js.map +1 -1
  124. package/build-module/components/global-styles/block-preview-panel.js +32 -0
  125. package/build-module/components/global-styles/block-preview-panel.js.map +1 -0
  126. package/build-module/components/global-styles/context-menu.js +7 -3
  127. package/build-module/components/global-styles/context-menu.js.map +1 -1
  128. package/build-module/components/global-styles/custom-css.js +51 -0
  129. package/build-module/components/global-styles/custom-css.js.map +1 -0
  130. package/build-module/components/global-styles/dimensions-panel.js +3 -7
  131. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  132. package/build-module/components/global-styles/global-styles-provider.js +15 -2
  133. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  134. package/build-module/components/global-styles/hooks.js +5 -3
  135. package/build-module/components/global-styles/hooks.js.map +1 -1
  136. package/build-module/components/global-styles/palette.js +1 -1
  137. package/build-module/components/global-styles/palette.js.map +1 -1
  138. package/build-module/components/global-styles/screen-block-list.js +2 -1
  139. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  140. package/build-module/components/global-styles/screen-block.js +8 -2
  141. package/build-module/components/global-styles/screen-block.js.map +1 -1
  142. package/build-module/components/global-styles/screen-border.js +27 -0
  143. package/build-module/components/global-styles/screen-border.js.map +1 -0
  144. package/build-module/components/global-styles/screen-colors.js +1 -1
  145. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  146. package/build-module/components/global-styles/screen-css.js +28 -0
  147. package/build-module/components/global-styles/screen-css.js.map +1 -0
  148. package/build-module/components/global-styles/screen-layout.js +0 -4
  149. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  150. package/build-module/components/global-styles/screen-root.js +14 -1
  151. package/build-module/components/global-styles/screen-root.js.map +1 -1
  152. package/build-module/components/global-styles/screen-style-variations.js +2 -2
  153. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  154. package/build-module/components/global-styles/ui.js +48 -5
  155. package/build-module/components/global-styles/ui.js.map +1 -1
  156. package/build-module/components/global-styles/use-global-styles-output.js +5 -1
  157. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  158. package/build-module/components/global-styles/utils.js +4 -4
  159. package/build-module/components/global-styles/utils.js.map +1 -1
  160. package/build-module/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -7
  161. package/build-module/components/global-styles-renderer/index.js.map +1 -0
  162. package/build-module/components/header-edit-mode/document-actions/index.js +13 -6
  163. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  164. package/build-module/components/header-edit-mode/index.js +16 -11
  165. package/build-module/components/header-edit-mode/index.js.map +1 -1
  166. package/build-module/components/keyboard-shortcuts/index.js +10 -1
  167. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  168. package/build-module/components/layout/index.js +203 -0
  169. package/build-module/components/layout/index.js.map +1 -0
  170. package/build-module/components/list/header.js +5 -1
  171. package/build-module/components/list/header.js.map +1 -1
  172. package/build-module/components/list/index.js +4 -19
  173. package/build-module/components/list/index.js.map +1 -1
  174. package/build-module/components/navigate-to-link/index.js +1 -3
  175. package/build-module/components/navigate-to-link/index.js.map +1 -1
  176. package/build-module/components/routes/index.js +1 -1
  177. package/build-module/components/routes/index.js.map +1 -1
  178. package/build-module/components/sidebar/index.js +30 -0
  179. package/build-module/components/sidebar/index.js.map +1 -0
  180. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +27 -7
  181. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  182. package/build-module/components/sidebar-edit-mode/index.js +3 -3
  183. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  184. package/build-module/components/sidebar-navigation-item/index.js +40 -0
  185. package/build-module/components/sidebar-navigation-item/index.js.map +1 -0
  186. package/build-module/components/sidebar-navigation-screen/index.js +39 -0
  187. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -0
  188. package/build-module/components/sidebar-navigation-screen-main/index.js +57 -0
  189. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -0
  190. package/build-module/components/sidebar-navigation-screen-templates/index.js +165 -0
  191. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -0
  192. package/build-module/components/site-icon/index.js +55 -0
  193. package/build-module/components/site-icon/index.js.map +1 -0
  194. package/build-module/components/site-title/index.js +43 -0
  195. package/build-module/components/site-title/index.js.map +1 -0
  196. package/build-module/components/style-book/index.js +156 -0
  197. package/build-module/components/style-book/index.js.map +1 -0
  198. package/build-module/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +4 -3
  199. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
  200. package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +43 -0
  201. package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
  202. package/build-module/index.js +5 -36
  203. package/build-module/index.js.map +1 -1
  204. package/build-module/store/actions.js +87 -42
  205. package/build-module/store/actions.js.map +1 -1
  206. package/build-module/store/reducer.js +35 -102
  207. package/build-module/store/reducer.js.map +1 -1
  208. package/build-module/store/selectors.js +60 -72
  209. package/build-module/store/selectors.js.map +1 -1
  210. package/build-style/style-rtl.css +550 -346
  211. package/build-style/style.css +550 -346
  212. package/package.json +32 -31
  213. package/src/components/add-new-template/add-custom-template-modal.js +1 -0
  214. package/src/components/add-new-template/index.js +6 -3
  215. package/src/components/add-new-template/new-template-part.js +15 -3
  216. package/src/components/add-new-template/new-template.js +14 -7
  217. package/src/components/add-new-template/style.scss +0 -4
  218. package/src/components/app/index.js +14 -43
  219. package/src/components/block-editor/editor-canvas.js +69 -0
  220. package/src/components/block-editor/index.js +102 -87
  221. package/src/components/block-editor/resizable-editor.js +9 -64
  222. package/src/components/block-editor/style.scss +25 -1
  223. package/src/components/code-editor/style.scss +1 -1
  224. package/src/components/editor/index.js +170 -236
  225. package/src/components/editor/style.scss +0 -22
  226. package/src/components/global-styles/block-preview-panel.js +29 -0
  227. package/src/components/global-styles/context-menu.js +11 -2
  228. package/src/components/global-styles/custom-css.js +73 -0
  229. package/src/components/global-styles/dimensions-panel.js +2 -5
  230. package/src/components/global-styles/global-styles-provider.js +39 -17
  231. package/src/components/global-styles/hooks.js +8 -3
  232. package/src/components/global-styles/palette.js +1 -1
  233. package/src/components/global-styles/screen-block-list.js +2 -1
  234. package/src/components/global-styles/screen-block.js +9 -1
  235. package/src/components/global-styles/screen-border.js +23 -0
  236. package/src/components/global-styles/screen-colors.js +2 -1
  237. package/src/components/global-styles/screen-css.js +33 -0
  238. package/src/components/global-styles/screen-layout.js +0 -3
  239. package/src/components/global-styles/screen-root.js +30 -1
  240. package/src/components/global-styles/screen-style-variations.js +5 -2
  241. package/src/components/global-styles/style.scss +31 -2
  242. package/src/components/global-styles/ui.js +47 -4
  243. package/src/components/global-styles/use-global-styles-output.js +5 -0
  244. package/src/components/global-styles/utils.js +8 -5
  245. package/src/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +3 -9
  246. package/src/components/header-edit-mode/document-actions/index.js +14 -9
  247. package/src/components/header-edit-mode/document-actions/style.scss +8 -1
  248. package/src/components/header-edit-mode/index.js +96 -78
  249. package/src/components/header-edit-mode/style.scss +5 -33
  250. package/src/components/keyboard-shortcuts/index.js +13 -0
  251. package/src/components/layout/index.js +278 -0
  252. package/src/components/layout/style.scss +176 -0
  253. package/src/components/list/header.js +5 -1
  254. package/src/components/list/index.js +12 -31
  255. package/src/components/list/style.scss +10 -4
  256. package/src/components/navigate-to-link/index.js +2 -8
  257. package/src/components/routes/index.js +1 -1
  258. package/src/components/sidebar/index.js +34 -0
  259. package/src/components/sidebar/style.scss +8 -0
  260. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +42 -7
  261. package/src/components/sidebar-edit-mode/index.js +3 -3
  262. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +21 -3
  263. package/src/components/sidebar-edit-mode/settings-header/style.scss +47 -34
  264. package/src/components/sidebar-edit-mode/style.scss +0 -13
  265. package/src/components/sidebar-navigation-item/index.js +51 -0
  266. package/src/components/sidebar-navigation-item/style.scss +17 -0
  267. package/src/components/sidebar-navigation-screen/index.js +55 -0
  268. package/src/components/sidebar-navigation-screen/style.scss +41 -0
  269. package/src/components/sidebar-navigation-screen-main/index.js +72 -0
  270. package/src/components/sidebar-navigation-screen-templates/index.js +181 -0
  271. package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
  272. package/src/components/site-icon/index.js +56 -0
  273. package/src/components/site-icon/style.scss +10 -0
  274. package/src/components/site-title/index.js +39 -0
  275. package/src/components/style-book/index.js +193 -0
  276. package/src/components/style-book/style.scss +78 -0
  277. package/src/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +3 -3
  278. package/src/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +36 -0
  279. package/src/components/template-details/style.scss +4 -0
  280. package/src/index.js +3 -53
  281. package/src/store/actions.js +93 -48
  282. package/src/store/reducer.js +29 -91
  283. package/src/store/selectors.js +61 -101
  284. package/src/store/test/actions.js +3 -15
  285. package/src/store/test/reducer.js +8 -192
  286. package/src/store/test/selectors.js +3 -42
  287. package/src/style.scss +19 -3
  288. package/build/components/editor/global-styles-renderer.js.map +0 -1
  289. package/build/components/navigation-sidebar/index.js +0 -62
  290. package/build/components/navigation-sidebar/index.js.map +0 -1
  291. package/build/components/navigation-sidebar/navigation-panel/constants.js +0 -77
  292. package/build/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
  293. package/build/components/navigation-sidebar/navigation-panel/index.js +0 -152
  294. package/build/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
  295. package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
  296. package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
  297. package/build/components/navigation-sidebar/navigation-toggle/index.js +0 -124
  298. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
  299. package/build/components/url-query-controller/index.js.map +0 -1
  300. package/build-module/components/editor/global-styles-renderer.js.map +0 -1
  301. package/build-module/components/navigation-sidebar/index.js +0 -45
  302. package/build-module/components/navigation-sidebar/index.js.map +0 -1
  303. package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -49
  304. package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
  305. package/build-module/components/navigation-sidebar/navigation-panel/index.js +0 -131
  306. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
  307. package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -66
  308. package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
  309. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +0 -108
  310. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
  311. package/build-module/components/url-query-controller/index.js.map +0 -1
  312. package/src/components/navigation-sidebar/index.js +0 -46
  313. package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -94
  314. package/src/components/navigation-sidebar/navigation-panel/index.js +0 -142
  315. package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -152
  316. package/src/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
  317. package/src/components/navigation-sidebar/navigation-toggle/index.js +0 -114
  318. package/src/components/navigation-sidebar/navigation-toggle/style.scss +0 -71
  319. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +0 -65
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
3
4
  /**
@@ -13,7 +14,8 @@ import NewTemplate from './new-template';
13
14
  import NewTemplatePart from './new-template-part';
14
15
  export default function AddNewTemplate(_ref) {
15
16
  let {
16
- templateType = 'wp_template'
17
+ templateType = 'wp_template',
18
+ ...props
17
19
  } = _ref;
18
20
  const postType = useSelect(select => select(coreStore).getPostType(templateType), [templateType]);
19
21
 
@@ -22,13 +24,13 @@ export default function AddNewTemplate(_ref) {
22
24
  }
23
25
 
24
26
  if (templateType === 'wp_template') {
25
- return createElement(NewTemplate, {
27
+ return createElement(NewTemplate, _extends({}, props, {
26
28
  postType: postType
27
- });
29
+ }));
28
30
  } else if (templateType === 'wp_template_part') {
29
- return createElement(NewTemplatePart, {
31
+ return createElement(NewTemplatePart, _extends({}, props, {
30
32
  postType: postType
31
- });
33
+ }));
32
34
  }
33
35
 
34
36
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/index.js"],"names":["useSelect","store","coreStore","NewTemplate","NewTemplatePart","AddNewTemplate","templateType","postType","select","getPostType"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AAEA,eAAe,SAASC,cAAT,OAA4D;AAAA,MAAnC;AAAEC,IAAAA,YAAY,GAAG;AAAjB,GAAmC;AAC1E,QAAMC,QAAQ,GAAGP,SAAS,CACvBQ,MAAF,IAAcA,MAAM,CAAEN,SAAF,CAAN,CAAoBO,WAApB,CAAiCH,YAAjC,CADW,EAEzB,CAAEA,YAAF,CAFyB,CAA1B;;AAKA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,MAAKD,YAAY,KAAK,aAAtB,EAAsC;AACrC,WAAO,cAAC,WAAD;AAAa,MAAA,QAAQ,EAAGC;AAAxB,MAAP;AACA,GAFD,MAEO,IAAKD,YAAY,KAAK,kBAAtB,EAA2C;AACjD,WAAO,cAAC,eAAD;AAAiB,MAAA,QAAQ,EAAGC;AAA5B,MAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport NewTemplate from './new-template';\nimport NewTemplatePart from './new-template-part';\n\nexport default function AddNewTemplate( { templateType = 'wp_template' } ) {\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! postType ) {\n\t\treturn null;\n\t}\n\n\tif ( templateType === 'wp_template' ) {\n\t\treturn <NewTemplate postType={ postType } />;\n\t} else if ( templateType === 'wp_template_part' ) {\n\t\treturn <NewTemplatePart postType={ postType } />;\n\t}\n\n\treturn null;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/index.js"],"names":["useSelect","store","coreStore","NewTemplate","NewTemplatePart","AddNewTemplate","templateType","props","postType","select","getPostType"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AAEA,eAAe,SAASC,cAAT,OAGX;AAAA,MAHoC;AACvCC,IAAAA,YAAY,GAAG,aADwB;AAEvC,OAAGC;AAFoC,GAGpC;AACH,QAAMC,QAAQ,GAAGR,SAAS,CACvBS,MAAF,IAAcA,MAAM,CAAEP,SAAF,CAAN,CAAoBQ,WAApB,CAAiCJ,YAAjC,CADW,EAEzB,CAAEA,YAAF,CAFyB,CAA1B;;AAKA,MAAK,CAAEE,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,MAAKF,YAAY,KAAK,aAAtB,EAAsC;AACrC,WAAO,cAAC,WAAD,eAAkBC,KAAlB;AAA0B,MAAA,QAAQ,EAAGC;AAArC,OAAP;AACA,GAFD,MAEO,IAAKF,YAAY,KAAK,kBAAtB,EAA2C;AACjD,WAAO,cAAC,eAAD,eAAsBC,KAAtB;AAA8B,MAAA,QAAQ,EAAGC;AAAzC,OAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport NewTemplate from './new-template';\nimport NewTemplatePart from './new-template-part';\n\nexport default function AddNewTemplate( {\n\ttemplateType = 'wp_template',\n\t...props\n} ) {\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! postType ) {\n\t\treturn null;\n\t}\n\n\tif ( templateType === 'wp_template' ) {\n\t\treturn <NewTemplate { ...props } postType={ postType } />;\n\t} else if ( templateType === 'wp_template_part' ) {\n\t\treturn <NewTemplatePart { ...props } postType={ postType } />;\n\t}\n\n\treturn null;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement, Fragment } from "@wordpress/element";
2
3
 
3
4
  /**
@@ -14,15 +15,19 @@ import { Button } from '@wordpress/components';
14
15
  import { __ } from '@wordpress/i18n';
15
16
  import { store as noticesStore } from '@wordpress/notices';
16
17
  import { store as coreStore } from '@wordpress/core-data';
18
+ import { plus } from '@wordpress/icons';
17
19
  /**
18
20
  * Internal dependencies
19
21
  */
20
22
 
21
23
  import { useHistory } from '../routes';
24
+ import { store as editSiteStore } from '../../store';
22
25
  import CreateTemplatePartModal from '../create-template-part-modal';
23
26
  export default function NewTemplatePart(_ref) {
24
27
  let {
25
- postType
28
+ postType,
29
+ showIcon = true,
30
+ toggleProps
26
31
  } = _ref;
27
32
  const history = useHistory();
28
33
  const [isModalOpen, setIsModalOpen] = useState(false);
@@ -32,6 +37,9 @@ export default function NewTemplatePart(_ref) {
32
37
  const {
33
38
  saveEntityRecord
34
39
  } = useDispatch(coreStore);
40
+ const {
41
+ __unstableSetCanvasMode
42
+ } = useDispatch(editSiteStore);
35
43
 
36
44
  async function createTemplatePart(_ref2) {
37
45
  let {
@@ -58,7 +66,10 @@ export default function NewTemplatePart(_ref) {
58
66
  }, {
59
67
  throwOnError: true
60
68
  });
61
- setIsModalOpen(false); // Navigate to the created template part editor.
69
+ setIsModalOpen(false); // Switch to edit mode.
70
+
71
+ __unstableSetCanvasMode('edit'); // Navigate to the created template part editor.
72
+
62
73
 
63
74
  history.push({
64
75
  postId: templatePart.id,
@@ -73,12 +84,13 @@ export default function NewTemplatePart(_ref) {
73
84
  }
74
85
  }
75
86
 
76
- return createElement(Fragment, null, createElement(Button, {
77
- variant: "primary",
87
+ return createElement(Fragment, null, createElement(Button, _extends({}, toggleProps, {
78
88
  onClick: () => {
79
89
  setIsModalOpen(true);
80
- }
81
- }, postType.labels.add_new), isModalOpen && createElement(CreateTemplatePartModal, {
90
+ },
91
+ icon: showIcon ? plus : null,
92
+ label: postType.labels.add_new
93
+ }), showIcon ? null : postType.labels.add_new), isModalOpen && createElement(CreateTemplatePartModal, {
82
94
  closeModal: () => setIsModalOpen(false),
83
95
  onCreate: createTemplatePart
84
96
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["kebabCase","useState","useDispatch","Button","__","store","noticesStore","coreStore","useHistory","CreateTemplatePartModal","NewTemplatePart","postType","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","createTemplatePart","title","area","type","cleanSlug","replace","templatePart","slug","content","throwOnError","push","postId","id","error","err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OAAO,EAAE,EAHV;AAICN,QAAAA;AAJD,OAH0C,EAS1C;AAAEO,QAAAA,YAAY,EAAE;AAAhB,OAT0C,CAA3C;AAYAZ,MAAAA,cAAc,CAAE,KAAF,CAAd,CAnBG,CAqBH;;AACAF,MAAAA,OAAO,CAACe,IAAR,CAAc;AACbC,QAAAA,MAAM,EAAEL,YAAY,CAACM,EADR;AAEblB,QAAAA,QAAQ,EAAEY,YAAY,CAACH;AAFV,OAAd,EAtBG,CA2BH;AACA,KA5BD,CA4BE,OAAQU,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG5B,EAAE,CACF,qDADE,CAHN;AAOAW,MAAAA,iBAAiB,CAAEgB,YAAF,EAAgB;AAAEX,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AAEAN,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AACD;;AAED,SACC,8BACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfA,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA;AAJF,KAMGH,QAAQ,CAACuB,MAAT,CAAgBC,OANnB,CADD,EASGtB,WAAW,IACZ,cAAC,uBAAD;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 { __ } 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\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\t// Currently template parts only allow latin chars.\n\t\t\t// Fallback slug will receive suffix by default.\n\t\t\tconst cleanSlug =\n\t\t\t\tkebabCase( title ).replace( /[^\\w-]+/g, '' ) ||\n\t\t\t\t'wp-custom-part';\n\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: cleanSlug,\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\t{ throwOnError: true }\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
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["kebabCase","useState","useDispatch","Button","__","store","noticesStore","coreStore","plus","useHistory","editSiteStore","CreateTemplatePartModal","NewTemplatePart","postType","showIcon","toggleProps","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","__unstableSetCanvasMode","createTemplatePart","title","area","type","cleanSlug","replace","templatePart","slug","content","throwOnError","push","postId","id","error","errorMessage","message","code","labels","add_new"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AAEA,eAAe,SAASC,eAAT,OAIX;AAAA,MAJqC;AACxCC,IAAAA,QADwC;AAExCC,IAAAA,QAAQ,GAAG,IAF6B;AAGxCC,IAAAA;AAHwC,GAIrC;AACH,QAAMC,OAAO,GAAGP,UAAU,EAA1B;AACA,QAAM,CAAEQ,WAAF,EAAeC,cAAf,IAAkCjB,QAAQ,CAAE,KAAF,CAAhD;AACA,QAAM;AAAEkB,IAAAA;AAAF,MAA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e,MAAAA,iBAAiB,CAAEiB,YAAF,EAAgB;AAAEX,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AAEAP,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AACD;;AAED,SACC,8BACC,cAAC,MAAD,eACMH,WADN;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA,KAJF;AAKC,IAAA,IAAI,EAAGJ,QAAQ,GAAGN,IAAH,GAAU,IAL1B;AAMC,IAAA,KAAK,EAAGK,QAAQ,CAAC0B,MAAT,CAAgBC;AANzB,MAQG1B,QAAQ,GAAG,IAAH,GAAUD,QAAQ,CAAC0B,MAAT,CAAgBC,OARrC,CADD,EAWGvB,WAAW,IACZ,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGI;AAFZ,IAZF,CADD;AAoBA","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 { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function NewTemplatePart( {\n\tpostType,\n\tshowIcon = true,\n\ttoggleProps,\n} ) {\n\tconst history = useHistory();\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { __unstableSetCanvasMode } = useDispatch( editSiteStore );\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\t// Currently template parts only allow latin chars.\n\t\t\t// Fallback slug will receive suffix by default.\n\t\t\tconst cleanSlug =\n\t\t\t\tkebabCase( title ).replace( /[^\\w-]+/g, '' ) ||\n\t\t\t\t'wp-custom-part';\n\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: cleanSlug,\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\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tsetIsModalOpen( false );\n\n\t\t\t// Switch to edit mode.\n\t\t\t__unstableSetCanvasMode( 'edit' );\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\t{ ...toggleProps }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\tlabel={ postType.labels.add_new }\n\t\t\t>\n\t\t\t\t{ showIcon ? null : 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"]}
@@ -9,7 +9,7 @@ import { DropdownMenu, MenuGroup, MenuItem, NavigableMenu } from '@wordpress/com
9
9
  import { useState } from '@wordpress/element';
10
10
  import { useDispatch } from '@wordpress/data';
11
11
  import { store as coreStore } from '@wordpress/core-data';
12
- import { archive, blockMeta, category, home, list, media, notFound, page, post, postAuthor, postDate, search, tag, layout as customGenericTemplateIcon } from '@wordpress/icons';
12
+ import { archive, blockMeta, category, home, list, media, notFound, page, plus, post, postAuthor, postDate, search, tag, layout as customGenericTemplateIcon } from '@wordpress/icons';
13
13
  import { __, sprintf } from '@wordpress/i18n';
14
14
  import { store as noticesStore } from '@wordpress/notices';
15
15
  /**
@@ -40,7 +40,9 @@ const TEMPLATE_ICONS = {
40
40
  };
41
41
  export default function NewTemplate(_ref) {
42
42
  let {
43
- postType
43
+ postType,
44
+ toggleProps,
45
+ showIcon = true
44
46
  } = _ref;
45
47
  const [showCustomTemplateModal, setShowCustomTemplateModal] = useState(false);
46
48
  const [showCustomGenericTemplateModal, setShowCustomGenericTemplateModal] = useState(false);
@@ -55,7 +57,8 @@ export default function NewTemplate(_ref) {
55
57
  createSuccessNotice
56
58
  } = useDispatch(noticesStore);
57
59
  const {
58
- setTemplate
60
+ setTemplate,
61
+ __unstableSetCanvasMode
59
62
  } = useDispatch(editSiteStore);
60
63
 
61
64
  async function createTemplate(template) {
@@ -100,7 +103,10 @@ export default function NewTemplate(_ref) {
100
103
  throwOnError: true
101
104
  }); // Set template before navigating away to avoid initial stale value.
102
105
 
103
- setTemplate(newTemplate.id, newTemplate.slug); // Navigate to the created template editor.
106
+ setTemplate(newTemplate.id, newTemplate.slug); // Switch to edit mode.
107
+
108
+ __unstableSetCanvasMode('edit'); // Navigate to the created template editor.
109
+
104
110
 
105
111
  history.push({
106
112
  postId: newTemplate.id,
@@ -128,15 +134,13 @@ export default function NewTemplate(_ref) {
128
134
 
129
135
  return createElement(Fragment, null, createElement(DropdownMenu, {
130
136
  className: "edit-site-new-template-dropdown",
131
- icon: null,
132
- text: postType.labels.add_new,
137
+ icon: showIcon ? plus : null,
138
+ text: showIcon ? null : postType.labels.add_new,
133
139
  label: postType.labels.add_new_item,
134
140
  popoverProps: {
135
141
  noArrow: false
136
142
  },
137
- toggleProps: {
138
- variant: 'primary'
139
- }
143
+ toggleProps: toggleProps
140
144
  }, () => createElement(Fragment, null, isCreatingTemplate && createElement(TemplateActionsLoadingScreen, null), createElement(NavigableMenu, {
141
145
  className: "edit-site-new-template-dropdown__popover"
142
146
  }, createElement(MenuGroup, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["apiFetch","addQueryArgs","DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useState","useDispatch","store","coreStore","archive","blockMeta","category","home","list","media","notFound","page","post","postAuthor","postDate","search","tag","layout","customGenericTemplateIcon","__","sprintf","noticesStore","AddCustomTemplateModal","useExistingTemplates","useDefaultTemplateTypes","useTaxonomiesMenuItems","usePostTypeMenuItems","useAuthorMenuItem","usePostTypeArchiveMenuItems","AddCustomGenericTemplateModal","TemplateActionsLoadingScreen","useHistory","editSiteStore","DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","single","index","author","taxonomy","date","attachment","NewTemplate","postType","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","createErrorNotice","createSuccessNotice","setTemplate","createTemplate","template","isWPSuggestion","title","description","slug","templatePrefix","templateContent","content","fallbackTemplate","path","is_custom","template_prefix","raw","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","labels","add_new","add_new_item","noArrow","variant","map","onClick","icon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SACCC,OADD,EAECC,SAFD,EAGCC,QAHD,EAICC,IAJD,EAKCC,IALD,EAMCC,KAND,EAOCC,QAPD,EAQCC,IARD,EASCC,IATD,EAUCC,UAVD,EAWCC,QAXD,EAYCC,MAZD,EAaCC,GAbD,EAcCC,MAAM,IAAIC,yBAdX,QAeO,kBAfP;AAgBA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASlB,KAAK,IAAImB,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,SACCC,oBADD,EAECC,uBAFD,EAGCC,sBAHD,EAICC,oBAJD,EAKCC,iBALD,EAMCC,2BAND,QAOO,SAPP;AAQA,OAAOC,6BAAP,MAA0C,qCAA1C;AACA,OAAOC,4BAAP,MAAyC,mCAAzC;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAAS7B,KAAK,IAAI8B,aAAlB,QAAuC,aAAvC;AAEA,MAAMC,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,QAF8B,EAG9B,MAH8B,EAI9B,OAJ8B,EAK9B,SAL8B,EAM9B,QAN8B,EAO9B,UAP8B,EAQ9B,MAR8B,EAS9B,KAT8B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NP,MAAAA,mCAAmC,CAAC1B,IAApC,CAA0CiC,QAA1C;AACA;AACD,GArBD,EA1BC,CAgDD;;AACAP,EAAAA,mCAAmC,SAAnC,IAAAA,mCAAmC,WAAnC,YAAAA,mCAAmC,CAAEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACCjF,sBAAsB,CAACkF,OAAvB,CAAgCF,SAAS,CAACpD,IAA1C,IACA5B,sBAAsB,CAACkF,OAAvB,CAAgCD,SAAS,CAACrD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMsB,gBAAgB,GAAG,CACxB,GAAGmB,mCADqB,EAExB,GAAG1E,2BAA2B,EAFN,EAGxB,GAAG8E,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOrB,gBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( { postType } ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate } = useDispatch( editSiteStore );\n\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug, templatePrefix } = template;\n\t\t\tlet templateContent = template.content;\n\t\t\t// Try to find fallback content from existing templates.\n\t\t\tif ( ! templateContent ) {\n\t\t\t\tconst fallbackTemplate = await apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tis_custom: ! isWPSuggestion,\n\t\t\t\t\t\ttemplate_prefix: templatePrefix,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\ttemplateContent = fallbackTemplate.content.raw;\n\t\t\t}\n\t\t\tconst newTemplate = 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\tdescription,\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\tcontent: templateContent,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t} );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\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: __( '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} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ null }\n\t\t\t\ttext={ postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tvariant: 'primary',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonClick\n\t\t\t\t\t\t\t\t\t\t\t\t\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t)\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{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["apiFetch","addQueryArgs","DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useState","useDispatch","store","coreStore","archive","blockMeta","category","home","list","media","notFound","page","plus","post","postAuthor","postDate","search","tag","layout","customGenericTemplateIcon","__","sprintf","noticesStore","AddCustomTemplateModal","useExistingTemplates","useDefaultTemplateTypes","useTaxonomiesMenuItems","usePostTypeMenuItems","useAuthorMenuItem","usePostTypeArchiveMenuItems","AddCustomGenericTemplateModal","TemplateActionsLoadingScreen","useHistory","editSiteStore","DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","single","index","author","taxonomy","date","attachment","NewTemplate","postType","toggleProps","showIcon","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","createErrorNotice","createSuccessNotice","setTemplate","__unstableSetCanvasMode","createTemplate","template","isWPSuggestion","title","description","slug","templatePrefix","templateContent","content","fallbackTemplate","path","is_custom","template_prefix","raw","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","labels","add_new","add_new_item","noArrow","map","onClick","icon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SACCC,OADD,EAECC,SAFD,EAGCC,QAHD,EAICC,IAJD,EAKCC,IALD,EAMCC,KAND,EAOCC,QAPD,EAQCC,IARD,EASCC,IATD,EAUCC,IAVD,EAWCC,UAXD,EAYCC,QAZD,EAaCC,MAbD,EAcCC,GAdD,EAeCC,MAAM,IAAIC,yBAfX,QAgBO,kBAhBP;AAiBA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASnB,KAAK,IAAIoB,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,SACCC,oBADD,EAECC,uBAFD,EAGCC,sBAHD,EAICC,oBAJD,EAKCC,iBALD,EAMCC,2BAND,QAOO,SAPP;AAQA,OAAOC,6BAAP,MAA0C,qCAA1C;AACA,OAAOC,4BAAP,MAAyC,mCAAzC;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAAS9B,KAAK,IAAI+B,aAAlB,QAAuC,aAAvC;AAEA,MAAMC,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,QAF8B,EAG9B,MAH8B,EAI9B,OAJ8B,EAK9B,SAL8B,EAM9B,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,CAACI,IAAT,KAAkB+C,QAAQ,CAAC/C,IADzB,CAAnB,CAJ0B,CAO1B;AACA;AACA;AACA;AACA;;AACA,QAAKgD,UAAU,GAAG,CAAC,CAAnB,EAAuB;AACtBR,MAAAA,mCAAmC,CAAEQ,UAAF,CAAnC,GAAoDD,QAApD;AACA,KAFD,MAEO;AACNP,MAAAA,mCAAmC,CAACzB,IAApC,CAA0CgC,QAA1C;AACA;AACD,GArBD,EA1BC,CAgDD;;AACAP,EAAAA,mCAAmC,SAAnC,IAAAA,mCAAmC,WAAnC,YAAAA,mCAAmC,CAAEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACCnF,sBAAsB,CAACoF,OAAvB,CAAgCF,SAAS,CAACnD,IAA1C,IACA/B,sBAAsB,CAACoF,OAAvB,CAAgCD,SAAS,CAACpD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMsB,gBAAgB,GAAG,CACxB,GAAGkB,mCADqB,EAExB,GAAG5E,2BAA2B,EAFN,EAGxB,GAAGgF,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOpB,gBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate, __unstableSetCanvasMode } =\n\t\tuseDispatch( editSiteStore );\n\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug, templatePrefix } = template;\n\t\t\tlet templateContent = template.content;\n\t\t\t// Try to find fallback content from existing templates.\n\t\t\tif ( ! templateContent ) {\n\t\t\t\tconst fallbackTemplate = await apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tis_custom: ! isWPSuggestion,\n\t\t\t\t\t\ttemplate_prefix: templatePrefix,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\ttemplateContent = fallbackTemplate.content.raw;\n\t\t\t}\n\t\t\tconst newTemplate = 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\tdescription,\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\tcontent: templateContent,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\n\t\t\t// Switch to edit mode.\n\t\t\t__unstableSetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t} );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\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: __( '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} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\ttext={ showIcon ? null : postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonClick\n\t\t\t\t\t\t\t\t\t\t\t\t\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t)\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{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
@@ -1,10 +1,11 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { SlotFillProvider } from '@wordpress/components';
6
+ import { SlotFillProvider, Popover } from '@wordpress/components';
7
7
  import { UnsavedChangesWarning } from '@wordpress/editor';
8
+ import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
8
9
  import { store as noticesStore } from '@wordpress/notices';
9
10
  import { useDispatch } from '@wordpress/data';
10
11
  import { __, sprintf } from '@wordpress/i18n';
@@ -14,14 +15,10 @@ import { PluginArea } from '@wordpress/plugins';
14
15
  */
15
16
 
16
17
  import { Routes } from '../routes';
17
- import Editor from '../editor';
18
- import List from '../list';
19
- import NavigationSidebar from '../navigation-sidebar';
20
- import getIsListPage from '../../utils/get-is-list-page';
21
- export default function EditSiteApp(_ref) {
18
+ import Layout from '../layout';
19
+ export default function App(_ref) {
22
20
  let {
23
- reboot,
24
- homeTemplate
21
+ reboot
25
22
  } = _ref;
26
23
  const {
27
24
  createErrorNotice
@@ -33,24 +30,14 @@ export default function EditSiteApp(_ref) {
33
30
  __('The "%s" plugin has encountered an error and cannot be rendered.'), name));
34
31
  }
35
32
 
36
- return createElement(SlotFillProvider, null, createElement(UnsavedChangesWarning, null), createElement(Routes, null, _ref2 => {
37
- var _params$postId;
38
-
39
- let {
40
- params
41
- } = _ref2;
42
- const isListPage = getIsListPage(params); // The existence of a 'front-page' supersedes every other setting.
43
-
44
- const homeTemplateType = (_params$postId = params.postId) !== null && _params$postId !== void 0 && _params$postId.includes('front-page') || params.postId === (homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postId) ? 'site-editor' : undefined;
45
- return createElement(Fragment, null, isListPage ? createElement(List, null) : createElement(Editor, {
46
- onError: reboot
47
- }), createElement(PluginArea, {
48
- onError: onPluginAreaError
49
- }), createElement(NavigationSidebar // Open the navigation sidebar by default when in the list page.
50
- , {
51
- isDefaultOpen: !!isListPage,
52
- activeTemplateType: isListPage ? params.postType : homeTemplateType
53
- }));
54
- }));
33
+ return createElement(ShortcutProvider, {
34
+ style: {
35
+ height: '100%'
36
+ }
37
+ }, createElement(SlotFillProvider, null, createElement(Popover.Slot, null), createElement(UnsavedChangesWarning, null), createElement(Routes, null, createElement(Layout, {
38
+ onError: reboot
39
+ }), createElement(PluginArea, {
40
+ onError: onPluginAreaError
41
+ }))));
55
42
  }
56
43
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/app/index.js"],"names":["SlotFillProvider","UnsavedChangesWarning","store","noticesStore","useDispatch","__","sprintf","PluginArea","Routes","Editor","List","NavigationSidebar","getIsListPage","EditSiteApp","reboot","homeTemplate","createErrorNotice","onPluginAreaError","name","params","isListPage","homeTemplateType","postId","includes","undefined","postType"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,uBAAjC;AACA,SAASC,qBAAT,QAAsC,mBAAtC;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,aAAP,MAA0B,8BAA1B;AAEA,eAAe,SAASC,WAAT,OAAiD;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA2B;AAC/D,QAAM;AAAEC,IAAAA;AAAF,MAAwBZ,WAAW,CAAED,YAAF,CAAzC;;AAEA,WAASc,iBAAT,CAA4BC,IAA5B,EAAmC;AAClCF,IAAAA,iBAAiB,CAChBV,OAAO;AACN;AACAD,IAAAA,EAAE,CACD,kEADC,CAFI,EAKNa,IALM,CADS,CAAjB;AASA;;AAED,SACC,cAAC,gBAAD,QACC,cAAC,qBAAD,OADD,EAGC,cAAC,MAAD,QACG,SAAkB;AAAA;;AAAA,QAAhB;AAAEC,MAAAA;AAAF,KAAgB;AACnB,UAAMC,UAAU,GAAGR,aAAa,CAAEO,MAAF,CAAhC,CADmB,CAGnB;;AACA,UAAME,gBAAgB,GACrB,kBAAAF,MAAM,CAACG,MAAP,0DAAeC,QAAf,CAAyB,YAAzB,KACAJ,MAAM,CAACG,MAAP,MAAkBP,YAAlB,aAAkBA,YAAlB,uBAAkBA,YAAY,CAAEO,MAAhC,CADA,GAEG,aAFH,GAGGE,SAJJ;AAMA,WACC,8BACGJ,UAAU,GACX,cAAC,IAAD,OADW,GAGX,cAAC,MAAD;AAAQ,MAAA,OAAO,EAAGN;AAAlB,MAJF,EAMC,cAAC,UAAD;AAAY,MAAA,OAAO,EAAGG;AAAtB,MAND,EASC,cAAC,iBAAD,CACC;AADD;AAEC,MAAA,aAAa,EAAG,CAAC,CAAEG,UAFpB;AAGC,MAAA,kBAAkB,EACjBA,UAAU,GACPD,MAAM,CAACM,QADA,GAEPJ;AANL,MATD,CADD;AAqBA,GAhCF,CAHD,CADD;AAwCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { UnsavedChangesWarning } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { PluginArea } from '@wordpress/plugins';\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, homeTemplate } ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\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\t// The existence of a 'front-page' supersedes every other setting.\n\t\t\t\t\tconst homeTemplateType =\n\t\t\t\t\t\tparams.postId?.includes( 'front-page' ) ||\n\t\t\t\t\t\tparams.postId === homeTemplate?.postId\n\t\t\t\t\t\t\t? 'site-editor'\n\t\t\t\t\t\t\t: undefined;\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<PluginArea onError={ onPluginAreaError } />\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\n\t\t\t\t\t\t\t\t\t\t? params.postType\n\t\t\t\t\t\t\t\t\t\t: homeTemplateType\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"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/app/index.js"],"names":["SlotFillProvider","Popover","UnsavedChangesWarning","ShortcutProvider","store","noticesStore","useDispatch","__","sprintf","PluginArea","Routes","Layout","App","reboot","createErrorNotice","onPluginAreaError","name","height"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,OAA3B,QAA0C,uBAA1C;AACA,SAASC,qBAAT,QAAsC,mBAAtC;AACA,SAASC,gBAAT,QAAiC,+BAAjC;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AAEA,eAAe,SAASC,GAAT,OAA2B;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AACzC,QAAM;AAAEC,IAAAA;AAAF,MAAwBR,WAAW,CAAED,YAAF,CAAzC;;AAEA,WAASU,iBAAT,CAA4BC,IAA5B,EAAmC;AAClCF,IAAAA,iBAAiB,CAChBN,OAAO;AACN;AACAD,IAAAA,EAAE,CACD,kEADC,CAFI,EAKNS,IALM,CADS,CAAjB;AASA;;AAED,SACC,cAAC,gBAAD;AAAkB,IAAA,KAAK,EAAG;AAAEC,MAAAA,MAAM,EAAE;AAAV;AAA1B,KACC,cAAC,gBAAD,QACC,cAAC,OAAD,CAAS,IAAT,OADD,EAEC,cAAC,qBAAD,OAFD,EAIC,cAAC,MAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAGJ;AAAlB,IADD,EAEC,cAAC,UAAD;AAAY,IAAA,OAAO,EAAGE;AAAtB,IAFD,CAJD,CADD,CADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { UnsavedChangesWarning } from '@wordpress/editor';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { PluginArea } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport { Routes } from '../routes';\nimport Layout from '../layout';\n\nexport default function App( { reboot } ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\treturn (\n\t\t<ShortcutProvider style={ { height: '100%' } }>\n\t\t\t<SlotFillProvider>\n\t\t\t\t<Popover.Slot />\n\t\t\t\t<UnsavedChangesWarning />\n\n\t\t\t\t<Routes>\n\t\t\t\t\t<Layout onError={ reboot } />\n\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t</Routes>\n\t\t\t</SlotFillProvider>\n\t\t</ShortcutProvider>\n\t);\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { createElement, Fragment } from "@wordpress/element";
3
+
4
+ /**
5
+ * WordPress dependencies
6
+ */
7
+ import { __experimentalUseResizeCanvas as useResizeCanvas, __unstableEditorStyles as EditorStyles, __unstableIframe as Iframe, __unstableUseMouseMoveTypingReset as useMouseMoveTypingReset, store as blockEditorStore } from '@wordpress/block-editor';
8
+ import { useSelect } from '@wordpress/data';
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+
13
+ import { store as editSiteStore } from '../../store';
14
+
15
+ function EditorCanvas(_ref) {
16
+ let {
17
+ enableResizing,
18
+ settings,
19
+ children,
20
+ ...props
21
+ } = _ref;
22
+ const {
23
+ deviceType,
24
+ isZoomOutMode
25
+ } = useSelect(select => ({
26
+ deviceType: select(editSiteStore).__experimentalGetPreviewDeviceType(),
27
+ isZoomOutMode: select(blockEditorStore).__unstableGetEditorMode() === 'zoom-out'
28
+ }), []);
29
+ const deviceStyles = useResizeCanvas(deviceType);
30
+ const mouseMoveTypingRef = useMouseMoveTypingReset();
31
+ return createElement(Iframe, _extends({
32
+ scale: isZoomOutMode && 0.45 || undefined,
33
+ frameSize: isZoomOutMode ? 100 : undefined,
34
+ style: enableResizing ? {} : deviceStyles,
35
+ head: createElement(Fragment, null, createElement(EditorStyles, {
36
+ styles: settings.styles
37
+ }), createElement("style", null, // Forming a "block formatting context" to prevent margin collapsing.
38
+ // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
39
+ `.is-root-container { display: flow-root; }
40
+ body { position: relative; }`), enableResizing && createElement("style", null, // Some themes will have `min-height: 100vh` for the root container,
41
+ // which isn't a requirement in auto resize mode.
42
+ `.is-root-container { min-height: 0 !important; }`)),
43
+ assets: settings.__unstableResolvedAssets,
44
+ ref: mouseMoveTypingRef,
45
+ name: "editor-canvas",
46
+ className: "edit-site-visual-editor__editor-canvas"
47
+ }, props), settings.svgFilters, children);
48
+ }
49
+
50
+ export default EditorCanvas;
51
+ //# sourceMappingURL=editor-canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/editor-canvas.js"],"names":["__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","store","blockEditorStore","useSelect","editSiteStore","EditorCanvas","enableResizing","settings","children","props","deviceType","isZoomOutMode","select","__experimentalGetPreviewDeviceType","__unstableGetEditorMode","deviceStyles","mouseMoveTypingRef","undefined","styles","__unstableResolvedAssets","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,YAAT,OAA0E;AAAA,MAAnD;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA,QAA5B;AAAsC,OAAGC;AAAzC,GAAmD;AACzE,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAAgCR,SAAS,CAC5CS,MAAF,KAAgB;AACfF,IAAAA,UAAU,EACTE,MAAM,CAAER,aAAF,CAAN,CAAwBS,kCAAxB,EAFc;AAGfF,IAAAA,aAAa,EACZC,MAAM,CAAEV,gBAAF,CAAN,CAA2BY,uBAA3B,OACA;AALc,GAAhB,CAD8C,EAQ9C,EAR8C,CAA/C;AAUA,QAAMC,YAAY,GAAGrB,eAAe,CAAEgB,UAAF,CAApC;AACA,QAAMM,kBAAkB,GAAGhB,uBAAuB,EAAlD;AACA,SACC,cAAC,MAAD;AACC,IAAA,KAAK,EAAKW,aAAa,IAAI,IAAnB,IAA6BM,SADtC;AAEC,IAAA,SAAS,EAAGN,aAAa,GAAG,GAAH,GAASM,SAFnC;AAGC,IAAA,KAAK,EAAGX,cAAc,GAAG,EAAH,GAAQS,YAH/B;AAIC,IAAA,IAAI,EACH,8BACC,cAAC,YAAD;AAAc,MAAA,MAAM,EAAGR,QAAQ,CAACW;AAAhC,MADD,EAEC,6BACC;AACA;AACC;AACP,oCAJK,CAFD,EAQGZ,cAAc,IACf,6BAEE;AACA;AACC,sDAJH,CATF,CALF;AAwBC,IAAA,MAAM,EAAGC,QAAQ,CAACY,wBAxBnB;AAyBC,IAAA,GAAG,EAAGH,kBAzBP;AA0BC,IAAA,IAAI,EAAC,eA1BN;AA2BC,IAAA,SAAS,EAAC;AA3BX,KA4BMP,KA5BN,GA+BGF,QAAQ,CAACa,UA/BZ,EAgCGZ,QAhCH,CADD;AAoCA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nfunction EditorCanvas( { enableResizing, settings, children, ...props } ) {\n\tconst { deviceType, isZoomOutMode } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdeviceType:\n\t\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tisZoomOutMode:\n\t\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() ===\n\t\t\t\t'zoom-out',\n\t\t} ),\n\t\t[]\n\t);\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst mouseMoveTypingRef = useMouseMoveTypingReset();\n\treturn (\n\t\t<Iframe\n\t\t\tscale={ ( isZoomOutMode && 0.45 ) || undefined }\n\t\t\tframeSize={ isZoomOutMode ? 100 : undefined }\n\t\t\tstyle={ enableResizing ? {} : deviceStyles }\n\t\t\thead={\n\t\t\t\t<>\n\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t<style>{\n\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\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`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\tbody { position: relative; }`\n\t\t\t\t\t}</style>\n\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tassets={ settings.__unstableResolvedAssets }\n\t\t\tref={ mouseMoveTypingRef }\n\t\t\tname=\"editor-canvas\"\n\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t{ settings.svgFilters }\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\nexport default EditorCanvas;\n"]}