@wordpress/edit-site 5.25.1-next.79a6196f.0 → 5.27.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 (324) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/actions/index.js +139 -36
  3. package/build/components/actions/index.js.map +1 -1
  4. package/build/components/editor-canvas-container/index.js +1 -1
  5. package/build/components/editor-canvas-container/index.js.map +1 -1
  6. package/build/components/global-styles/font-families.js +3 -2
  7. package/build/components/global-styles/font-families.js.map +1 -1
  8. package/build/components/global-styles/font-family-item.js +3 -4
  9. package/build/components/global-styles/font-family-item.js.map +1 -1
  10. package/build/components/global-styles/font-library-modal/context.js +80 -41
  11. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  12. package/build/components/global-styles/font-library-modal/font-collection.js +49 -22
  13. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  14. package/build/components/global-styles/font-library-modal/fonts-grid.js +4 -1
  15. package/build/components/global-styles/font-library-modal/fonts-grid.js.map +1 -1
  16. package/build/components/global-styles/font-library-modal/index.js +4 -4
  17. package/build/components/global-styles/font-library-modal/index.js.map +1 -1
  18. package/build/components/global-styles/font-library-modal/installed-fonts.js +16 -8
  19. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  20. package/build/components/global-styles/font-library-modal/library-font-card.js +1 -1
  21. package/build/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
  22. package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  23. package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  24. package/build/components/global-styles/font-library-modal/local-fonts.js +13 -4
  25. package/build/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
  26. package/build/components/global-styles/font-library-modal/resolvers.js +49 -20
  27. package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  28. package/build/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
  29. package/build/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
  30. package/build/components/global-styles/font-library-modal/utils/index.js +103 -17
  31. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  32. package/build/components/global-styles/font-library-modal/utils/preview-styles.js +4 -3
  33. package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
  34. package/build/components/global-styles/screen-typography.js +4 -1
  35. package/build/components/global-styles/screen-typography.js.map +1 -1
  36. package/build/components/layout/hooks.js +6 -5
  37. package/build/components/layout/hooks.js.map +1 -1
  38. package/build/components/layout/index.js +19 -28
  39. package/build/components/layout/index.js.map +1 -1
  40. package/build/components/layout/router.js +135 -0
  41. package/build/components/layout/router.js.map +1 -0
  42. package/build/components/page-pages/index.js +92 -69
  43. package/build/components/page-pages/index.js.map +1 -1
  44. package/build/components/page-patterns/dataviews-pattern-actions.js +11 -6
  45. package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
  46. package/build/components/page-patterns/index.js +295 -15
  47. package/build/components/page-patterns/index.js.map +1 -1
  48. package/build/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +51 -23
  49. package/build/components/page-templates-template-parts/actions.js.map +1 -0
  50. package/build/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
  51. package/build/components/page-templates-template-parts/index.js +395 -0
  52. package/build/components/page-templates-template-parts/index.js.map +1 -0
  53. package/build/components/preferences-modal/index.js +9 -134
  54. package/build/components/preferences-modal/index.js.map +1 -1
  55. package/build/components/revisions/index.js +1 -1
  56. package/build/components/revisions/index.js.map +1 -1
  57. package/build/components/save-button/index.js +4 -2
  58. package/build/components/save-button/index.js.map +1 -1
  59. package/build/components/save-panel/index.js +6 -5
  60. package/build/components/save-panel/index.js.map +1 -1
  61. package/build/components/sidebar/index.js +3 -1
  62. package/build/components/sidebar/index.js.map +1 -1
  63. package/build/components/sidebar-dataviews/dataview-item.js +3 -1
  64. package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
  65. package/build/components/sidebar-dataviews/default-views.js +4 -2
  66. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  67. package/build/components/sidebar-dataviews/index.js +2 -2
  68. package/build/components/sidebar-dataviews/index.js.map +1 -1
  69. package/build/components/sidebar-navigation-screen/index.js +8 -7
  70. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  71. package/build/components/sidebar-navigation-screen-pages/index.js +2 -10
  72. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  73. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +26 -3
  74. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
  75. package/build/components/sidebar-navigation-screen-templates-browse/content.js +76 -0
  76. package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
  77. package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
  78. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  79. package/build/components/site-hub/index.js +3 -1
  80. package/build/components/site-hub/index.js.map +1 -1
  81. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -12
  82. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  83. package/build/components/sync-state-with-url/use-sync-path-with-url.js +25 -2
  84. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  85. package/build/hooks/commands/use-edit-mode-commands.js +33 -5
  86. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  87. package/build/hooks/push-changes-to-global-styles/index.js +13 -6
  88. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  89. package/build/hooks/template-part-edit.js +7 -6
  90. package/build/hooks/template-part-edit.js.map +1 -1
  91. package/build/index.js +1 -1
  92. package/build/index.js.map +1 -1
  93. package/build/store/actions.js +11 -29
  94. package/build/store/actions.js.map +1 -1
  95. package/build/store/private-actions.js +85 -1
  96. package/build/store/private-actions.js.map +1 -1
  97. package/build/store/selectors.js +2 -2
  98. package/build/store/selectors.js.map +1 -1
  99. package/build/utils/get-is-list-page.js +1 -1
  100. package/build/utils/get-is-list-page.js.map +1 -1
  101. package/build/utils/use-actual-current-theme.js +32 -0
  102. package/build/utils/use-actual-current-theme.js.map +1 -0
  103. package/build-module/components/actions/index.js +139 -36
  104. package/build-module/components/actions/index.js.map +1 -1
  105. package/build-module/components/editor-canvas-container/index.js +1 -1
  106. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  107. package/build-module/components/global-styles/font-families.js +3 -2
  108. package/build-module/components/global-styles/font-families.js.map +1 -1
  109. package/build-module/components/global-styles/font-family-item.js +4 -5
  110. package/build-module/components/global-styles/font-family-item.js.map +1 -1
  111. package/build-module/components/global-styles/font-library-modal/context.js +82 -42
  112. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  113. package/build-module/components/global-styles/font-library-modal/font-collection.js +49 -22
  114. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  115. package/build-module/components/global-styles/font-library-modal/fonts-grid.js +4 -1
  116. package/build-module/components/global-styles/font-library-modal/fonts-grid.js.map +1 -1
  117. package/build-module/components/global-styles/font-library-modal/index.js +4 -4
  118. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  119. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +16 -8
  120. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  121. package/build-module/components/global-styles/font-library-modal/library-font-card.js +1 -1
  122. package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
  123. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  124. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  125. package/build-module/components/global-styles/font-library-modal/local-fonts.js +13 -4
  126. package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
  127. package/build-module/components/global-styles/font-library-modal/resolvers.js +45 -18
  128. package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  129. package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
  130. package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
  131. package/build-module/components/global-styles/font-library-modal/utils/index.js +99 -16
  132. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  133. package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +4 -3
  134. package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
  135. package/build-module/components/global-styles/screen-typography.js +4 -1
  136. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  137. package/build-module/components/layout/hooks.js +6 -5
  138. package/build-module/components/layout/hooks.js.map +1 -1
  139. package/build-module/components/layout/index.js +19 -28
  140. package/build-module/components/layout/index.js.map +1 -1
  141. package/build-module/components/layout/router.js +127 -0
  142. package/build-module/components/layout/router.js.map +1 -0
  143. package/build-module/components/page-pages/index.js +91 -70
  144. package/build-module/components/page-pages/index.js.map +1 -1
  145. package/build-module/components/page-patterns/dataviews-pattern-actions.js +11 -6
  146. package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
  147. package/build-module/components/page-patterns/index.js +296 -16
  148. package/build-module/components/page-patterns/index.js.map +1 -1
  149. package/build-module/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +52 -24
  150. package/build-module/components/page-templates-template-parts/actions.js.map +1 -0
  151. package/build-module/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
  152. package/build-module/components/page-templates-template-parts/index.js +385 -0
  153. package/build-module/components/page-templates-template-parts/index.js.map +1 -0
  154. package/build-module/components/preferences-modal/index.js +12 -136
  155. package/build-module/components/preferences-modal/index.js.map +1 -1
  156. package/build-module/components/revisions/index.js +1 -1
  157. package/build-module/components/revisions/index.js.map +1 -1
  158. package/build-module/components/save-button/index.js +4 -2
  159. package/build-module/components/save-button/index.js.map +1 -1
  160. package/build-module/components/save-panel/index.js +7 -6
  161. package/build-module/components/save-panel/index.js.map +1 -1
  162. package/build-module/components/sidebar/index.js +3 -1
  163. package/build-module/components/sidebar/index.js.map +1 -1
  164. package/build-module/components/sidebar-dataviews/dataview-item.js +3 -1
  165. package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
  166. package/build-module/components/sidebar-dataviews/default-views.js +4 -2
  167. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  168. package/build-module/components/sidebar-dataviews/index.js +2 -2
  169. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  170. package/build-module/components/sidebar-navigation-screen/index.js +8 -7
  171. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  172. package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -10
  173. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  174. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +27 -4
  175. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
  176. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +68 -0
  177. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
  178. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
  179. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  180. package/build-module/components/site-hub/index.js +3 -1
  181. package/build-module/components/site-hub/index.js.map +1 -1
  182. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -11
  183. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  184. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +25 -2
  185. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  186. package/build-module/hooks/commands/use-edit-mode-commands.js +33 -5
  187. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  188. package/build-module/hooks/push-changes-to-global-styles/index.js +13 -6
  189. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  190. package/build-module/hooks/template-part-edit.js +7 -6
  191. package/build-module/hooks/template-part-edit.js.map +1 -1
  192. package/build-module/index.js +1 -1
  193. package/build-module/index.js.map +1 -1
  194. package/build-module/store/actions.js +13 -30
  195. package/build-module/store/actions.js.map +1 -1
  196. package/build-module/store/private-actions.js +83 -0
  197. package/build-module/store/private-actions.js.map +1 -1
  198. package/build-module/store/selectors.js +2 -2
  199. package/build-module/store/selectors.js.map +1 -1
  200. package/build-module/utils/get-is-list-page.js +1 -1
  201. package/build-module/utils/get-is-list-page.js.map +1 -1
  202. package/build-module/utils/use-actual-current-theme.js +24 -0
  203. package/build-module/utils/use-actual-current-theme.js.map +1 -0
  204. package/build-style/style-rtl.css +293 -188
  205. package/build-style/style.css +293 -188
  206. package/package.json +42 -42
  207. package/src/components/actions/index.js +236 -84
  208. package/src/components/editor-canvas-container/index.js +1 -1
  209. package/src/components/global-styles/font-families.js +14 -8
  210. package/src/components/global-styles/font-family-item.js +7 -4
  211. package/src/components/global-styles/font-library-modal/context.js +156 -50
  212. package/src/components/global-styles/font-library-modal/font-collection.js +56 -21
  213. package/src/components/global-styles/font-library-modal/fonts-grid.js +6 -2
  214. package/src/components/global-styles/font-library-modal/index.js +4 -4
  215. package/src/components/global-styles/font-library-modal/installed-fonts.js +18 -8
  216. package/src/components/global-styles/font-library-modal/library-font-card.js +2 -1
  217. package/src/components/global-styles/font-library-modal/library-font-variant.js +10 -9
  218. package/src/components/global-styles/font-library-modal/local-fonts.js +14 -4
  219. package/src/components/global-styles/font-library-modal/resolvers.js +50 -17
  220. package/src/components/global-styles/font-library-modal/style.scss +1 -0
  221. package/src/components/global-styles/font-library-modal/utils/filter-fonts.js +19 -2
  222. package/src/components/global-styles/font-library-modal/utils/index.js +136 -29
  223. package/src/components/global-styles/font-library-modal/utils/preview-styles.js +7 -3
  224. package/src/components/global-styles/font-library-modal/utils/test/filter-fonts.spec.js +40 -10
  225. package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +5 -5
  226. package/src/components/global-styles/screen-typography.js +9 -3
  227. package/src/components/global-styles/style.scss +4 -0
  228. package/src/components/header-edit-mode/style.scss +15 -5
  229. package/src/components/layout/hooks.js +6 -5
  230. package/src/components/layout/index.js +80 -96
  231. package/src/components/layout/router.js +121 -0
  232. package/src/components/layout/style.scss +13 -16
  233. package/src/components/page/style.scss +1 -8
  234. package/src/components/page-pages/index.js +142 -148
  235. package/src/components/page-pages/style.scss +41 -2
  236. package/src/components/page-patterns/dataviews-pattern-actions.js +11 -6
  237. package/src/components/page-patterns/index.js +392 -14
  238. package/src/components/page-patterns/style.scss +36 -2
  239. package/src/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +90 -37
  240. package/src/components/{page-templates → page-templates-template-parts}/index.js +198 -169
  241. package/src/components/page-templates-template-parts/style.scss +44 -0
  242. package/src/components/preferences-modal/index.js +8 -211
  243. package/src/components/revisions/index.js +1 -1
  244. package/src/components/save-button/index.js +7 -4
  245. package/src/components/save-panel/index.js +13 -12
  246. package/src/components/sidebar/index.js +4 -5
  247. package/src/components/sidebar-dataviews/dataview-item.js +2 -1
  248. package/src/components/sidebar-dataviews/default-views.js +4 -2
  249. package/src/components/sidebar-dataviews/index.js +8 -6
  250. package/src/components/sidebar-navigation-item/style.scss +1 -1
  251. package/src/components/sidebar-navigation-screen/index.js +19 -10
  252. package/src/components/sidebar-navigation-screen-pages/index.js +2 -10
  253. package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +32 -6
  254. package/src/components/sidebar-navigation-screen-templates-browse/content.js +73 -0
  255. package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -1
  256. package/src/components/site-hub/index.js +4 -1
  257. package/src/components/site-hub/style.scss +1 -12
  258. package/src/components/site-icon/style.scss +1 -1
  259. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +40 -10
  260. package/src/components/sync-state-with-url/use-sync-path-with-url.js +32 -0
  261. package/src/hooks/commands/use-edit-mode-commands.js +50 -3
  262. package/src/hooks/push-changes-to-global-styles/index.js +29 -23
  263. package/src/hooks/template-part-edit.js +12 -12
  264. package/src/index.js +1 -1
  265. package/src/store/actions.js +17 -51
  266. package/src/store/private-actions.js +133 -0
  267. package/src/store/selectors.js +2 -4
  268. package/src/style.scss +1 -1
  269. package/src/utils/get-is-list-page.js +3 -2
  270. package/src/utils/use-actual-current-theme.js +27 -0
  271. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
  272. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
  273. package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -71
  274. package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
  275. package/build/components/page-main/index.js +0 -44
  276. package/build/components/page-main/index.js.map +0 -1
  277. package/build/components/page-patterns/dataviews-patterns.js +0 -307
  278. package/build/components/page-patterns/dataviews-patterns.js.map +0 -1
  279. package/build/components/page-template-parts/add-new-template-part.js.map +0 -1
  280. package/build/components/page-template-parts/index.js +0 -81
  281. package/build/components/page-template-parts/index.js.map +0 -1
  282. package/build/components/page-templates/index.js +0 -352
  283. package/build/components/page-templates/index.js.map +0 -1
  284. package/build/components/page-templates/template-actions.js.map +0 -1
  285. package/build/components/post-preview/index.js +0 -29
  286. package/build/components/post-preview/index.js.map +0 -1
  287. package/build/components/preferences-modal/enable-feature.js +0 -36
  288. package/build/components/preferences-modal/enable-feature.js.map +0 -1
  289. package/build/components/preferences-modal/enable-panel-option.js +0 -33
  290. package/build/components/preferences-modal/enable-panel-option.js.map +0 -1
  291. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -52
  292. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
  293. package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -63
  294. package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
  295. package/build-module/components/page-main/index.js +0 -36
  296. package/build-module/components/page-main/index.js.map +0 -1
  297. package/build-module/components/page-patterns/dataviews-patterns.js +0 -299
  298. package/build-module/components/page-patterns/dataviews-patterns.js.map +0 -1
  299. package/build-module/components/page-template-parts/add-new-template-part.js.map +0 -1
  300. package/build-module/components/page-template-parts/index.js +0 -73
  301. package/build-module/components/page-template-parts/index.js.map +0 -1
  302. package/build-module/components/page-templates/index.js +0 -344
  303. package/build-module/components/page-templates/index.js.map +0 -1
  304. package/build-module/components/page-templates/template-actions.js.map +0 -1
  305. package/build-module/components/post-preview/index.js +0 -21
  306. package/build-module/components/post-preview/index.js.map +0 -1
  307. package/build-module/components/preferences-modal/enable-feature.js +0 -29
  308. package/build-module/components/preferences-modal/enable-feature.js.map +0 -1
  309. package/build-module/components/preferences-modal/enable-panel-option.js +0 -26
  310. package/build-module/components/preferences-modal/enable-panel-option.js.map +0 -1
  311. package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
  312. package/src/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -62
  313. package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +0 -271
  314. package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamily.spec.js +0 -58
  315. package/src/components/page-main/index.js +0 -38
  316. package/src/components/page-patterns/dataviews-patterns.js +0 -380
  317. package/src/components/page-template-parts/index.js +0 -99
  318. package/src/components/page-templates/style.scss +0 -13
  319. package/src/components/post-preview/index.js +0 -16
  320. package/src/components/preferences-modal/enable-feature.js +0 -31
  321. package/src/components/preferences-modal/enable-panel-option.js +0 -23
  322. /package/build/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
  323. /package/build-module/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
  324. /package/src/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
@@ -1,45 +1,78 @@
1
- /**
2
- * WordPress dependencies
3
- *
4
- */
5
1
  /**
6
2
  * WordPress dependencies
7
3
  */
8
4
  import apiFetch from '@wordpress/api-fetch';
9
5
 
10
- export async function fetchInstallFont( data ) {
6
+ const FONT_FAMILIES_URL = '/wp/v2/font-families';
7
+ const FONT_COLLECTIONS_URL = '/wp/v2/font-collections';
8
+
9
+ export async function fetchInstallFontFamily( data ) {
11
10
  const config = {
12
- path: '/wp/v2/font-families',
11
+ path: FONT_FAMILIES_URL,
13
12
  method: 'POST',
14
13
  body: data,
15
14
  };
16
- return apiFetch( config );
15
+ const response = await apiFetch( config );
16
+ return {
17
+ id: response.id,
18
+ ...response.font_family_settings,
19
+ fontFace: [],
20
+ };
17
21
  }
18
22
 
19
- export async function fetchUninstallFonts( fonts ) {
20
- const data = {
21
- font_families: fonts,
23
+ export async function fetchInstallFontFace( fontFamilyId, data ) {
24
+ const config = {
25
+ path: `${ FONT_FAMILIES_URL }/${ fontFamilyId }/font-faces`,
26
+ method: 'POST',
27
+ body: data,
28
+ };
29
+ const response = await apiFetch( config );
30
+ return {
31
+ id: response.id,
32
+ ...response.font_face_settings,
22
33
  };
34
+ }
35
+
36
+ export async function fetchGetFontFamilyBySlug( slug ) {
37
+ const config = {
38
+ path: `${ FONT_FAMILIES_URL }?slug=${ slug }&_embed=true`,
39
+ method: 'GET',
40
+ };
41
+ const response = await apiFetch( config );
42
+ if ( ! response || response.length === 0 ) {
43
+ return null;
44
+ }
45
+ const fontFamilyPost = response[ 0 ];
46
+ return {
47
+ id: fontFamilyPost.id,
48
+ ...fontFamilyPost.font_family_settings,
49
+ fontFace:
50
+ fontFamilyPost?._embedded?.font_faces.map(
51
+ ( face ) => face.font_face_settings
52
+ ) || [],
53
+ };
54
+ }
55
+
56
+ export async function fetchUninstallFontFamily( fontFamilyId ) {
23
57
  const config = {
24
- path: '/wp/v2/font-families',
58
+ path: `${ FONT_FAMILIES_URL }/${ fontFamilyId }?force=true`,
25
59
  method: 'DELETE',
26
- data,
27
60
  };
28
- return apiFetch( config );
61
+ return await apiFetch( config );
29
62
  }
30
63
 
31
64
  export async function fetchFontCollections() {
32
65
  const config = {
33
- path: '/wp/v2/font-collections',
66
+ path: FONT_COLLECTIONS_URL,
34
67
  method: 'GET',
35
68
  };
36
- return apiFetch( config );
69
+ return await apiFetch( config );
37
70
  }
38
71
 
39
72
  export async function fetchFontCollection( id ) {
40
73
  const config = {
41
- path: `/wp/v2/font-collections/${ id }`,
74
+ path: `${ FONT_COLLECTIONS_URL }/${ id }`,
42
75
  method: 'GET',
43
76
  };
44
- return apiFetch( config );
77
+ return await apiFetch( config );
45
78
  }
@@ -51,6 +51,7 @@
51
51
 
52
52
  .font-library-modal__font-card {
53
53
  border: 1px solid #e5e5e5;
54
+ width: 100%;
54
55
  height: auto;
55
56
  padding: 1rem;
56
57
  margin-top: -1px; /* To collapse the margin with the previous element */
@@ -1,16 +1,33 @@
1
+ /**
2
+ * Filters a list of fonts based on the specified filters.
3
+ *
4
+ * This function filters a given array of fonts based on the criteria provided in the filters object.
5
+ * It supports filtering by category and a search term. If the category is provided and not equal to 'all',
6
+ * the function filters the fonts array to include only those fonts that belong to the specified category.
7
+ * Additionally, if a search term is provided, it filters the fonts array to include only those fonts
8
+ * whose name includes the search term, case-insensitively.
9
+ *
10
+ * @param {Array} fonts Array of font objects in font-collection schema fashion to be filtered. Each font object should have a 'categories' property and a 'font_family_settings' property with a 'name' key.
11
+ * @param {Object} filters Object containing the filter criteria. It should have a 'category' key and/or a 'search' key.
12
+ * The 'category' key is a string representing the category to filter by.
13
+ * The 'search' key is a string representing the search term to filter by.
14
+ * @return {Array} Array of filtered font objects based on the provided criteria.
15
+ */
1
16
  export default function filterFonts( fonts, filters ) {
2
17
  const { category, search } = filters;
3
18
  let filteredFonts = fonts || [];
4
19
 
5
20
  if ( category && category !== 'all' ) {
6
21
  filteredFonts = filteredFonts.filter(
7
- ( font ) => font.category === category
22
+ ( font ) => font.categories.indexOf( category ) !== -1
8
23
  );
9
24
  }
10
25
 
11
26
  if ( search ) {
12
27
  filteredFonts = filteredFonts.filter( ( font ) =>
13
- font.name.toLowerCase().includes( search.toLowerCase() )
28
+ font.font_family_settings.name
29
+ .toLowerCase()
30
+ .includes( search.toLowerCase() )
14
31
  );
15
32
  }
16
33
 
@@ -8,6 +8,13 @@ import { privateApis as componentsPrivateApis } from '@wordpress/components';
8
8
  */
9
9
  import { FONT_WEIGHTS, FONT_STYLES } from './constants';
10
10
  import { unlock } from '../../../../lock-unlock';
11
+ import { fetchInstallFontFace } from '../resolvers';
12
+ import { formatFontFamily } from './preview-styles';
13
+
14
+ /**
15
+ * Browser dependencies
16
+ */
17
+ const { File } = window;
11
18
 
12
19
  export function setUIValuesNeeded( font, extraValues = {} ) {
13
20
  if ( ! font.name && ( font.fontFamily || font.slug ) ) {
@@ -87,13 +94,18 @@ export async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {
87
94
  // eslint-disable-next-line no-undef
88
95
  } else if ( source instanceof File ) {
89
96
  dataSource = await source.arrayBuffer();
97
+ } else {
98
+ return;
90
99
  }
91
100
 
92
- // eslint-disable-next-line no-undef
93
- const newFont = new FontFace( fontFace.fontFamily, dataSource, {
94
- style: fontFace.fontStyle,
95
- weight: fontFace.fontWeight,
96
- } );
101
+ const newFont = new window.FontFace(
102
+ formatFontFamily( fontFace.fontFamily ),
103
+ dataSource,
104
+ {
105
+ style: fontFace.fontStyle,
106
+ weight: fontFace.fontWeight,
107
+ }
108
+ );
97
109
 
98
110
  const loadedFace = await newFont.load();
99
111
 
@@ -130,37 +142,132 @@ export function getDisplaySrcFromFontFace( input, urlPrefix ) {
130
142
  return src;
131
143
  }
132
144
 
133
- export function makeFormDataFromFontFamily( fontFamily ) {
145
+ export function makeFontFamilyFormData( fontFamily ) {
134
146
  const formData = new FormData();
135
147
  const { kebabCase } = unlock( componentsPrivateApis );
136
148
 
137
- const newFontFamily = {
138
- ...fontFamily,
149
+ const { fontFace, category, ...familyWithValidParameters } = fontFamily;
150
+ const fontFamilySettings = {
151
+ ...familyWithValidParameters,
139
152
  slug: kebabCase( fontFamily.slug ),
140
153
  };
141
154
 
142
- if ( newFontFamily?.fontFace ) {
143
- const newFontFaces = newFontFamily.fontFace.map(
144
- ( face, faceIndex ) => {
145
- if ( face.file ) {
146
- // Slugified file name because the it might contain spaces or characters treated differently on the server.
147
- const fileId = `file-${ faceIndex }`;
148
- // Add the files to the formData
149
- formData.append( fileId, face.file, face.file.name );
150
- // remove the file object from the face object the file is referenced by the uploadedFile key
151
- const { file, ...faceWithoutFileProperty } = face;
152
- const newFace = {
153
- ...faceWithoutFileProperty,
154
- uploadedFile: fileId,
155
- };
156
- return newFace;
157
- }
158
- return face;
155
+ formData.append(
156
+ 'font_family_settings',
157
+ JSON.stringify( fontFamilySettings )
158
+ );
159
+ return formData;
160
+ }
161
+
162
+ export function makeFontFacesFormData( font ) {
163
+ if ( font?.fontFace ) {
164
+ const fontFacesFormData = font.fontFace.map( ( face, faceIndex ) => {
165
+ const formData = new FormData();
166
+ if ( face.file ) {
167
+ // Slugified file name because the it might contain spaces or characters treated differently on the server.
168
+ const fileId = `file-${ faceIndex }`;
169
+ // Add the files to the formData
170
+ formData.append( fileId, face.file, face.file.name );
171
+ // remove the file object from the face object the file is referenced in src
172
+ const { file, ...faceWithoutFileProperty } = face;
173
+ const fontFaceSettings = {
174
+ ...faceWithoutFileProperty,
175
+ src: fileId,
176
+ };
177
+ formData.append(
178
+ 'font_face_settings',
179
+ JSON.stringify( fontFaceSettings )
180
+ );
181
+ } else {
182
+ formData.append( 'font_face_settings', JSON.stringify( face ) );
159
183
  }
160
- );
161
- newFontFamily.fontFace = newFontFaces;
184
+ return formData;
185
+ } );
186
+
187
+ return fontFacesFormData;
162
188
  }
189
+ }
163
190
 
164
- formData.append( 'font_family_settings', JSON.stringify( newFontFamily ) );
165
- return formData;
191
+ export async function batchInstallFontFaces( fontFamilyId, fontFacesData ) {
192
+ const promises = fontFacesData.map( ( faceData ) =>
193
+ fetchInstallFontFace( fontFamilyId, faceData )
194
+ );
195
+ const responses = await Promise.allSettled( promises );
196
+
197
+ const results = {
198
+ errors: [],
199
+ successes: [],
200
+ };
201
+
202
+ responses.forEach( ( result, index ) => {
203
+ if ( result.status === 'fulfilled' ) {
204
+ const response = result.value;
205
+ if ( response.id ) {
206
+ results.successes.push( response );
207
+ } else {
208
+ results.errors.push( {
209
+ data: fontFacesData[ index ],
210
+ message: `Error: ${ response.message }`,
211
+ } );
212
+ }
213
+ } else {
214
+ // Handle network errors or other fetch-related errors
215
+ results.errors.push( {
216
+ data: fontFacesData[ index ],
217
+ message: `Fetch error: ${ result.reason.message }`,
218
+ } );
219
+ }
220
+ } );
221
+
222
+ return results;
223
+ }
224
+
225
+ /*
226
+ * Downloads a font face asset from a URL to the client and returns a File object.
227
+ */
228
+ export async function downloadFontFaceAsset( url ) {
229
+ return fetch( new Request( url ) )
230
+ .then( ( response ) => {
231
+ if ( ! response.ok ) {
232
+ throw new Error(
233
+ `Error downloading font face asset from ${ url }. Server responded with status: ${ response.status }`
234
+ );
235
+ }
236
+ return response.blob();
237
+ } )
238
+ .then( ( blob ) => {
239
+ const filename = url.split( '/' ).pop();
240
+ const file = new File( [ blob ], filename, {
241
+ type: blob.type,
242
+ } );
243
+ return file;
244
+ } )
245
+ .catch( ( error ) => {
246
+ // eslint-disable-next-line no-console
247
+ console.error(
248
+ `Error downloading font face asset from ${ url }:`,
249
+ error
250
+ );
251
+ throw error;
252
+ } );
253
+ }
254
+
255
+ /*
256
+ * Determine if a given Font Face is present in a given collection.
257
+ * We determine that a font face has been installed by comparing the fontWeight and fontStyle
258
+ *
259
+ * @param {Object} fontFace The Font Face to seek
260
+ * @param {Array} collection The Collection to seek in
261
+ * @returns True if the font face is found in the collection. Otherwise False.
262
+ */
263
+ export function checkFontFaceInstalled( fontFace, collection ) {
264
+ return (
265
+ -1 !==
266
+ collection.findIndex( ( collectionFontFace ) => {
267
+ return (
268
+ collectionFontFace.fontWeight === fontFace.fontWeight &&
269
+ collectionFontFace.fontStyle === fontFace.fontStyle
270
+ );
271
+ } )
272
+ );
166
273
  }
@@ -35,9 +35,13 @@ export function formatFontFamily( input ) {
35
35
  .split( ',' )
36
36
  .map( ( font ) => {
37
37
  font = font.trim(); // Remove any leading or trailing white spaces
38
- // If the font doesn't have single quotes and contains a space, then add single quotes around it
39
- if ( ! font.startsWith( "'" ) && font.indexOf( ' ' ) !== -1 ) {
40
- return `'${ font }'`;
38
+ // If the font doesn't start with quotes and contains a space, then wrap in quotes.
39
+ // Check that string starts with a single or double quote and not a space
40
+ if (
41
+ ! ( font.startsWith( '"' ) || font.startsWith( "'" ) ) &&
42
+ font.indexOf( ' ' ) !== -1
43
+ ) {
44
+ return `"${ font }"`;
41
45
  }
42
46
  return font; // Return font as is if no transformation is needed
43
47
  } )
@@ -5,11 +5,26 @@ import filterFonts from '../filter-fonts';
5
5
 
6
6
  describe( 'filterFonts', () => {
7
7
  const mockFonts = [
8
- { name: 'Arial', category: 'sans-serif' },
9
- { name: 'Arial Condensed', category: 'sans-serif' },
10
- { name: 'Times New Roman', category: 'serif' },
11
- { name: 'Courier New', category: 'monospace' },
12
- { name: 'Romantic', category: 'cursive' },
8
+ {
9
+ font_family_settings: { name: 'Arial' },
10
+ categories: [ 'sans-serif' ],
11
+ },
12
+ {
13
+ font_family_settings: { name: 'Arial Condensed' },
14
+ categories: [ 'sans-serif' ],
15
+ },
16
+ {
17
+ font_family_settings: { name: 'Times New Roman' },
18
+ categories: [ 'serif' ],
19
+ },
20
+ {
21
+ font_family_settings: { name: 'Courier New' },
22
+ categories: [ 'monospace' ],
23
+ },
24
+ {
25
+ font_family_settings: { name: 'Romantic' },
26
+ categories: [ 'cursive' ],
27
+ },
13
28
  ];
14
29
 
15
30
  it( 'should return all fonts if no filters are provided', () => {
@@ -20,7 +35,10 @@ describe( 'filterFonts', () => {
20
35
  it( 'should filter by category', () => {
21
36
  const result = filterFonts( mockFonts, { category: 'serif' } );
22
37
  expect( result ).toEqual( [
23
- { name: 'Times New Roman', category: 'serif' },
38
+ {
39
+ font_family_settings: { name: 'Times New Roman' },
40
+ categories: [ 'serif' ],
41
+ },
24
42
  ] );
25
43
  } );
26
44
 
@@ -32,15 +50,24 @@ describe( 'filterFonts', () => {
32
50
  it( 'should filter by search', () => {
33
51
  const result = filterFonts( mockFonts, { search: 'ari' } );
34
52
  expect( result ).toEqual( [
35
- { name: 'Arial', category: 'sans-serif' },
36
- { name: 'Arial Condensed', category: 'sans-serif' },
53
+ {
54
+ font_family_settings: { name: 'Arial' },
55
+ categories: [ 'sans-serif' ],
56
+ },
57
+ {
58
+ font_family_settings: { name: 'Arial Condensed' },
59
+ categories: [ 'sans-serif' ],
60
+ },
37
61
  ] );
38
62
  } );
39
63
 
40
64
  it( 'should be case insensitive when filtering by search', () => {
41
65
  const result = filterFonts( mockFonts, { search: 'RoMANtic' } );
42
66
  expect( result ).toEqual( [
43
- { name: 'Romantic', category: 'cursive' },
67
+ {
68
+ font_family_settings: { name: 'Romantic' },
69
+ categories: [ 'cursive' ],
70
+ },
44
71
  ] );
45
72
  } );
46
73
 
@@ -50,7 +77,10 @@ describe( 'filterFonts', () => {
50
77
  search: 'Times',
51
78
  } );
52
79
  expect( result ).toEqual( [
53
- { name: 'Times New Roman', category: 'serif' },
80
+ {
81
+ font_family_settings: { name: 'Times New Roman' },
82
+ categories: [ 'serif' ],
83
+ },
54
84
  ] );
55
85
  } );
56
86
 
@@ -123,13 +123,13 @@ describe( 'getFamilyPreviewStyle', () => {
123
123
  describe( 'formatFontFamily', () => {
124
124
  it( 'should transform "Baloo 2, system-ui" correctly', () => {
125
125
  expect( formatFontFamily( 'Baloo 2, system-ui' ) ).toBe(
126
- "'Baloo 2', system-ui"
126
+ '"Baloo 2", system-ui'
127
127
  );
128
128
  } );
129
129
 
130
130
  it( 'should ignore extra spaces', () => {
131
131
  expect( formatFontFamily( ' Baloo 2 , system-ui' ) ).toBe(
132
- "'Baloo 2', system-ui"
132
+ '"Baloo 2", system-ui'
133
133
  );
134
134
  } );
135
135
 
@@ -144,18 +144,18 @@ describe( 'formatFontFamily', () => {
144
144
  } );
145
145
 
146
146
  it( 'should wrap single font name with spaces in quotes', () => {
147
- expect( formatFontFamily( 'Baloo 2' ) ).toBe( "'Baloo 2'" );
147
+ expect( formatFontFamily( 'Baloo 2' ) ).toBe( '"Baloo 2"' );
148
148
  } );
149
149
 
150
150
  it( 'should wrap multiple font names with spaces in quotes', () => {
151
151
  expect( formatFontFamily( 'Baloo Bhai 2, Baloo 2' ) ).toBe(
152
- "'Baloo Bhai 2', 'Baloo 2'"
152
+ '"Baloo Bhai 2", "Baloo 2"'
153
153
  );
154
154
  } );
155
155
 
156
156
  it( 'should wrap only those font names with spaces which are not already quoted', () => {
157
157
  expect( formatFontFamily( 'Baloo Bhai 2, Arial' ) ).toBe(
158
- "'Baloo Bhai 2', Arial"
158
+ '"Baloo Bhai 2", Arial'
159
159
  );
160
160
  } );
161
161
  } );
@@ -3,6 +3,8 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { __experimentalVStack as VStack } from '@wordpress/components';
6
+ import { store as editorStore } from '@wordpress/editor';
7
+ import { useSelect } from '@wordpress/data';
6
8
 
7
9
  /**
8
10
  * Internal dependencies
@@ -12,6 +14,12 @@ import FontFamilies from './font-families';
12
14
  import ScreenHeader from './header';
13
15
 
14
16
  function ScreenTypography() {
17
+ const fontLibraryEnabled = useSelect(
18
+ ( select ) =>
19
+ select( editorStore ).getEditorSettings().fontLibraryEnabled,
20
+ []
21
+ );
22
+
15
23
  return (
16
24
  <>
17
25
  <ScreenHeader
@@ -22,9 +30,7 @@ function ScreenTypography() {
22
30
  />
23
31
  <div className="edit-site-global-styles-screen-typography">
24
32
  <VStack spacing={ 6 }>
25
- { ! window.__experimentalDisableFontLibrary && (
26
- <FontFamilies />
27
- ) }
33
+ { fontLibraryEnabled && <FontFamilies /> }
28
34
  <TypographyElements />
29
35
  </VStack>
30
36
  </div>
@@ -42,6 +42,10 @@
42
42
  border-radius: $radius-block-ui;
43
43
  }
44
44
 
45
+ .edit-site-global-styles-screen-typography__font-variants-count {
46
+ color: $gray-700;
47
+ }
48
+
45
49
  .edit-site-global-styles-screen-colors {
46
50
  margin: $grid-unit-20;
47
51
 
@@ -143,16 +143,26 @@ $header-toolbar-min-width: 335px;
143
143
  }
144
144
 
145
145
  .block-editor-block-mover {
146
+ // Modified group borders.
146
147
  border-left: none;
147
148
 
148
149
  &::before {
149
150
  content: "";
150
151
  width: $border-width;
151
- margin-top: $grid-unit + $grid-unit-05;
152
- margin-bottom: $grid-unit + $grid-unit-05;
152
+ margin-top: $grid-unit-15;
153
+ margin-bottom: $grid-unit-15;
153
154
  background-color: $gray-300;
154
155
  margin-left: $grid-unit;
155
156
  }
157
+
158
+ // Modified block movers horizontal separator.
159
+ .block-editor-block-mover__move-button-container {
160
+ &::before {
161
+ width: calc(100% - #{$grid-unit-30});
162
+ background: $gray-300;
163
+ left: calc(50% + 1px);
164
+ }
165
+ }
156
166
  }
157
167
  }
158
168
 
@@ -164,7 +174,7 @@ $header-toolbar-min-width: 335px;
164
174
  border-bottom: 0;
165
175
  }
166
176
 
167
- // Modified group borders
177
+ // Modified group borders.
168
178
  .components-toolbar-group,
169
179
  .components-toolbar {
170
180
  border-right: none;
@@ -172,8 +182,8 @@ $header-toolbar-min-width: 335px;
172
182
  &::after {
173
183
  content: "";
174
184
  width: $border-width;
175
- margin-top: $grid-unit + $grid-unit-05;
176
- margin-bottom: $grid-unit + $grid-unit-05;
185
+ margin-top: $grid-unit-15;
186
+ margin-bottom: $grid-unit-15;
177
187
  background-color: $gray-300;
178
188
  margin-left: $grid-unit;
179
189
  }
@@ -46,16 +46,17 @@ export function useIsSiteEditorLoading() {
46
46
  useEffect( () => {
47
47
  if ( inLoadingPause ) {
48
48
  /*
49
- * We're using an arbitrary 1s timeout here to catch brief moments
50
- * without any resolving selectors that would result in displaying
51
- * brief flickers of loading state and loaded state.
49
+ * We're using an arbitrary 100ms timeout here to catch brief
50
+ * moments without any resolving selectors that would result in
51
+ * displaying brief flickers of loading state and loaded state.
52
52
  *
53
53
  * It's worth experimenting with different values, since this also
54
- * adds 1s of artificial delay after loading has finished.
54
+ * adds 100ms of artificial delay after loading has finished.
55
55
  */
56
+ const ARTIFICIAL_DELAY = 100;
56
57
  const timeout = setTimeout( () => {
57
58
  setLoaded( true );
58
- }, 1000 );
59
+ }, ARTIFICIAL_DELAY );
59
60
 
60
61
  return () => {
61
62
  clearTimeout( timeout );