@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 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useEffect","useSelect","useDispatch","store","coreDataStore","privateApis","routerPrivateApis","editSiteStore","unlock","useLocation","useInitEditedEntityFromURL","params","postId","postType","isRequestingSite","homepageId","url","select","getSite","getUnstableBase","siteData","base","show_on_front","page_on_front","home","setEditedEntity","setTemplate","setTemplatePart","setPage","setNavigationMenu","context","path"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,aAAvC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAkBD,MAAM,CAAEF,iBAAF,CAA9B;AAEA,eAAe,SAASI,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,QAAuB;AAAjC,MAAwCJ,WAAW,EAAzD;AACA,QAAM;AAAEK,IAAAA,gBAAF;AAAoBC,IAAAA,UAApB;AAAgCC,IAAAA;AAAhC,MAAwCf,SAAS,CAAIgB,MAAF,IAAc;AACtE,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,QAA+BF,MAAM,CAAEb,aAAF,CAA3C;AACA,UAAMgB,QAAQ,GAAGF,OAAO,EAAxB;AACA,UAAMG,IAAI,GAAGF,eAAe,EAA5B;AAEA,WAAO;AACNL,MAAAA,gBAAgB,EAAE,CAAEO,IADd;AAENN,MAAAA,UAAU,EACTK,QAAQ,EAAEE,aAAV,KAA4B,MAA5B,GACGF,QAAQ,CAACG,aADZ,GAEG,IALE;AAMNP,MAAAA,GAAG,EAAEK,IAAI,EAAEG;AANL,KAAP;AAQA,GAbsD,EAapD,EAboD,CAAvD;AAeA,QAAM;AACLC,IAAAA,eADK;AAELC,IAAAA,WAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,OAJK;AAKLC,IAAAA;AALK,MAMF3B,WAAW,CAAEK,aAAF,CANf;AAQAP,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKa,QAAQ,IAAID,MAAjB,EAA0B;AACzB,cAASC,QAAT;AACC,aAAK,aAAL;AACCa,UAAAA,WAAW,CAAEd,MAAF,CAAX;AACA;;AACD,aAAK,kBAAL;AACCe,UAAAA,eAAe,CAAEf,MAAF,CAAf;AACA;;AACD,aAAK,eAAL;AACCiB,UAAAA,iBAAiB,CAAEjB,MAAF,CAAjB;AACA;;AACD,aAAK,UAAL;AACCa,UAAAA,eAAe,CAAEZ,QAAF,EAAYD,MAAZ,CAAf;AACA;;AACD;AACCgB,UAAAA,OAAO,CAAE;AACRE,YAAAA,OAAO,EAAE;AAAEjB,cAAAA,QAAF;AAAYD,cAAAA;AAAZ;AADD,WAAF,CAAP;AAdF;;AAmBA;AACA,KAtBe,CAwBhB;;;AACA,QAAKG,UAAL,EAAkB;AACjBa,MAAAA,OAAO,CAAE;AACRE,QAAAA,OAAO,EAAE;AAAEjB,UAAAA,QAAQ,EAAE,MAAZ;AAAoBD,UAAAA,MAAM,EAAEG;AAA5B;AADD,OAAF,CAAP;AAGA,KAJD,MAIO,IAAK,CAAED,gBAAP,EAA0B;AAChCc,MAAAA,OAAO,CAAE;AACRG,QAAAA,IAAI,EAAEf;AADE,OAAF,CAAP;AAGA;AACD,GAlCQ,EAkCN,CACFA,GADE,EAEFJ,MAFE,EAGFC,QAHE,EAIFE,UAJE,EAKFD,gBALE,EAMFW,eANE,EAOFG,OAPE,EAQFF,WARE,EASFC,eATE,EAUFE,iBAVE,CAlCM,CAAT;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params: { postId, postType } = {} } = useLocation();\n\tconst { isRequestingSite, homepageId, url } = useSelect( ( select ) => {\n\t\tconst { getSite, getUnstableBase } = select( coreDataStore );\n\t\tconst siteData = getSite();\n\t\tconst base = getUnstableBase();\n\n\t\treturn {\n\t\t\tisRequestingSite: ! base,\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\turl: base?.home,\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tsetEditedEntity,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetPage,\n\t\tsetNavigationMenu,\n\t} = useDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif ( postType && postId ) {\n\t\t\tswitch ( postType ) {\n\t\t\t\tcase 'wp_template':\n\t\t\t\t\tsetTemplate( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_template_part':\n\t\t\t\t\tsetTemplatePart( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_navigation':\n\t\t\t\t\tsetNavigationMenu( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_block':\n\t\t\t\t\tsetEditedEntity( postType, postId );\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tcontext: { postType, postId },\n\t\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// In all other cases, we need to set the home page in the site editor view.\n\t\tif ( homepageId ) {\n\t\t\tsetPage( {\n\t\t\t\tcontext: { postType: 'page', postId: homepageId },\n\t\t\t} );\n\t\t} else if ( ! isRequestingSite ) {\n\t\t\tsetPage( {\n\t\t\t\tpath: url,\n\t\t\t} );\n\t\t}\n\t}, [\n\t\turl,\n\t\tpostId,\n\t\tpostType,\n\t\thomepageId,\n\t\tisRequestingSite,\n\t\tsetEditedEntity,\n\t\tsetPage,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetNavigationMenu,\n\t] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useEffect","useSelect","useDispatch","store","coreDataStore","privateApis","routerPrivateApis","editSiteStore","unlock","normalizeRecordKey","useLocation","useInitEditedEntityFromURL","params","postType","postId","isRequestingSite","homepageId","url","select","getSite","getUnstableBase","siteData","base","show_on_front","page_on_front","home","setEditedEntity","setTemplate","setTemplatePart","setPage","setNavigationMenu","context","Number","path"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,aAAvC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,OAAOC,kBAAP,MAA+B,kCAA/B;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAkBF,MAAM,CAAEF,iBAAF,CAA9B;AAEA,eAAe,SAASK,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA;AAAF,MAAaF,WAAW,EAA9B;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAeD,MAArB;AAEA,QAAME,MAAM,GAAGL,kBAAkB,CAAEG,MAAM,EAAEE,MAAV,CAAjC;AAEA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA,UAApB;AAAgCC,IAAAA;AAAhC,MAAwChB,SAAS,CAAIiB,MAAF,IAAc;AACtE,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,QAA+BF,MAAM,CAAEd,aAAF,CAA3C;AACA,UA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,EAAEhB;AADE,OAAF,CAAP;AAGA;AACD,GAlCQ,EAkCN,CACFA,GADE,EAEFH,MAFE,EAGFD,QAHE,EAIFG,UAJE,EAKFD,gBALE,EAMFW,eANE,EAOFG,OAPE,EAQFF,WARE,EASFC,eATE,EAUFE,iBAVE,CAlCM,CAAT;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport normalizeRecordKey from '../../utils/normalize-record-key';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params } = useLocation();\n\n\tconst { postType } = params;\n\n\tconst postId = normalizeRecordKey( params?.postId );\n\n\tconst { isRequestingSite, homepageId, url } = useSelect( ( select ) => {\n\t\tconst { getSite, getUnstableBase } = select( coreDataStore );\n\t\tconst siteData = getSite();\n\t\tconst base = getUnstableBase();\n\n\t\treturn {\n\t\t\tisRequestingSite: ! base,\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\turl: base?.home,\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tsetEditedEntity,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetPage,\n\t\tsetNavigationMenu,\n\t} = useDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif ( postType && postId ) {\n\t\t\tswitch ( postType ) {\n\t\t\t\tcase 'wp_template':\n\t\t\t\t\tsetTemplate( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_template_part':\n\t\t\t\t\tsetTemplatePart( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_navigation':\n\t\t\t\t\tsetNavigationMenu( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_block':\n\t\t\t\t\tsetEditedEntity( postType, postId );\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tcontext: { postType, postId },\n\t\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// In all other cases, we need to set the home page in the site editor view.\n\t\tif ( homepageId ) {\n\t\t\tsetPage( {\n\t\t\t\tcontext: { postType: 'page', postId: Number( homepageId ) },\n\t\t\t} );\n\t\t} else if ( ! isRequestingSite ) {\n\t\t\tsetPage( {\n\t\t\t\tpath: url,\n\t\t\t} );\n\t\t}\n\t}, [\n\t\turl,\n\t\tpostId,\n\t\tpostType,\n\t\thomepageId,\n\t\tisRequestingSite,\n\t\tsetEditedEntity,\n\t\tsetPage,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetNavigationMenu,\n\t] );\n}\n"]}
@@ -34,6 +34,13 @@ export function getPathFromURL(urlParams) {
34
34
 
35
35
  return path;
36
36
  }
37
+
38
+ function isSubset(subset, superset) {
39
+ return Object.entries(subset).every(([key, value]) => {
40
+ return superset[key] === value;
41
+ });
42
+ }
43
+
37
44
  export default function useSyncPathWithURL() {
38
45
  const history = useHistory();
39
46
  const {
@@ -44,8 +51,6 @@ export default function useSyncPathWithURL() {
44
51
  params: navigatorParams,
45
52
  goTo
46
53
  } = useNavigator();
47
- const currentUrlParams = useRef(urlParams);
48
- const currentPath = useRef(navigatorLocation.path);
49
54
  const isMounting = useRef(true);
50
55
  useEffect(() => {
51
56
  // The navigatorParams are only initially filled properly when the
@@ -56,16 +61,13 @@ export default function useSyncPathWithURL() {
56
61
  }
57
62
 
58
63
  function updateUrlParams(newUrlParams) {
59
- if (Object.entries(newUrlParams).every(([key, value]) => {
60
- return currentUrlParams.current[key] === value;
61
- })) {
64
+ if (isSubset(newUrlParams, urlParams)) {
62
65
  return;
63
66
  }
64
67
 
65
- const updatedParams = { ...currentUrlParams.current,
68
+ const updatedParams = { ...urlParams,
66
69
  ...newUrlParams
67
70
  };
68
- currentUrlParams.current = updatedParams;
69
71
  history.push(updatedParams);
70
72
  }
71
73
 
@@ -97,15 +99,17 @@ export default function useSyncPathWithURL() {
97
99
  path: navigatorLocation.path === '/' ? undefined : navigatorLocation.path
98
100
  });
99
101
  }
100
- }, [navigatorLocation?.path, navigatorParams, history]);
102
+ }, // Trigger only when navigator changes to prevent infinite loops.
103
+ // eslint-disable-next-line react-hooks/exhaustive-deps
104
+ [navigatorLocation?.path, navigatorParams]);
101
105
  useEffect(() => {
102
- currentUrlParams.current = urlParams;
103
106
  const path = getPathFromURL(urlParams);
104
107
 
105
- if (currentPath.current !== path) {
106
- currentPath.current = path;
108
+ if (navigatorLocation.path !== path) {
107
109
  goTo(path);
108
110
  }
109
- }, [urlParams, goTo]);
111
+ }, // Trigger only when URL changes to prevent infinite loops.
112
+ // eslint-disable-next-line react-hooks/exhaustive-deps
113
+ [urlParams]);
110
114
  }
111
115
  //# sourceMappingURL=use-sync-path-with-url.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["__experimentalUseNavigator","useNavigator","useEffect","useRef","privateApis","routerPrivateApis","unlock","useLocation","useHistory","getPathFromURL","urlParams","path","postType","postId","encodeURIComponent","useSyncPathWithURL","history","params","location","navigatorLocation","navigatorParams","goTo","currentUrlParams","currentPath","isMounting","current","updateUrlParams","newUrlParams","Object","entries","every","key","value","updatedParams","push","undefined","startsWith","canvas","categoryType","categoryId"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAA0B,IAAIC,YAAvC,QAA2D,uBAA3D;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;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JR,OAAF,CAAf;AAMA,KAPM,MAOA;AACNe,MAAAA,eAAe,CAAE;AAChBd,QAAAA,QAAQ,EAAEuB,SADM;AAEhBtB,QAAAA,MAAM,EAAEsB,SAFQ;AAGhBG,QAAAA,YAAY,EAAEH,SAHE;AAIhBI,QAAAA,UAAU,EAAEJ,SAJI;AAKhBxB,QAAAA,IAAI,EACHQ,iBAAiB,CAACR,IAAlB,KAA2B,GAA3B,GACGwB,SADH,GAEGhB,iBAAiB,CAACR;AARN,OAAF,CAAf;AAUA;AACD,GA1DQ,EA0DN,CAAEQ,iBAAiB,EAAER,IAArB,EAA2BS,eAA3B,EAA4CJ,OAA5C,CA1DM,CAAT;AA4DAd,EAAAA,SAAS,CAAE,MAAM;AAChBoB,IAAAA,gBAAgB,CAACG,OAAjB,GAA2Bf,SAA3B;AACA,UAAMC,IAAI,GAAGF,cAAc,CAAEC,SAAF,CAA3B;;AACA,QAAKa,WAAW,CAACE,OAAZ,KAAwBd,IAA7B,EAAoC;AACnCY,MAAAA,WAAW,CAACE,OAAZ,GAAsBd,IAAtB;AACAU,MAAAA,IAAI,CAAEV,IAAF,CAAJ;AACA;AACD,GAPQ,EAON,CAAED,SAAF,EAAaW,IAAb,CAPM,CAAT;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport function getPathFromURL( urlParams ) {\n\tlet path = urlParams?.path ?? '/';\n\n\t// Compute the navigator path based on the URL params.\n\tif ( urlParams?.postType && urlParams?.postId ) {\n\t\tswitch ( urlParams.postType ) {\n\t\t\tcase 'wp_block':\n\t\t\tcase 'wp_template':\n\t\t\tcase 'wp_template_part':\n\t\t\tcase 'page':\n\t\t\t\tpath = `/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tpath = `/navigation/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t}\n\t}\n\n\treturn path;\n}\n\nexport default function useSyncPathWithURL() {\n\tconst history = useHistory();\n\tconst { params: urlParams } = useLocation();\n\tconst {\n\t\tlocation: navigatorLocation,\n\t\tparams: navigatorParams,\n\t\tgoTo,\n\t} = useNavigator();\n\tconst currentUrlParams = useRef( urlParams );\n\tconst currentPath = useRef( navigatorLocation.path );\n\tconst isMounting = useRef( true );\n\n\tuseEffect( () => {\n\t\t// The navigatorParams are only initially filled properly when the\n\t\t// navigator screens mount. so we ignore the first synchronisation.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\tfunction updateUrlParams( newUrlParams ) {\n\t\t\tif (\n\t\t\t\tObject.entries( newUrlParams ).every( ( [ key, value ] ) => {\n\t\t\t\t\treturn currentUrlParams.current[ key ] === value;\n\t\t\t\t} )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst updatedParams = {\n\t\t\t\t...currentUrlParams.current,\n\t\t\t\t...newUrlParams,\n\t\t\t};\n\t\t\tcurrentUrlParams.current = updatedParams;\n\t\t\thistory.push( updatedParams );\n\t\t}\n\n\t\tif ( navigatorParams?.postType && navigatorParams?.postId ) {\n\t\t\tupdateUrlParams( {\n\t\t\t\tpostType: navigatorParams?.postType,\n\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\tpath: undefined,\n\t\t\t} );\n\t\t} else if (\n\t\t\tnavigatorLocation.path.startsWith( '/page/' ) &&\n\t\t\tnavigatorParams?.postId\n\t\t) {\n\t\t\tupdateUrlParams( {\n\t\t\t\tpostType: 'page',\n\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\tpath: undefined,\n\t\t\t} );\n\t\t} else if ( navigatorLocation.path === '/patterns' ) {\n\t\t\tupdateUrlParams( {\n\t\t\t\tpostType: undefined,\n\t\t\t\tpostId: undefined,\n\t\t\t\tcanvas: undefined,\n\t\t\t\tpath: navigatorLocation.path,\n\t\t\t} );\n\t\t} else {\n\t\t\tupdateUrlParams( {\n\t\t\t\tpostType: undefined,\n\t\t\t\tpostId: undefined,\n\t\t\t\tcategoryType: undefined,\n\t\t\t\tcategoryId: undefined,\n\t\t\t\tpath:\n\t\t\t\t\tnavigatorLocation.path === '/'\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: navigatorLocation.path,\n\t\t\t} );\n\t\t}\n\t}, [ navigatorLocation?.path, navigatorParams, history ] );\n\n\tuseEffect( () => {\n\t\tcurrentUrlParams.current = urlParams;\n\t\tconst path = getPathFromURL( urlParams );\n\t\tif ( currentPath.current !== path ) {\n\t\t\tcurrentPath.current = path;\n\t\t\tgoTo( path );\n\t\t}\n\t}, [ urlParams, goTo ] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["__experimentalUseNavigator","useNavigator","useEffect","useRef","privateApis","routerPrivateApis","unlock","useLocation","useHistory","getPathFromURL","urlParams","path","postType","postId","encodeURIComponent","isSubset","subset","superset","Object","entries","every","key","value","useSyncPathWithURL","history","params","location","navigatorLocation","navigatorParams","goTo","isMounting","current","updateUrlParams","newUrlParams","updatedParams","push","undefined","startsWith","canvas","categoryType","categoryId"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAA0B,IAAIC,YAAvC,QAA2D,uBAA3D;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf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M;AAEhBvB,QAAAA,MAAM,EAAEuB,SAFQ;AAGhBG,QAAAA,YAAY,EAAEH,SAHE;AAIhBI,QAAAA,UAAU,EAAEJ,SAJI;AAKhBzB,QAAAA,IAAI,EACHgB,iBAAiB,CAAChB,IAAlB,KAA2B,GAA3B,GACGyB,SADH,GAEGT,iBAAiB,CAAChB;AARN,OAAF,CAAf;AAUA;AACD,GAtDO,EAuDR;AACA;AACA,GAAEgB,iBAAiB,EAAEhB,IAArB,EAA2BiB,eAA3B,CAzDQ,CAAT;AA4DA1B,EAAAA,SAAS,CACR,MAAM;AACL,UAAMS,IAAI,GAAGF,cAAc,CAAEC,SAAF,CAA3B;;AACA,QAAKiB,iBAAiB,CAAChB,IAAlB,KAA2BA,IAAhC,EAAuC;AACtCkB,MAAAA,IAAI,CAAElB,IAAF,CAAJ;AACA;AACD,GANO,EAOR;AACA;AACA,GAAED,SAAF,CATQ,CAAT;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport function getPathFromURL( urlParams ) {\n\tlet path = urlParams?.path ?? '/';\n\n\t// Compute the navigator path based on the URL params.\n\tif ( urlParams?.postType && urlParams?.postId ) {\n\t\tswitch ( urlParams.postType ) {\n\t\t\tcase 'wp_block':\n\t\t\tcase 'wp_template':\n\t\t\tcase 'wp_template_part':\n\t\t\tcase 'page':\n\t\t\t\tpath = `/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tpath = `/navigation/${ encodeURIComponent(\n\t\t\t\t\turlParams.postType\n\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t}\n\t}\n\n\treturn path;\n}\n\nfunction isSubset( subset, superset ) {\n\treturn Object.entries( subset ).every( ( [ key, value ] ) => {\n\t\treturn superset[ key ] === value;\n\t} );\n}\n\nexport default function useSyncPathWithURL() {\n\tconst history = useHistory();\n\tconst { params: urlParams } = useLocation();\n\tconst {\n\t\tlocation: navigatorLocation,\n\t\tparams: navigatorParams,\n\t\tgoTo,\n\t} = useNavigator();\n\tconst isMounting = useRef( true );\n\n\tuseEffect(\n\t\t() => {\n\t\t\t// The navigatorParams are only initially filled properly when the\n\t\t\t// navigator screens mount. so we ignore the first synchronisation.\n\t\t\tif ( isMounting.current ) {\n\t\t\t\tisMounting.current = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction updateUrlParams( newUrlParams ) {\n\t\t\t\tif ( isSubset( newUrlParams, urlParams ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst updatedParams = {\n\t\t\t\t\t...urlParams,\n\t\t\t\t\t...newUrlParams,\n\t\t\t\t};\n\t\t\t\thistory.push( updatedParams );\n\t\t\t}\n\n\t\t\tif ( navigatorParams?.postType && navigatorParams?.postId ) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: navigatorParams?.postType,\n\t\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t} );\n\t\t\t} else if (\n\t\t\t\tnavigatorLocation.path.startsWith( '/page/' ) &&\n\t\t\t\tnavigatorParams?.postId\n\t\t\t) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: 'page',\n\t\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\t\tpath: undefined,\n\t\t\t\t} );\n\t\t\t} else if ( navigatorLocation.path === '/patterns' ) {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: undefined,\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t\tcanvas: undefined,\n\t\t\t\t\tpath: navigatorLocation.path,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tupdateUrlParams( {\n\t\t\t\t\tpostType: undefined,\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t\tcategoryType: undefined,\n\t\t\t\t\tcategoryId: undefined,\n\t\t\t\t\tpath:\n\t\t\t\t\t\tnavigatorLocation.path === '/'\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: navigatorLocation.path,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t// Trigger only when navigator changes to prevent infinite loops.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ navigatorLocation?.path, navigatorParams ]\n\t);\n\n\tuseEffect(\n\t\t() => {\n\t\t\tconst path = getPathFromURL( urlParams );\n\t\t\tif ( navigatorLocation.path !== path ) {\n\t\t\t\tgoTo( path );\n\t\t\t}\n\t\t},\n\t\t// Trigger only when URL changes to prevent infinite loops.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ urlParams ]\n\t);\n}\n"]}
@@ -10,6 +10,7 @@ import { __, sprintf } from '@wordpress/i18n';
10
10
  import { DropdownMenu, MenuGroup, MenuItem, __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
11
11
  import { moreVertical } from '@wordpress/icons';
12
12
  import { store as noticesStore } from '@wordpress/notices';
13
+ import { decodeEntities } from '@wordpress/html-entities';
13
14
  /**
14
15
  * Internal dependencies
15
16
  */
@@ -52,7 +53,7 @@ export default function TemplateActions({
52
53
  await saveEditedEntityRecord('postType', template.type, template.id);
53
54
  createSuccessNotice(sprintf(
54
55
  /* translators: The template/part's name. */
55
- __('"%s" reverted.'), template.title.rendered), {
56
+ __('"%s" reverted.'), decodeEntities(template.title.rendered)), {
56
57
  type: 'snackbar',
57
58
  id: 'edit-site-template-reverted'
58
59
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"names":["useDispatch","useSelect","store","coreStore","useState","__","sprintf","DropdownMenu","MenuGroup","MenuItem","__experimentalConfirmDialog","ConfirmDialog","moreVertical","noticesStore","editSiteStore","isTemplateRemovable","isTemplateRevertable","RenameMenuItem","TemplateActions","postType","postId","className","toggleProps","onRemove","template","select","getEntityRecord","removeTemplate","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","isRemovable","isRevertable","revertAndSaveTemplate","allowUndo","type","id","title","rendered","error","errorMessage","message","code","onClose","DeleteMenuItem","isTemplate","isModalOpen","setIsModalOpen"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,2BAA2B,IAAIC,aAJhC,QAKO,uBALP;AAMA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASV,KAAK,IAAIW,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,SAASX,KAAK,IAAIY,aAAlB,QAAuC,aAAvC;AACA,OAAOC,mBAAP,MAAgC,mCAAhC;AACA,OAAOC,oBAAP,MAAiC,oCAAjC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA,eAAe,SAASC,eAAT,CAA0B;AACxCC,EAAAA,QADwC;AAExCC,EAAAA,MAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA,WAJwC;AAKxCC,EAAAA;AALwC,CAA1B,EAMX;AACH,QAAMC,QAAQ,GAAGvB,SAAS,CACvBwB,MAAF,IACCA,MAAM,CAAEtB,SAAF,CAAN,CAAoBuB,eAApB,CAAqC,UAArC,EAAiDP,QAAjD,EAA2DC,MAA3D,CAFwB,EAGzB,CAAED,QAAF,EAAYC,MAAZ,CAHyB,CAA1B;AAKA,QAAM;AAAEO,IAAAA,cAAF;AAAkBC,IAAAA;AAAl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D;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport RenameMenuItem from './rename-menu-item';\n\nexport default function TemplateActions( {\n\tpostType,\n\tpostId,\n\tclassName,\n\ttoggleProps,\n\tonRemove,\n} ) {\n\tconst template = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', postType, postId ),\n\t\t[ postType, postId ]\n\t);\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" reverted.' ),\n\t\t\t\t\ttemplate.title.rendered\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-template-reverted',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while reverting the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName={ className }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenameMenuItem\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DeleteMenuItem\n\t\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonRemove?.();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisTemplate={ template.type === 'wp_template' }\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\t{ isRevertable && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t'Use the template as supplied by the theme.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction DeleteMenuItem( { onRemove, isTemplate } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tisDestructive\n\t\t\t\tisTertiary\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Delete' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ onRemove }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t>\n\t\t\t\t{ isTemplate\n\t\t\t\t\t? __( 'Are you sure you want to delete this template?' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'Are you sure you want to delete this template part?'\n\t\t\t\t\t ) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/index.js"],"names":["useDispatch","useSelect","store","coreStore","useState","__","sprintf","DropdownMenu","MenuGroup","MenuItem","__experimentalConfirmDialog","ConfirmDialog","moreVertical","noticesStore","decodeEntities","editSiteStore","isTemplateRemovable","isTemplateRevertable","RenameMenuItem","TemplateActions","postType","postId","className","toggleProps","onRemove","template","select","getEntityRecord","removeTemplate","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","isRemovable","isRevertable","revertAndSaveTemplate","allowUndo","type","id","title","rendered","error","errorMessage","message","code","onClose","DeleteMenuItem","isTemplate","isModalOpen","setIsModalOpen"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,YADD,EAEC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AAE,CACR,4CADQ,CADV;AAIC,IAAA,OAAO,EAAG,MAAM;AACf8B,MAAAA,qBAAqB;AACrBU,MAAAA,OAAO;AACP;AAPF,KASGxC,EAAE,CAAE,sBAAF,CATL,CAlBF,CAPF,CADD;AA0CA;;AAED,SAASyC,cAAT,CAAyB;AAAEtB,EAAAA,QAAF;AAAYuB,EAAAA;AAAZ,CAAzB,EAAoD;AACnD,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC7C,QAAQ,CAAE,KAAF,CAAhD;AACA,SACC,8BACC,cAAC,QAAD;AACC,IAAA,aAAa,MADd;AAEC,IAAA,UAAU,MAFX;AAGC,IAAA,OAAO,EAAG,MAAM6C,cAAc,CAAE,IAAF;AAH/B,KAKG5C,EAAE,CAAE,QAAF,CALL,CADD,EAQC,cAAC,aAAD;AACC,IAAA,MAAM,EAAG2C,WADV;AAEC,IAAA,SAAS,EAAGxB,QAFb;AAGC,IAAA,QAAQ,EAAG,MAAMyB,cAAc,CAAE,KAAF,CAHhC;AAIC,IAAA,iBAAiB,EAAG5C,EAAE,CAAE,QAAF;AAJvB,KAMG0C,UAAU,GACT1C,EAAE,CAAE,gDAAF,CADO,GAETA,EAAE,CACF,qDADE,CARN,CARD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport RenameMenuItem from './rename-menu-item';\n\nexport default function TemplateActions( {\n\tpostType,\n\tpostId,\n\tclassName,\n\ttoggleProps,\n\tonRemove,\n} ) {\n\tconst template = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'postType', postType, postId ),\n\t\t[ postType, postId ]\n\t);\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" reverted.' ),\n\t\t\t\t\tdecodeEntities( template.title.rendered )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-template-reverted',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while reverting the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName={ className }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenameMenuItem\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DeleteMenuItem\n\t\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonRemove?.();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisTemplate={ template.type === 'wp_template' }\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\t{ isRevertable && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t'Use the template as supplied by the theme.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction DeleteMenuItem( { onRemove, isTemplate } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tisDestructive\n\t\t\t\tisTertiary\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Delete' ) }\n\t\t\t</MenuItem>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\tonConfirm={ onRemove }\n\t\t\t\tonCancel={ () => setIsModalOpen( false ) }\n\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t>\n\t\t\t\t{ isTemplate\n\t\t\t\t\t? __( 'Are you sure you want to delete this template?' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'Are you sure you want to delete this template part?'\n\t\t\t\t\t ) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"]}
@@ -9,15 +9,17 @@ import { useDispatch } from '@wordpress/data';
9
9
  import { Button, MenuItem, Modal, TextControl, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
10
10
  import { store as coreStore } from '@wordpress/core-data';
11
11
  import { store as noticesStore } from '@wordpress/notices';
12
+ import { decodeEntities } from '@wordpress/html-entities';
12
13
  export default function RenameMenuItem({
13
14
  template,
14
15
  onClose
15
16
  }) {
16
- const [title, setTitle] = useState(() => template.title.rendered);
17
+ const title = decodeEntities(template.title.rendered);
18
+ const [editedTitle, setEditedTitle] = useState(title);
17
19
  const [isModalOpen, setIsModalOpen] = useState(false);
18
20
  const {
19
21
  editEntityRecord,
20
- saveEditedEntityRecord
22
+ __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
21
23
  } = useDispatch(coreStore);
22
24
  const {
23
25
  createSuccessNotice,
@@ -33,14 +35,15 @@ export default function RenameMenuItem({
33
35
 
34
36
  try {
35
37
  await editEntityRecord('postType', template.type, template.id, {
36
- title
38
+ title: editedTitle
37
39
  }); // Update state before saving rerenders the list.
38
40
 
39
- setTitle('');
41
+ setEditedTitle('');
40
42
  setIsModalOpen(false);
41
43
  onClose(); // Persist edited entity.
42
44
 
43
- await saveEditedEntityRecord('postType', template.type, template.id, {
45
+ await saveSpecifiedEntityEdits('postType', template.type, template.id, ['title'], // Only save title to avoid persisting other edits.
46
+ {
44
47
  throwOnError: true
45
48
  });
46
49
  createSuccessNotice(__('Entity renamed.'), {
@@ -57,7 +60,7 @@ export default function RenameMenuItem({
57
60
  return createElement(Fragment, null, createElement(MenuItem, {
58
61
  onClick: () => {
59
62
  setIsModalOpen(true);
60
- setTitle(template.title.rendered);
63
+ setEditedTitle(title);
61
64
  }
62
65
  }, __('Rename')), isModalOpen && createElement(Modal, {
63
66
  title: __('Rename'),
@@ -72,8 +75,8 @@ export default function RenameMenuItem({
72
75
  }, createElement(TextControl, {
73
76
  __nextHasNoMarginBottom: true,
74
77
  label: __('Name'),
75
- value: title,
76
- onChange: setTitle,
78
+ value: editedTitle,
79
+ onChange: setEditedTitle,
77
80
  required: true
78
81
  }), createElement(HStack, {
79
82
  justify: "right"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/rename-menu-item.js"],"names":["__","useState","useDispatch","Button","MenuItem","Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","noticesStore","RenameMenuItem","template","onClose","title","setTitle","rendered","isModalOpen","setIsModalOpen","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","type","is_custom","onTemplateRename","event","preventDefault","id","throwOnError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SACCC,MADD,EAECC,QAFD,EAGCC,KAHD,EAICC,WAJD,EAKCC,oBAAoB,IAAIC,MALzB,EAMCC,oBAAoB,IAAIC,MANzB,QAOO,uBAPP;AAQA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,cAAT,CAAyB;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAAzB,EAAiD;AAC/D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsBjB,QAAQ,CAAE,MAAMc,QAAQ,CAACE,KAAT,CAAeE,QAAvB,CAApC;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkCpB,QAAQ,CAAE,KAAF,CAAhD;AAEA,QAAM;AAAEqB,IAAAA,gBAAF;AAAo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AAd;AACAH,MAAAA,QAAQ,CAAEH,QAAQ,CAACE,KAAT,CAAeE,QAAjB,CAAR;AACA;AAJF,KAMGnB,EAAE,CAAE,QAAF,CANL,CADD,EASGoB,WAAW,IACZ,cAAC,KAAD;AACC,IAAA,KAAK,EAAGpB,EAAE,CAAE,QAAF,CADX;AAEC,IAAA,cAAc,EAAG,MAAM;AACtBqB,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA,KAJF;AAKC,IAAA,gBAAgB,EAAC;AALlB,KAOC;AAAM,IAAA,QAAQ,EAAGO;AAAjB,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,WAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAG5B,EAAE,CAAE,MAAF,CAFX;AAGC,IAAA,KAAK,EAAGiB,KAHT;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,QAAQ;AALT,IADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AAJF,KAMGrB,EAAE,CAAE,QAAF,CANL,CADD,EAUC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CAVD,CATD,CADD,CAPD,CAVF,CADD;AAgDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tMenuItem,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenameMenuItem( { template, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => template.title.rendered );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tif ( template.type === 'wp_template' && ! template.is_custom ) {\n\t\treturn null;\n\t}\n\n\tasync function onTemplateRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\ttitle,\n\t\t\t} );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( template.title.rendered );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/template-actions/rename-menu-item.js"],"names":["__","useState","useDispatch","Button","MenuItem","Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","noticesStore","decodeEntities","RenameMenuItem","template","onClose","title","rendered","editedTitle","setEditedTitle","isModalOpen","setIsModalOpen","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","createSuccessNotice","createErrorNotice","type","is_custom","onTemplateRename","event","preventDefault","id","throwOnError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB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AAIC,IAAA,QAAQ,EAAGC,cAJZ;AAKC,IAAA,QAAQ;AALT,IADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfE,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AAJF,KAMGvB,EAAE,CAAE,QAAF,CANL,CADD,EAUC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CAVD,CATD,CADD,CAPD,CAVF,CADD;AAgDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tMenuItem,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nexport default function RenameMenuItem( { template, onClose } ) {\n\tconst title = decodeEntities( template.title.rendered );\n\tconst [ editedTitle, setEditedTitle ] = useState( title );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tif ( template.type === 'wp_template' && ! template.is_custom ) {\n\t\treturn null;\n\t}\n\n\tasync function onTemplateRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\ttitle: editedTitle,\n\t\t\t} );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetEditedTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t[ 'title' ], // Only save title to avoid persisting other edits.\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetEditedTitle( title );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\tvalue={ editedTitle }\n\t\t\t\t\t\t\t\tonChange={ setEditedTitle }\n\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -10,6 +10,7 @@ import { decodeEntities } from '@wordpress/html-entities';
10
10
  */
11
11
 
12
12
  import { store as editSiteStore } from '../../store';
13
+ import normalizeRecordKey from '../../utils/normalize-record-key';
13
14
  export default function useEditedEntityRecord(postType, postId) {
14
15
  const {
15
16
  record,
@@ -30,7 +31,8 @@ export default function useEditedEntityRecord(postType, postId) {
30
31
  __experimentalGetTemplateInfo: getTemplateInfo
31
32
  } = select(editorStore);
32
33
  const usedPostType = postType !== null && postType !== void 0 ? postType : getEditedPostType();
33
- const usedPostId = postId !== null && postId !== void 0 ? postId : getEditedPostId();
34
+ let usedPostId = postId !== null && postId !== void 0 ? postId : getEditedPostId();
35
+ usedPostId = normalizeRecordKey(usedPostId, usedPostType);
34
36
 
35
37
  const _record = getEditedEntityRecord('postType', usedPostType, usedPostId);
36
38
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useSelect","store","coreStore","editorStore","decodeEntities","editSiteStore","useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","select","getEditedPostType","getEditedPostId","getEditedEntityRecord","hasFinishedResolution","__experimentalGetTemplateInfo","getTemplate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c,OADF;AAENb,MAAAA,KAAK,EAAEe,YAAY,CAACf,KAFd;AAGNC,MAAAA,WAAW,EAAEc,YAAY,CAACd,WAHpB;AAINC,MAAAA,QAAQ,EAAEY,SAJJ;AAKNX,MAAAA,IAAI,EAAEY,YAAY,CAACZ;AALb,KAAP;AAOA,GA/B8D,EAgC/D,CAAEN,QAAF,EAAYC,MAAZ,CAhC+D,CAAhE;AAmCA,SAAO;AACNI,IAAAA,QADM;AAENC,IAAAA,IAFM;AAGNJ,IAAAA,MAHM;AAINiB,IAAAA,QAAQ,EAAE,MAAQhB,KAAK,GAAGN,cAAc,CAAEM,KAAF,CAAjB,GAA6B,IAJ9C;AAKNiB,IAAAA,cAAc,EAAE,MACfhB,WAAW,GAAGP,cAAc,CAAEO,WAAF,CAAjB,GAAmC;AANzC,GAAP;AAQA","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( postType, postId ) {\n\tconst { record, title, description, isLoaded, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst usedPostType = postType ?? getEditedPostType();\n\t\t\tconst usedPostId = postId ?? getEditedPostId();\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tusedPostType,\n\t\t\t\tusedPostId\n\t\t\t);\n\t\t\tconst _isLoaded =\n\t\t\t\tusedPostId &&\n\t\t\t\thasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tusedPostType,\n\t\t\t\t\tusedPostId,\n\t\t\t\t] );\n\t\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\t\treturn {\n\t\t\t\trecord: _record,\n\t\t\t\ttitle: templateInfo.title,\n\t\t\t\tdescription: templateInfo.description,\n\t\t\t\tisLoaded: _isLoaded,\n\t\t\t\ticon: templateInfo.icon,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn {\n\t\tisLoaded,\n\t\ticon,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useSelect","store","coreStore","editorStore","decodeEntities","editSiteStore","normalizeRecordKey","useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","select","getEditedPostType","getEditedPostId","getEditedEntityRecord","hasFinishedResolution","__experimentalGetTemplateInfo","getTemplateInfo","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,aAAvC;AACA,OAAOC,kBAAP,MAA+B,kCAA/B;AAEA,eAAe,SAASC,qBAAT,CAAgCC,QAAhC,EAA0CC,MAA1C,EAAmD;AACjE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA,WAAjB;AAA8BC,IAAAA,QAA9B;AAAwCC,IAAAA;AAAxC,MAAiDd,SAAS,CAC7De,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC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F,CAAjB,GAAmC;AANzC,GAAP;AAQA","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';\nimport normalizeRecordKey from '../../utils/normalize-record-key';\n\nexport default function useEditedEntityRecord( postType, postId ) {\n\tconst { record, title, description, isLoaded, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst usedPostType = postType ?? getEditedPostType();\n\n\t\t\tlet usedPostId = postId ?? getEditedPostId();\n\n\t\t\tusedPostId = normalizeRecordKey( usedPostId, usedPostType );\n\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tusedPostType,\n\t\t\t\tusedPostId\n\t\t\t);\n\t\t\tconst _isLoaded =\n\t\t\t\tusedPostId &&\n\t\t\t\thasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tusedPostType,\n\t\t\t\t\tusedPostId,\n\t\t\t\t] );\n\t\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\t\treturn {\n\t\t\t\trecord: _record,\n\t\t\t\ttitle: templateInfo.title,\n\t\t\t\tdescription: templateInfo.description,\n\t\t\t\tisLoaded: _isLoaded,\n\t\t\t\ticon: templateInfo.icon,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn {\n\t\tisLoaded,\n\t\ticon,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"]}
@@ -11,17 +11,20 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
11
11
  import { store as preferencesStore } from '@wordpress/preferences';
12
12
  import { store as coreStore } from '@wordpress/core-data';
13
13
  import { store as noticesStore } from '@wordpress/notices';
14
+ import { useViewportMatch } from '@wordpress/compose';
14
15
  /**
15
16
  * Internal dependencies
16
17
  */
17
18
 
18
19
  import { unlock } from '../../lock-unlock';
19
20
  import { store as editSiteStore } from '../../store';
21
+ import getIsListPage from '../../utils/get-is-list-page';
20
22
  const {
21
23
  useGlobalStylesReset
22
24
  } = unlock(blockEditorPrivateApis);
23
25
  const {
24
- useHistory
26
+ useHistory,
27
+ useLocation
25
28
  } = unlock(routerPrivateApis);
26
29
 
27
30
  function useGlobalStylesResetCommands() {
@@ -52,8 +55,15 @@ function useGlobalStylesResetCommands() {
52
55
  function useGlobalStylesOpenCssCommands() {
53
56
  const {
54
57
  openGeneralSidebar,
55
- setEditorCanvasContainerView
58
+ setEditorCanvasContainerView,
59
+ setCanvasMode
56
60
  } = unlock(useDispatch(editSiteStore));
61
+ const {
62
+ params
63
+ } = useLocation();
64
+ const isMobileViewport = useViewportMatch('medium', '<');
65
+ const isListPage = getIsListPage(params, isMobileViewport);
66
+ const isEditorPage = !isListPage;
57
67
  const history = useHistory();
58
68
  const {
59
69
  canEditCSS
@@ -72,6 +82,9 @@ function useGlobalStylesOpenCssCommands() {
72
82
  canEditCSS: (_globalStyles$_links$ = !!globalStyles?._links?.['wp:action-edit-css']) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : false
73
83
  };
74
84
  }, []);
85
+ const {
86
+ getCanvasMode
87
+ } = unlock(useSelect(editSiteStore));
75
88
  const commands = useMemo(() => {
76
89
  if (!canEditCSS) {
77
90
  return [];
@@ -85,15 +98,23 @@ function useGlobalStylesOpenCssCommands() {
85
98
  close
86
99
  }) => {
87
100
  close();
88
- history.push({
89
- path: '/wp_global_styles',
90
- canvas: 'edit'
91
- });
101
+
102
+ if (!isEditorPage) {
103
+ history.push({
104
+ path: '/wp_global_styles',
105
+ canvas: 'edit'
106
+ });
107
+ }
108
+
109
+ if (isEditorPage && getCanvasMode() !== 'edit') {
110
+ setCanvasMode('edit');
111
+ }
112
+
92
113
  openGeneralSidebar('edit-site/global-styles');
93
114
  setEditorCanvasContainerView('global-styles-css');
94
115
  }
95
116
  }];
96
- }, [history, openGeneralSidebar, setEditorCanvasContainerView, canEditCSS]);
117
+ }, [history, openGeneralSidebar, setEditorCanvasContainerView, canEditCSS, isEditorPage, getCanvasMode, setCanvasMode]);
97
118
  return {
98
119
  isLoading: false,
99
120
  commands
@@ -103,8 +124,18 @@ function useGlobalStylesOpenCssCommands() {
103
124
  export function useCommonCommands() {
104
125
  const {
105
126
  openGeneralSidebar,
106
- setEditorCanvasContainerView
127
+ setEditorCanvasContainerView,
128
+ setCanvasMode
107
129
  } = unlock(useDispatch(editSiteStore));
130
+ const {
131
+ params
132
+ } = useLocation();
133
+ const isMobileViewport = useViewportMatch('medium', '<');
134
+ const isListPage = getIsListPage(params, isMobileViewport);
135
+ const isEditorPage = !isListPage;
136
+ const {
137
+ getCanvasMode
138
+ } = unlock(useSelect(editSiteStore));
108
139
  const {
109
140
  set
110
141
  } = useDispatch(preferencesStore);
@@ -133,10 +164,18 @@ export function useCommonCommands() {
133
164
  close
134
165
  }) => {
135
166
  close();
136
- history.push({
137
- path: '/wp_global_styles',
138
- canvas: 'edit'
139
- });
167
+
168
+ if (!isEditorPage) {
169
+ history.push({
170
+ path: '/wp_global_styles',
171
+ canvas: 'edit'
172
+ });
173
+ }
174
+
175
+ if (isEditorPage && getCanvasMode() !== 'edit') {
176
+ setCanvasMode('edit');
177
+ }
178
+
140
179
  openGeneralSidebar('edit-site/global-styles');
141
180
  setEditorCanvasContainerView('global-styles-revisions');
142
181
  }
@@ -148,10 +187,17 @@ export function useCommonCommands() {
148
187
  close
149
188
  }) => {
150
189
  close();
151
- history.push({
152
- path: '/wp_global_styles',
153
- canvas: 'edit'
154
- });
190
+
191
+ if (!isEditorPage) {
192
+ history.push({
193
+ path: '/wp_global_styles',
194
+ canvas: 'edit'
195
+ });
196
+ }
197
+
198
+ if (isEditorPage && getCanvasMode() !== 'edit') {
199
+ setCanvasMode('edit');
200
+ }
155
201
 
156
202
  if (isDistractionFree) {
157
203
  set(editSiteStore.name, 'distractionFree', false);
@@ -171,10 +217,18 @@ export function useCommonCommands() {
171
217
  close
172
218
  }) => {
173
219
  close();
174
- history.push({
175
- path: '/wp_global_styles',
176
- canvas: 'edit'
177
- });
220
+
221
+ if (!isEditorPage) {
222
+ history.push({
223
+ path: '/wp_global_styles',
224
+ canvas: 'edit'
225
+ });
226
+ }
227
+
228
+ if (isEditorPage && getCanvasMode() !== 'edit') {
229
+ setCanvasMode('edit');
230
+ }
231
+
178
232
  openGeneralSidebar('edit-site/global-styles');
179
233
  set('core/edit-site', 'welcomeGuideStyles', true); // sometimes there's a focus loss that happens after some time
180
234
  // that closes the modal, we need to force reopening it.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-common-commands.js"],"names":["useMemo","useDispatch","useSelect","__","trash","backup","help","styles","external","useCommandLoader","useCommand","privateApis","blockEditorPrivateApis","routerPrivateApis","store","preferencesStore","coreStore","noticesStore","unlock","editSiteStore","useGlobalStylesReset","useHistory","useGlobalStylesResetCommands","canReset","onReset","commands","name","label","icon","callback","close","isLoading","useGlobalStylesOpenCssCommands","openGeneralSidebar","setEditorCanvasContainerView","history","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","undefined","_links","push","path","canvas","useCommonCommands","set","createInfoNotice","homeUrl","isDistractionFree","getUnstableBase","home","get","type","setTimeout","window","open","hook"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAA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FS,EAEP,GAFO,CAAV;AAGA,KAhBU;AAiBXpB,IAAAA,IAAI,EAAEtB;AAjBK,GAAF,CAAV;AAoBAI,EAAAA,UAAU,CAAE;AACXgB,IAAAA,IAAI,EAAE,0BADK;AAEXC,IAAAA,KAAK,EAAExB,EAAE,CAAE,WAAF,CAFE;AAGX0B,IAAAA,QAAQ,EAAE,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAiB;AAC1BA,MAAAA,KAAK;AACL2B,MAAAA,MAAM,CAACC,IAAP,CAAaR,OAAb,EAAsB,QAAtB;AACA,KANU;AAOXtB,IAAAA,IAAI,EAAEpB;AAPK,GAAF,CAAV;AAUAC,EAAAA,gBAAgB,CAAE;AACjBiB,IAAAA,IAAI,EAAE,oCADW;AAEjBiC,IAAAA,IAAI,EAAErC;AAFW,GAAF,CAAhB;AAKAb,EAAAA,gBAAgB,CAAE;AACjBiB,IAAAA,IAAI,EAAE,gCADW;AAEjBiC,IAAAA,IAAI,EAAE3B;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { trash, backup, help, styles, external } from '@wordpress/icons';\nimport { useCommandLoader, useCommand } from '@wordpress/commands';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\n\nconst { useGlobalStylesReset } = unlock( blockEditorPrivateApis );\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction useGlobalStylesResetCommands() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst commands = useMemo( () => {\n\t\tif ( ! canReset ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/reset-global-styles',\n\t\t\t\tlabel: __( 'Reset styles to defaults' ),\n\t\t\t\ticon: trash,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tonReset();\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [ canReset, onReset ] );\n\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nfunction useGlobalStylesOpenCssCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tconst history = useHistory();\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS:\n\t\t\t\t!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,\n\t\t};\n\t}, [] );\n\n\tconst commands = useMemo( () => {\n\t\tif ( ! canEditCSS ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/open-styles-css',\n\t\t\t\tlabel: __( 'Open CSS' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\thistory.push( {\n\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t} );\n\t\t\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\t\t\tsetEditorCanvasContainerView( 'global-styles-css' );\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [\n\t\thistory,\n\t\topenGeneralSidebar,\n\t\tsetEditorCanvasContainerView,\n\t\tcanEditCSS,\n\t] );\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nexport function useCommonCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tconst { set } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst history = useHistory();\n\tconst { homeUrl, isDistractionFree } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\tisDistractionFree: select( preferencesStore ).get(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-global-styles-revisions',\n\t\tlabel: __( 'Open styles revisions' ),\n\t\ticon: backup,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\thistory.push( {\n\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tsetEditorCanvasContainerView( 'global-styles-revisions' );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-styles',\n\t\tlabel: __( 'Open styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\thistory.push( {\n\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\tset( editSiteStore.name, 'distractionFree', false );\n\t\t\t\tcreateInfoNotice( __( 'Distraction free mode turned off.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t},\n\t\ticon: styles,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/toggle-styles-welcome-guide',\n\t\tlabel: __( 'Learn about styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\thistory.push( {\n\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t// sometimes there's a focus loss that happens after some time\n\t\t\t// that closes the modal, we need to force reopening it.\n\t\t\tsetTimeout( () => {\n\t\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t}, 500 );\n\t\t},\n\t\ticon: help,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/view-site',\n\t\tlabel: __( 'View site' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\twindow.open( homeUrl, '_blank' );\n\t\t},\n\t\ticon: external,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/reset-global-styles',\n\t\thook: useGlobalStylesResetCommands,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/open-styles-css',\n\t\thook: useGlobalStylesOpenCssCommands,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-common-commands.js"],"names":["useMemo","useDispatch","useSelect","__","trash","backup","help","styles","external","useCommandLoader","useCommand","privateApis","blockEditorPrivateApis","routerPrivateApis","store","preferencesStore","coreStore","noticesStore","useViewportMatch","unlock","editSiteStore","getIsListPage","useGlobalStylesReset","useHistory","useLocation","useGlobalStylesResetCommands","canReset","onReset","commands","name","label","icon","callback","close","isLoading","useGlobalStylesOpenCssCommands","openGeneralSidebar","setEditorCanvasContainerView","setCanvasMode","params","isMobileViewport","isListPage","isEditorPage","history","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","undefined","_links","getCanvasMode","push","path","canvas","useCommonCommands","set","createInfoNotice","homeUrl","isDistractionFree","getUnstableBase","home","get","type","setTimeout","window","open","hook"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,EAAgBC,MAAhB,EAAwBC,IAAxB,EAA8BC,MAA9B,EAAsCC,QAAtC,QAAsD,kBAAtD;AACA,SAASC,gBAAT,EAA2BC,UAA3B,QAA6C,qBAA7C;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASD,WAAW,IAAIE,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,YAAlB,QAAsC,oBAAtC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASL,KAAK,IAAIM,aAAlB,QAAuC,aAAvC;AACA,OAAOC,aAAP,MAA0B,8BAA1B;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAA2BH,MAAM,CAAEP,sBAAF,CAAvC;AACA,MAAM;AAAEW,EAAAA,UAAF;AAAcC,EAAAA;AAAd,IAA8BL,MAAM,CAAEN,iBAAF,CAA1C;;AAEA,SAASY,4BAAT,GAAwC;AACvC,QAAM,CAAEC,QAAF,EAAYC,OAAZ,IAAwBL,oBAAoB,EAAlD;AACA,QAAMM,QAAQ,GAAG5B,OAAO,CAAE,MAAM;AAC/B,QAAK,CAAE0B,QAAP,EAAkB;AACjB,aAAO,EAAP;AACA;;AAED,WAAO,CACN;AACCG,MAAAA,IAAI,EAAE,oCADP;AAECC,MAAAA,KAAK,EAAE3B,EAAE,CAAE,0BAAF,CAFV;AAGC4B,MAAAA,IAAI,EAAE3B,KAHP;AA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Y,IAAIU,aAAa,OAAO,MAAzC,EAAkD;AACjDd,QAAAA,aAAa,CAAE,MAAF,CAAb;AACA;;AACDF,MAAAA,kBAAkB,CAAE,yBAAF,CAAlB;AACAqB,MAAAA,GAAG,CAAE,gBAAF,EAAoB,oBAApB,EAA0C,IAA1C,CAAH,CAZ0B,CAa1B;AACA;;AACAQ,MAAAA,UAAU,CAAE,MAAM;AACjBR,QAAAA,GAAG,CAAE,gBAAF,EAAoB,oBAApB,EAA0C,IAA1C,CAAH;AACA,OAFS,EAEP,GAFO,CAAV;AAGA,KArBU;AAsBX1B,IAAAA,IAAI,EAAEzB;AAtBK,GAAF,CAAV;AAyBAI,EAAAA,UAAU,CAAE;AACXmB,IAAAA,IAAI,EAAE,0BADK;AAEXC,IAAAA,KAAK,EAAE3B,EAAE,CAAE,WAAF,CAFE;AAGX6B,IAAAA,QAAQ,EAAE,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAiB;AAC1BA,MAAAA,KAAK;AACLiC,MAAAA,MAAM,CAACC,IAAP,CAAaR,OAAb,EAAsB,QAAtB;AACA,KANU;AAOX5B,IAAAA,IAAI,EAAEvB;AAPK,GAAF,CAAV;AAUAC,EAAAA,gBAAgB,CAAE;AACjBoB,IAAAA,IAAI,EAAE,oCADW;AAEjBuC,IAAAA,IAAI,EAAE3C;AAFW,GAAF,CAAhB;AAKAhB,EAAAA,gBAAgB,CAAE;AACjBoB,IAAAA,IAAI,EAAE,gCADW;AAEjBuC,IAAAA,IAAI,EAAEjC;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { trash, backup, help, styles, external } from '@wordpress/icons';\nimport { useCommandLoader, useCommand } from '@wordpress/commands';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport getIsListPage from '../../utils/get-is-list-page';\n\nconst { useGlobalStylesReset } = unlock( blockEditorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nfunction useGlobalStylesResetCommands() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst commands = useMemo( () => {\n\t\tif ( ! canReset ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/reset-global-styles',\n\t\t\t\tlabel: __( 'Reset styles to defaults' ),\n\t\t\t\ticon: trash,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tonReset();\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [ canReset, onReset ] );\n\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nfunction useGlobalStylesOpenCssCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView, setCanvasMode } =\n\t\tunlock( useDispatch( editSiteStore ) );\n\tconst { params } = useLocation();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isListPage = getIsListPage( params, isMobileViewport );\n\tconst isEditorPage = ! isListPage;\n\tconst history = useHistory();\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS:\n\t\t\t\t!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,\n\t\t};\n\t}, [] );\n\tconst { getCanvasMode } = unlock( useSelect( editSiteStore ) );\n\n\tconst commands = useMemo( () => {\n\t\tif ( ! canEditCSS ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/open-styles-css',\n\t\t\t\tlabel: __( 'Open CSS' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tif ( ! isEditorPage ) {\n\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t\t\t}\n\t\t\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\t\t\tsetEditorCanvasContainerView( 'global-styles-css' );\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [\n\t\thistory,\n\t\topenGeneralSidebar,\n\t\tsetEditorCanvasContainerView,\n\t\tcanEditCSS,\n\t\tisEditorPage,\n\t\tgetCanvasMode,\n\t\tsetCanvasMode,\n\t] );\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nexport function useCommonCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView, setCanvasMode } =\n\t\tunlock( useDispatch( editSiteStore ) );\n\tconst { params } = useLocation();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isListPage = getIsListPage( params, isMobileViewport );\n\tconst isEditorPage = ! isListPage;\n\tconst { getCanvasMode } = unlock( useSelect( editSiteStore ) );\n\tconst { set } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst history = useHistory();\n\tconst { homeUrl, isDistractionFree } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\tisDistractionFree: select( preferencesStore ).get(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-global-styles-revisions',\n\t\tlabel: __( 'Open styles revisions' ),\n\t\ticon: backup,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( ! isEditorPage ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tsetEditorCanvasContainerView( 'global-styles-revisions' );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-styles',\n\t\tlabel: __( 'Open styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( ! isEditorPage ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t}\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\tset( editSiteStore.name, 'distractionFree', false );\n\t\t\t\tcreateInfoNotice( __( 'Distraction free mode turned off.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t},\n\t\ticon: styles,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/toggle-styles-welcome-guide',\n\t\tlabel: __( 'Learn about styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( ! isEditorPage ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t// sometimes there's a focus loss that happens after some time\n\t\t\t// that closes the modal, we need to force reopening it.\n\t\t\tsetTimeout( () => {\n\t\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t}, 500 );\n\t\t},\n\t\ticon: help,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/view-site',\n\t\tlabel: __( 'View site' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\twindow.open( homeUrl, '_blank' );\n\t\t},\n\t\ticon: external,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/reset-global-styles',\n\t\thook: useGlobalStylesResetCommands,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/open-styles-css',\n\t\thook: useGlobalStylesOpenCssCommands,\n\t} );\n}\n"]}