@wordpress/edit-site 5.14.0 → 5.15.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 (341) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-page/index.js +1 -6
  3. package/build/components/add-new-page/index.js.map +1 -1
  4. package/build/components/add-new-pattern/index.js +21 -7
  5. package/build/components/add-new-pattern/index.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +10 -8
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/block-editor/constants.js +1 -1
  9. package/build/components/block-editor/constants.js.map +1 -1
  10. package/build/components/block-editor/editor-canvas.js +1 -1
  11. package/build/components/block-editor/editor-canvas.js.map +1 -1
  12. package/build/components/block-editor/index.js +0 -4
  13. package/build/components/block-editor/index.js.map +1 -1
  14. package/build/components/block-editor/use-site-editor-settings.js +87 -13
  15. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  16. package/build/components/code-editor/index.js +60 -28
  17. package/build/components/code-editor/index.js.map +1 -1
  18. package/build/components/create-pattern-modal/index.js +7 -3
  19. package/build/components/create-pattern-modal/index.js.map +1 -1
  20. package/build/components/editor/index.js +1 -1
  21. package/build/components/editor/index.js.map +1 -1
  22. package/build/components/header-edit-mode/index.js +13 -9
  23. package/build/components/header-edit-mode/index.js.map +1 -1
  24. package/build/components/layout/index.js +8 -3
  25. package/build/components/layout/index.js.map +1 -1
  26. package/build/components/page-actions/index.js +2 -2
  27. package/build/components/page-actions/index.js.map +1 -1
  28. package/build/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -16
  29. package/build/components/page-actions/trash-page-menu-item.js.map +1 -0
  30. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
  31. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  32. package/build/components/page-patterns/duplicate-menu-item.js +163 -0
  33. package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
  34. package/build/components/page-patterns/grid-item.js +83 -58
  35. package/build/components/page-patterns/grid-item.js.map +1 -1
  36. package/build/components/page-patterns/grid.js +5 -18
  37. package/build/components/page-patterns/grid.js.map +1 -1
  38. package/build/components/page-patterns/header.js +69 -0
  39. package/build/components/page-patterns/header.js.map +1 -0
  40. package/build/components/page-patterns/index.js +3 -1
  41. package/build/components/page-patterns/index.js.map +1 -1
  42. package/build/components/page-patterns/pagination.js +63 -0
  43. package/build/components/page-patterns/pagination.js.map +1 -0
  44. package/build/components/page-patterns/patterns-list.js +95 -30
  45. package/build/components/page-patterns/patterns-list.js.map +1 -1
  46. package/build/components/page-patterns/rename-menu-item.js +109 -0
  47. package/build/components/page-patterns/rename-menu-item.js.map +1 -0
  48. package/build/components/page-patterns/use-patterns.js +102 -121
  49. package/build/components/page-patterns/use-patterns.js.map +1 -1
  50. package/build/components/page-template-parts/add-new-template-part.js +74 -0
  51. package/build/components/page-template-parts/add-new-template-part.js.map +1 -0
  52. package/build/components/page-template-parts/index.js +2 -23
  53. package/build/components/page-template-parts/index.js.map +1 -1
  54. package/build/components/resizable-frame/index.js +78 -36
  55. package/build/components/resizable-frame/index.js.map +1 -1
  56. package/build/components/save-panel/index.js +5 -5
  57. package/build/components/save-panel/index.js.map +1 -1
  58. package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
  59. package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  60. package/build/components/sidebar-edit-mode/page-panels/page-status.js +3 -8
  61. package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  62. package/build/components/sidebar-navigation-screen/index.js +14 -8
  63. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  64. package/build/components/sidebar-navigation-screen-main/index.js +4 -2
  65. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  66. package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
  67. package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
  68. package/build/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
  69. package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
  70. package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
  71. package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
  72. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
  73. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  74. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +4 -3
  75. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  76. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
  77. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
  78. package/build/components/sidebar-navigation-screen-page/index.js +2 -3
  79. package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-screen-page/status-label.js +1 -34
  81. package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
  82. package/build/components/sidebar-navigation-screen-pages/index.js +33 -25
  83. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  84. package/build/components/sidebar-navigation-screen-pattern/index.js +9 -7
  85. package/build/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
  86. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
  87. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  88. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
  89. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
  90. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +11 -3
  91. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
  92. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +5 -2
  93. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  94. package/build/components/sidebar-navigation-screen-patterns/index.js +72 -51
  95. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  96. package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
  97. package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
  98. package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +11 -1
  99. package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
  100. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
  101. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  102. package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
  103. package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
  104. package/build/components/site-hub/index.js +24 -11
  105. package/build/components/site-hub/index.js.map +1 -1
  106. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +10 -5
  107. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  108. package/build/components/sync-state-with-url/use-sync-path-with-url.js +15 -12
  109. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  110. package/build/components/template-actions/index.js +3 -1
  111. package/build/components/template-actions/index.js.map +1 -1
  112. package/build/components/template-actions/rename-menu-item.js +12 -8
  113. package/build/components/template-actions/rename-menu-item.js.map +1 -1
  114. package/build/components/use-edited-entity-record/index.js +6 -1
  115. package/build/components/use-edited-entity-record/index.js.map +1 -1
  116. package/build/hooks/commands/use-common-commands.js +78 -20
  117. package/build/hooks/commands/use-common-commands.js.map +1 -1
  118. package/build/hooks/push-changes-to-global-styles/index.js +56 -10
  119. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  120. package/build/store/private-actions.js +7 -1
  121. package/build/store/private-actions.js.map +1 -1
  122. package/build/utils/normalize-record-key.js +19 -0
  123. package/build/utils/normalize-record-key.js.map +1 -0
  124. package/build/utils/use-activate-theme.js +1 -1
  125. package/build/utils/use-activate-theme.js.map +1 -1
  126. package/build-module/components/add-new-page/index.js +1 -6
  127. package/build-module/components/add-new-page/index.js.map +1 -1
  128. package/build-module/components/add-new-pattern/index.js +19 -7
  129. package/build-module/components/add-new-pattern/index.js.map +1 -1
  130. package/build-module/components/add-new-template/utils.js +9 -6
  131. package/build-module/components/add-new-template/utils.js.map +1 -1
  132. package/build-module/components/block-editor/constants.js +1 -1
  133. package/build-module/components/block-editor/constants.js.map +1 -1
  134. package/build-module/components/block-editor/editor-canvas.js +1 -1
  135. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  136. package/build-module/components/block-editor/index.js +0 -4
  137. package/build-module/components/block-editor/index.js.map +1 -1
  138. package/build-module/components/block-editor/use-site-editor-settings.js +89 -14
  139. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  140. package/build-module/components/code-editor/index.js +62 -30
  141. package/build-module/components/code-editor/index.js.map +1 -1
  142. package/build-module/components/create-pattern-modal/index.js +6 -3
  143. package/build-module/components/create-pattern-modal/index.js.map +1 -1
  144. package/build-module/components/editor/index.js +1 -1
  145. package/build-module/components/editor/index.js.map +1 -1
  146. package/build-module/components/header-edit-mode/index.js +13 -9
  147. package/build-module/components/header-edit-mode/index.js.map +1 -1
  148. package/build-module/components/layout/index.js +8 -3
  149. package/build-module/components/layout/index.js.map +1 -1
  150. package/build-module/components/page-actions/index.js +2 -2
  151. package/build-module/components/page-actions/index.js.map +1 -1
  152. package/build-module/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -17
  153. package/build-module/components/page-actions/trash-page-menu-item.js.map +1 -0
  154. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
  155. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  156. package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
  157. package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
  158. package/build-module/components/page-patterns/grid-item.js +84 -64
  159. package/build-module/components/page-patterns/grid-item.js.map +1 -1
  160. package/build-module/components/page-patterns/grid.js +5 -17
  161. package/build-module/components/page-patterns/grid.js.map +1 -1
  162. package/build-module/components/page-patterns/header.js +54 -0
  163. package/build-module/components/page-patterns/header.js.map +1 -0
  164. package/build-module/components/page-patterns/index.js +3 -1
  165. package/build-module/components/page-patterns/index.js.map +1 -1
  166. package/build-module/components/page-patterns/pagination.js +54 -0
  167. package/build-module/components/page-patterns/pagination.js.map +1 -0
  168. package/build-module/components/page-patterns/patterns-list.js +96 -33
  169. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  170. package/build-module/components/page-patterns/rename-menu-item.js +97 -0
  171. package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
  172. package/build-module/components/page-patterns/use-patterns.js +103 -122
  173. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  174. package/build-module/components/page-template-parts/add-new-template-part.js +58 -0
  175. package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -0
  176. package/build-module/components/page-template-parts/index.js +3 -22
  177. package/build-module/components/page-template-parts/index.js.map +1 -1
  178. package/build-module/components/resizable-frame/index.js +79 -39
  179. package/build-module/components/resizable-frame/index.js.map +1 -1
  180. package/build-module/components/save-panel/index.js +5 -5
  181. package/build-module/components/save-panel/index.js.map +1 -1
  182. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
  183. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  184. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +3 -8
  185. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  186. package/build-module/components/sidebar-navigation-screen/index.js +15 -9
  187. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  188. package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
  189. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  190. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
  191. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
  192. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
  193. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
  194. package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
  195. package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
  196. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
  197. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  198. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +4 -3
  199. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  200. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
  201. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
  202. package/build-module/components/sidebar-navigation-screen-page/index.js +2 -3
  203. package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
  204. package/build-module/components/sidebar-navigation-screen-page/status-label.js +1 -32
  205. package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
  206. package/build-module/components/sidebar-navigation-screen-pages/index.js +33 -25
  207. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  208. package/build-module/components/sidebar-navigation-screen-pattern/index.js +8 -7
  209. package/build-module/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
  210. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
  211. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  212. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
  213. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
  214. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +11 -3
  215. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
  216. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +4 -2
  217. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  218. package/build-module/components/sidebar-navigation-screen-patterns/index.js +76 -53
  219. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  220. package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
  221. package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
  222. package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -1
  223. package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
  224. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
  225. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  226. package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
  227. package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
  228. package/build-module/components/site-hub/index.js +24 -11
  229. package/build-module/components/site-hub/index.js.map +1 -1
  230. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -5
  231. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  232. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +16 -12
  233. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  234. package/build-module/components/template-actions/index.js +2 -1
  235. package/build-module/components/template-actions/index.js.map +1 -1
  236. package/build-module/components/template-actions/rename-menu-item.js +11 -8
  237. package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
  238. package/build-module/components/use-edited-entity-record/index.js +3 -1
  239. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  240. package/build-module/hooks/commands/use-common-commands.js +74 -20
  241. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  242. package/build-module/hooks/push-changes-to-global-styles/index.js +57 -10
  243. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  244. package/build-module/store/private-actions.js +7 -1
  245. package/build-module/store/private-actions.js.map +1 -1
  246. package/build-module/utils/normalize-record-key.js +12 -0
  247. package/build-module/utils/normalize-record-key.js.map +1 -0
  248. package/build-module/utils/use-activate-theme.js +1 -1
  249. package/build-module/utils/use-activate-theme.js.map +1 -1
  250. package/build-style/style-rtl.css +221 -63
  251. package/build-style/style.css +221 -63
  252. package/package.json +39 -40
  253. package/src/components/add-new-page/index.js +0 -3
  254. package/src/components/add-new-pattern/index.js +23 -12
  255. package/src/components/add-new-template/utils.js +9 -6
  256. package/src/components/block-editor/constants.js +5 -1
  257. package/src/components/block-editor/editor-canvas.js +1 -1
  258. package/src/components/block-editor/index.js +0 -4
  259. package/src/components/block-editor/use-site-editor-settings.js +99 -20
  260. package/src/components/canvas-spinner/style.scss +14 -0
  261. package/src/components/code-editor/index.js +51 -33
  262. package/src/components/create-pattern-modal/index.js +5 -2
  263. package/src/components/editor/index.js +2 -2
  264. package/src/components/header-edit-mode/document-actions/style.scss +4 -0
  265. package/src/components/header-edit-mode/index.js +29 -22
  266. package/src/components/layout/index.js +16 -2
  267. package/src/components/layout/style.scss +2 -1
  268. package/src/components/page-actions/index.js +2 -2
  269. package/src/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +9 -22
  270. package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
  271. package/src/components/page-patterns/duplicate-menu-item.js +196 -0
  272. package/src/components/page-patterns/grid-item.js +189 -133
  273. package/src/components/page-patterns/grid.js +3 -20
  274. package/src/components/page-patterns/header.js +69 -0
  275. package/src/components/page-patterns/index.js +6 -1
  276. package/src/components/page-patterns/pagination.js +80 -0
  277. package/src/components/page-patterns/patterns-list.js +160 -72
  278. package/src/components/page-patterns/rename-menu-item.js +115 -0
  279. package/src/components/page-patterns/style.scss +140 -30
  280. package/src/components/page-patterns/use-patterns.js +102 -172
  281. package/src/components/page-template-parts/add-new-template-part.js +57 -0
  282. package/src/components/page-template-parts/index.js +3 -22
  283. package/src/components/resizable-frame/index.js +102 -34
  284. package/src/components/resizable-frame/style.scss +9 -9
  285. package/src/components/save-panel/index.js +10 -4
  286. package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  287. package/src/components/sidebar-edit-mode/page-panels/page-status.js +2 -5
  288. package/src/components/sidebar-navigation-item/style.scss +5 -12
  289. package/src/components/sidebar-navigation-screen/index.js +14 -7
  290. package/src/components/sidebar-navigation-screen/style.scss +14 -0
  291. package/src/components/sidebar-navigation-screen-main/index.js +44 -40
  292. package/src/components/sidebar-navigation-screen-main/template-part-hint.js +34 -0
  293. package/src/components/sidebar-navigation-screen-navigation-menu/index.js +4 -3
  294. package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
  295. package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +1 -1
  296. package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +15 -5
  297. package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
  298. package/src/components/sidebar-navigation-screen-page/index.js +3 -3
  299. package/src/components/sidebar-navigation-screen-page/status-label.js +1 -35
  300. package/src/components/sidebar-navigation-screen-pages/index.js +39 -29
  301. package/src/components/sidebar-navigation-screen-pattern/index.js +5 -2
  302. package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -1
  303. package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +2 -1
  304. package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +12 -2
  305. package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +5 -2
  306. package/src/components/sidebar-navigation-screen-patterns/index.js +103 -98
  307. package/src/components/sidebar-navigation-screen-patterns/style.scss +20 -0
  308. package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
  309. package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +9 -0
  310. package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
  311. package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -1
  312. package/src/components/site-hub/index.js +45 -28
  313. package/src/components/site-hub/style.scss +13 -0
  314. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +8 -2
  315. package/src/components/sync-state-with-url/use-sync-path-with-url.js +73 -66
  316. package/src/components/template-actions/index.js +2 -1
  317. package/src/components/template-actions/rename-menu-item.js +17 -10
  318. package/src/components/use-edited-entity-record/index.js +6 -1
  319. package/src/hooks/commands/use-common-commands.js +56 -23
  320. package/src/hooks/push-changes-to-global-styles/index.js +63 -9
  321. package/src/store/private-actions.js +5 -1
  322. package/src/style.scss +10 -12
  323. package/src/utils/normalize-record-key.js +11 -0
  324. package/src/utils/use-activate-theme.js +1 -1
  325. package/build/components/code-editor/code-editor-text-area.js +0 -96
  326. package/build/components/code-editor/code-editor-text-area.js.map +0 -1
  327. package/build/components/keyboard-shortcuts/index.js +0 -148
  328. package/build/components/keyboard-shortcuts/index.js.map +0 -1
  329. package/build/components/page-actions/delete-page-menu-item.js.map +0 -1
  330. package/build/components/page-content-focus-manager/constants.js +0 -9
  331. package/build/components/page-content-focus-manager/constants.js.map +0 -1
  332. package/build-module/components/code-editor/code-editor-text-area.js +0 -84
  333. package/build-module/components/code-editor/code-editor-text-area.js.map +0 -1
  334. package/build-module/components/keyboard-shortcuts/index.js +0 -132
  335. package/build-module/components/keyboard-shortcuts/index.js.map +0 -1
  336. package/build-module/components/page-actions/delete-page-menu-item.js.map +0 -1
  337. package/build-module/components/page-content-focus-manager/constants.js +0 -2
  338. package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
  339. package/src/components/code-editor/code-editor-text-area.js +0 -84
  340. package/src/components/keyboard-shortcuts/index.js +0 -137
  341. package/src/components/page-content-focus-manager/constants.js +0 -5
@@ -1,19 +1,14 @@
1
1
  import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import { get, set } from 'lodash';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
6
  import { addFilter } from '@wordpress/hooks';
12
7
  import { createHigherOrderComponent } from '@wordpress/compose';
13
8
  import { InspectorAdvancedControls, store as blockEditorStore, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
14
9
  import { BaseControl, Button } from '@wordpress/components';
15
10
  import { __, sprintf } from '@wordpress/i18n';
16
- import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, getBlockType } from '@wordpress/blocks';
11
+ import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, getBlockType, hasBlockSupport } from '@wordpress/blocks';
17
12
  import { useContext, useMemo, useCallback } from '@wordpress/element';
18
13
  import { useDispatch } from '@wordpress/data';
19
14
  import { store as noticesStore } from '@wordpress/notices';
@@ -85,6 +80,15 @@ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
85
80
  'typography.fontSize': 'fontSize',
86
81
  'typography.fontFamily': 'fontFamily'
87
82
  };
83
+ const SUPPORTED_STYLES = ['border', 'color', 'spacing', 'typography'];
84
+
85
+ const getValueFromObjectPath = (object, path) => {
86
+ let value = object;
87
+ path.forEach(fieldName => {
88
+ value = value?.[fieldName];
89
+ });
90
+ return value;
91
+ };
88
92
 
89
93
  function useChangesToPush(name, attributes) {
90
94
  const supports = useSupportedStyles(name);
@@ -98,13 +102,55 @@ function useChangesToPush(name, attributes) {
98
102
  } = STYLE_PROPERTY[key];
99
103
  const presetAttributeKey = path.join('.');
100
104
  const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
101
- const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : get(attributes.style, path);
105
+ const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : getValueFromObjectPath(attributes.style, path);
102
106
  return value ? [{
103
107
  path,
104
108
  value
105
109
  }] : [];
106
110
  }), [supports, name, attributes]);
107
111
  }
112
+ /**
113
+ * Sets the value at path of object.
114
+ * If a portion of path doesn’t exist, it’s created.
115
+ * Arrays are created for missing index properties while objects are created
116
+ * for all other missing properties.
117
+ *
118
+ * This function intentionally mutates the input object.
119
+ *
120
+ * Inspired by _.set().
121
+ *
122
+ * @see https://lodash.com/docs/4.17.15#set
123
+ *
124
+ * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
125
+ *
126
+ * @param {Object} object Object to modify
127
+ * @param {Array} path Path of the property to set.
128
+ * @param {*} value Value to set.
129
+ */
130
+
131
+
132
+ function setNestedValue(object, path, value) {
133
+ if (!object || typeof object !== 'object') {
134
+ return object;
135
+ }
136
+
137
+ path.reduce((acc, key, idx) => {
138
+ if (acc[key] === undefined) {
139
+ if (Number.isInteger(path[idx + 1])) {
140
+ acc[key] = [];
141
+ } else {
142
+ acc[key] = {};
143
+ }
144
+ }
145
+
146
+ if (idx === path.length - 1) {
147
+ acc[key] = value;
148
+ }
149
+
150
+ return acc[key];
151
+ }, object);
152
+ return object;
153
+ }
108
154
 
109
155
  function cloneDeep(object) {
110
156
  return !object ? {} : JSON.parse(JSON.stringify(object));
@@ -141,8 +187,8 @@ function PushChangesToGlobalStylesControl({
141
187
  path,
142
188
  value
143
189
  } of changes) {
144
- set(newBlockStyles, path, undefined);
145
- set(newUserConfig, ['styles', 'blocks', name, ...path], value);
190
+ setNestedValue(newBlockStyles, path, undefined);
191
+ setNestedValue(newUserConfig, ['styles', 'blocks', name, ...path], value);
146
192
  } // @wordpress/core-data doesn't support editing multiple entity types in
147
193
  // a single undo level. So for now, we disable @wordpress/core-data undo
148
194
  // tracking and implement our own Undo button in the snackbar
@@ -190,8 +236,9 @@ function PushChangesToGlobalStylesControl({
190
236
 
191
237
  const withPushChangesToGlobalStyles = createHigherOrderComponent(BlockEdit => props => {
192
238
  const blockEditingMode = useBlockEditingMode();
239
+ const supportsStyles = SUPPORTED_STYLES.some(feature => hasBlockSupport(props.name, feature));
193
240
  return createElement(Fragment, null, createElement(BlockEdit, { ...props
194
- }), blockEditingMode === 'default' && createElement(InspectorAdvancedControls, null, createElement(PushChangesToGlobalStylesControl, { ...props
241
+ }), blockEditingMode === 'default' && supportsStyles && createElement(InspectorAdvancedControls, null, createElement(PushChangesToGlobalStylesControl, { ...props
195
242
  })));
196
243
  });
197
244
  addFilter('editor.BlockEdit', 'core/edit-site/push-changes-to-global-styles', withPushChangesToGlobalStyles);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["get","set","addFilter","createHigherOrderComponent","InspectorAdvancedControls","store","blockEditorStore","privateApis","blockEditorPrivateApis","BaseControl","Button","__","sprintf","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","getBlockType","useContext","useMemo","useCallback","useDispatch","noticesStore","useSupportedStyles","unlock","GlobalStylesContext","useBlockEditingMode","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","useChangesToPush","name","attributes","supports","flatMap","key","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","createSuccessNotice","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SACCC,yBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAAW,IAAIC,sBAHhB,QAIO,yBAJP;AAKA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,uBAApC;AACA,SAASC,EAAT,EAAaC,OAAb,Q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AAmBC,KAAF,IAAa;AAC7B,QAAMC,gBAAgB,GAAG3C,mBAAmB,EAA5C;AACA,SACC,8BACC,cAAC,SAAD,OAAgB0C;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IACD,cAAC,yBAAD,QACC,cAAC,gCAAD,OAAuCD;AAAvC,IADD,CAHF,CADD;AAUA,CAb8D,CAAhE;AAgBAhE,SAAS,CACR,kBADQ,EAER,8CAFQ,EAGR8D,6BAHQ,CAAT","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 { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext, useBlockEditingMode } = unlock(\n\tblockEditorPrivateApis\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_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.caption.color.text': 'color',\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 useChangesToPush( name, attributes ) {\n\tconst supports = useSupportedStyles( name );\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupports.flatMap( ( key ) => {\n\t\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\t\tconst presetAttributeValue =\n\t\t\t\t\tattributes[\n\t\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[\n\t\t\t\t\t\t\tpresetAttributeKey\n\t\t\t\t\t\t]\n\t\t\t\t\t];\n\t\t\t\tconst value = presetAttributeValue\n\t\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t\t: get( attributes.style, path );\n\t\t\t\treturn value ? [ { path, value } ] : [];\n\t\t\t} ),\n\t\t[ supports, name, attributes ]\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 = useChangesToPush( name, attributes );\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\tconst blockEditingMode = useBlockEditingMode();\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t\t</InspectorAdvancedControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\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":["addFilter","createHigherOrderComponent","InspectorAdvancedControls","store","blockEditorStore","privateApis","blockEditorPrivateApis","BaseControl","Button","__","sprintf","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","getBlockType","hasBlockSupport","useContext","useMemo","useCallback","useDispatch","noticesStore","useSupportedStyles","unlock","GlobalStylesContext","useBlockEditingMode","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","SUPPORTED_STYLES","getValueFromObjectPath","object","path","value","forEach","fieldName","useChangesToPush","name","attributes","supports","flatMap","key","presetAttributeKey","join","presetAttributeValue","style","setNestedValue","reduce","acc","idx","undefined","Number","isInteger","length","cloneDeep","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","createSuccessNotice","pushChanges","blockStyles","newBlockStyles","newUserConfig","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode","supportsStyles","some","feature"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,kBAA1B;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SACCC,yBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAAW,IAAIC,sBAHhB,QAIO,yBAJP;AAKA,SAASC,WAAT,EAAsBC,MAAtB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7DyE,SAAF,IAAmBC,KAAF,IAAa;AAC7B,QAAMC,gBAAgB,GAAGrD,mBAAmB,EAA5C;AACA,QAAMsD,cAAc,GAAGnD,gBAAgB,CAACoD,IAAjB,CAAyBC,OAAF,IAC7CjE,eAAe,CAAE6D,KAAK,CAACzC,IAAR,EAAc6C,OAAd,CADO,CAAvB;AAIA,SACC,8BACC,cAAC,SAAD,OAAgBJ;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IAAkCC,cAAlC,IACD,cAAC,yBAAD,QACC,cAAC,gCAAD,OAAuCF;AAAvC,IADD,CAHF,CADD;AAUA,CAjB8D,CAAhE;AAoBA3E,SAAS,CACR,kBADQ,EAER,8CAFQ,EAGRyE,6BAHQ,CAAT","sourcesContent":["/**\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\thasBlockSupport,\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 { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext, useBlockEditingMode } = unlock(\n\tblockEditorPrivateApis\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_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.caption.color.text': 'color',\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\nconst SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\nfunction useChangesToPush( name, attributes ) {\n\tconst supports = useSupportedStyles( name );\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupports.flatMap( ( key ) => {\n\t\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\t\tconst presetAttributeValue =\n\t\t\t\t\tattributes[\n\t\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[\n\t\t\t\t\t\t\tpresetAttributeKey\n\t\t\t\t\t\t]\n\t\t\t\t\t];\n\t\t\t\tconst value = presetAttributeValue\n\t\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t\t: getValueFromObjectPath( attributes.style, path );\n\t\t\t\treturn value ? [ { path, value } ] : [];\n\t\t\t} ),\n\t\t[ supports, name, attributes ]\n\t);\n}\n\n/**\n * Sets the value at path of object.\n * If a portion of path doesn’t exist, it’s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.\n *\n * @param {Object} object Object to modify\n * @param {Array} path Path of the property to set.\n * @param {*} value Value to set.\n */\nfunction setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tpath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === path.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\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 = useChangesToPush( name, attributes );\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\tsetNestedValue( newBlockStyles, path, undefined );\n\t\t\tsetNestedValue(\n\t\t\t\tnewUserConfig,\n\t\t\t\t[ 'styles', 'blocks', name, ...path ],\n\t\t\t\tvalue\n\t\t\t);\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\tconst blockEditingMode = useBlockEditingMode();\n\t\tconst supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>\n\t\t\thasBlockSupport( props.name, feature )\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ blockEditingMode === 'default' && supportsStyles && (\n\t\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t\t</InspectorAdvancedControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
@@ -11,7 +11,8 @@ import { store as preferencesStore } from '@wordpress/preferences';
11
11
 
12
12
  export const setCanvasMode = mode => ({
13
13
  registry,
14
- dispatch
14
+ dispatch,
15
+ select
15
16
  }) => {
16
17
  registry.dispatch(blockEditorStore).__unstableSetEditorMode('edit');
17
18
 
@@ -22,6 +23,11 @@ export const setCanvasMode = mode => ({
22
23
 
23
24
  if (mode === 'edit' && registry.select(preferencesStore).get('core/edit-site', 'showListViewByDefault')) {
24
25
  dispatch.setIsListViewOpened(true);
26
+ } // Switch focus away from editing the template when switching to view mode.
27
+
28
+
29
+ if (mode === 'view' && select.isPage()) {
30
+ dispatch.setHasPageContentFocus(true);
25
31
  }
26
32
  };
27
33
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/private-actions.js"],"names":["store","blockEditorStore","preferencesStore","setCanvasMode","mode","registry","dispatch","__unstableSetEditorMode","type","select","get","setIsListViewOpened","setEditorCanvasContainerView","view"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GACvBC,IAAF,IACA,CAAE;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAAF,KAA8B;AAC7BD,EAAAA,QAAQ,CAACC,QAAT,CAAmBL,gBAAnB,EAAsCM,uBAAtC,CAA+D,MAA/D;;AACAD,EAAAA,QAAQ,CAAE;AACTE,IAAAA,IAAI,EAAE,iBADG;AAETJ,IAAAA;AAFS,GAAF,CAAR,CAF6B,CAM7B;;AACA,MACCA,IAAI,KAAK,MAAT,IACAC,QAAQ,CACNI,MADF,CACUP,gBADV,EAEEQ,GAFF,CAEO,gBAFP,EAEyB,uBAFzB,CAFD,EAKE;AACDJ,IAAAA,QAAQ,CAACK,mBAAT,CAA8B,IAA9B;AACA;AACD,CAjBK;AAmBP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAA4B,GACtCC,IAAF,IACA,CAAE;AAAEP,EAAAA;AAAF,CAAF,KAAoB;AACnBA,EAAAA,QAAQ,CAAE;AACTE,IAAAA,IAAI,EAAE,kCADG;AAETK,IAAAA;AAFS,GAAF,CAAR;AAIA,CAPK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Action that switches the canvas mode.\n *\n * @param {?string} mode Canvas mode.\n */\nexport const setCanvasMode =\n\t( mode ) =>\n\t( { registry, dispatch } ) => {\n\t\tregistry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );\n\t\tdispatch( {\n\t\t\ttype: 'SET_CANVAS_MODE',\n\t\t\tmode,\n\t\t} );\n\t\t// Check if the block list view should be open by default.\n\t\tif (\n\t\t\tmode === 'edit' &&\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core/edit-site', 'showListViewByDefault' )\n\t\t) {\n\t\t\tdispatch.setIsListViewOpened( true );\n\t\t}\n\t};\n\n/**\n * Action that switches the editor canvas container view.\n *\n * @param {?string} view Editor canvas container view.\n */\nexport const setEditorCanvasContainerView =\n\t( view ) =>\n\t( { dispatch } ) => {\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITOR_CANVAS_CONTAINER_VIEW',\n\t\t\tview,\n\t\t} );\n\t};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/private-actions.js"],"names":["store","blockEditorStore","preferencesStore","setCanvasMode","mode","registry","dispatch","select","__unstableSetEditorMode","type","get","setIsListViewOpened","isPage","setHasPageContentFocus","setEditorCanvasContainerView","view"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GACvBC,IAAF,IACA,CAAE;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAF,KAAsC;AACrCF,EAAAA,QAAQ,CAACC,QAAT,CAAmBL,gBAAnB,EAAsCO,uBAAtC,CAA+D,MAA/D;;AACAF,EAAAA,QAAQ,CAAE;AACTG,IAAAA,IAAI,EAAE,iBADG;AAETL,IAAAA;AAFS,GAAF,CAAR,CAFqC,CAMrC;;AACA,MACCA,IAAI,KAAK,MAAT,IACAC,QAAQ,CACNE,MADF,CACUL,gBADV,EAEEQ,GAFF,CAEO,gBAFP,EAEyB,uBAFzB,CAFD,EAKE;AACDJ,IAAAA,QAAQ,CAACK,mBAAT,CAA8B,IAA9B;AACA,GAdoC,CAerC;;;AACA,MAAKP,IAAI,KAAK,MAAT,IAAmBG,MAAM,CAACK,MAAP,EAAxB,EAA0C;AACzCN,IAAAA,QAAQ,CAACO,sBAAT,CAAiC,IAAjC;AACA;AACD,CArBK;AAuBP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAA4B,GACtCC,IAAF,IACA,CAAE;AAAET,EAAAA;AAAF,CAAF,KAAoB;AACnBA,EAAAA,QAAQ,CAAE;AACTG,IAAAA,IAAI,EAAE,kCADG;AAETM,IAAAA;AAFS,GAAF,CAAR;AAIA,CAPK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Action that switches the canvas mode.\n *\n * @param {?string} mode Canvas mode.\n */\nexport const setCanvasMode =\n\t( mode ) =>\n\t( { registry, dispatch, select } ) => {\n\t\tregistry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );\n\t\tdispatch( {\n\t\t\ttype: 'SET_CANVAS_MODE',\n\t\t\tmode,\n\t\t} );\n\t\t// Check if the block list view should be open by default.\n\t\tif (\n\t\t\tmode === 'edit' &&\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core/edit-site', 'showListViewByDefault' )\n\t\t) {\n\t\t\tdispatch.setIsListViewOpened( true );\n\t\t}\n\t\t// Switch focus away from editing the template when switching to view mode.\n\t\tif ( mode === 'view' && select.isPage() ) {\n\t\t\tdispatch.setHasPageContentFocus( true );\n\t\t}\n\t};\n\n/**\n * Action that switches the editor canvas container view.\n *\n * @param {?string} view Editor canvas container view.\n */\nexport const setEditorCanvasContainerView =\n\t( view ) =>\n\t( { dispatch } ) => {\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITOR_CANVAS_CONTAINER_VIEW',\n\t\t\tview,\n\t\t} );\n\t};\n"]}
@@ -0,0 +1,12 @@
1
+ function isNumericID(str) {
2
+ return /^\s*\d+\s*$/.test(str);
3
+ }
4
+
5
+ export default function normalizeRecordKey(postId) {
6
+ if (isNumericID(postId)) {
7
+ postId = Number(postId);
8
+ }
9
+
10
+ return postId;
11
+ }
12
+ //# sourceMappingURL=normalize-record-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/utils/normalize-record-key.js"],"names":["isNumericID","str","test","normalizeRecordKey","postId","Number"],"mappings":"AAAA,SAASA,WAAT,CAAsBC,GAAtB,EAA4B;AAC3B,SAAO,cAAcC,IAAd,CAAoBD,GAApB,CAAP;AACA;;AAED,eAAe,SAASE,kBAAT,CAA6BC,MAA7B,EAAsC;AACpD,MAAKJ,WAAW,CAAEI,MAAF,CAAhB,EAA6B;AAC5BA,IAAAA,MAAM,GAAGC,MAAM,CAAED,MAAF,CAAf;AACA;;AAED,SAAOA,MAAP;AACA","sourcesContent":["function isNumericID( str ) {\n\treturn /^\\s*\\d+\\s*$/.test( str );\n}\n\nexport default function normalizeRecordKey( postId ) {\n\tif ( isNumericID( postId ) ) {\n\t\tpostId = Number( postId );\n\t}\n\n\treturn postId;\n}\n"]}
@@ -23,7 +23,7 @@ export function useActivateTheme() {
23
23
  const location = useLocation();
24
24
  return async () => {
25
25
  if (isPreviewingTheme()) {
26
- const activationURL = 'themes.php?action=activate&stylesheet=' + currentlyPreviewingTheme() + '&_wpnonce=' + window.BLOCK_THEME_ACTIVATE_NONCE;
26
+ const activationURL = 'themes.php?action=activate&stylesheet=' + currentlyPreviewingTheme() + '&_wpnonce=' + window.WP_BLOCK_THEME_ACTIVATE_NONCE;
27
27
  await window.fetch(activationURL);
28
28
  const {
29
29
  wp_theme_preview: themePreview,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/utils/use-activate-theme.js"],"names":["privateApis","routerPrivateApis","unlock","isPreviewingTheme","currentlyPreviewingTheme","useHistory","useLocation","useActivateTheme","history","location","activationURL","window","BLOCK_THEME_ACTIVATE_NONCE","fetch","wp_theme_preview","themePreview","params","replace"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,gBAAvB;AACA,SACCC,iBADD,EAECC,wBAFD,QAGO,uBAHP;AAKA,MAAM;AAAEC,EAAAA,UAAF;AAAcC,EAAAA;AAAd,IAA8BJ,MAAM,CAAED,iBAAF,CAA1C;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,gBAAT,GAA4B;AAClC,QAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,QAAMI,QAAQ,GAAGH,WAAW,EAA5B;AAEA,SAAO,YAAY;AAClB,QAAKH,iBAAiB,EAAtB,EAA2B;AAC1B,YAAMO,aAAa,GAClB,2CACAN,wBAAwB,EADxB,GAEA,YAFA,GAGAO,MAAM,CAACC,0BAJR;AAKA,YAAMD,MAAM,CAACE,KAAP,CAAcH,aAAd,CAAN;AACA,YAAM;AAAEI,QAAAA,gBAAgB,EAAEC,YAApB;AAAkC,WAAGC;AAArC,UACLP,QAAQ,CAACO,MADV;AAEAR,MAAAA,OAAO,CAACS,OAAR,CAAiBD,MAAjB;AACA;AACD,GAZD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from './is-previewing-theme';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\n/**\n * This should be refactored to use the REST API, once the REST API can activate themes.\n *\n * @return {Function} A function that activates the theme.\n */\nexport function useActivateTheme() {\n\tconst history = useHistory();\n\tconst location = useLocation();\n\n\treturn async () => {\n\t\tif ( isPreviewingTheme() ) {\n\t\t\tconst activationURL =\n\t\t\t\t'themes.php?action=activate&stylesheet=' +\n\t\t\t\tcurrentlyPreviewingTheme() +\n\t\t\t\t'&_wpnonce=' +\n\t\t\t\twindow.BLOCK_THEME_ACTIVATE_NONCE;\n\t\t\tawait window.fetch( activationURL );\n\t\t\tconst { wp_theme_preview: themePreview, ...params } =\n\t\t\t\tlocation.params;\n\t\t\thistory.replace( params );\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/utils/use-activate-theme.js"],"names":["privateApis","routerPrivateApis","unlock","isPreviewingTheme","currentlyPreviewingTheme","useHistory","useLocation","useActivateTheme","history","location","activationURL","window","WP_BLOCK_THEME_ACTIVATE_NONCE","fetch","wp_theme_preview","themePreview","params","replace"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,gBAAvB;AACA,SACCC,iBADD,EAECC,wBAFD,QAGO,uBAHP;AAKA,MAAM;AAAEC,EAAAA,UAAF;AAAcC,EAAAA;AAAd,IAA8BJ,MAAM,CAAED,iBAAF,CAA1C;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,gBAAT,GAA4B;AAClC,QAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,QAAMI,QAAQ,GAAGH,WAAW,EAA5B;AAEA,SAAO,YAAY;AAClB,QAAKH,iBAAiB,EAAtB,EAA2B;AAC1B,YAAMO,aAAa,GAClB,2CACAN,wBAAwB,EADxB,GAEA,YAFA,GAGAO,MAAM,CAACC,6BAJR;AAKA,YAAMD,MAAM,CAACE,KAAP,CAAcH,aAAd,CAAN;AACA,YAAM;AAAEI,QAAAA,gBAAgB,EAAEC,YAApB;AAAkC,WAAGC;AAArC,UACLP,QAAQ,CAACO,MADV;AAEAR,MAAAA,OAAO,CAACS,OAAR,CAAiBD,MAAjB;AACA;AACD,GAZD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from './is-previewing-theme';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\n/**\n * This should be refactored to use the REST API, once the REST API can activate themes.\n *\n * @return {Function} A function that activates the theme.\n */\nexport function useActivateTheme() {\n\tconst history = useHistory();\n\tconst location = useLocation();\n\n\treturn async () => {\n\t\tif ( isPreviewingTheme() ) {\n\t\t\tconst activationURL =\n\t\t\t\t'themes.php?action=activate&stylesheet=' +\n\t\t\t\tcurrentlyPreviewingTheme() +\n\t\t\t\t'&_wpnonce=' +\n\t\t\t\twindow.WP_BLOCK_THEME_ACTIVATE_NONCE;\n\t\t\tawait window.fetch( activationURL );\n\t\t\tconst { wp_theme_preview: themePreview, ...params } =\n\t\t\t\tlocation.params;\n\t\t\thistory.replace( params );\n\t\t}\n\t};\n}\n"]}