@wordpress/edit-site 5.3.1 → 5.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/build/components/add-new-template/new-template-part.js +8 -5
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +8 -5
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/block-editor/editor-canvas.js +3 -3
  7. package/build/components/block-editor/editor-canvas.js.map +1 -1
  8. package/build/components/block-editor/index.js +3 -3
  9. package/build/components/block-editor/index.js.map +1 -1
  10. package/build/components/editor/index.js +26 -38
  11. package/build/components/editor/index.js.map +1 -1
  12. package/build/components/global-styles/block-preview-panel.js +10 -12
  13. package/build/components/global-styles/block-preview-panel.js.map +1 -1
  14. package/build/components/global-styles/border-panel.js +2 -2
  15. package/build/components/global-styles/border-panel.js.map +1 -1
  16. package/build/components/global-styles/color-palette-panel.js +2 -2
  17. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  18. package/build/components/global-styles/context-menu.js +9 -2
  19. package/build/components/global-styles/context-menu.js.map +1 -1
  20. package/build/components/global-styles/custom-css.js +2 -2
  21. package/build/components/global-styles/custom-css.js.map +1 -1
  22. package/build/components/global-styles/dimensions-panel.js +2 -2
  23. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  24. package/build/components/global-styles/global-styles-provider.js +2 -2
  25. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  26. package/build/components/global-styles/gradients-palette-panel.js +2 -2
  27. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  28. package/build/components/global-styles/header.js +1 -1
  29. package/build/components/global-styles/header.js.map +1 -1
  30. package/build/components/global-styles/hooks.js +2 -2
  31. package/build/components/global-styles/hooks.js.map +1 -1
  32. package/build/components/global-styles/navigation-button.js +1 -1
  33. package/build/components/global-styles/navigation-button.js.map +1 -1
  34. package/build/components/global-styles/palette.js +2 -2
  35. package/build/components/global-styles/palette.js.map +1 -1
  36. package/build/components/global-styles/preview.js +2 -2
  37. package/build/components/global-styles/preview.js.map +1 -1
  38. package/build/components/global-styles/screen-background-color.js +2 -2
  39. package/build/components/global-styles/screen-background-color.js.map +1 -1
  40. package/build/components/global-styles/screen-border.js +0 -6
  41. package/build/components/global-styles/screen-border.js.map +1 -1
  42. package/build/components/global-styles/screen-button-color.js +2 -2
  43. package/build/components/global-styles/screen-button-color.js.map +1 -1
  44. package/build/components/global-styles/screen-colors.js +2 -2
  45. package/build/components/global-styles/screen-colors.js.map +1 -1
  46. package/build/components/global-styles/screen-css.js +5 -5
  47. package/build/components/global-styles/screen-css.js.map +1 -1
  48. package/build/components/global-styles/screen-effects.js +53 -0
  49. package/build/components/global-styles/screen-effects.js.map +1 -0
  50. package/build/components/global-styles/screen-heading-color.js +2 -2
  51. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  52. package/build/components/global-styles/screen-link-color.js +2 -2
  53. package/build/components/global-styles/screen-link-color.js.map +1 -1
  54. package/build/components/global-styles/screen-root.js +2 -2
  55. package/build/components/global-styles/screen-root.js.map +1 -1
  56. package/build/components/global-styles/screen-style-variations.js +2 -2
  57. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  58. package/build/components/global-styles/screen-text-color.js +2 -2
  59. package/build/components/global-styles/screen-text-color.js.map +1 -1
  60. package/build/components/global-styles/screen-typography.js +2 -2
  61. package/build/components/global-styles/screen-typography.js.map +1 -1
  62. package/build/components/global-styles/shadow-panel.js +3 -3
  63. package/build/components/global-styles/shadow-panel.js.map +1 -1
  64. package/build/components/global-styles/typography-panel.js +2 -2
  65. package/build/components/global-styles/typography-panel.js.map +1 -1
  66. package/build/components/global-styles/typography-preview.js +2 -2
  67. package/build/components/global-styles/typography-preview.js.map +1 -1
  68. package/build/components/global-styles/ui.js +10 -10
  69. package/build/components/global-styles/ui.js.map +1 -1
  70. package/build/components/global-styles-renderer/index.js +2 -2
  71. package/build/components/global-styles-renderer/index.js.map +1 -1
  72. package/build/components/header-edit-mode/index.js +6 -3
  73. package/build/components/header-edit-mode/index.js.map +1 -1
  74. package/build/components/keyboard-shortcut-help-modal/config.js +1 -1
  75. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  76. package/build/components/layout/index.js +13 -24
  77. package/build/components/layout/index.js.map +1 -1
  78. package/build/components/list/actions/rename-menu-item.js +1 -1
  79. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  80. package/build/components/list/table.js +1 -0
  81. package/build/components/list/table.js.map +1 -1
  82. package/build/components/navigation-inspector/navigation-menu.js +2 -2
  83. package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
  84. package/build/components/save-panel/index.js +78 -0
  85. package/build/components/save-panel/index.js.map +1 -0
  86. package/build/components/sidebar/index.js +42 -5
  87. package/build/components/sidebar/index.js.map +1 -1
  88. package/build/components/sidebar-navigation-screen/index.js +28 -7
  89. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  90. package/build/components/sidebar-navigation-screen-navigation-item/index.js +72 -0
  91. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
  92. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
  93. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  94. package/build/components/sidebar-navigation-screen-template/index.js +70 -0
  95. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -0
  96. package/build/components/sidebar-navigation-screen-templates/index.js +32 -82
  97. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  98. package/build/components/sidebar-navigation-screen-templates-browse/index.js +43 -0
  99. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
  100. package/build/components/site-hub/index.js +14 -49
  101. package/build/components/site-hub/index.js.map +1 -1
  102. package/build/components/style-book/index.js +10 -3
  103. package/build/components/style-book/index.js.map +1 -1
  104. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +55 -20
  105. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  106. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +3 -3
  107. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  108. package/build/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +12 -12
  109. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
  110. package/build/components/use-edited-entity-record/index.js +6 -2
  111. package/build/components/use-edited-entity-record/index.js.map +1 -1
  112. package/build/hooks/push-changes-to-global-styles/index.js +2 -2
  113. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  114. package/build/{experiments.js → private-apis.js} +3 -3
  115. package/build/private-apis.js.map +1 -0
  116. package/build/store/index.js +3 -3
  117. package/build/store/index.js.map +1 -1
  118. package/build/utils/get-is-list-page.js +5 -6
  119. package/build/utils/get-is-list-page.js.map +1 -1
  120. package/build-module/components/add-new-template/new-template-part.js +7 -4
  121. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  122. package/build-module/components/add-new-template/new-template.js +7 -4
  123. package/build-module/components/add-new-template/new-template.js.map +1 -1
  124. package/build-module/components/block-editor/editor-canvas.js +1 -1
  125. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  126. package/build-module/components/block-editor/index.js +3 -3
  127. package/build-module/components/block-editor/index.js.map +1 -1
  128. package/build-module/components/editor/index.js +28 -41
  129. package/build-module/components/editor/index.js.map +1 -1
  130. package/build-module/components/global-styles/block-preview-panel.js +10 -11
  131. package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
  132. package/build-module/components/global-styles/border-panel.js +3 -3
  133. package/build-module/components/global-styles/border-panel.js.map +1 -1
  134. package/build-module/components/global-styles/color-palette-panel.js +3 -3
  135. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  136. package/build-module/components/global-styles/context-menu.js +9 -3
  137. package/build-module/components/global-styles/context-menu.js.map +1 -1
  138. package/build-module/components/global-styles/custom-css.js +3 -3
  139. package/build-module/components/global-styles/custom-css.js.map +1 -1
  140. package/build-module/components/global-styles/dimensions-panel.js +3 -3
  141. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  142. package/build-module/components/global-styles/global-styles-provider.js +3 -3
  143. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  144. package/build-module/components/global-styles/gradients-palette-panel.js +3 -3
  145. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  146. package/build-module/components/global-styles/header.js +2 -2
  147. package/build-module/components/global-styles/header.js.map +1 -1
  148. package/build-module/components/global-styles/hooks.js +3 -3
  149. package/build-module/components/global-styles/hooks.js.map +1 -1
  150. package/build-module/components/global-styles/navigation-button.js +2 -2
  151. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  152. package/build-module/components/global-styles/palette.js +3 -3
  153. package/build-module/components/global-styles/palette.js.map +1 -1
  154. package/build-module/components/global-styles/preview.js +3 -3
  155. package/build-module/components/global-styles/preview.js.map +1 -1
  156. package/build-module/components/global-styles/screen-background-color.js +3 -3
  157. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  158. package/build-module/components/global-styles/screen-border.js +0 -5
  159. package/build-module/components/global-styles/screen-border.js.map +1 -1
  160. package/build-module/components/global-styles/screen-button-color.js +3 -3
  161. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  162. package/build-module/components/global-styles/screen-colors.js +3 -3
  163. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  164. package/build-module/components/global-styles/screen-css.js +5 -5
  165. package/build-module/components/global-styles/screen-css.js.map +1 -1
  166. package/build-module/components/global-styles/screen-effects.js +35 -0
  167. package/build-module/components/global-styles/screen-effects.js.map +1 -0
  168. package/build-module/components/global-styles/screen-heading-color.js +3 -3
  169. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  170. package/build-module/components/global-styles/screen-link-color.js +3 -3
  171. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  172. package/build-module/components/global-styles/screen-root.js +3 -3
  173. package/build-module/components/global-styles/screen-root.js.map +1 -1
  174. package/build-module/components/global-styles/screen-style-variations.js +3 -3
  175. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  176. package/build-module/components/global-styles/screen-text-color.js +3 -3
  177. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  178. package/build-module/components/global-styles/screen-typography.js +3 -3
  179. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  180. package/build-module/components/global-styles/shadow-panel.js +4 -4
  181. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  182. package/build-module/components/global-styles/typography-panel.js +3 -3
  183. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  184. package/build-module/components/global-styles/typography-preview.js +3 -3
  185. package/build-module/components/global-styles/typography-preview.js.map +1 -1
  186. package/build-module/components/global-styles/ui.js +10 -11
  187. package/build-module/components/global-styles/ui.js.map +1 -1
  188. package/build-module/components/global-styles-renderer/index.js +3 -3
  189. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  190. package/build-module/components/header-edit-mode/index.js +6 -3
  191. package/build-module/components/header-edit-mode/index.js.map +1 -1
  192. package/build-module/components/keyboard-shortcut-help-modal/config.js +1 -1
  193. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  194. package/build-module/components/layout/index.js +12 -24
  195. package/build-module/components/layout/index.js.map +1 -1
  196. package/build-module/components/list/actions/rename-menu-item.js +1 -1
  197. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  198. package/build-module/components/list/table.js +1 -0
  199. package/build-module/components/list/table.js.map +1 -1
  200. package/build-module/components/navigation-inspector/navigation-menu.js +3 -3
  201. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
  202. package/build-module/components/save-panel/index.js +64 -0
  203. package/build-module/components/save-panel/index.js.map +1 -0
  204. package/build-module/components/sidebar/index.js +36 -5
  205. package/build-module/components/sidebar/index.js.map +1 -1
  206. package/build-module/components/sidebar-navigation-screen/index.js +27 -9
  207. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  208. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +55 -0
  209. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
  210. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
  211. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  212. package/build-module/components/sidebar-navigation-screen-template/index.js +53 -0
  213. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -0
  214. package/build-module/components/sidebar-navigation-screen-templates/index.js +34 -81
  215. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  216. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
  217. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
  218. package/build-module/components/site-hub/index.js +14 -46
  219. package/build-module/components/site-hub/index.js.map +1 -1
  220. package/build-module/components/style-book/index.js +11 -4
  221. package/build-module/components/style-book/index.js.map +1 -1
  222. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +55 -21
  223. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  224. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
  225. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  226. package/build-module/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +11 -11
  227. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
  228. package/build-module/components/use-edited-entity-record/index.js +6 -2
  229. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  230. package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
  231. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  232. package/build-module/{experiments.js → private-apis.js} +2 -2
  233. package/build-module/private-apis.js.map +1 -0
  234. package/build-module/store/index.js +1 -1
  235. package/build-module/store/index.js.map +1 -1
  236. package/build-module/utils/get-is-list-page.js +5 -6
  237. package/build-module/utils/get-is-list-page.js.map +1 -1
  238. package/build-style/style-rtl.css +100 -62
  239. package/build-style/style.css +100 -62
  240. package/package.json +20 -20
  241. package/src/components/add-new-template/new-template-part.js +7 -4
  242. package/src/components/add-new-template/new-template.js +8 -6
  243. package/src/components/block-editor/editor-canvas.js +1 -1
  244. package/src/components/block-editor/index.js +3 -3
  245. package/src/components/editor/index.js +32 -71
  246. package/src/components/editor/style.scss +2 -2
  247. package/src/components/global-styles/block-preview-panel.js +8 -12
  248. package/src/components/global-styles/border-panel.js +3 -3
  249. package/src/components/global-styles/color-palette-panel.js +3 -3
  250. package/src/components/global-styles/context-menu.js +14 -2
  251. package/src/components/global-styles/custom-css.js +3 -3
  252. package/src/components/global-styles/dimensions-panel.js +3 -3
  253. package/src/components/global-styles/global-styles-provider.js +3 -3
  254. package/src/components/global-styles/gradients-palette-panel.js +3 -3
  255. package/src/components/global-styles/header.js +2 -2
  256. package/src/components/global-styles/hooks.js +3 -3
  257. package/src/components/global-styles/navigation-button.js +4 -2
  258. package/src/components/global-styles/palette.js +3 -3
  259. package/src/components/global-styles/preview.js +3 -3
  260. package/src/components/global-styles/screen-background-color.js +3 -3
  261. package/src/components/global-styles/screen-border.js +0 -5
  262. package/src/components/global-styles/screen-button-color.js +3 -3
  263. package/src/components/global-styles/screen-colors.js +3 -3
  264. package/src/components/global-styles/screen-css.js +14 -7
  265. package/src/components/global-styles/screen-effects.js +28 -0
  266. package/src/components/global-styles/screen-heading-color.js +3 -3
  267. package/src/components/global-styles/screen-link-color.js +3 -3
  268. package/src/components/global-styles/screen-root.js +3 -3
  269. package/src/components/global-styles/screen-style-variations.js +3 -3
  270. package/src/components/global-styles/screen-text-color.js +3 -3
  271. package/src/components/global-styles/screen-typography.js +3 -3
  272. package/src/components/global-styles/shadow-panel.js +4 -4
  273. package/src/components/global-styles/style.scss +2 -5
  274. package/src/components/global-styles/typography-panel.js +3 -3
  275. package/src/components/global-styles/typography-preview.js +3 -3
  276. package/src/components/global-styles/ui.js +8 -8
  277. package/src/components/global-styles-renderer/index.js +3 -3
  278. package/src/components/header-edit-mode/index.js +6 -3
  279. package/src/components/keyboard-shortcut-help-modal/config.js +1 -1
  280. package/src/components/layout/index.js +38 -48
  281. package/src/components/layout/style.scss +36 -26
  282. package/src/components/list/actions/rename-menu-item.js +1 -1
  283. package/src/components/list/table.js +4 -0
  284. package/src/components/navigation-inspector/navigation-menu.js +3 -3
  285. package/src/components/save-panel/index.js +68 -0
  286. package/src/components/save-panel/style.scss +5 -0
  287. package/src/components/sidebar/index.js +36 -8
  288. package/src/components/sidebar/style.scss +15 -0
  289. package/src/components/sidebar-navigation-screen/index.js +27 -11
  290. package/src/components/sidebar-navigation-screen/style.scss +4 -6
  291. package/src/components/sidebar-navigation-screen-navigation-item/index.js +52 -0
  292. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +1 -1
  293. package/src/components/sidebar-navigation-screen-template/index.js +52 -0
  294. package/src/components/sidebar-navigation-screen-templates/index.js +49 -83
  295. package/src/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
  296. package/src/components/site-hub/index.js +67 -122
  297. package/src/components/site-hub/style.scss +1 -10
  298. package/src/components/style-book/index.js +11 -7
  299. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +48 -14
  300. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
  301. package/src/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +10 -10
  302. package/src/components/use-edited-entity-record/index.js +6 -2
  303. package/src/hooks/push-changes-to-global-styles/index.js +3 -3
  304. package/src/{experiments.js → private-apis.js} +1 -1
  305. package/src/store/index.js +1 -1
  306. package/src/style.scss +1 -0
  307. package/src/utils/get-is-list-page.js +5 -5
  308. package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
  309. package/build/experiments.js.map +0 -1
  310. package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
  311. package/build-module/experiments.js.map +0 -1
@@ -9,6 +9,8 @@ var _element = require("@wordpress/element");
9
9
 
10
10
  var _data = require("@wordpress/data");
11
11
 
12
+ var _coreData = require("@wordpress/core-data");
13
+
12
14
  var _routes = require("../routes");
13
15
 
14
16
  var _store = require("../../store");
@@ -21,33 +23,66 @@ var _store = require("../../store");
21
23
  * Internal dependencies
22
24
  */
23
25
  function useInitEditedEntityFromURL() {
26
+ const {
27
+ params: {
28
+ postId,
29
+ postType,
30
+ path = '/'
31
+ } = {}
32
+ } = (0, _routes.useLocation)();
33
+ const {
34
+ isRequestingSite,
35
+ homepageId
36
+ } = (0, _data.useSelect)(select => {
37
+ const {
38
+ getSite
39
+ } = select(_coreData.store);
40
+ const siteData = getSite();
41
+ return {
42
+ isRequestingSite: !siteData,
43
+ homepageId: (siteData === null || siteData === void 0 ? void 0 : siteData.show_on_front) === 'page' ? siteData.page_on_front : null
44
+ };
45
+ }, []);
24
46
  const {
25
47
  setTemplate,
26
48
  setTemplatePart,
27
49
  setPage
28
50
  } = (0, _data.useDispatch)(_store.store);
29
- const {
30
- params: {
31
- postId,
32
- postType
33
- }
34
- } = (0, _routes.useLocation)(); // Set correct entity on page navigation.
35
-
36
51
  (0, _element.useEffect)(() => {
37
- // This URL scheme mean we can't open a template part with the context of a given post.
38
- // Potentially posts and pages could be moved to a "context" query string instead.
39
- if ('page' === postType || 'post' === postType) {
40
- setPage({
41
- context: {
42
- postType,
43
- postId
52
+ switch (path) {
53
+ case '/templates/single':
54
+ setTemplate(postId);
55
+ break;
56
+
57
+ case '/template-parts/single':
58
+ setTemplatePart(postId);
59
+ break;
60
+
61
+ case '/navigation/single':
62
+ setPage({
63
+ context: {
64
+ postType,
65
+ postId
66
+ }
67
+ });
68
+ break;
69
+
70
+ default:
71
+ {
72
+ if (homepageId) {
73
+ setPage({
74
+ context: {
75
+ postType: 'page',
76
+ postId: homepageId
77
+ }
78
+ });
79
+ } else if (!isRequestingSite) {
80
+ setPage({
81
+ path: '/'
82
+ });
83
+ }
44
84
  }
45
- }); // Resolves correct template based on ID.
46
- } else if ('wp_template' === postType) {
47
- setTemplate(postId);
48
- } else if ('wp_template_part' === postType) {
49
- setTemplatePart(postId);
50
85
  }
51
- }, [postId, postType]);
86
+ }, [path, postId, homepageId, isRequestingSite, setPage, setTemplate, setTemplatePart]);
52
87
  }
53
88
  //# sourceMappingURL=use-init-edited-entity-from-url.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","setTemplate","setTemplatePart","setPage","editSiteStore","params","postId","postType","context"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA;AAAhC,MACL,uBAAaC,YAAb,CADD;AAEA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEF,0BAFJ,CAHoD,CAOpD;;AACA,0BAAW,MAAM;AAChB;AACA;AACA,QAAK,WAAWA,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDJ,MAAAA,OAAO,CAAE;AAAEK,QAAAA,OAAO,EAAE;AAAED,UAAAA,QAAF;AAAYD,UAAAA;AAAZ;AAAX,OAAF,CAAP,CADiD,CACH;AAC9C,KAFD,MAEO,IAAK,kBAAkBC,QAAvB,EAAkC;AACxCN,MAAAA,WAAW,CAAEK,MAAF,CAAX;AACA,KAFM,MAEA,IAAK,uBAAuBC,QAA5B,EAAuC;AAC7CL,MAAAA,eAAe,CAAEI,MAAF,CAAf;AACA;AACD,GAVD,EAUG,CAAEA,MAAF,EAAUC,QAAV,CAVH;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { setTemplate, setTemplatePart, setPage } =\n\t\tuseDispatch( editSiteStore );\n\tconst {\n\t\tparams: { postId, postType },\n\t} = useLocation();\n\n\t// Set correct entity on page navigation.\n\tuseEffect( () => {\n\t\t// This URL scheme mean we can't open a template part with the context of a given post.\n\t\t// Potentially posts and pages could be moved to a \"context\" query string instead.\n\t\tif ( 'page' === postType || 'post' === postType ) {\n\t\t\tsetPage( { context: { postType, postId } } ); // Resolves correct template based on ID.\n\t\t} else if ( 'wp_template' === postType ) {\n\t\t\tsetTemplate( postId );\n\t\t} else if ( 'wp_template_part' === postType ) {\n\t\t\tsetTemplatePart( postId );\n\t\t}\n\t}, [ postId, postType ] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","params","postId","postType","path","isRequestingSite","homepageId","select","getSite","coreDataStore","siteData","show_on_front","page_on_front","setTemplate","setTemplatePart","setPage","editSiteStore","context"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,QAAV;AAAoBC,MAAAA,IAAI,GAAG;AAA3B,QAAmC;AAA7C,MAAoD,0BAA1D;AACA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAmC,qBAAaC,MAAF,IAAc;AACjE,UAAM;AAAEC,MAAAA;AAAF,QAAcD,MAAM,CAAEE,eAAF,CAA1B;AACA,UAAMC,QAAQ,GAAGF,OAAO,EAAxB;AAEA,WAAO;AACNH,MAAAA,gBAAgB,EAAE,CAAEK,QADd;AAENJ,MAAAA,UAAU,EACT,CAAAI,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEC,aAAV,MAA4B,MAA5B,GACGD,QAAQ,CAACE,aADZ,GAEG;AALE,KAAP;AAOA,GAXwC,EAWtC,EAXsC,CAAzC;AAaA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA;AAAhC,MACL,uBAAaC,YAAb,CADD;AAGA,0BAAW,MAAM;AAChB,YAASZ,IAAT;AACC,WAAK,mBAAL;AACCS,QAAAA,WAAW,CAAEX,MAAF,CAAX;AACA;;AACD,WAAK,wBAAL;AACCY,QAAAA,eAAe,CAAEZ,MAAF,CAAf;AACA;;AACD,WAAK,oBAAL;AACCa,QAAAA,OAAO,CAAE;AACRE,UAAAA,OAAO,EAAE;AAAEd,YAAAA,QAAF;AAAYD,YAAAA;AAAZ;AADD,SAAF,CAAP;AAGA;;AACD;AAAS;AACR,cAAKI,UAAL,EAAkB;AACjBS,YAAAA,OAAO,CAAE;AACRE,cAAAA,OAAO,EAAE;AAAEd,gBAAAA,QAAQ,EAAE,MAAZ;AAAoBD,gBAAAA,MAAM,EAAEI;AAA5B;AADD,aAAF,CAAP;AAGA,WAJD,MAIO,IAAK,CAAED,gBAAP,EAA0B;AAChCU,YAAAA,OAAO,CAAE;AACRX,cAAAA,IAAI,EAAE;AADE,aAAF,CAAP;AAGA;AACD;AAtBF;AAwBA,GAzBD,EAyBG,CACFA,IADE,EAEFF,MAFE,EAGFI,UAHE,EAIFD,gBAJE,EAKFU,OALE,EAMFF,WANE,EAOFC,eAPE,CAzBH;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params: { postId, postType, path = '/' } = {} } = useLocation();\n\tconst { isRequestingSite, homepageId } = useSelect( ( select ) => {\n\t\tconst { getSite } = select( coreDataStore );\n\t\tconst siteData = getSite();\n\n\t\treturn {\n\t\t\tisRequestingSite: ! siteData,\n\t\t\thomepageId:\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? siteData.page_on_front\n\t\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst { setTemplate, setTemplatePart, setPage } =\n\t\tuseDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tswitch ( path ) {\n\t\t\tcase '/templates/single':\n\t\t\t\tsetTemplate( postId );\n\t\t\t\tbreak;\n\t\t\tcase '/template-parts/single':\n\t\t\t\tsetTemplatePart( postId );\n\t\t\t\tbreak;\n\t\t\tcase '/navigation/single':\n\t\t\t\tsetPage( {\n\t\t\t\t\tcontext: { postType, postId },\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif ( homepageId ) {\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tcontext: { postType: 'page', postId: homepageId },\n\t\t\t\t\t} );\n\t\t\t\t} else if ( ! isRequestingSite ) {\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tpath: '/',\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [\n\t\tpath,\n\t\tpostId,\n\t\thomepageId,\n\t\tisRequestingSite,\n\t\tsetPage,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t] );\n}\n"]}
@@ -13,7 +13,7 @@ var _store = require("../../store");
13
13
 
14
14
  var _routes = require("../routes");
15
15
 
16
- var _experiments = require("../../experiments");
16
+ var _privateApis = require("../../private-apis");
17
17
 
18
18
  /**
19
19
  * WordPress dependencies
@@ -27,10 +27,10 @@ function useSyncCanvasModeWithURL() {
27
27
  const {
28
28
  params
29
29
  } = (0, _routes.useLocation)();
30
- const canvasMode = (0, _data.useSelect)(select => (0, _experiments.unlock)(select(_store.store)).getCanvasMode(), []);
30
+ const canvasMode = (0, _data.useSelect)(select => (0, _privateApis.unlock)(select(_store.store)).getCanvasMode(), []);
31
31
  const {
32
32
  setCanvasMode
33
- } = (0, _experiments.unlock)((0, _data.useDispatch)(_store.store));
33
+ } = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
34
34
  const currentCanvasMode = (0, _element.useRef)(canvasMode);
35
35
  const {
36
36
  canvas: canvasInUrl = 'view'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js"],"names":["useSyncCanvasModeWithURL","history","params","canvasMode","select","editSiteStore","getCanvasMode","setCanvasMode","currentCanvasMode","canvas","canvasInUrl","currentCanvasInUrl","current","push"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,wBAAT,GAAoC;AAClD,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,UAAU,GAAG,qBAChBC,MAAF,IAAc,yBAAQA,MAAM,CAAEC,YAAF,CAAd,EAAkCC,aAAlC,EADI,EAElB,EAFkB,CAAnB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaF,YAAb,CAAR,CAA1B;AACA,QAAMG,iBAAiB,GAAG,qBAAQL,UAAR,CAA1B;AACA,QAAM;AAAEM,IAAAA,MAAM,EAAEC,WAAW,GAAG;AAAxB,MAAmCR,MAAzC;AACA,QAAMS,kBAAkB,GAAG,qBAAQD,WAAR,CAA3B;AACA,0BAAW,MAAM;AAChBF,IAAAA,iBAAiB,CAACI,OAAlB,GAA4BT,UAA5B;;AACA,QAAKK,iBAAiB,KAAKG,kBAA3B,EAAgD;AAC/CV,MAAAA,OAAO,CAACY,IAAR,CAAc,EACb,GAAGX,MADU;AAEbO,QAAAA,MAAM,EAAEN;AAFK,OAAd;AAIA;AACD,GARD,EAQG,CAAEA,UAAF,CARH;AAUA,0BAAW,MAAM;AAChBQ,IAAAA,kBAAkB,CAACC,OAAnB,GAA6BF,WAA7B;;AACA,QAAKA,WAAW,KAAKF,iBAAiB,CAACI,OAAvC,EAAiD;AAChDL,MAAAA,aAAa,CAAEG,WAAF,CAAb;AACA;AACD,GALD,EAKG,CAAEA,WAAF,CALH;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { useLocation, useHistory } from '../routes';\nimport { unlock } from '../../experiments';\n\nexport default function useSyncCanvasModeWithURL() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst canvasMode = useSelect(\n\t\t( select ) => unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t[]\n\t);\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst currentCanvasMode = useRef( canvasMode );\n\tconst { canvas: canvasInUrl = 'view' } = params;\n\tconst currentCanvasInUrl = useRef( canvasInUrl );\n\tuseEffect( () => {\n\t\tcurrentCanvasMode.current = canvasMode;\n\t\tif ( currentCanvasMode !== currentCanvasInUrl ) {\n\t\t\thistory.push( {\n\t\t\t\t...params,\n\t\t\t\tcanvas: canvasMode,\n\t\t\t} );\n\t\t}\n\t}, [ canvasMode ] );\n\n\tuseEffect( () => {\n\t\tcurrentCanvasInUrl.current = canvasInUrl;\n\t\tif ( canvasInUrl !== currentCanvasMode.current ) {\n\t\t\tsetCanvasMode( canvasInUrl );\n\t\t}\n\t}, [ canvasInUrl ] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js"],"names":["useSyncCanvasModeWithURL","history","params","canvasMode","select","editSiteStore","getCanvasMode","setCanvasMode","currentCanvasMode","canvas","canvasInUrl","currentCanvasInUrl","current","push"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,wBAAT,GAAoC;AAClD,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,UAAU,GAAG,qBAChBC,MAAF,IAAc,yBAAQA,MAAM,CAAEC,YAAF,CAAd,EAAkCC,aAAlC,EADI,EAElB,EAFkB,CAAnB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaF,YAAb,CAAR,CAA1B;AACA,QAAMG,iBAAiB,GAAG,qBAAQL,UAAR,CAA1B;AACA,QAAM;AAAEM,IAAAA,MAAM,EAAEC,WAAW,GAAG;AAAxB,MAAmCR,MAAzC;AACA,QAAMS,kBAAkB,GAAG,qBAAQD,WAAR,CAA3B;AACA,0BAAW,MAAM;AAChBF,IAAAA,iBAAiB,CAACI,OAAlB,GAA4BT,UAA5B;;AACA,QAAKK,iBAAiB,KAAKG,kBAA3B,EAAgD;AAC/CV,MAAAA,OAAO,CAACY,IAAR,CAAc,EACb,GAAGX,MADU;AAEbO,QAAAA,MAAM,EAAEN;AAFK,OAAd;AAIA;AACD,GARD,EAQG,CAAEA,UAAF,CARH;AAUA,0BAAW,MAAM;AAChBQ,IAAAA,kBAAkB,CAACC,OAAnB,GAA6BF,WAA7B;;AACA,QAAKA,WAAW,KAAKF,iBAAiB,CAACI,OAAvC,EAAiD;AAChDL,MAAAA,aAAa,CAAEG,WAAF,CAAb;AACA;AACD,GALD,EAKG,CAAEA,WAAF,CALH;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { useLocation, useHistory } from '../routes';\nimport { unlock } from '../../private-apis';\n\nexport default function useSyncCanvasModeWithURL() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst canvasMode = useSelect(\n\t\t( select ) => unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t[]\n\t);\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst currentCanvasMode = useRef( canvasMode );\n\tconst { canvas: canvasInUrl = 'view' } = params;\n\tconst currentCanvasInUrl = useRef( canvasInUrl );\n\tuseEffect( () => {\n\t\tcurrentCanvasMode.current = canvasMode;\n\t\tif ( currentCanvasMode !== currentCanvasInUrl ) {\n\t\t\thistory.push( {\n\t\t\t\t...params,\n\t\t\t\tcanvas: canvasMode,\n\t\t\t} );\n\t\t}\n\t}, [ canvasMode ] );\n\n\tuseEffect( () => {\n\t\tcurrentCanvasInUrl.current = canvasInUrl;\n\t\tif ( canvasInUrl !== currentCanvasMode.current ) {\n\t\t\tsetCanvasMode( canvasInUrl );\n\t\t}\n\t}, [ canvasInUrl ] );\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = useSyncSidebarPathWithURL;
6
+ exports.default = useSyncPathWithURL;
7
7
 
8
8
  var _components = require("@wordpress/components");
9
9
 
@@ -18,36 +18,36 @@ var _routes = require("../routes");
18
18
  /**
19
19
  * Internal dependencies
20
20
  */
21
- function useSyncSidebarPathWithURL() {
21
+ function useSyncPathWithURL() {
22
22
  const history = (0, _routes.useHistory)();
23
23
  const {
24
24
  params
25
25
  } = (0, _routes.useLocation)();
26
26
  const {
27
- sidebar = '/'
27
+ path = '/'
28
28
  } = params;
29
29
  const {
30
30
  location,
31
31
  goTo
32
32
  } = (0, _components.__experimentalUseNavigator)();
33
- const currentSidebar = (0, _element.useRef)(sidebar);
33
+ const currentPath = (0, _element.useRef)(path);
34
34
  const currentNavigatorLocation = (0, _element.useRef)(location.path);
35
35
  (0, _element.useEffect)(() => {
36
- currentSidebar.current = sidebar;
36
+ currentPath.current = path;
37
37
 
38
- if (sidebar !== currentNavigatorLocation.current) {
39
- goTo(sidebar);
38
+ if (path !== currentNavigatorLocation.current) {
39
+ goTo(path);
40
40
  }
41
- }, [sidebar]);
41
+ }, [path]);
42
42
  (0, _element.useEffect)(() => {
43
43
  currentNavigatorLocation.current = location.path;
44
44
 
45
- if (location.path !== currentSidebar.current) {
45
+ if (location.path !== currentPath.current) {
46
46
  history.push({ ...params,
47
- sidebar: location.path
47
+ path: location.path
48
48
  });
49
49
  }
50
50
  }, [location.path, history]);
51
- return sidebar;
51
+ return path;
52
52
  }
53
- //# sourceMappingURL=use-sync-sidebar-path-with-url.js.map
53
+ //# sourceMappingURL=use-sync-path-with-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["useSyncPathWithURL","history","params","path","location","goTo","currentPath","currentNavigatorLocation","current","push"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAM;AAAEC,IAAAA,IAAI,GAAG;AAAT,MAAiBD,MAAvB;AACA,QAAM;AAAEE,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAqB,6CAA3B;AACA,QAAMC,WAAW,GAAG,qBAAQH,IAAR,CAApB;AACA,QAAMI,wBAAwB,GAAG,qBAAQH,QAAQ,CAACD,IAAjB,CAAjC;AACA,0BAAW,MAAM;AAChBG,IAAAA,WAAW,CAACE,OAAZ,GAAsBL,IAAtB;;AACA,QAAKA,IAAI,KAAKI,wBAAwB,CAACC,OAAvC,EAAiD;AAChDH,MAAAA,IAAI,CAAEF,IAAF,CAAJ;AACA;AACD,GALD,EAKG,CAAEA,IAAF,CALH;AAMA,0BAAW,MAAM;AAChBI,IAAAA,wBAAwB,CAACC,OAAzB,GAAmCJ,QAAQ,CAACD,IAA5C;;AACA,QAAKC,QAAQ,CAACD,IAAT,KAAkBG,WAAW,CAACE,OAAnC,EAA6C;AAC5CP,MAAAA,OAAO,CAACQ,IAAR,CAAc,EACb,GAAGP,MADU;AAEbC,QAAAA,IAAI,EAAEC,QAAQ,CAACD;AAFF,OAAd;AAIA;AACD,GARD,EAQG,CAAEC,QAAQ,CAACD,IAAX,EAAiBF,OAAjB,CARH;AAUA,SAAOE,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useLocation, useHistory } from '../routes';\n\nexport default function useSyncPathWithURL() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst { path = '/' } = params;\n\tconst { location, goTo } = useNavigator();\n\tconst currentPath = useRef( path );\n\tconst currentNavigatorLocation = useRef( location.path );\n\tuseEffect( () => {\n\t\tcurrentPath.current = path;\n\t\tif ( path !== currentNavigatorLocation.current ) {\n\t\t\tgoTo( path );\n\t\t}\n\t}, [ path ] );\n\tuseEffect( () => {\n\t\tcurrentNavigatorLocation.current = location.path;\n\t\tif ( location.path !== currentPath.current ) {\n\t\t\thistory.push( {\n\t\t\t\t...params,\n\t\t\t\tpath: location.path,\n\t\t\t} );\n\t\t}\n\t}, [ location.path, history ] );\n\n\treturn path;\n}\n"]}
@@ -26,6 +26,7 @@ function useEditedEntityRecord() {
26
26
  const {
27
27
  record,
28
28
  title,
29
+ description,
29
30
  isLoaded
30
31
  } = (0, _data.useSelect)(select => {
31
32
  const {
@@ -45,16 +46,19 @@ function useEditedEntityRecord() {
45
46
 
46
47
  const _isLoaded = !!postId;
47
48
 
49
+ const templateInfo = getTemplateInfo(_record);
48
50
  return {
49
51
  record: _record,
50
- title: getTemplateInfo(_record).title,
52
+ title: templateInfo.title,
53
+ description: templateInfo.description,
51
54
  isLoaded: _isLoaded
52
55
  };
53
56
  }, []);
54
57
  return {
55
58
  isLoaded,
56
59
  record,
57
- getTitle: () => title ? (0, _htmlEntities.decodeEntities)(title) : null
60
+ getTitle: () => title ? (0, _htmlEntities.decodeEntities)(title) : null,
61
+ getDescription: () => description ? (0, _htmlEntities.decodeEntities)(description) : null
58
62
  };
59
63
  }
60
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","record","title","isLoaded","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","postType","postId","_record","_isLoaded","getTitle"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA;AAAjB,MAA8B,qBAAaC,MAAF,IAAc;AAC5D,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAA4BJ,MAAM,CAAEK,eAAF,CAAxC;AACA,UAAM;AAAEC,MAAAA,6BAA6B,EAAEC;AAAjC,QACLP,MAAM,CAAEQ,aAAF,CADP;AAEA,UAAMC,QAAQ,GAAGR,iBAAiB,EAAlC;AACA,UAAMS,MAAM,GAAGR,eAAe,EAA9B;;AACA,UAAMS,OAAO,GAAGP,qBAAqB,CAAE,UAAF,EAAcK,QAAd,EAAwBC,MAAxB,CAArC;;AACA,UAAME,SAAS,GAAG,CAAC,CAAEF,MAArB;;AAEA,WAAO;AACNb,MAAAA,MAAM,EAAEc,OADF;AAENb,MAAAA,KAAK,EAAES,eAAe,CAAEI,OAAF,CAAf,CAA2Bb,KAF5B;AAGNC,MAAAA,QAAQ,EAAEa;AAHJ,KAAP;AAKA,GAfmC,EAejC,EAfiC,CAApC;AAiBA,SAAO;AACNb,IAAAA,QADM;AAENF,IAAAA,MAFM;AAGNgB,IAAAA,QAAQ,EAAE,MAAQf,KAAK,GAAG,kCAAgBA,KAAhB,CAAH,GAA6B;AAH9C,GAAP;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord() {\n\tconst { record, title, isLoaded } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst _record = getEditedEntityRecord( 'postType', postType, postId );\n\t\tconst _isLoaded = !! postId;\n\n\t\treturn {\n\t\t\trecord: _record,\n\t\t\ttitle: getTemplateInfo( _record ).title,\n\t\t\tisLoaded: _isLoaded,\n\t\t};\n\t}, [] );\n\n\treturn {\n\t\tisLoaded,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","record","title","description","isLoaded","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","postType","postId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA,WAAjB;AAA8BC,IAAAA;AAA9B,MAA2C,qBAAaC,MAAF,IAAc;AACzE,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAA4BJ,MAAM,CAAEK,eAAF,CAAxC;AACA,UAAM;AAAEC,MAAAA,6BAA6B,EAAEC;AAAjC,QACLP,MAAM,CAAEQ,aAAF,CADP;AAEA,UAAMC,QAAQ,GAAGR,iBAAiB,EAAlC;AACA,UAAMS,MAAM,GAAGR,eAAe,EAA9B;;AACA,UAAMS,OAAO,GAAGP,qBAAqB,CAAE,UAAF,EAAcK,QAAd,EAAwBC,MAAxB,CAArC;;AACA,UAAME,SAAS,GAAG,CAAC,CAAEF,MAArB;;AACA,UAAMG,YAAY,GAAGN,eAAe,CAAEI,OAAF,CAApC;AAEA,WAAO;AACNf,MAAAA,MAAM,EAAEe,OADF;AAENd,MAAAA,KAAK,EAAEgB,YAAY,CAAChB,KAFd;AAGNC,MAAAA,WAAW,EAAEe,YAAY,CAACf,WAHpB;AAINC,MAAAA,QAAQ,EAAEa;AAJJ,KAAP;AAMA,GAjBgD,EAiB9C,EAjB8C,CAAjD;AAmBA,SAAO;AACNb,IAAAA,QADM;AAENH,IAAAA,MAFM;AAGNkB,IAAAA,QAAQ,EAAE,MAAQjB,KAAK,GAAG,kCAAgBA,KAAhB,CAAH,GAA6B,IAH9C;AAINkB,IAAAA,cAAc,EAAE,MACfjB,WAAW,GAAG,kCAAgBA,WAAhB,CAAH,GAAmC;AALzC,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord() {\n\tconst { record, title, description, isLoaded } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst _record = getEditedEntityRecord( 'postType', postType, postId );\n\t\tconst _isLoaded = !! postId;\n\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\treturn {\n\t\t\trecord: _record,\n\t\t\ttitle: templateInfo.title,\n\t\t\tdescription: templateInfo.description,\n\t\t\tisLoaded: _isLoaded,\n\t\t};\n\t}, [] );\n\n\treturn {\n\t\tisLoaded,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"]}
@@ -22,7 +22,7 @@ var _notices = require("@wordpress/notices");
22
22
 
23
23
  var _hooks2 = require("../../components/global-styles/hooks");
24
24
 
25
- var _experiments = require("../../experiments");
25
+ var _privateApis = require("../../private-apis");
26
26
 
27
27
  /**
28
28
  * External dependencies
@@ -37,7 +37,7 @@ var _experiments = require("../../experiments");
37
37
  */
38
38
  const {
39
39
  GlobalStylesContext
40
- } = (0, _experiments.unlock)(_blockEditor.experiments); // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
40
+ } = (0, _privateApis.unlock)(_blockEditor.privateApis); // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
41
41
  // removed by moving PushChangesToGlobalStylesControl to
42
42
  // @wordpress/block-editor.
43
43
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["GlobalStylesContext","blockEditorExperiments","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","getChangesToPush","name","attributes","flatMap","key","STYLE_PROPERTY","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props"],"mappings":";;AAqBA;;AAlBA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAA0B,yBAAQC,wBAAR,CAAhC,C,CAEA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG;AACnC,sBAAoB,OADe;AAEnC,gBAAc,OAFqB;AAGnC,8BAA4B,OAHO;AAInC,qCAAmC,OAJA;AAKnC,yCAAuC,aALJ;AAMnC,uCAAqC,WANF;AAOnC,gCAA8B,OAPK;AAQnC,sCAAoC,OARD;AASnC,2CAAyC,aATN;AAUnC,yCAAuC,WAVJ;AAWnC,4BAA0B,OAXS;AAYnC,uCAAqC,OAZF;AAanC,4CAA0C,aAbP;AAcnC,+BAA6B,UAdM;AAenC,qCAAmC,UAfA;AAgBnC,uBAAqB,OAhBc;AAiBnC,kCAAgC,OAjBG;AAkBnC,uCAAqC,aAlBF;AAmBnC,gCAA8B,UAnBK;AAoBnC,uBAAqB,OApBc;AAqBnC,kCAAgC,OArBG;AAsBnC,uCAAqC,aAtBF;AAuBnC,gCAA8B,UAvBK;AAwBnC,uBAAqB,OAxBc;AAyBnC,kCAAgC,OAzBG;AA0BnC,uCAAqC,aA1BF;AA2BnC,gCAA8B,UA3BK;AA4BnC,uBAAqB,OA5Bc;AA6BnC,kCAAgC,OA7BG;AA8BnC,uCAAqC,aA9BF;AA+BnC,gCAA8B,UA/BK;AAgCnC,uBAAqB,OAhCc;AAiCnC,kCAAgC,OAjCG;AAkCnC,uCAAqC,aAlCF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,oBACC;AACA,kBAAI,oBAAJ,CAFD,EAGC,0BAAcxB,IAAd,EAAqBiC,KAHtB,CADkB,EAMlB;AACCC,MAAAA,IAAI,EAAE,UADP;AAECC,MAAAA,OAAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;;AAECC,QAAAA,OAAO,GAAG;AACTf,UAAAA,uCAAuC;;AACvCL,UAAAA,aAAa,CAAE;AAAEP,YAAAA,KAAK,EAAEkB;AAAT,WAAF,CAAb;AACAP,UAAAA,aAAa,CAAE,MAAMD,UAAR,EAAoB;AAChCY,YAAAA,UAAU,EAAE;AADoB,WAApB,CAAb;AAGA;;AARF,OADQ;AAFV,KANkB,CAAnB;AAsBA,GA7CmB,EA6CjB,CAAEd,OAAF,EAAWjB,UAAX,EAAuBmB,UAAvB,EAAmCpB,IAAnC,CA7CiB,CAApB;AA+CA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAG,oBACN;AACA,kBACC,wFADD,CAFM,EAKN,0BAAcA,IAAd,EAAqBiC,KALf;AAFR,KAUC,4BAAC,uBAAD,CAAa,WAAb,QACG,cAAI,QAAJ,CADH,CAVD,EAaC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,QAAQ,EAAGf,OAAO,CAACS,MAAR,KAAmB,CAF/B;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKG,cAAI,gBAAJ,CALH,CAbD,CADD;AAuBA;;AAED,MAAMY,6BAA6B,GAAG,yCACnCC,SAAF,IAAmBC,KAAF,IAEf,qDACC,4BAAC,SAAD,EAAgBA,KAAhB,CADD,EAEC,4BAAC,sCAAD,QACC,4BAAC,gCAAD,EAAuCA,KAAvC,CADD,CAFD,CAHmC,CAAtC;AAYA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels } from '../../components/global-styles/hooks';\nimport { unlock } from '../../experiments';\n\nconst { GlobalStylesContext } = unlock( blockEditorExperiments );\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nfunction getChangesToPush( name, attributes ) {\n\treturn getSupportedGlobalStylesPanels( name ).flatMap( ( key ) => {\n\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\tconst presetAttributeKey = path.join( '.' );\n\t\tconst presetAttributeValue =\n\t\t\tattributes[\n\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t];\n\t\tconst value = presetAttributeValue\n\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t: get( attributes.style, path );\n\t\treturn value ? [ { path, value } ] : [];\n\t} );\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst changes = useMemo(\n\t\t() => getChangesToPush( name, attributes ),\n\t\t[ name, attributes ]\n\t);\n\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { style: blockStyles } = attributes;\n\n\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\tfor ( const { path, value } of changes ) {\n\t\t\tset( newBlockStyles, path, undefined );\n\t\t\tset( newUserConfig, [ 'styles', 'blocks', name, ...path ], value );\n\t\t}\n\n\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t// tracking and implement our own Undo button in the snackbar\n\t\t// notification.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { style: newBlockStyles } );\n\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\tsetAttributes( { style: blockStyles } );\n\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\tundoIgnore: true,\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}\n\t\t);\n\t}, [ changes, attributes, userConfig, name ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) =>\n\t\t(\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t</InspectorAdvancedControls>\n\t\t\t</>\n\t\t)\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["GlobalStylesContext","blockEditorPrivateApis","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","getChangesToPush","name","attributes","flatMap","key","STYLE_PROPERTY","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props"],"mappings":";;AAqBA;;AAlBA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAA0B,yBAAQC,wBAAR,CAAhC,C,CAEA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG;AACnC,sBAAoB,OADe;AAEnC,gBAAc,OAFqB;AAGnC,8BAA4B,OAHO;AAInC,qCAAmC,OAJA;AAKnC,yCAAuC,aALJ;AAMnC,uCAAqC,WANF;AAOnC,gCAA8B,OAPK;AAQnC,sCAAoC,OARD;AASnC,2CAAyC,aATN;AAUnC,yCAAuC,WAVJ;AAWnC,4BAA0B,OAXS;AAYnC,uCAAqC,OAZF;AAanC,4CAA0C,aAbP;AAcnC,+BAA6B,UAdM;AAenC,qCAAmC,UAfA;AAgBnC,uBAAqB,OAhBc;AAiBnC,kCAAgC,OAjBG;AAkBnC,uCAAqC,aAlBF;AAmBnC,gCAA8B,UAnBK;AAoBnC,uBAAqB,OApBc;AAqBnC,kCAAgC,OArBG;AAsBnC,uCAAqC,aAtBF;AAuBnC,gCAA8B,UAvBK;AAwBnC,uBAAqB,OAxBc;AAyBnC,kCAAgC,OAzBG;AA0BnC,uCAAqC,aA1BF;AA2BnC,gCAA8B,UA3BK;AA4BnC,uBAAqB,OA5Bc;AA6BnC,kCAAgC,OA7BG;AA8BnC,uCAAqC,aA9BF;AA+BnC,gCAA8B,UA/BK;AAgCnC,uBAAqB,OAhCc;AAiCnC,kCAAgC,OAjCG;AAkCnC,uCAAqC,aAlCF;AAmCnC,gCAA8B,UAnCK;AAoCnC,uBAAqB,OApCc;AAqCnC,kCAAgC,OArCG;AAs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kB,EAMlB;AACCC,MAAAA,IAAI,EAAE,UADP;AAECC,MAAAA,OAAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;;AAECC,QAAAA,OAAO,GAAG;AACTf,UAAAA,uCAAuC;;AACvCL,UAAAA,aAAa,CAAE;AAAEP,YAAAA,KAAK,EAAEkB;AAAT,WAAF,CAAb;AACAP,UAAAA,aAAa,CAAE,MAAMD,UAAR,EAAoB;AAChCY,YAAAA,UAAU,EAAE;AADoB,WAApB,CAAb;AAGA;;AARF,OADQ;AAFV,KANkB,CAAnB;AAsBA,GA7CmB,EA6CjB,CAAEd,OAAF,EAAWjB,UAAX,EAAuBmB,UAAvB,EAAmCpB,IAAnC,CA7CiB,CAApB;AA+CA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAG,oBACN;AACA,kBACC,wFADD,CAFM,EAKN,0BAAcA,IAAd,EAAqBiC,KALf;AAFR,KAUC,4BAAC,uBAAD,CAAa,WAAb,QACG,cAAI,QAAJ,CADH,CAVD,EAaC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,QAAQ,EAAGf,OAAO,CAACS,MAAR,KAAmB,CAF/B;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKG,cAAI,gBAAJ,CALH,CAbD,CADD;AAuBA;;AAED,MAAMY,6BAA6B,GAAG,yCACnCC,SAAF,IAAmBC,KAAF,IAEf,qDACC,4BAAC,SAAD,EAAgBA,KAAhB,CADD,EAEC,4BAAC,sCAAD,QACC,4BAAC,gCAAD,EAAuCA,KAAvC,CADD,CAFD,CAHmC,CAAtC;AAYA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels } from '../../components/global-styles/hooks';\nimport { unlock } from '../../private-apis';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nfunction getChangesToPush( name, attributes ) {\n\treturn getSupportedGlobalStylesPanels( name ).flatMap( ( key ) => {\n\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\tconst presetAttributeKey = path.join( '.' );\n\t\tconst presetAttributeValue =\n\t\t\tattributes[\n\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t];\n\t\tconst value = presetAttributeValue\n\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t: get( attributes.style, path );\n\t\treturn value ? [ { path, value } ] : [];\n\t} );\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst changes = useMemo(\n\t\t() => getChangesToPush( name, attributes ),\n\t\t[ name, attributes ]\n\t);\n\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { style: blockStyles } = attributes;\n\n\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\tfor ( const { path, value } of changes ) {\n\t\t\tset( newBlockStyles, path, undefined );\n\t\t\tset( newUserConfig, [ 'styles', 'blocks', name, ...path ], value );\n\t\t}\n\n\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t// tracking and implement our own Undo button in the snackbar\n\t\t// notification.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { style: newBlockStyles } );\n\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\tsetAttributes( { style: blockStyles } );\n\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\tundoIgnore: true,\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}\n\t\t);\n\t}, [ changes, attributes, userConfig, name ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) =>\n\t\t(\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t</InspectorAdvancedControls>\n\t\t\t</>\n\t\t)\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.unlock = exports.lock = void 0;
7
7
 
8
- var _experiments = require("@wordpress/experiments");
8
+ var _privateApis = require("@wordpress/private-apis");
9
9
 
10
10
  /**
11
11
  * WordPress dependencies
@@ -13,7 +13,7 @@ var _experiments = require("@wordpress/experiments");
13
13
  const {
14
14
  lock,
15
15
  unlock
16
- } = (0, _experiments.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/edit-site');
16
+ } = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/edit-site');
17
17
  exports.unlock = unlock;
18
18
  exports.lock = lock;
19
- //# sourceMappingURL=experiments.js.map
19
+ //# sourceMappingURL=private-apis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/private-apis.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,sBAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/edit-site'\n\t);\n"]}
@@ -21,7 +21,7 @@ var privateSelectors = _interopRequireWildcard(require("./private-selectors"));
21
21
 
22
22
  var _constants = require("./constants");
23
23
 
24
- var _experiments = require("../experiments");
24
+ var _privateApis = require("../private-apis");
25
25
 
26
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
27
 
@@ -43,6 +43,6 @@ exports.storeConfig = storeConfig;
43
43
  const store = (0, _data.createReduxStore)(_constants.STORE_NAME, storeConfig);
44
44
  exports.store = store;
45
45
  (0, _data.register)(store);
46
- (0, _experiments.unlock)(store).registerPrivateSelectors(privateSelectors);
47
- (0, _experiments.unlock)(store).registerPrivateActions(privateActions);
46
+ (0, _privateApis.unlock)(store).registerPrivateSelectors(privateSelectors);
47
+ (0, _privateApis.unlock)(store).registerPrivateActions(privateActions);
48
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["storeConfig","reducer","actions","selectors","store","STORE_NAME","registerPrivateSelectors","privateSelectors","registerPrivateActions","privateActions"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAdA;AACA;AACA;;AAGA;AACA;AACA;AASO,MAAMA,WAAW,GAAG;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA;AAH0B,CAApB;;AAMA,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8BL,WAA9B,CAAd;;AACP,oBAAUI,KAAV;AACA,yBAAQA,KAAR,EAAgBE,wBAAhB,CAA0CC,gBAA1C;AACA,yBAAQH,KAAR,EAAgBI,sBAAhB,CAAwCC,cAAxC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as privateActions from './private-actions';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../experiments';\n\nexport const storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n};\n\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\nunlock( store ).registerPrivateSelectors( privateSelectors );\nunlock( store ).registerPrivateActions( privateActions );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["storeConfig","reducer","actions","selectors","store","STORE_NAME","registerPrivateSelectors","privateSelectors","registerPrivateActions","privateActions"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAdA;AACA;AACA;;AAGA;AACA;AACA;AASO,MAAMA,WAAW,GAAG;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA;AAH0B,CAApB;;AAMA,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8BL,WAA9B,CAAd;;AACP,oBAAUI,KAAV;AACA,yBAAQA,KAAR,EAAgBE,wBAAhB,CAA0CC,gBAA1C;AACA,yBAAQH,KAAR,EAAgBI,sBAAhB,CAAwCC,cAAxC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as privateActions from './private-actions';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../private-apis';\n\nexport const storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n};\n\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\nunlock( store ).registerPrivateSelectors( privateSelectors );\nunlock( store ).registerPrivateActions( privateActions );\n"]}
@@ -8,16 +8,15 @@ exports.default = getIsListPage;
8
8
  /**
9
9
  * Returns if the params match the list page route.
10
10
  *
11
- * @param {Object} params The search params.
12
- * @param {string} params.postId The post ID.
13
- * @param {string} params.postType The post type.
11
+ * @param {Object} params The url params.
12
+ * @param {string} params.path The current path.
13
+ *
14
14
  * @return {boolean} Is list page or not.
15
15
  */
16
16
  function getIsListPage(_ref) {
17
17
  let {
18
- postId,
19
- postType
18
+ path
20
19
  } = _ref;
21
- return !!(!postId && postType);
20
+ return path === '/templates/all' || path === '/template-parts/all';
22
21
  }
23
22
  //# sourceMappingURL=get-is-list-page.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/utils/get-is-list-page.js"],"names":["getIsListPage","postId","postType"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,OAA+C;AAAA,MAAvB;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AAC7D,SAAO,CAAC,EAAI,CAAED,MAAF,IAAYC,QAAhB,CAAR;AACA","sourcesContent":["/**\n * Returns if the params match the list page route.\n *\n * @param {Object} params The search params.\n * @param {string} params.postId The post ID.\n * @param {string} params.postType The post type.\n * @return {boolean} Is list page or not.\n */\nexport default function getIsListPage( { postId, postType } ) {\n\treturn !! ( ! postId && postType );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/utils/get-is-list-page.js"],"names":["getIsListPage","path"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,OAAmC;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACjD,SAAOA,IAAI,KAAK,gBAAT,IAA6BA,IAAI,KAAK,qBAA7C;AACA","sourcesContent":["/**\n * Returns if the params match the list page route.\n *\n * @param {Object} params The url params.\n * @param {string} params.path The current path.\n *\n * @return {boolean} Is list page or not.\n */\nexport default function getIsListPage( { path } ) {\n\treturn path === '/templates/all' || path === '/template-parts/all';\n}\n"]}
@@ -19,7 +19,7 @@ import { useHistory } from '../routes';
19
19
  import { store as editSiteStore } from '../../store';
20
20
  import CreateTemplatePartModal from '../create-template-part-modal';
21
21
  import { useExistingTemplateParts, getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from '../../utils/template-part-create';
22
- import { unlock } from '../../experiments';
22
+ import { unlock } from '../../private-apis';
23
23
  export default function NewTemplatePart(_ref) {
24
24
  let {
25
25
  postType,
@@ -67,9 +67,12 @@ export default function NewTemplatePart(_ref) {
67
67
 
68
68
  setCanvasMode('edit'); // Navigate to the created template part editor.
69
69
 
70
- history.push({
71
- postId: templatePart.id,
72
- postType: templatePart.type
70
+ window.queueMicrotask(() => {
71
+ history.push({
72
+ postId: templatePart.id,
73
+ postType: 'wp_template_part',
74
+ path: '/template-parts/single'
75
+ });
73
76
  }); // TODO: Add a success notice?
74
77
  } catch (error) {
75
78
  const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while creating the template part.');
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["useState","useDispatch","Button","__","store","noticesStore","coreStore","plus","useHistory","editSiteStore","CreateTemplatePartModal","useExistingTemplateParts","getUniqueTemplatePartTitle","getCleanTemplatePartSlug","unlock","NewTemplatePart","postType","showIcon","toggleProps","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","setCanvasMode","existingTemplateParts","createTemplatePart","title","area","type","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","push","postId","id","error","errorMessage","message","code","labels","add_new"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,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;AACA,SACCC,wBADD,EAECC,0BAFD,EAGCC,wBAHD,QAIO,kCAJP;AAKA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,eAAe,SAASC,eAAT,OAIX;AAAA,MAJqC;AACxCC,IAAAA,QADwC;AAExCC,IAAAA,QAAQ,GAAG,IAF6B;AAGxCC,IAAAA;AAHwC,GAIrC;AACH,QAAMC,OAAO,GAAGX,UAAU,EAA1B;AACA,QAAM,CAAEY,WAAF,EAAeC,cAAf,IAAkCrB,QAAQ,CAAE,KAAF,CAAhD;AACA,QAAM;AAAEsB,IAAAA;AAAF,MAAwBrB,WAAW,CAAEI,YAAF,CAAzC;AACA,QAAM;AAAEkB,IAAAA;AAAF,MAAuBtB,WAAW,CAAEK,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AmB,MAAAA,iBAAiB,CAAEkB,YAAF,EAAgB;AAAEX,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AAEAR,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,GAAGV,IAAH,GAAU,IAL1B;AAMC,IAAA,KAAK,EAAGS,QAAQ,CAAC2B,MAAT,CAAgBC;AANzB,MAQG3B,QAAQ,GAAG,IAAH,GAAUD,QAAQ,CAAC2B,MAAT,CAAgBC,OARrC,CADD,EAWGxB,WAAW,IACZ,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGK;AAFZ,IAZF,CADD;AAoBA","sourcesContent":["/**\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';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from '../../utils/template-part-create';\nimport { unlock } from '../../experiments';\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 { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst existingTemplateParts = useExistingTemplateParts();\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 uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\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: uniqueTitle,\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\tsetCanvasMode( '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"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["useState","useDispatch","Button","__","store","noticesStore","coreStore","plus","useHistory","editSiteStore","CreateTemplatePartModal","useExistingTemplateParts","getUniqueTemplatePartTitle","getCleanTemplatePartSlug","unlock","NewTemplatePart","postType","showIcon","toggleProps","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","setCanvasMode","existingTemplateParts","createTemplatePart","title","area","type","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","window","queueMicrotask","push","postId","id","path","error","errorMessage","message","code","labels","add_new"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,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;AACA,SACCC,wBADD,EAECC,0BAFD,EAGCC,wBAHD,QAIO,kCAJP;AAKA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,eAAe,SAASC,eAAT,OAIX;AAAA,MAJqC;AACxCC,IAAAA,QADwC;AAExCC,IAAAA,QAAQ,GAAG,IAF6B;AAGxCC,IAAAA;AAHwC,GAIrC;AACH,QAAMC,OAAO,GAAGX,UAAU,EAA1B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bxB,UAAAA,QAAQ,EAAE,kBAFG;AAGbyB,UAAAA,IAAI,EAAE;AAHO,SAAd;AAKA,OAND,EAzBG,CAiCH;AACA,KAlCD,CAkCE,OAAQC,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEGzC,EAAE,CACF,qDADE,CAHN;AAOAmB,MAAAA,iBAAiB,CAAEqB,YAAF,EAAgB;AAAEd,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AAEAR,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,GAAGV,IAAH,GAAU,IAL1B;AAMC,IAAA,KAAK,EAAGS,QAAQ,CAAC8B,MAAT,CAAgBC;AANzB,MAQG9B,QAAQ,GAAG,IAAH,GAAUD,QAAQ,CAAC8B,MAAT,CAAgBC,OARrC,CADD,EAWG3B,WAAW,IACZ,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGK;AAFZ,IAZF,CADD;AAoBA","sourcesContent":["/**\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';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from '../../utils/template-part-create';\nimport { unlock } from '../../private-apis';\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 { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst existingTemplateParts = useExistingTemplateParts();\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 uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\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: uniqueTitle,\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\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template part editor.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: templatePart.id,\n\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\tpath: '/template-parts/single',\n\t\t\t\t} );\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"]}
@@ -22,7 +22,7 @@ import AddCustomGenericTemplateModal from './add-custom-generic-template-modal';
22
22
  import TemplateActionsLoadingScreen from './template-actions-loading-screen';
23
23
  import { useHistory } from '../routes';
24
24
  import { store as editSiteStore } from '../../store';
25
- import { unlock } from '../../experiments';
25
+ import { unlock } from '../../private-apis';
26
26
  const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'taxonomy', 'search', '404'];
27
27
  const TEMPLATE_ICONS = {
28
28
  'front-page': home,
@@ -108,9 +108,12 @@ export default function NewTemplate(_ref) {
108
108
 
109
109
  setCanvasMode('edit'); // Navigate to the created template editor.
110
110
 
111
- history.push({
112
- postId: newTemplate.id,
113
- postType: newTemplate.type
111
+ window.queueMicrotask(() => {
112
+ history.push({
113
+ postId: newTemplate.id,
114
+ postType: newTemplate.type,
115
+ path: '/templates/single'
116
+ });
114
117
  });
115
118
  createSuccessNotice(sprintf( // translators: %s: Title of the created template e.g: "Category".
116
119
  __('"%s" successfully created.'), title), {