@wordpress/edit-site 4.19.0 → 5.1.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 (382) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +1 -0
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/index.js +8 -5
  5. package/build/components/add-new-template/index.js.map +1 -1
  6. package/build/components/add-new-template/new-template-part.js +21 -6
  7. package/build/components/add-new-template/new-template-part.js.map +1 -1
  8. package/build/components/add-new-template/new-template.js +12 -8
  9. package/build/components/add-new-template/new-template.js.map +1 -1
  10. package/build/components/app/index.js +15 -30
  11. package/build/components/app/index.js.map +1 -1
  12. package/build/components/block-editor/editor-canvas.js +64 -0
  13. package/build/components/block-editor/editor-canvas.js.map +1 -0
  14. package/build/components/block-editor/index.js +62 -59
  15. package/build/components/block-editor/index.js.map +1 -1
  16. package/build/components/block-editor/resizable-editor.js +10 -44
  17. package/build/components/block-editor/resizable-editor.js.map +1 -1
  18. package/build/components/editor/index.js +76 -135
  19. package/build/components/editor/index.js.map +1 -1
  20. package/build/components/global-styles/block-preview-panel.js +57 -0
  21. package/build/components/global-styles/block-preview-panel.js.map +1 -0
  22. package/build/components/global-styles/border-panel.js +0 -1
  23. package/build/components/global-styles/border-panel.js.map +1 -1
  24. package/build/components/global-styles/context-menu.js +6 -2
  25. package/build/components/global-styles/context-menu.js.map +1 -1
  26. package/build/components/global-styles/custom-css.js +62 -0
  27. package/build/components/global-styles/custom-css.js.map +1 -0
  28. package/build/components/global-styles/dimensions-panel.js +2 -6
  29. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  30. package/build/components/global-styles/global-styles-provider.js +18 -4
  31. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  32. package/build/components/global-styles/hooks.js +5 -2
  33. package/build/components/global-styles/hooks.js.map +1 -1
  34. package/build/components/global-styles/palette.js +1 -1
  35. package/build/components/global-styles/palette.js.map +1 -1
  36. package/build/components/global-styles/screen-background-color.js +0 -1
  37. package/build/components/global-styles/screen-background-color.js.map +1 -1
  38. package/build/components/global-styles/screen-block-list.js +2 -1
  39. package/build/components/global-styles/screen-block-list.js.map +1 -1
  40. package/build/components/global-styles/screen-block.js +5 -1
  41. package/build/components/global-styles/screen-block.js.map +1 -1
  42. package/build/components/global-styles/screen-border.js +47 -0
  43. package/build/components/global-styles/screen-border.js.map +1 -0
  44. package/build/components/global-styles/screen-button-color.js +0 -2
  45. package/build/components/global-styles/screen-button-color.js.map +1 -1
  46. package/build/components/global-styles/screen-colors.js +5 -1
  47. package/build/components/global-styles/screen-colors.js.map +1 -1
  48. package/build/components/global-styles/screen-css.js +42 -0
  49. package/build/components/global-styles/screen-css.js.map +1 -0
  50. package/build/components/global-styles/screen-heading-color.js +1 -3
  51. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  52. package/build/components/global-styles/screen-layout.js +4 -5
  53. package/build/components/global-styles/screen-layout.js.map +1 -1
  54. package/build/components/global-styles/screen-link-color.js +0 -1
  55. package/build/components/global-styles/screen-link-color.js.map +1 -1
  56. package/build/components/global-styles/screen-root.js +20 -2
  57. package/build/components/global-styles/screen-root.js.map +1 -1
  58. package/build/components/global-styles/screen-style-variations.js +3 -3
  59. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  60. package/build/components/global-styles/screen-text-color.js +0 -1
  61. package/build/components/global-styles/screen-text-color.js.map +1 -1
  62. package/build/components/global-styles/screen-typography.js +4 -0
  63. package/build/components/global-styles/screen-typography.js.map +1 -1
  64. package/build/components/global-styles/typography-utils.js +17 -5
  65. package/build/components/global-styles/typography-utils.js.map +1 -1
  66. package/build/components/global-styles/ui.js +50 -4
  67. package/build/components/global-styles/ui.js.map +1 -1
  68. package/build/components/global-styles/use-global-styles-output.js +5 -1
  69. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  70. package/build/components/global-styles/utils.js +14 -4
  71. package/build/components/global-styles/utils.js.map +1 -1
  72. package/build/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -8
  73. package/build/components/global-styles-renderer/index.js.map +1 -0
  74. package/build/components/header-edit-mode/document-actions/index.js +21 -45
  75. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  76. package/build/components/header-edit-mode/index.js +19 -12
  77. package/build/components/header-edit-mode/index.js.map +1 -1
  78. package/build/components/keyboard-shortcuts/index.js +11 -1
  79. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  80. package/build/components/layout/index.js +200 -0
  81. package/build/components/layout/index.js.map +1 -0
  82. package/build/components/list/header.js +5 -1
  83. package/build/components/list/header.js.map +1 -1
  84. package/build/components/list/index.js +4 -22
  85. package/build/components/list/index.js.map +1 -1
  86. package/build/components/navigate-to-link/index.js +1 -3
  87. package/build/components/navigate-to-link/index.js.map +1 -1
  88. package/build/components/routes/index.js +1 -1
  89. package/build/components/routes/index.js.map +1 -1
  90. package/build/components/sidebar/index.js +46 -0
  91. package/build/components/sidebar/index.js.map +1 -0
  92. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +24 -4
  93. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  94. package/build/components/sidebar-edit-mode/index.js +4 -2
  95. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  96. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
  97. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  98. package/build/components/sidebar-navigation-item/index.js +53 -0
  99. package/build/components/sidebar-navigation-item/index.js.map +1 -0
  100. package/build/components/sidebar-navigation-screen/index.js +49 -0
  101. package/build/components/sidebar-navigation-screen/index.js.map +1 -0
  102. package/build/components/sidebar-navigation-screen-main/index.js +46 -0
  103. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -0
  104. package/build/components/sidebar-navigation-screen-templates/index.js +169 -0
  105. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -0
  106. package/build/components/site-hub/index.js +149 -0
  107. package/build/components/site-hub/index.js.map +1 -0
  108. package/build/components/site-icon/index.js +70 -0
  109. package/build/components/site-icon/index.js.map +1 -0
  110. package/build/components/style-book/index.js +173 -0
  111. package/build/components/style-book/index.js.map +1 -0
  112. package/build/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +5 -4
  113. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
  114. package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +53 -0
  115. package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
  116. package/build/components/use-edited-entity-record/index.js +60 -0
  117. package/build/components/use-edited-entity-record/index.js.map +1 -0
  118. package/build/hooks/index.js +2 -0
  119. package/build/hooks/index.js.map +1 -1
  120. package/build/hooks/push-changes-to-global-styles/index.js +144 -0
  121. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -0
  122. package/build/index.js +7 -45
  123. package/build/index.js.map +1 -1
  124. package/build/store/actions.js +93 -43
  125. package/build/store/actions.js.map +1 -1
  126. package/build/store/reducer.js +35 -107
  127. package/build/store/reducer.js.map +1 -1
  128. package/build/store/selectors.js +69 -78
  129. package/build/store/selectors.js.map +1 -1
  130. package/build-module/components/add-new-template/add-custom-template-modal.js +1 -0
  131. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  132. package/build-module/components/add-new-template/index.js +7 -5
  133. package/build-module/components/add-new-template/index.js.map +1 -1
  134. package/build-module/components/add-new-template/new-template-part.js +18 -6
  135. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  136. package/build-module/components/add-new-template/new-template.js +13 -9
  137. package/build-module/components/add-new-template/new-template.js.map +1 -1
  138. package/build-module/components/app/index.js +15 -28
  139. package/build-module/components/app/index.js.map +1 -1
  140. package/build-module/components/block-editor/editor-canvas.js +51 -0
  141. package/build-module/components/block-editor/editor-canvas.js.map +1 -0
  142. package/build-module/components/block-editor/index.js +62 -60
  143. package/build-module/components/block-editor/index.js.map +1 -1
  144. package/build-module/components/block-editor/resizable-editor.js +11 -40
  145. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  146. package/build-module/components/editor/index.js +75 -129
  147. package/build-module/components/editor/index.js.map +1 -1
  148. package/build-module/components/global-styles/block-preview-panel.js +46 -0
  149. package/build-module/components/global-styles/block-preview-panel.js.map +1 -0
  150. package/build-module/components/global-styles/border-panel.js +0 -1
  151. package/build-module/components/global-styles/border-panel.js.map +1 -1
  152. package/build-module/components/global-styles/context-menu.js +7 -3
  153. package/build-module/components/global-styles/context-menu.js.map +1 -1
  154. package/build-module/components/global-styles/custom-css.js +52 -0
  155. package/build-module/components/global-styles/custom-css.js.map +1 -0
  156. package/build-module/components/global-styles/dimensions-panel.js +3 -7
  157. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  158. package/build-module/components/global-styles/global-styles-provider.js +18 -4
  159. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  160. package/build-module/components/global-styles/hooks.js +5 -3
  161. package/build-module/components/global-styles/hooks.js.map +1 -1
  162. package/build-module/components/global-styles/palette.js +1 -1
  163. package/build-module/components/global-styles/palette.js.map +1 -1
  164. package/build-module/components/global-styles/screen-background-color.js +0 -1
  165. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  166. package/build-module/components/global-styles/screen-block-list.js +2 -1
  167. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  168. package/build-module/components/global-styles/screen-block.js +4 -1
  169. package/build-module/components/global-styles/screen-block.js.map +1 -1
  170. package/build-module/components/global-styles/screen-border.js +30 -0
  171. package/build-module/components/global-styles/screen-border.js.map +1 -0
  172. package/build-module/components/global-styles/screen-button-color.js +0 -2
  173. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  174. package/build-module/components/global-styles/screen-colors.js +4 -1
  175. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  176. package/build-module/components/global-styles/screen-css.js +28 -0
  177. package/build-module/components/global-styles/screen-css.js.map +1 -0
  178. package/build-module/components/global-styles/screen-heading-color.js +1 -3
  179. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  180. package/build-module/components/global-styles/screen-layout.js +3 -4
  181. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  182. package/build-module/components/global-styles/screen-link-color.js +0 -1
  183. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  184. package/build-module/components/global-styles/screen-root.js +21 -3
  185. package/build-module/components/global-styles/screen-root.js.map +1 -1
  186. package/build-module/components/global-styles/screen-style-variations.js +2 -2
  187. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  188. package/build-module/components/global-styles/screen-text-color.js +0 -1
  189. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  190. package/build-module/components/global-styles/screen-typography.js +3 -0
  191. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  192. package/build-module/components/global-styles/typography-utils.js +17 -5
  193. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  194. package/build-module/components/global-styles/ui.js +48 -5
  195. package/build-module/components/global-styles/ui.js.map +1 -1
  196. package/build-module/components/global-styles/use-global-styles-output.js +5 -1
  197. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  198. package/build-module/components/global-styles/utils.js +13 -5
  199. package/build-module/components/global-styles/utils.js.map +1 -1
  200. package/build-module/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -7
  201. package/build-module/components/global-styles-renderer/index.js.map +1 -0
  202. package/build-module/components/header-edit-mode/document-actions/index.js +22 -43
  203. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  204. package/build-module/components/header-edit-mode/index.js +16 -11
  205. package/build-module/components/header-edit-mode/index.js.map +1 -1
  206. package/build-module/components/keyboard-shortcuts/index.js +10 -1
  207. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  208. package/build-module/components/layout/index.js +173 -0
  209. package/build-module/components/layout/index.js.map +1 -0
  210. package/build-module/components/list/header.js +5 -1
  211. package/build-module/components/list/header.js.map +1 -1
  212. package/build-module/components/list/index.js +4 -19
  213. package/build-module/components/list/index.js.map +1 -1
  214. package/build-module/components/navigate-to-link/index.js +1 -3
  215. package/build-module/components/navigate-to-link/index.js.map +1 -1
  216. package/build-module/components/routes/index.js +1 -1
  217. package/build-module/components/routes/index.js.map +1 -1
  218. package/build-module/components/sidebar/index.js +33 -0
  219. package/build-module/components/sidebar/index.js.map +1 -0
  220. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +27 -7
  221. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  222. package/build-module/components/sidebar-edit-mode/index.js +6 -4
  223. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  224. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +11 -1
  225. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  226. package/build-module/components/sidebar-navigation-item/index.js +40 -0
  227. package/build-module/components/sidebar-navigation-item/index.js.map +1 -0
  228. package/build-module/components/sidebar-navigation-screen/index.js +39 -0
  229. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -0
  230. package/build-module/components/sidebar-navigation-screen-main/index.js +32 -0
  231. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -0
  232. package/build-module/components/sidebar-navigation-screen-templates/index.js +147 -0
  233. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -0
  234. package/build-module/components/site-hub/index.js +126 -0
  235. package/build-module/components/site-hub/index.js.map +1 -0
  236. package/build-module/components/site-icon/index.js +55 -0
  237. package/build-module/components/site-icon/index.js.map +1 -0
  238. package/build-module/components/style-book/index.js +156 -0
  239. package/build-module/components/style-book/index.js.map +1 -0
  240. package/build-module/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +4 -3
  241. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
  242. package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +43 -0
  243. package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
  244. package/build-module/components/use-edited-entity-record/index.js +48 -0
  245. package/build-module/components/use-edited-entity-record/index.js.map +1 -0
  246. package/build-module/hooks/index.js +1 -0
  247. package/build-module/hooks/index.js.map +1 -1
  248. package/build-module/hooks/push-changes-to-global-styles/index.js +132 -0
  249. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -0
  250. package/build-module/index.js +9 -36
  251. package/build-module/index.js.map +1 -1
  252. package/build-module/store/actions.js +87 -42
  253. package/build-module/store/actions.js.map +1 -1
  254. package/build-module/store/reducer.js +35 -102
  255. package/build-module/store/reducer.js.map +1 -1
  256. package/build-module/store/selectors.js +60 -72
  257. package/build-module/store/selectors.js.map +1 -1
  258. package/build-style/style-rtl.css +549 -352
  259. package/build-style/style.css +549 -352
  260. package/package.json +33 -31
  261. package/src/components/add-new-template/add-custom-template-modal.js +1 -0
  262. package/src/components/add-new-template/index.js +6 -3
  263. package/src/components/add-new-template/new-template-part.js +15 -3
  264. package/src/components/add-new-template/new-template.js +14 -7
  265. package/src/components/add-new-template/style.scss +0 -4
  266. package/src/components/app/index.js +14 -43
  267. package/src/components/block-editor/editor-canvas.js +69 -0
  268. package/src/components/block-editor/index.js +100 -87
  269. package/src/components/block-editor/resizable-editor.js +9 -64
  270. package/src/components/block-editor/style.scss +25 -1
  271. package/src/components/code-editor/style.scss +1 -1
  272. package/src/components/editor/index.js +157 -238
  273. package/src/components/editor/style.scss +0 -22
  274. package/src/components/global-styles/block-preview-panel.js +44 -0
  275. package/src/components/global-styles/border-panel.js +0 -1
  276. package/src/components/global-styles/context-menu.js +11 -2
  277. package/src/components/global-styles/custom-css.js +74 -0
  278. package/src/components/global-styles/dimensions-panel.js +2 -5
  279. package/src/components/global-styles/global-styles-provider.js +50 -22
  280. package/src/components/global-styles/hooks.js +8 -3
  281. package/src/components/global-styles/palette.js +1 -1
  282. package/src/components/global-styles/screen-background-color.js +0 -1
  283. package/src/components/global-styles/screen-block-list.js +2 -1
  284. package/src/components/global-styles/screen-block.js +6 -1
  285. package/src/components/global-styles/screen-border.js +25 -0
  286. package/src/components/global-styles/screen-button-color.js +0 -2
  287. package/src/components/global-styles/screen-colors.js +5 -1
  288. package/src/components/global-styles/screen-css.js +33 -0
  289. package/src/components/global-styles/screen-heading-color.js +1 -3
  290. package/src/components/global-styles/screen-layout.js +2 -3
  291. package/src/components/global-styles/screen-link-color.js +0 -1
  292. package/src/components/global-styles/screen-root.js +37 -1
  293. package/src/components/global-styles/screen-style-variations.js +5 -2
  294. package/src/components/global-styles/screen-text-color.js +0 -1
  295. package/src/components/global-styles/screen-typography.js +3 -0
  296. package/src/components/global-styles/style.scss +31 -2
  297. package/src/components/global-styles/test/typography-utils.js +72 -23
  298. package/src/components/global-styles/typography-utils.js +24 -4
  299. package/src/components/global-styles/ui.js +47 -4
  300. package/src/components/global-styles/use-global-styles-output.js +5 -0
  301. package/src/components/global-styles/utils.js +18 -6
  302. package/src/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +3 -9
  303. package/src/components/header-edit-mode/document-actions/index.js +31 -45
  304. package/src/components/header-edit-mode/document-actions/style.scss +8 -1
  305. package/src/components/header-edit-mode/index.js +96 -78
  306. package/src/components/header-edit-mode/style.scss +6 -33
  307. package/src/components/keyboard-shortcuts/index.js +13 -0
  308. package/src/components/layout/index.js +235 -0
  309. package/src/components/layout/style.scss +183 -0
  310. package/src/components/list/header.js +5 -1
  311. package/src/components/list/index.js +12 -31
  312. package/src/components/list/style.scss +3 -4
  313. package/src/components/navigate-to-link/index.js +2 -8
  314. package/src/components/routes/index.js +1 -1
  315. package/src/components/sidebar/index.js +37 -0
  316. package/src/components/sidebar/style.scss +8 -0
  317. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +42 -7
  318. package/src/components/sidebar-edit-mode/index.js +4 -4
  319. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
  320. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +21 -3
  321. package/src/components/sidebar-edit-mode/settings-header/style.scss +47 -34
  322. package/src/components/sidebar-edit-mode/style.scss +0 -13
  323. package/src/components/sidebar-navigation-item/index.js +51 -0
  324. package/src/components/sidebar-navigation-item/style.scss +17 -0
  325. package/src/components/sidebar-navigation-screen/index.js +55 -0
  326. package/src/components/sidebar-navigation-screen/style.scss +39 -0
  327. package/src/components/sidebar-navigation-screen-main/index.js +44 -0
  328. package/src/components/sidebar-navigation-screen-templates/index.js +163 -0
  329. package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
  330. package/src/components/site-hub/index.js +150 -0
  331. package/src/components/site-hub/style.scss +31 -0
  332. package/src/components/site-icon/index.js +56 -0
  333. package/src/components/site-icon/style.scss +10 -0
  334. package/src/components/style-book/index.js +193 -0
  335. package/src/components/style-book/style.scss +78 -0
  336. package/src/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +3 -3
  337. package/src/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +36 -0
  338. package/src/components/template-details/style.scss +4 -0
  339. package/src/components/use-edited-entity-record/index.js +37 -0
  340. package/src/hooks/index.js +1 -0
  341. package/src/hooks/push-changes-to-global-styles/index.js +162 -0
  342. package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
  343. package/src/index.js +5 -53
  344. package/src/store/actions.js +93 -48
  345. package/src/store/reducer.js +29 -91
  346. package/src/store/selectors.js +61 -101
  347. package/src/store/test/actions.js +3 -15
  348. package/src/store/test/reducer.js +8 -192
  349. package/src/store/test/selectors.js +3 -42
  350. package/src/style.scss +21 -3
  351. package/build/components/editor/global-styles-renderer.js.map +0 -1
  352. package/build/components/navigation-sidebar/index.js +0 -62
  353. package/build/components/navigation-sidebar/index.js.map +0 -1
  354. package/build/components/navigation-sidebar/navigation-panel/constants.js +0 -77
  355. package/build/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
  356. package/build/components/navigation-sidebar/navigation-panel/index.js +0 -152
  357. package/build/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
  358. package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
  359. package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
  360. package/build/components/navigation-sidebar/navigation-toggle/index.js +0 -124
  361. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
  362. package/build/components/url-query-controller/index.js.map +0 -1
  363. package/build-module/components/editor/global-styles-renderer.js.map +0 -1
  364. package/build-module/components/navigation-sidebar/index.js +0 -45
  365. package/build-module/components/navigation-sidebar/index.js.map +0 -1
  366. package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -49
  367. package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
  368. package/build-module/components/navigation-sidebar/navigation-panel/index.js +0 -131
  369. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
  370. package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -66
  371. package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
  372. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +0 -108
  373. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
  374. package/build-module/components/url-query-controller/index.js.map +0 -1
  375. package/src/components/navigation-sidebar/index.js +0 -46
  376. package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -94
  377. package/src/components/navigation-sidebar/navigation-panel/index.js +0 -142
  378. package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -152
  379. package/src/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
  380. package/src/components/navigation-sidebar/navigation-toggle/index.js +0 -114
  381. package/src/components/navigation-sidebar/navigation-toggle/style.scss +0 -71
  382. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +0 -65
@@ -1,3 +1,6 @@
1
+ // Variables
2
+ $block-preview-height: 150px;
3
+
1
4
  .edit-site-global-styles-preview {
2
5
  display: flex;
3
6
  align-items: center;
@@ -28,7 +31,8 @@
28
31
  }
29
32
 
30
33
  .edit-site-global-styles-screen-heading-color,
31
- .edit-site-global-styles-screen-typography {
34
+ .edit-site-global-styles-screen-typography,
35
+ .edit-site-global-styles-screen-css {
32
36
  margin: $grid-unit-20;
33
37
  }
34
38
 
@@ -52,8 +56,12 @@
52
56
  }
53
57
  }
54
58
 
55
- .edit-site-global-styles-header__description,
59
+ .edit-site-global-styles-header__description {
60
+ padding: 0 $grid-unit-20;
61
+ }
62
+
56
63
  .edit-site-block-types-search {
64
+ margin-bottom: $grid-unit-10;
57
65
  padding: 0 $grid-unit-20;
58
66
  }
59
67
 
@@ -117,3 +125,24 @@
117
125
  overflow: hidden;
118
126
  text-overflow: ellipsis;
119
127
  }
128
+
129
+ .edit-site-global-styles__block-preview-panel {
130
+ position: relative;
131
+ width: 100%;
132
+ height: $block-preview-height + 2 * $border-width;
133
+ overflow: auto;
134
+ border: $gray-200 $border-width solid;
135
+ border-radius: $radius-block-ui;
136
+ }
137
+
138
+ .edit-site-global-styles__custom-css-input textarea {
139
+ font-family: $editor_html_font;
140
+ }
141
+
142
+ .edit-site-global-styles__custom-css-theme-css {
143
+ width: 100%;
144
+ line-break: anywhere;
145
+ white-space: break-spaces;
146
+ max-height: 200px;
147
+ overflow-y: scroll;
148
+ }
@@ -7,7 +7,8 @@ describe( 'typography utils', () => {
7
7
  describe( 'getTypographyFontSizeValue', () => {
8
8
  [
9
9
  {
10
- message: 'returns value when fluid typography is deactivated',
10
+ message:
11
+ 'should return value when fluid typography is not active',
11
12
  preset: {
12
13
  size: '28px',
13
14
  },
@@ -16,7 +17,7 @@ describe( 'typography utils', () => {
16
17
  },
17
18
 
18
19
  {
19
- message: 'returns value where font size is 0',
20
+ message: 'should return value where font size is 0',
20
21
  preset: {
21
22
  size: 0,
22
23
  },
@@ -25,7 +26,7 @@ describe( 'typography utils', () => {
25
26
  },
26
27
 
27
28
  {
28
- message: "returns value where font size is '0'",
29
+ message: "should return value where font size is '0'",
29
30
  preset: {
30
31
  size: '0',
31
32
  },
@@ -34,7 +35,7 @@ describe( 'typography utils', () => {
34
35
  },
35
36
 
36
37
  {
37
- message: 'returns value where `size` is `null`.',
38
+ message: 'should return value where `size` is `null`.',
38
39
  preset: {
39
40
  size: null,
40
41
  },
@@ -43,7 +44,7 @@ describe( 'typography utils', () => {
43
44
  },
44
45
 
45
46
  {
46
- message: 'returns value when fluid is `false`',
47
+ message: 'should return value when fluid is `false`',
47
48
  preset: {
48
49
  size: '28px',
49
50
  fluid: false,
@@ -55,7 +56,7 @@ describe( 'typography utils', () => {
55
56
  },
56
57
 
57
58
  {
58
- message: 'returns already clamped value',
59
+ message: 'should return already clamped value',
59
60
  preset: {
60
61
  size: 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
61
62
  fluid: false,
@@ -68,7 +69,7 @@ describe( 'typography utils', () => {
68
69
  },
69
70
 
70
71
  {
71
- message: 'returns value with unsupported unit',
72
+ message: 'should return value with unsupported unit',
72
73
  preset: {
73
74
  size: '1000%',
74
75
  fluid: false,
@@ -80,7 +81,7 @@ describe( 'typography utils', () => {
80
81
  },
81
82
 
82
83
  {
83
- message: 'returns clamp value with rem min and max units',
84
+ message: 'should return clamp value with rem min and max units',
84
85
  preset: {
85
86
  size: '1.75rem',
86
87
  },
@@ -92,7 +93,7 @@ describe( 'typography utils', () => {
92
93
  },
93
94
 
94
95
  {
95
- message: 'returns clamp value with eem min and max units',
96
+ message: 'should return clamp value with eem min and max units',
96
97
  preset: {
97
98
  size: '1.75em',
98
99
  },
@@ -104,7 +105,7 @@ describe( 'typography utils', () => {
104
105
  },
105
106
 
106
107
  {
107
- message: 'returns clamp value for floats',
108
+ message: 'should return clamp value for floats',
108
109
  preset: {
109
110
  size: '100.175px',
110
111
  },
@@ -116,7 +117,8 @@ describe( 'typography utils', () => {
116
117
  },
117
118
 
118
119
  {
119
- message: 'coerces integer to `px` and returns clamp value',
120
+ message:
121
+ 'should coerce integer to `px` and returns clamp value',
120
122
  preset: {
121
123
  size: 33,
122
124
  fluid: true,
@@ -129,7 +131,7 @@ describe( 'typography utils', () => {
129
131
  },
130
132
 
131
133
  {
132
- message: 'coerces float to `px` and returns clamp value',
134
+ message: 'should coerce float to `px` and returns clamp value',
133
135
  preset: {
134
136
  size: 100.23,
135
137
  fluid: true,
@@ -142,7 +144,8 @@ describe( 'typography utils', () => {
142
144
  },
143
145
 
144
146
  {
145
- message: 'returns clamp value when `fluid` is empty array',
147
+ message:
148
+ 'should return clamp value when `fluid` is empty array',
146
149
  preset: {
147
150
  size: '28px',
148
151
  fluid: [],
@@ -155,7 +158,7 @@ describe( 'typography utils', () => {
155
158
  },
156
159
 
157
160
  {
158
- message: 'returns clamp value when `fluid` is `null`',
161
+ message: 'should return clamp value when `fluid` is `null`',
159
162
  preset: {
160
163
  size: '28px',
161
164
  fluid: null,
@@ -169,7 +172,7 @@ describe( 'typography utils', () => {
169
172
 
170
173
  {
171
174
  message:
172
- 'returns clamp value if min font size is greater than max',
175
+ 'should return clamp value if min font size is greater than max',
173
176
  preset: {
174
177
  size: '3rem',
175
178
  fluid: {
@@ -185,7 +188,7 @@ describe( 'typography utils', () => {
185
188
  },
186
189
 
187
190
  {
188
- message: 'returns value with invalid min/max fluid units',
191
+ message: 'should return value with invalid min/max fluid units',
189
192
  preset: {
190
193
  size: '10em',
191
194
  fluid: {
@@ -201,7 +204,7 @@ describe( 'typography utils', () => {
201
204
 
202
205
  {
203
206
  message:
204
- 'returns value when size is < lower bounds and no fluid min/max set',
207
+ 'should return value when size is < lower bounds and no fluid min/max set',
205
208
  preset: {
206
209
  size: '3px',
207
210
  },
@@ -213,7 +216,7 @@ describe( 'typography utils', () => {
213
216
 
214
217
  {
215
218
  message:
216
- 'returns value when size is equal to lower bounds and no fluid min/max set',
219
+ 'should return value when size is equal to lower bounds and no fluid min/max set',
217
220
  preset: {
218
221
  size: '14px',
219
222
  },
@@ -224,7 +227,8 @@ describe( 'typography utils', () => {
224
227
  },
225
228
 
226
229
  {
227
- message: 'returns clamp value with different min max units',
230
+ message:
231
+ 'should return clamp value with different min max units',
228
232
  preset: {
229
233
  size: '28px',
230
234
  fluid: {
@@ -240,7 +244,8 @@ describe( 'typography utils', () => {
240
244
  },
241
245
 
242
246
  {
243
- message: 'returns clamp value where no fluid max size is set',
247
+ message:
248
+ 'should return clamp value where no fluid max size is set',
244
249
  preset: {
245
250
  size: '28px',
246
251
  fluid: {
@@ -255,7 +260,8 @@ describe( 'typography utils', () => {
255
260
  },
256
261
 
257
262
  {
258
- message: 'returns clamp value where no fluid min size is set',
263
+ message:
264
+ 'should return clamp value where no fluid min size is set',
259
265
  preset: {
260
266
  size: '28px',
261
267
  fluid: {
@@ -320,7 +326,7 @@ describe( 'typography utils', () => {
320
326
 
321
327
  {
322
328
  message:
323
- 'returns clamp value when min and max font sizes are equal',
329
+ 'should return clamp value when min and max font sizes are equal',
324
330
  preset: {
325
331
  size: '4rem',
326
332
  fluid: {
@@ -333,8 +339,51 @@ describe( 'typography utils', () => {
333
339
  },
334
340
  expected: 'clamp(30px, 1.875rem + ((1vw - 7.68px) * 1), 30px)',
335
341
  },
342
+
343
+ {
344
+ message:
345
+ 'should use default min font size value where min font size unit in fluid config is not supported',
346
+ preset: {
347
+ size: '15px',
348
+ },
349
+ typographySettings: {
350
+ fluid: {
351
+ minFontSize: '16%',
352
+ },
353
+ },
354
+ expected:
355
+ 'clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.12), 15px)',
356
+ },
357
+
358
+ // Equivalent custom config PHP unit tests in `test_should_covert_font_sizes_to_fluid_values()`.
359
+ {
360
+ message: 'should return clamp value using custom fluid config',
361
+ preset: {
362
+ size: '17px',
363
+ },
364
+ typographySettings: {
365
+ fluid: {
366
+ minFontSize: '16px',
367
+ },
368
+ },
369
+ expected: 'clamp(16px, 1rem + ((1vw - 7.68px) * 0.12), 17px)',
370
+ },
371
+
372
+ {
373
+ message:
374
+ 'should return value when font size <= custom min font size bound',
375
+ preset: {
376
+ size: '15px',
377
+ },
378
+ typographySettings: {
379
+ fluid: {
380
+ minFontSize: '16px',
381
+ },
382
+ },
383
+ expected: '15px',
384
+ },
336
385
  ].forEach( ( { message, preset, typographySettings, expected } ) => {
337
- it( `should ${ message }`, () => {
386
+ it( `${ message }`, () => {
338
387
  expect(
339
388
  getTypographyFontSizeValue( preset, typographySettings )
340
389
  ).toBe( expected );
@@ -23,13 +23,23 @@ import { getComputedFluidTypographyValue } from '@wordpress/block-editor';
23
23
  * @property {boolean|FluidPreset|undefined} fluid A font size slug
24
24
  */
25
25
 
26
+ /**
27
+ * @typedef {Object} TypographySettings
28
+ * @property {?string|?number} size A default font size.
29
+ * @property {?string} minViewPortWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.
30
+ * @property {?string} maxViewPortWidth Maximum size up to which type will have fluidity. Optional if size is specified.
31
+ * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
32
+ * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.
33
+ * @property {?string} minFontSize The smallest a calculated font size may be. Optional.
34
+ */
35
+
26
36
  /**
27
37
  * Returns a font-size value based on a given font-size preset.
28
38
  * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
29
39
  *
30
- * @param {Preset} preset
31
- * @param {Object} typographySettings
32
- * @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
40
+ * @param {Preset} preset
41
+ * @param {Object} typographySettings
42
+ * @param {boolean|TypographySettings} typographySettings.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.
33
43
  *
34
44
  * @return {string|*} A font-size value or the value of preset.size.
35
45
  */
@@ -44,7 +54,11 @@ export function getTypographyFontSizeValue( preset, typographySettings ) {
44
54
  return defaultSize;
45
55
  }
46
56
 
47
- if ( true !== typographySettings?.fluid ) {
57
+ if (
58
+ ! typographySettings?.fluid ||
59
+ ( typeof typographySettings?.fluid === 'object' &&
60
+ Object.keys( typographySettings.fluid ).length === 0 )
61
+ ) {
48
62
  return defaultSize;
49
63
  }
50
64
 
@@ -53,10 +67,16 @@ export function getTypographyFontSizeValue( preset, typographySettings ) {
53
67
  return defaultSize;
54
68
  }
55
69
 
70
+ const fluidTypographySettings =
71
+ typeof typographySettings?.fluid === 'object'
72
+ ? typographySettings?.fluid
73
+ : {};
74
+
56
75
  const fluidFontSizeValue = getComputedFluidTypographyValue( {
57
76
  minimumFontSize: preset?.fluid?.min,
58
77
  maximumFontSize: preset?.fluid?.max,
59
78
  fontSize: defaultSize,
79
+ minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
60
80
  } );
61
81
 
62
82
  if ( !! fluidFontSizeValue ) {
@@ -4,6 +4,7 @@
4
4
  import {
5
5
  __experimentalNavigatorProvider as NavigatorProvider,
6
6
  __experimentalNavigatorScreen as NavigatorScreen,
7
+ __experimentalUseNavigator as useNavigator,
7
8
  } from '@wordpress/components';
8
9
  import { getBlockTypes } from '@wordpress/blocks';
9
10
 
@@ -24,6 +25,9 @@ import ScreenHeadingColor from './screen-heading-color';
24
25
  import ScreenButtonColor from './screen-button-color';
25
26
  import ScreenLayout from './screen-layout';
26
27
  import ScreenStyleVariations from './screen-style-variations';
28
+ import ScreenBorder from './screen-border';
29
+ import StyleBook from '../style-book';
30
+ import ScreenCSS from './screen-css';
27
31
 
28
32
  function GlobalStylesNavigationScreen( { className, ...props } ) {
29
33
  return (
@@ -40,7 +44,8 @@ function GlobalStylesNavigationScreen( { className, ...props } ) {
40
44
  }
41
45
 
42
46
  function ContextScreens( { name } ) {
43
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
47
+ const parentMenu =
48
+ name === undefined ? '' : '/blocks/' + encodeURIComponent( name );
44
49
 
45
50
  return (
46
51
  <>
@@ -108,6 +113,10 @@ function ContextScreens( { name } ) {
108
113
  <ScreenButtonColor name={ name } />
109
114
  </GlobalStylesNavigationScreen>
110
115
 
116
+ <GlobalStylesNavigationScreen path={ parentMenu + '/border' }>
117
+ <ScreenBorder name={ name } />
118
+ </GlobalStylesNavigationScreen>
119
+
111
120
  <GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>
112
121
  <ScreenLayout name={ name } />
113
122
  </GlobalStylesNavigationScreen>
@@ -115,9 +124,36 @@ function ContextScreens( { name } ) {
115
124
  );
116
125
  }
117
126
 
118
- function GlobalStylesUI() {
119
- const blocks = getBlockTypes();
127
+ function GlobalStylesStyleBook( { onClose } ) {
128
+ const navigator = useNavigator();
129
+ const { path } = navigator.location;
130
+ return (
131
+ <StyleBook
132
+ isSelected={ ( blockName ) =>
133
+ // Match '/blocks/core%2Fbutton' and
134
+ // '/blocks/core%2Fbutton/typography', but not
135
+ // '/blocks/core%2Fbuttons'.
136
+ path === `/blocks/${ encodeURIComponent( blockName ) }` ||
137
+ path.startsWith(
138
+ `/blocks/${ encodeURIComponent( blockName ) }/`
139
+ )
140
+ }
141
+ onSelect={ ( blockName ) => {
142
+ // Clear navigator history by going back to the root.
143
+ const depth = path.match( /\//g ).length;
144
+ for ( let i = 0; i < depth; i++ ) {
145
+ navigator.goBack();
146
+ }
147
+ // Now go to the selected block.
148
+ navigator.goTo( '/blocks/' + encodeURIComponent( blockName ) );
149
+ } }
150
+ onClose={ onClose }
151
+ />
152
+ );
153
+ }
120
154
 
155
+ function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
156
+ const blocks = getBlockTypes();
121
157
  return (
122
158
  <NavigatorProvider
123
159
  className="edit-site-global-styles-sidebar__navigator-provider"
@@ -138,7 +174,7 @@ function GlobalStylesUI() {
138
174
  { blocks.map( ( block ) => (
139
175
  <GlobalStylesNavigationScreen
140
176
  key={ 'menu-block-' + block.name }
141
- path={ '/blocks/' + block.name }
177
+ path={ '/blocks/' + encodeURIComponent( block.name ) }
142
178
  >
143
179
  <ScreenBlock name={ block.name } />
144
180
  </GlobalStylesNavigationScreen>
@@ -152,6 +188,13 @@ function GlobalStylesUI() {
152
188
  name={ block.name }
153
189
  />
154
190
  ) ) }
191
+
192
+ { isStyleBookOpened && (
193
+ <GlobalStylesStyleBook onClose={ onCloseStyleBook } />
194
+ ) }
195
+ <GlobalStylesNavigationScreen path="/css">
196
+ <ScreenCSS />
197
+ </GlobalStylesNavigationScreen>
155
198
  </NavigatorProvider>
156
199
  );
157
200
  }
@@ -919,6 +919,11 @@ export function useGlobalStylesOutput() {
919
919
  css: globalStyles,
920
920
  isGlobalStyles: true,
921
921
  },
922
+ // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
923
+ {
924
+ css: mergedConfig.styles.css ?? '',
925
+ isGlobalStyles: true,
926
+ },
922
927
  ];
923
928
 
924
929
  return [ stylesheets, mergedConfig.settings, filters ];
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, find } from 'lodash';
4
+ import { get } from 'lodash';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -86,7 +86,7 @@ export const PRESET_METADATA = [
86
86
  },
87
87
  ];
88
88
 
89
- const STYLE_PATH_TO_CSS_VAR_INFIX = {
89
+ export const STYLE_PATH_TO_CSS_VAR_INFIX = {
90
90
  'color.background': 'color',
91
91
  'color.text': 'color',
92
92
  'elements.link.color.text': 'color',
@@ -100,6 +100,15 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = {
100
100
  'typography.fontFamily': 'font-family',
101
101
  };
102
102
 
103
+ // A static list of block attributes that store global style preset slugs.
104
+ export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
105
+ 'color.background': 'backgroundColor',
106
+ 'color.text': 'textColor',
107
+ 'color.gradient': 'gradient',
108
+ 'typography.fontSize': 'fontSize',
109
+ 'typography.fontFamily': 'fontFamily',
110
+ };
111
+
103
112
  function findInPresetsBy(
104
113
  features,
105
114
  blockName,
@@ -120,8 +129,7 @@ function findInPresetsBy(
120
129
  for ( const origin of origins ) {
121
130
  const presets = presetByOrigin[ origin ];
122
131
  if ( presets ) {
123
- const presetObject = find(
124
- presets,
132
+ const presetObject = presets.find(
125
133
  ( preset ) =>
126
134
  preset[ presetProperty ] === presetValueValue
127
135
  );
@@ -164,7 +172,9 @@ export function getPresetVariableFromValue(
164
172
 
165
173
  const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];
166
174
 
167
- const metadata = find( PRESET_METADATA, [ 'cssVarInfix', cssVarInfix ] );
175
+ const metadata = PRESET_METADATA.find(
176
+ ( data ) => data.cssVarInfix === cssVarInfix
177
+ );
168
178
 
169
179
  if ( ! metadata ) {
170
180
  // The property doesn't have preset data
@@ -196,7 +206,9 @@ function getValueFromPresetVariable(
196
206
  variable,
197
207
  [ presetType, slug ]
198
208
  ) {
199
- const metadata = find( PRESET_METADATA, [ 'cssVarInfix', presetType ] );
209
+ const metadata = PRESET_METADATA.find(
210
+ ( data ) => data.cssVarInfix === presetType
211
+ );
200
212
  if ( ! metadata ) {
201
213
  return variable;
202
214
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { filter } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -30,10 +25,9 @@ function useGlobalStylesRenderer() {
30
25
  }
31
26
 
32
27
  const currentStoreSettings = getSettings();
33
- const nonGlobalStyles = filter(
34
- currentStoreSettings.styles,
35
- ( style ) => ! style.isGlobalStyles
36
- );
28
+ const nonGlobalStyles = Object.values(
29
+ currentStoreSettings.styles ?? []
30
+ ).filter( ( style ) => ! style.isGlobalStyles );
37
31
  updateSettings( {
38
32
  ...currentStoreSettings,
39
33
  styles: [ ...nonGlobalStyles, ...styles ],
@@ -20,17 +20,18 @@ import {
20
20
  } from '@wordpress/components';
21
21
  import { chevronDown } from '@wordpress/icons';
22
22
  import { useState, useMemo } from '@wordpress/element';
23
- import { store as blockEditorStore } from '@wordpress/block-editor';
24
- import { store as coreStore } from '@wordpress/core-data';
25
- import { store as editorStore } from '@wordpress/editor';
23
+ import {
24
+ store as blockEditorStore,
25
+ useBlockDisplayInformation,
26
+ BlockIcon,
27
+ } from '@wordpress/block-editor';
26
28
  import { store as preferencesStore } from '@wordpress/preferences';
27
- import { decodeEntities } from '@wordpress/html-entities';
28
29
 
29
30
  /**
30
31
  * Internal dependencies
31
32
  */
32
33
  import TemplateDetails from '../../template-details';
33
- import { store as editSiteStore } from '../../../store';
34
+ import useEditedEntityRecord from '../../use-edited-entity-record';
34
35
 
35
36
  function getBlockDisplayText( block ) {
36
37
  if ( block ) {
@@ -52,10 +53,13 @@ function useSecondaryText() {
52
53
  []
53
54
  );
54
55
 
56
+ const blockInformation = useBlockDisplayInformation( activeEntityBlockId );
57
+
55
58
  if ( activeEntityBlockId ) {
56
59
  return {
57
60
  label: getBlockDisplayText( getBlock( activeEntityBlockId ) ),
58
61
  isActive: true,
62
+ icon: blockInformation?.icon,
59
63
  };
60
64
  }
61
65
 
@@ -63,36 +67,16 @@ function useSecondaryText() {
63
67
  }
64
68
 
65
69
  export default function DocumentActions() {
66
- const { showIconLabels, entityTitle, template, templateType, isLoaded } =
67
- useSelect( ( select ) => {
68
- const { getEditedPostType, getEditedPostId } =
69
- select( editSiteStore );
70
- const { getEditedEntityRecord } = select( coreStore );
71
- const { __experimentalGetTemplateInfo: getTemplateInfo } =
72
- select( editorStore );
73
- const postType = getEditedPostType();
74
- const postId = getEditedPostId();
75
- const record = getEditedEntityRecord(
76
- 'postType',
77
- postType,
78
- postId
79
- );
80
- const _isLoaded = !! postId;
81
-
82
- return {
83
- showIconLabels: select( preferencesStore ).get(
84
- 'core/edit-site',
85
- 'showIconLabels'
86
- ),
87
- entityTitle: getTemplateInfo( record ).title,
88
- isLoaded: _isLoaded,
89
- template: record,
90
- templateType: postType,
91
- };
92
- }, [] );
93
- const entityLabel =
94
- templateType === 'wp_template_part' ? 'template part' : 'template';
95
- const { label } = useSecondaryText();
70
+ const showIconLabels = useSelect(
71
+ ( select ) =>
72
+ select( preferencesStore ).get(
73
+ 'core/edit-site',
74
+ 'showIconLabels'
75
+ ),
76
+ []
77
+ );
78
+ const { isLoaded, record, getTitle } = useEditedEntityRecord();
79
+ const { label, icon } = useSecondaryText();
96
80
 
97
81
  // Use internal state instead of a ref to make sure that the component
98
82
  // re-renders when the popover's anchor updates.
@@ -118,7 +102,7 @@ export default function DocumentActions() {
118
102
  }
119
103
 
120
104
  // Return feedback that the template does not seem to exist.
121
- if ( ! entityTitle ) {
105
+ if ( ! record ) {
122
106
  return (
123
107
  <div className="edit-site-document-actions">
124
108
  { __( 'Template not found' ) }
@@ -126,6 +110,11 @@ export default function DocumentActions() {
126
110
  );
127
111
  }
128
112
 
113
+ const entityLabel =
114
+ record.type === 'wp_template_part'
115
+ ? __( 'template part' )
116
+ : __( 'template' );
117
+
129
118
  return (
130
119
  <div
131
120
  className={ classnames( 'edit-site-document-actions', {
@@ -148,15 +137,12 @@ export default function DocumentActions() {
148
137
  entityLabel
149
138
  ) }
150
139
  </VisuallyHidden>
151
- { decodeEntities( entityTitle ) }
152
- </Text>
153
-
154
- <Text
155
- size="body"
156
- className="edit-site-document-actions__secondary-item"
157
- >
158
- { label ?? '' }
140
+ { getTitle() }
159
141
  </Text>
142
+ <div className="edit-site-document-actions__secondary-item">
143
+ <BlockIcon icon={ icon } showColors />
144
+ <Text size="body">{ label ?? '' }</Text>
145
+ </div>
160
146
 
161
147
  <Dropdown
162
148
  popoverProps={ popoverProps }
@@ -181,7 +167,7 @@ export default function DocumentActions() {
181
167
  contentClassName="edit-site-document-actions__info-dropdown"
182
168
  renderContent={ ( { onClose } ) => (
183
169
  <TemplateDetails
184
- template={ template }
170
+ template={ record }
185
171
  onClose={ onClose }
186
172
  />
187
173
  ) }