@wordpress/edit-site 5.4.0 → 5.6.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 (339) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +12 -3
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/new-template-part.js +8 -7
  5. package/build/components/add-new-template/new-template-part.js.map +1 -1
  6. package/build/components/add-new-template/new-template.js +19 -16
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/app/index.js +4 -2
  9. package/build/components/app/index.js.map +1 -1
  10. package/build/components/block-editor/editor-canvas.js +2 -1
  11. package/build/components/block-editor/editor-canvas.js.map +1 -1
  12. package/build/components/editor/index.js +5 -7
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/global-styles/border-panel.js +20 -159
  15. package/build/components/global-styles/border-panel.js.map +1 -1
  16. package/build/components/global-styles/context-menu.js +13 -11
  17. package/build/components/global-styles/context-menu.js.map +1 -1
  18. package/build/components/global-styles/dimensions-panel.js +41 -487
  19. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  20. package/build/components/global-styles/duotone-panel.js +78 -0
  21. package/build/components/global-styles/duotone-panel.js.map +1 -0
  22. package/build/components/global-styles/filter-utils.js +17 -0
  23. package/build/components/global-styles/filter-utils.js.map +1 -0
  24. package/build/components/global-styles/hooks.js +11 -26
  25. package/build/components/global-styles/hooks.js.map +1 -1
  26. package/build/components/global-styles/preview.js +9 -5
  27. package/build/components/global-styles/preview.js.map +1 -1
  28. package/build/components/global-styles/screen-block-list.js +6 -11
  29. package/build/components/global-styles/screen-block-list.js.map +1 -1
  30. package/build/components/global-styles/screen-border.js +14 -6
  31. package/build/components/global-styles/screen-border.js.map +1 -1
  32. package/build/components/global-styles/screen-filters.js +46 -0
  33. package/build/components/global-styles/screen-filters.js.map +1 -0
  34. package/build/components/global-styles/screen-layout.js +13 -5
  35. package/build/components/global-styles/screen-layout.js.map +1 -1
  36. package/build/components/global-styles/screen-root.js +2 -1
  37. package/build/components/global-styles/screen-root.js.map +1 -1
  38. package/build/components/global-styles/screen-style-variations.js +2 -1
  39. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  40. package/build/components/global-styles/screen-variations.js +1 -1
  41. package/build/components/global-styles/screen-variations.js.map +1 -1
  42. package/build/components/global-styles/shadow-panel.js +6 -4
  43. package/build/components/global-styles/shadow-panel.js.map +1 -1
  44. package/build/components/global-styles/typography-panel.js +2 -5
  45. package/build/components/global-styles/typography-panel.js.map +1 -1
  46. package/build/components/global-styles/ui.js +7 -1
  47. package/build/components/global-styles/ui.js.map +1 -1
  48. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  49. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  50. package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
  51. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  52. package/build/components/keyboard-shortcuts/global.js +48 -0
  53. package/build/components/keyboard-shortcuts/global.js.map +1 -0
  54. package/build/components/keyboard-shortcuts/index.js +67 -0
  55. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  56. package/build/components/keyboard-shortcuts/register.js +153 -0
  57. package/build/components/keyboard-shortcuts/register.js.map +1 -0
  58. package/build/components/layout/index.js +12 -1
  59. package/build/components/layout/index.js.map +1 -1
  60. package/build/components/list/added-by.js +127 -136
  61. package/build/components/list/added-by.js.map +1 -1
  62. package/build/components/list/index.js +2 -1
  63. package/build/components/list/index.js.map +1 -1
  64. package/build/components/list/table.js +9 -7
  65. package/build/components/list/table.js.map +1 -1
  66. package/build/components/routes/link.js +4 -1
  67. package/build/components/routes/link.js.map +1 -1
  68. package/build/components/save-hub/index.js +82 -0
  69. package/build/components/save-hub/index.js.map +1 -0
  70. package/build/components/save-panel/index.js +11 -1
  71. package/build/components/save-panel/index.js.map +1 -1
  72. package/build/components/sidebar/index.js +27 -17
  73. package/build/components/sidebar/index.js.map +1 -1
  74. package/build/components/sidebar-button/index.js +30 -0
  75. package/build/components/sidebar-button/index.js.map +1 -0
  76. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  77. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  78. package/build/components/sidebar-navigation-screen/index.js +14 -11
  79. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-screen-main/index.js +16 -16
  81. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  82. package/build/components/sidebar-navigation-screen-navigation-item/index.js +22 -26
  83. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  84. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +97 -14
  85. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  86. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  87. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  88. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  89. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  90. package/build/components/sidebar-navigation-screen-template/index.js +66 -27
  91. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  92. package/build/components/sidebar-navigation-screen-templates/index.js +30 -17
  93. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  94. package/build/components/sidebar-navigation-screen-templates-browse/index.js +14 -10
  95. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  96. package/build/components/site-hub/index.js +3 -1
  97. package/build/components/site-hub/index.js.map +1 -1
  98. package/build/components/style-book/index.js +151 -21
  99. package/build/components/style-book/index.js.map +1 -1
  100. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  101. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  102. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  103. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  104. package/build/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
  105. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  106. package/build/components/template-details/index.js +5 -10
  107. package/build/components/template-details/index.js.map +1 -1
  108. package/build/components/template-part-converter/convert-to-regular.js +8 -12
  109. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  110. package/build/components/template-part-converter/convert-to-template-part.js +2 -2
  111. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  112. package/build/components/template-part-converter/index.js +19 -14
  113. package/build/components/template-part-converter/index.js.map +1 -1
  114. package/build/components/use-edited-entity-record/index.js +6 -6
  115. package/build/components/use-edited-entity-record/index.js.map +1 -1
  116. package/build/index.js +13 -22
  117. package/build/index.js.map +1 -1
  118. package/build/store/actions.js +2 -2
  119. package/build/store/actions.js.map +1 -1
  120. package/build/utils/get-is-list-page.js +1 -1
  121. package/build/utils/get-is-list-page.js.map +1 -1
  122. package/build/utils/history.js +8 -2
  123. package/build/utils/history.js.map +1 -1
  124. package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
  125. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  126. package/build-module/components/add-new-template/new-template-part.js +8 -7
  127. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  128. package/build-module/components/add-new-template/new-template.js +21 -17
  129. package/build-module/components/add-new-template/new-template.js.map +1 -1
  130. package/build-module/components/app/index.js +3 -2
  131. package/build-module/components/app/index.js.map +1 -1
  132. package/build-module/components/block-editor/editor-canvas.js +2 -1
  133. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  134. package/build-module/components/editor/index.js +5 -6
  135. package/build-module/components/editor/index.js.map +1 -1
  136. package/build-module/components/global-styles/border-panel.js +21 -157
  137. package/build-module/components/global-styles/border-panel.js.map +1 -1
  138. package/build-module/components/global-styles/context-menu.js +14 -11
  139. package/build-module/components/global-styles/context-menu.js.map +1 -1
  140. package/build-module/components/global-styles/dimensions-panel.js +43 -480
  141. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  142. package/build-module/components/global-styles/duotone-panel.js +67 -0
  143. package/build-module/components/global-styles/duotone-panel.js.map +1 -0
  144. package/build-module/components/global-styles/filter-utils.js +9 -0
  145. package/build-module/components/global-styles/filter-utils.js.map +1 -0
  146. package/build-module/components/global-styles/hooks.js +11 -26
  147. package/build-module/components/global-styles/hooks.js.map +1 -1
  148. package/build-module/components/global-styles/preview.js +10 -6
  149. package/build-module/components/global-styles/preview.js.map +1 -1
  150. package/build-module/components/global-styles/screen-block-list.js +6 -8
  151. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  152. package/build-module/components/global-styles/screen-border.js +12 -3
  153. package/build-module/components/global-styles/screen-border.js.map +1 -1
  154. package/build-module/components/global-styles/screen-filters.js +33 -0
  155. package/build-module/components/global-styles/screen-filters.js.map +1 -0
  156. package/build-module/components/global-styles/screen-layout.js +11 -2
  157. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  158. package/build-module/components/global-styles/screen-root.js +2 -1
  159. package/build-module/components/global-styles/screen-root.js.map +1 -1
  160. package/build-module/components/global-styles/screen-style-variations.js +2 -1
  161. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  162. package/build-module/components/global-styles/screen-variations.js +1 -1
  163. package/build-module/components/global-styles/screen-variations.js.map +1 -1
  164. package/build-module/components/global-styles/shadow-panel.js +6 -4
  165. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  166. package/build-module/components/global-styles/typography-panel.js +2 -5
  167. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  168. package/build-module/components/global-styles/ui.js +6 -1
  169. package/build-module/components/global-styles/ui.js.map +1 -1
  170. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  171. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  172. package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
  173. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  174. package/build-module/components/keyboard-shortcuts/global.js +37 -0
  175. package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
  176. package/build-module/components/keyboard-shortcuts/index.js +65 -0
  177. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  178. package/build-module/components/keyboard-shortcuts/register.js +141 -0
  179. package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
  180. package/build-module/components/layout/index.js +10 -1
  181. package/build-module/components/layout/index.js.map +1 -1
  182. package/build-module/components/list/added-by.js +126 -138
  183. package/build-module/components/list/added-by.js.map +1 -1
  184. package/build-module/components/list/index.js +2 -1
  185. package/build-module/components/list/index.js.map +1 -1
  186. package/build-module/components/list/table.js +9 -7
  187. package/build-module/components/list/table.js.map +1 -1
  188. package/build-module/components/routes/link.js +5 -2
  189. package/build-module/components/routes/link.js.map +1 -1
  190. package/build-module/components/save-hub/index.js +68 -0
  191. package/build-module/components/save-hub/index.js.map +1 -0
  192. package/build-module/components/save-panel/index.js +8 -1
  193. package/build-module/components/save-panel/index.js.map +1 -1
  194. package/build-module/components/sidebar/index.js +24 -19
  195. package/build-module/components/sidebar/index.js.map +1 -1
  196. package/build-module/components/sidebar-button/index.js +18 -0
  197. package/build-module/components/sidebar-button/index.js.map +1 -0
  198. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  199. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  200. package/build-module/components/sidebar-navigation-screen/index.js +12 -12
  201. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  202. package/build-module/components/sidebar-navigation-screen-main/index.js +16 -16
  203. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  204. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +24 -30
  205. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  206. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +91 -14
  207. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  208. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  209. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  210. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  211. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  212. package/build-module/components/sidebar-navigation-screen-template/index.js +67 -30
  213. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  214. package/build-module/components/sidebar-navigation-screen-templates/index.js +28 -18
  215. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  216. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +13 -10
  217. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  218. package/build-module/components/site-hub/index.js +3 -1
  219. package/build-module/components/site-hub/index.js.map +1 -1
  220. package/build-module/components/style-book/index.js +152 -25
  221. package/build-module/components/style-book/index.js.map +1 -1
  222. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  223. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  224. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  225. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  226. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +65 -18
  227. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  228. package/build-module/components/template-details/index.js +5 -9
  229. package/build-module/components/template-details/index.js.map +1 -1
  230. package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
  231. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  232. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
  233. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  234. package/build-module/components/template-part-converter/index.js +20 -15
  235. package/build-module/components/template-part-converter/index.js.map +1 -1
  236. package/build-module/components/use-edited-entity-record/index.js +6 -6
  237. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  238. package/build-module/index.js +16 -23
  239. package/build-module/index.js.map +1 -1
  240. package/build-module/store/actions.js +2 -2
  241. package/build-module/store/actions.js.map +1 -1
  242. package/build-module/utils/get-is-list-page.js +1 -1
  243. package/build-module/utils/get-is-list-page.js.map +1 -1
  244. package/build-module/utils/history.js +9 -3
  245. package/build-module/utils/history.js.map +1 -1
  246. package/build-style/style-rtl.css +203 -143
  247. package/build-style/style.css +203 -143
  248. package/package.json +31 -31
  249. package/src/components/add-new-template/add-custom-template-modal.js +14 -10
  250. package/src/components/add-new-template/new-template-part.js +7 -9
  251. package/src/components/add-new-template/new-template.js +60 -38
  252. package/src/components/add-new-template/style.scss +12 -6
  253. package/src/components/app/index.js +9 -6
  254. package/src/components/block-editor/editor-canvas.js +2 -1
  255. package/src/components/block-editor/style.scss +1 -1
  256. package/src/components/editor/index.js +62 -65
  257. package/src/components/editor/style.scss +0 -6
  258. package/src/components/global-styles/border-panel.js +24 -199
  259. package/src/components/global-styles/context-menu.js +18 -12
  260. package/src/components/global-styles/dimensions-panel.js +43 -577
  261. package/src/components/global-styles/duotone-panel.js +82 -0
  262. package/src/components/global-styles/filter-utils.js +9 -0
  263. package/src/components/global-styles/hooks.js +12 -36
  264. package/src/components/global-styles/preview.js +155 -140
  265. package/src/components/global-styles/screen-block-list.js +6 -11
  266. package/src/components/global-styles/screen-border.js +10 -3
  267. package/src/components/global-styles/screen-filters.js +27 -0
  268. package/src/components/global-styles/screen-layout.js +9 -2
  269. package/src/components/global-styles/screen-root.js +1 -1
  270. package/src/components/global-styles/screen-style-variations.js +5 -1
  271. package/src/components/global-styles/screen-variations.js +0 -1
  272. package/src/components/global-styles/shadow-panel.js +4 -3
  273. package/src/components/global-styles/style.scss +10 -0
  274. package/src/components/global-styles/typography-panel.js +5 -7
  275. package/src/components/global-styles/ui.js +6 -1
  276. package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
  277. package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
  278. package/src/components/keyboard-shortcuts/global.js +35 -0
  279. package/src/components/keyboard-shortcuts/index.js +70 -0
  280. package/src/components/keyboard-shortcuts/register.js +157 -0
  281. package/src/components/layout/index.js +19 -0
  282. package/src/components/layout/style.scss +9 -4
  283. package/src/components/list/added-by.js +152 -155
  284. package/src/components/list/index.js +3 -1
  285. package/src/components/list/style.scss +5 -13
  286. package/src/components/list/table.js +11 -9
  287. package/src/components/routes/link.js +9 -2
  288. package/src/components/save-hub/index.js +78 -0
  289. package/src/components/save-hub/style.scss +15 -0
  290. package/src/components/save-panel/index.js +8 -1
  291. package/src/components/sidebar/index.js +33 -16
  292. package/src/components/sidebar/style.scss +4 -3
  293. package/src/components/sidebar-button/index.js +21 -0
  294. package/src/components/sidebar-button/style.scss +24 -0
  295. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
  296. package/src/components/sidebar-edit-mode/style.scss +16 -0
  297. package/src/components/sidebar-navigation-item/style.scss +1 -23
  298. package/src/components/sidebar-navigation-screen/index.js +37 -38
  299. package/src/components/sidebar-navigation-screen/style.scss +16 -9
  300. package/src/components/sidebar-navigation-screen-main/index.js +24 -11
  301. package/src/components/sidebar-navigation-screen-navigation-item/index.js +39 -26
  302. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +99 -12
  303. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  304. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  305. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
  306. package/src/components/sidebar-navigation-screen-template/index.js +89 -30
  307. package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
  308. package/src/components/sidebar-navigation-screen-templates/index.js +29 -14
  309. package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
  310. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -6
  311. package/src/components/site-hub/index.js +5 -1
  312. package/src/components/site-hub/style.scss +5 -1
  313. package/src/components/style-book/index.js +234 -55
  314. package/src/components/style-book/style.scss +1 -45
  315. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +28 -23
  316. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  317. package/src/components/sync-state-with-url/use-sync-path-with-url.js +77 -17
  318. package/src/components/template-details/index.js +4 -8
  319. package/src/components/template-part-converter/convert-to-regular.js +10 -17
  320. package/src/components/template-part-converter/convert-to-template-part.js +9 -16
  321. package/src/components/template-part-converter/index.js +28 -12
  322. package/src/components/use-edited-entity-record/index.js +26 -18
  323. package/src/index.js +11 -22
  324. package/src/store/actions.js +2 -2
  325. package/src/store/test/actions.js +0 -2
  326. package/src/style.scss +3 -1
  327. package/src/utils/get-is-list-page.js +1 -1
  328. package/src/utils/history.js +13 -9
  329. package/build/components/navigation-inspector/index.js +0 -161
  330. package/build/components/navigation-inspector/index.js.map +0 -1
  331. package/build/components/navigation-inspector/navigation-menu.js +0 -62
  332. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  333. package/build-module/components/navigation-inspector/index.js +0 -146
  334. package/build-module/components/navigation-inspector/index.js.map +0 -1
  335. package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
  336. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  337. package/src/components/navigation-inspector/index.js +0 -191
  338. package/src/components/navigation-inspector/navigation-menu.js +0 -66
  339. package/src/components/navigation-inspector/style.scss +0 -46
@@ -8,6 +8,10 @@ import classnames from 'classnames';
8
8
  */
9
9
  import {
10
10
  Button,
11
+ __unstableComposite as Composite,
12
+ __unstableUseCompositeState as useCompositeState,
13
+ __unstableCompositeItem as CompositeItem,
14
+ Disabled,
11
15
  TabPanel,
12
16
  createSlotFill,
13
17
  __experimentalUseSlotFills as useSlotFills,
@@ -20,24 +24,106 @@ import {
20
24
  createBlock,
21
25
  } from '@wordpress/blocks';
22
26
  import {
23
- BlockPreview,
27
+ BlockList,
24
28
  privateApis as blockEditorPrivateApis,
29
+ store as blockEditorStore,
30
+ __unstableEditorStyles as EditorStyles,
31
+ __unstableIframe as Iframe,
25
32
  } from '@wordpress/block-editor';
33
+ import { useSelect } from '@wordpress/data';
26
34
  import { closeSmall } from '@wordpress/icons';
27
- import { useResizeObserver } from '@wordpress/compose';
35
+ import {
36
+ useResizeObserver,
37
+ useFocusOnMount,
38
+ useFocusReturn,
39
+ useMergeRefs,
40
+ } from '@wordpress/compose';
28
41
  import { useMemo, memo } from '@wordpress/element';
42
+ import { ESCAPE } from '@wordpress/keycodes';
29
43
 
30
44
  /**
31
45
  * Internal dependencies
32
46
  */
33
47
  import { unlock } from '../../private-apis';
34
48
 
35
- const { useGlobalStyle } = unlock( blockEditorPrivateApis );
49
+ const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(
50
+ blockEditorPrivateApis
51
+ );
36
52
 
37
53
  const SLOT_FILL_NAME = 'EditSiteStyleBook';
38
54
  const { Slot: StyleBookSlot, Fill: StyleBookFill } =
39
55
  createSlotFill( SLOT_FILL_NAME );
40
56
 
57
+ // The content area of the Style Book is rendered within an iframe so that global styles
58
+ // are applied to elements within the entire content area. To support elements that are
59
+ // not part of the block previews, such as headings and layout for the block previews,
60
+ // additional CSS rules need to be passed into the iframe. These are hard-coded below.
61
+ // Note that button styles are unset, and then focus rules from the `Button` component are
62
+ // applied to the `button` element, targeted via `.edit-site-style-book__example`.
63
+ // This is to ensure that browser default styles for buttons are not applied to the previews.
64
+ const STYLE_BOOK_IFRAME_STYLES = `
65
+ .edit-site-style-book__examples {
66
+ max-width: 900px;
67
+ margin: 0 auto;
68
+ }
69
+
70
+ .edit-site-style-book__example {
71
+ border-radius: 2px;
72
+ cursor: pointer;
73
+ display: flex;
74
+ flex-direction: column;
75
+ gap: 40px;
76
+ margin-bottom: 40px;
77
+ padding: 16px;
78
+ width: 100%;
79
+ box-sizing: border-box;
80
+ }
81
+
82
+ .edit-site-style-book__example.is-selected {
83
+ box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
84
+ }
85
+
86
+ .edit-site-style-book__example:focus:not(:disabled) {
87
+ box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
88
+ outline: 3px solid transparent;
89
+ }
90
+
91
+ .edit-site-style-book__examples.is-wide .edit-site-style-book__example {
92
+ flex-direction: row;
93
+ }
94
+
95
+ .edit-site-style-book__example-title {
96
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
97
+ font-size: 11px;
98
+ font-weight: 500;
99
+ line-height: normal;
100
+ margin: 0;
101
+ text-align: left;
102
+ text-transform: uppercase;
103
+ }
104
+
105
+ .edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {
106
+ text-align: right;
107
+ width: 120px;
108
+ }
109
+
110
+ .edit-site-style-book__example-preview {
111
+ width: 100%;
112
+ }
113
+
114
+ .edit-site-style-book__example-preview .block-editor-block-list__insertion-point,
115
+ .edit-site-style-book__example-preview .block-list-appender {
116
+ display: none;
117
+ }
118
+
119
+ .edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {
120
+ margin-top: 0;
121
+ }
122
+ .edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {
123
+ margin-bottom: 0;
124
+ }
125
+ `;
126
+
41
127
  function getExamples() {
42
128
  // Use our own example for the Heading block so that we can show multiple
43
129
  // heading levels.
@@ -90,6 +176,9 @@ function getExamples() {
90
176
 
91
177
  function StyleBook( { isSelected, onSelect, onClose } ) {
92
178
  const [ resizeObserver, sizes ] = useResizeObserver();
179
+ const focusOnMountRef = useFocusOnMount( 'firstElement' );
180
+ const sectionFocusReturnRef = useFocusReturn();
181
+
93
182
  const [ textColor ] = useGlobalStyle( 'color.text' );
94
183
  const [ backgroundColor ] = useGlobalStyle( 'color.background' );
95
184
  const examples = useMemo( getExamples, [] );
@@ -108,8 +197,26 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
108
197
  } ) ),
109
198
  [ examples ]
110
199
  );
200
+
201
+ const originalSettings = useSelect(
202
+ ( select ) => select( blockEditorStore ).getSettings(),
203
+ []
204
+ );
205
+ const settings = useMemo(
206
+ () => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
207
+ [ originalSettings ]
208
+ );
209
+
210
+ function closeOnEscape( event ) {
211
+ if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
212
+ event.preventDefault();
213
+ onClose();
214
+ }
215
+ }
216
+
111
217
  return (
112
218
  <StyleBookFill>
219
+ { /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
113
220
  <section
114
221
  className={ classnames( 'edit-site-style-book', {
115
222
  'is-wide': sizes.width > 600,
@@ -119,6 +226,11 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
119
226
  background: backgroundColor,
120
227
  } }
121
228
  aria-label={ __( 'Style Book' ) }
229
+ onKeyDown={ closeOnEscape }
230
+ ref={ useMergeRefs( [
231
+ sectionFocusReturnRef,
232
+ focusOnMountRef,
233
+ ] ) }
122
234
  >
123
235
  { resizeObserver }
124
236
  <Button
@@ -126,18 +238,54 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
126
238
  icon={ closeSmall }
127
239
  label={ __( 'Close Style Book' ) }
128
240
  onClick={ onClose }
241
+ showTooltip={ false }
129
242
  />
130
243
  <TabPanel
131
244
  className="edit-site-style-book__tab-panel"
132
245
  tabs={ tabs }
133
246
  >
134
247
  { ( tab ) => (
135
- <Examples
136
- examples={ examples }
137
- category={ tab.name }
138
- isSelected={ isSelected }
139
- onSelect={ onSelect }
140
- />
248
+ <Iframe
249
+ className="edit-site-style-book__iframe"
250
+ head={
251
+ <>
252
+ <EditorStyles styles={ settings.styles } />
253
+ <style>
254
+ {
255
+ // Forming a "block formatting context" to prevent margin collapsing.
256
+ // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
257
+ `.is-root-container { display: flow-root; }
258
+ body { position: relative; padding: 32px !important; }` +
259
+ STYLE_BOOK_IFRAME_STYLES
260
+ }
261
+ </style>
262
+ </>
263
+ }
264
+ name="style-book-canvas"
265
+ tabIndex={ 0 }
266
+ >
267
+ { /* Filters need to be rendered before children to avoid Safari rendering issues. */ }
268
+ { settings.svgFilters }
269
+ <Examples
270
+ className={ classnames(
271
+ 'edit-site-style-book__examples',
272
+ {
273
+ 'is-wide': sizes.width > 600,
274
+ }
275
+ ) }
276
+ examples={ examples }
277
+ category={ tab.name }
278
+ label={ sprintf(
279
+ // translators: %s: Category of blocks, e.g. Text.
280
+ __(
281
+ 'Examples of blocks in the %s category'
282
+ ),
283
+ tab.title
284
+ ) }
285
+ isSelected={ isSelected }
286
+ onSelect={ onSelect }
287
+ />
288
+ </Iframe>
141
289
  ) }
142
290
  </TabPanel>
143
291
  </section>
@@ -145,52 +293,83 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
145
293
  );
146
294
  }
147
295
 
148
- const Examples = memo( ( { examples, category, isSelected, onSelect } ) => (
149
- <div className="edit-site-style-book__examples">
150
- { examples
151
- .filter( ( example ) => example.category === category )
152
- .map( ( example ) => (
153
- <Example
154
- key={ example.name }
155
- title={ example.title }
156
- blocks={ example.blocks }
157
- isSelected={ isSelected( example.name ) }
158
- onClick={ () => {
159
- onSelect( example.name );
160
- } }
161
- />
162
- ) ) }
163
- </div>
164
- ) );
165
-
166
- const Example = memo( ( { title, blocks, isSelected, onClick } ) => (
167
- <button
168
- className={ classnames( 'edit-site-style-book__example', {
169
- 'is-selected': isSelected,
170
- } ) }
171
- aria-label={ sprintf(
172
- // translators: %s: Title of a block, e.g. Heading.
173
- __( 'Open %s styles in Styles panel' ),
174
- title
175
- ) }
176
- onClick={ onClick }
177
- >
178
- <span className="edit-site-style-book__example-title">{ title }</span>
179
- <div className="edit-site-style-book__example-preview">
180
- <BlockPreview
181
- blocks={ blocks }
182
- viewportWidth={ 0 }
183
- additionalStyles={ [
184
- {
185
- css:
186
- '.wp-block:first-child { margin-top: 0; }' +
187
- '.wp-block:last-child { margin-bottom: 0; }',
188
- },
189
- ] }
190
- />
191
- </div>
192
- </button>
193
- ) );
296
+ const Examples = memo(
297
+ ( { className, examples, category, label, isSelected, onSelect } ) => {
298
+ const composite = useCompositeState( { orientation: 'vertical' } );
299
+ return (
300
+ <Composite
301
+ { ...composite }
302
+ className={ className }
303
+ aria-label={ label }
304
+ >
305
+ { examples
306
+ .filter( ( example ) => example.category === category )
307
+ .map( ( example ) => (
308
+ <Example
309
+ key={ example.name }
310
+ id={ `example-${ example.name }` }
311
+ composite={ composite }
312
+ title={ example.title }
313
+ blocks={ example.blocks }
314
+ isSelected={ isSelected( example.name ) }
315
+ onClick={ () => {
316
+ onSelect( example.name );
317
+ } }
318
+ />
319
+ ) ) }
320
+ </Composite>
321
+ );
322
+ }
323
+ );
324
+
325
+ const Example = ( { composite, id, title, blocks, isSelected, onClick } ) => {
326
+ const originalSettings = useSelect(
327
+ ( select ) => select( blockEditorStore ).getSettings(),
328
+ []
329
+ );
330
+ const settings = useMemo(
331
+ () => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
332
+ [ originalSettings ]
333
+ );
334
+
335
+ // Cache the list of blocks to avoid additional processing when the component is re-rendered.
336
+ const renderedBlocks = useMemo(
337
+ () => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),
338
+ [ blocks ]
339
+ );
340
+
341
+ return (
342
+ <CompositeItem
343
+ { ...composite }
344
+ className={ classnames( 'edit-site-style-book__example', {
345
+ 'is-selected': isSelected,
346
+ } ) }
347
+ id={ id }
348
+ aria-label={ sprintf(
349
+ // translators: %s: Title of a block, e.g. Heading.
350
+ __( 'Open %s styles in Styles panel' ),
351
+ title
352
+ ) }
353
+ onClick={ onClick }
354
+ role="button"
355
+ as="div"
356
+ >
357
+ <span className="edit-site-style-book__example-title">
358
+ { title }
359
+ </span>
360
+ <div className="edit-site-style-book__example-preview" aria-hidden>
361
+ <Disabled className="edit-site-style-book__example-preview__content">
362
+ <ExperimentalBlockEditorProvider
363
+ value={ renderedBlocks }
364
+ settings={ settings }
365
+ >
366
+ <BlockList renderAppender={ false } />
367
+ </ExperimentalBlockEditorProvider>
368
+ </Disabled>
369
+ </div>
370
+ </CompositeItem>
371
+ );
372
+ };
194
373
 
195
374
  function useHasStyleBook() {
196
375
  const fills = useSlotFills( SLOT_FILL_NAME );
@@ -26,53 +26,9 @@
26
26
  bottom: 0;
27
27
  left: 0;
28
28
  overflow: auto;
29
- padding: $grid-unit-40;
29
+ padding: 0;
30
30
  position: absolute;
31
31
  right: 0;
32
32
  top: $grid-unit-60; // Height of tabs.
33
33
  }
34
34
  }
35
-
36
- .edit-site-style-book__examples {
37
- max-width: 900px;
38
- margin: 0 auto;
39
- }
40
-
41
- .edit-site-style-book__example {
42
- background: none;
43
- border-radius: $radius-block-ui;
44
- border: none;
45
- color: inherit;
46
- cursor: pointer;
47
- display: flex;
48
- flex-direction: column;
49
- gap: $grid-unit-50;
50
- margin-bottom: $grid-unit-50;
51
- padding: $grid-unit-20;
52
- width: 100%;
53
-
54
- &.is-selected {
55
- box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
56
- }
57
-
58
- .edit-site-style-book.is-wide & {
59
- flex-direction: row;
60
- }
61
- }
62
-
63
- .edit-site-style-book__example-title {
64
- font-size: 11px;
65
- font-weight: 500;
66
- margin: 0;
67
- text-align: left;
68
- text-transform: uppercase;
69
-
70
- .edit-site-style-book.is-wide & {
71
- text-align: right;
72
- width: 120px;
73
- }
74
- }
75
-
76
- .edit-site-style-book__example-preview {
77
- width: 100%;
78
- }
@@ -12,8 +12,8 @@ import { useLocation } from '../routes';
12
12
  import { store as editSiteStore } from '../../store';
13
13
 
14
14
  export default function useInitEditedEntityFromURL() {
15
- const { params: { postId, postType, path = '/' } = {} } = useLocation();
16
- const { isRequestingSite, homepageId } = useSelect( ( select ) => {
15
+ const { params: { postId, postType } = {} } = useLocation();
16
+ const { isRequestingSite, homepageId, url } = useSelect( ( select ) => {
17
17
  const { getSite } = select( coreDataStore );
18
18
  const siteData = getSite();
19
19
 
@@ -23,6 +23,7 @@ export default function useInitEditedEntityFromURL() {
23
23
  siteData?.show_on_front === 'page'
24
24
  ? siteData.page_on_front
25
25
  : null,
26
+ url: siteData?.url,
26
27
  };
27
28
  }, [] );
28
29
 
@@ -30,33 +31,37 @@ export default function useInitEditedEntityFromURL() {
30
31
  useDispatch( editSiteStore );
31
32
 
32
33
  useEffect( () => {
33
- switch ( path ) {
34
- case '/templates/single':
35
- setTemplate( postId );
36
- break;
37
- case '/template-parts/single':
38
- setTemplatePart( postId );
39
- break;
40
- case '/navigation/single':
41
- setPage( {
42
- context: { postType, postId },
43
- } );
44
- break;
45
- default: {
46
- if ( homepageId ) {
34
+ if ( postType && postId ) {
35
+ switch ( postType ) {
36
+ case 'wp_template':
37
+ setTemplate( postId );
38
+ break;
39
+ case 'wp_template_part':
40
+ setTemplatePart( postId );
41
+ break;
42
+ default:
47
43
  setPage( {
48
- context: { postType: 'page', postId: homepageId },
44
+ context: { postType, postId },
49
45
  } );
50
- } else if ( ! isRequestingSite ) {
51
- setPage( {
52
- path: '/',
53
- } );
54
- }
55
46
  }
47
+
48
+ return;
49
+ }
50
+
51
+ // In all other cases, we need to set the home page in the site editor view.
52
+ if ( homepageId ) {
53
+ setPage( {
54
+ context: { postType: 'page', postId: homepageId },
55
+ } );
56
+ } else if ( ! isRequestingSite ) {
57
+ setPage( {
58
+ path: url,
59
+ } );
56
60
  }
57
61
  }, [
58
- path,
62
+ url,
59
63
  postId,
64
+ postType,
60
65
  homepageId,
61
66
  isRequestingSite,
62
67
  setPage,
@@ -20,22 +20,52 @@ export default function useSyncCanvasModeWithURL() {
20
20
  );
21
21
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
22
22
  const currentCanvasMode = useRef( canvasMode );
23
- const { canvas: canvasInUrl = 'view' } = params;
23
+ const { canvas: canvasInUrl } = params;
24
24
  const currentCanvasInUrl = useRef( canvasInUrl );
25
+ const currentUrlParams = useRef( params );
26
+ useEffect( () => {
27
+ currentUrlParams.current = params;
28
+ }, [ params ] );
29
+
25
30
  useEffect( () => {
26
31
  currentCanvasMode.current = canvasMode;
27
- if ( currentCanvasMode !== currentCanvasInUrl ) {
32
+ if ( canvasMode === 'init' ) {
33
+ return;
34
+ }
35
+
36
+ if (
37
+ canvasMode === 'edit' &&
38
+ currentCanvasInUrl.current !== canvasMode
39
+ ) {
40
+ history.push( {
41
+ ...currentUrlParams.current,
42
+ canvas: 'edit',
43
+ } );
44
+ }
45
+
46
+ if (
47
+ canvasMode === 'view' &&
48
+ currentCanvasInUrl.current !== undefined
49
+ ) {
28
50
  history.push( {
29
- ...params,
30
- canvas: canvasMode,
51
+ ...currentUrlParams.current,
52
+ canvas: undefined,
31
53
  } );
32
54
  }
33
- }, [ canvasMode ] );
55
+ }, [ canvasMode, history ] );
34
56
 
35
57
  useEffect( () => {
36
58
  currentCanvasInUrl.current = canvasInUrl;
37
- if ( canvasInUrl !== currentCanvasMode.current ) {
38
- setCanvasMode( canvasInUrl );
59
+ if (
60
+ canvasInUrl === undefined &&
61
+ currentCanvasMode.current !== 'view'
62
+ ) {
63
+ setCanvasMode( 'view' );
64
+ } else if (
65
+ canvasInUrl === 'edit' &&
66
+ currentCanvasMode.current !== 'edit'
67
+ ) {
68
+ setCanvasMode( 'edit' );
39
69
  }
40
- }, [ canvasInUrl ] );
70
+ }, [ canvasInUrl, setCanvasMode ] );
41
71
  }
@@ -9,28 +9,88 @@ import { useEffect, useRef } from '@wordpress/element';
9
9
  */
10
10
  import { useLocation, useHistory } from '../routes';
11
11
 
12
+ export function getPathFromURL( urlParams ) {
13
+ let path = urlParams?.path ?? '/';
14
+
15
+ // Compute the navigator path based on the URL params.
16
+ if ( urlParams?.postType && urlParams?.postId ) {
17
+ switch ( urlParams.postType ) {
18
+ case 'wp_template':
19
+ case 'wp_template_part':
20
+ path = `/${ encodeURIComponent(
21
+ urlParams.postType
22
+ ) }/${ encodeURIComponent( urlParams.postId ) }`;
23
+ break;
24
+ default:
25
+ path = `/navigation/${ encodeURIComponent(
26
+ urlParams.postType
27
+ ) }/${ encodeURIComponent( urlParams.postId ) }`;
28
+ }
29
+ }
30
+
31
+ return path;
32
+ }
33
+
12
34
  export default function useSyncPathWithURL() {
13
35
  const history = useHistory();
14
- const { params } = useLocation();
15
- const { path = '/' } = params;
16
- const { location, goTo } = useNavigator();
17
- const currentPath = useRef( path );
18
- const currentNavigatorLocation = useRef( location.path );
36
+ const { params: urlParams } = useLocation();
37
+ const {
38
+ location: navigatorLocation,
39
+ params: navigatorParams,
40
+ goTo,
41
+ } = useNavigator();
42
+ const currentUrlParams = useRef( urlParams );
43
+ const currentPath = useRef( navigatorLocation.path );
44
+ const isMounting = useRef( true );
45
+
19
46
  useEffect( () => {
20
- currentPath.current = path;
21
- if ( path !== currentNavigatorLocation.current ) {
22
- goTo( path );
47
+ // The navigatorParams are only initially filled properly when the
48
+ // navigator screens mount. so we ignore the first synchronisation.
49
+ if ( isMounting.current ) {
50
+ isMounting.current = false;
51
+ return;
23
52
  }
24
- }, [ path ] );
25
- useEffect( () => {
26
- currentNavigatorLocation.current = location.path;
27
- if ( location.path !== currentPath.current ) {
28
- history.push( {
29
- ...params,
30
- path: location.path,
53
+
54
+ function updateUrlParams( newUrlParams ) {
55
+ if (
56
+ Object.entries( newUrlParams ).every( ( [ key, value ] ) => {
57
+ return currentUrlParams.current[ key ] === value;
58
+ } )
59
+ ) {
60
+ return;
61
+ }
62
+ const updatedParams = {
63
+ ...currentUrlParams.current,
64
+ ...newUrlParams,
65
+ };
66
+ currentUrlParams.current = updatedParams;
67
+ history.push( updatedParams );
68
+ }
69
+
70
+ if ( navigatorParams?.postType && navigatorParams?.postId ) {
71
+ updateUrlParams( {
72
+ postType: navigatorParams?.postType,
73
+ postId: navigatorParams?.postId,
74
+ path: undefined,
75
+ } );
76
+ } else {
77
+ updateUrlParams( {
78
+ postType: undefined,
79
+ postId: undefined,
80
+ path:
81
+ navigatorLocation.path === '/'
82
+ ? undefined
83
+ : navigatorLocation.path,
31
84
  } );
32
85
  }
33
- }, [ location.path, history ] );
86
+ }, [ navigatorLocation?.path, navigatorParams, history ] );
34
87
 
35
- return path;
88
+ useEffect( () => {
89
+ currentUrlParams.current = urlParams;
90
+ const path = getPathFromURL( urlParams );
91
+ if ( currentPath.current !== path ) {
92
+ currentPath.current = path;
93
+ goTo( path );
94
+ }
95
+ }, [ urlParams, goTo ] );
36
96
  }